For all those who asked, below is my code for displaying percentage levels for skills and spells. Someone asked a question on how to allow a person to have both spells and skills, the answer is that Circle really doesn't differentiate between the two, and you just assign skills to a spell caster as you would assign spells, in class.c. All the code below goes in spec_procs.c. I make no warrenty to the code being the most efficient, but it seems to work rather well. replace: int spell_sort_info.... with: int spell_sort_info[MAX_SPELLS+1]; /* sorted list of spells */ int skill_sort_info[MAX_SKILLS-MAX_SPELLS+1]; /* sorted list of skills */ replace: void sort_spells..... with: void sort_spells(void) { int a, b, tmp; /* First sort the spells */ /* initialize array */ for (a = 1; a < MAX_SPELLS; a++) spell_sort_info[a] = a; /* Sort. 'a' starts at 1, not 0, to remove 'RESERVED' */ for (a = 1; a < MAX_SPELLS - 1; a++) for (b = a + 1; b < MAX_SPELLS; b++) if (strcmp(spells[spell_sort_info[a]], spells[spell_sort_info[b]]) > 0) { tmp = spell_sort_info[a]; spell_sort_info[a] = spell_sort_info[b]; spell_sort_info[b] = tmp; } /* Now sort the skills */ /* initialize array */ for (a = 1; a < MAX_SKILLS - MAX_SPELLS; a++) skill_sort_info[a] = a + MAX_SPELLS; for (a = 1; a < MAX_SKILLS - MAX_SPELLS - 1; a++) for (b = a + 1; b < MAX_SKILLS - MAX_SPELLS; b++) if (strcmp(spells[skill_sort_info[a]], spells[skill_sort_info[b]]) > 0) { tmp = skill_sort_info[a]; skill_sort_info[a] = skill_sort_info[b]; skill_sort_info[b] = tmp; } } replace: void list_skills... with: void list_skills(struct char_data * ch) { extern char *spells[]; extern struct spell_info_type spell_info[]; int counter, i, sortpos; if (!GET_PRACTICES(ch)) strcpy(buf, "You have no practice sessions remaining.\r\n\r\n"); else sprintf(buf, "You have %d practice session%s remaining.\r\n\r\n", GET_PRACTICES(ch), (GET_PRACTICES(ch) == 1 ? "" : "s")); strcpy(buf2, buf); counter = 1; /* Used to display spells and skills in two columns */ for (sortpos = 1; sortpos < MAX_SPELLS; sortpos++) { i = spell_sort_info[sortpos]; if (strlen(buf2) >= MAX_STRING_LENGTH - 32) { strcat(buf2, "**OVERFLOW**\r\n"); break; } if (GET_LEVEL(ch) >= spell_info[i].min_level[(int) GET_CLASS(ch)]) { counter++; if (counter == 2){ sprintf(buf, "You know of the following spells:\r\n"); sprintf(buf,"%s+------------------------------------",buf); sprintf(buf,"%s+------------------------------------+\r\n", buf); strcat(buf2,buf); } sprintf(buf, "| %-30s %3d ", spells[i], GET_SKILL(ch, i)); if (counter % 2) sprintf(buf, "%s|\r\n",buf); strcat(buf2, buf); } } if (counter != 1){ if (!(counter % 2)) strcat(buf2,"| |\r\n"); sprintf(buf,"+------------------------------------"); sprintf(buf,"%s+------------------------------------+\r\n\r\n", buf); strcat(buf2, buf); } else strcat(buf2,"You do not know any spells.\r\n\r\n"); counter = 1; for (sortpos = 1; sortpos < MAX_SKILLS - MAX_SPELLS; sortpos++) { i = skill_sort_info[sortpos]; if (strlen(buf2) >= MAX_STRING_LENGTH - 32) { strcat(buf2, "**OVERFLOW**\r\n"); break; } if (GET_LEVEL(ch) >= spell_info[i].min_level[(int) GET_CLASS(ch)]) { counter++; if (counter == 2){ sprintf(buf, "You know of the following skills:\r\n"); sprintf(buf,"%s+------------------------------------",buf); sprintf(buf,"%s+------------------------------------+\r\n", buf); strcat(buf2,buf); } sprintf(buf, "| %-30s %3d ", spells[i], GET_SKILL(ch, i)); if (counter % 2) sprintf(buf, "%s|\r\n",buf); strcat(buf2, buf); } } if (counter != 1){ if (!(counter % 2)) strcat(buf2,"| |\r\n"); sprintf(buf,"+------------------------------------"); sprintf(buf,"%s+------------------------------------+\r\n", buf); strcat(buf2, buf); } else strcat(buf2,"You do not know any skills."); page_string(ch->desc, buf2, 1); } And that is all. I hope I got everything right, if you have problems let me know, I could have made and error in copying it. Hope this is what people have been looking for. ---------------------------------------------------------------------- Michael Donovan | If you are expecting to find University of Michigan | something witty here, you are donovan@engin.umich.edu | looking in the wrong place. ---------------------------------------------------------------------- +-----------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://cspo.queensu.ca/~fletcher/Circle/list_faq.html | +-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST