Welcome to the Builder Academy

Question Separating out Skills and Spells to two different functions

More
21 Nov 2024 22:26 - 21 Nov 2024 22:27 #10449 by zi
YES! adding sort_skills(); to db.c was the key.  THANK YOU THOMAS!

Here's what my output looks like
Code:
> programs   --- [PROGRAM DATABASE] --- animate dead         -----------------[+] armor                -----------------[+] bless                -----------------[+] blindness            -----------------[+] burning hands        -----------------[+] call lightning       -----------------[+] charm person         -----------------[+] chill touch          -----------------[+] clone                -----------------[+] color spray          -----------------[+] control weather      -----------------[+] create food          -----------------[+] create water         -----------------[+] cure blind           -----------------[+] cure critic          -----------------[+] cure light           -----------------[+] curse                -----------------[+] darkness             -----------------[+] detect alignment     -----------------[+] detect invisibility  -----------------[+] detect magic         -----------------[+] detect poison        -----------------[+] dispel evil          -----------------[+] dispel good          -----------------[+] earthquake           -----------------[+] enchant weapon       -----------------[+] energy drain         -----------------[+] fireball             -----------------[+] fly                  -----------------[+] group armor          -----------------[+] group heal           -----------------[+] harm                 -----------------[+] heal                 -----------------[+] identify             -----------------[+] infravision          -----------------[+] invisibility         -----------------[+] lightning bolt       -----------------[+] locate object        -----------------[+] magic missile        -----------------[+] poison               -----------------[+] protection from evil -----------------[+] remove curse         -----------------[+] remove poison        -----------------[+] sanctuary            -----------------[+] sense life           -----------------[+] shocking grasp       -----------------[+] sleep                -----------------[+] strength             -----------------[+] summon               -----------------[+] teleport             -----------------[+] waterwalk            -----------------[+] word of recall       -----------------[+]     - You have 0 downloads available - > ssss (this is my temp "skill" call)   --- [SKILL DATABASE] --- backstab             -----------------[+] bandage              -----------------[+] bash                 -----------------[+] fourth attack        -----------------[+] hide                 -----------------[+] kick                 -----------------[+] pick lock            -----------------[+] rescue               -----------------[+] second attack        -----------------[+] sneak                -----------------[+] steal                -----------------[+] third attack         -----------------[+] track                -----------------[+] whirlwind            -----------------[+]     - You have 0 practices available -


NOW I can have my tech classes train up and view spells (programs) with one call and the fighting/hands on stuff with another (skills).
Last edit: 21 Nov 2024 22:27 by zi. Reason: pretend the formatting works for the output, it does IRL ;)

Please Log in or Create an account to join the conversation.

More
27 Apr 2025 19:35 #10690 by Fubar
Never thought about separating them, I like that idea. I have something similar.
Attachments:

Please Log in or Create an account to join the conversation.

More
28 Apr 2025 15:45 - 28 Apr 2025 15:49 #10691 by Salty
Code:
void list_skills(struct char_data *ch) {   int i, num = 0;   send_to_char(ch, "You have %d practice session%s remaining.\r\n", GET_PRACTICES(ch), GET_PRACTICES(ch) == 1 ? "" : "s");   if (!IS_BARD(ch) || GET_LEVEL(ch) > LVL_MAX_MORTAL)   {     send_to_char(ch, "\n\rYou know of the following spells:\r\n");     send_to_char(ch, "---------------------------------------------------------------------------\n\r");     /* Begin counting Spells */     for (i = 1; i <= NUM_SPELLS; i++)     {       if ((GET_LEVEL(ch) >= spell_info[i].min_level[GET_CLASS(ch)]) || GET_LEVEL(ch) > LVL_IMMORT)       {         send_to_char(ch, "%-17s %3d %%   ", spell_info[i].name, GET_SKILL(ch, i));         num += 1;         if ((num % 3) == 0)           send_to_char(ch, "\n\r");       }     }   }   num = 0;   if (IS_BARD(ch) || GET_LEVEL(ch) > LVL_MAX_MORTAL)   {     send_to_char(ch, "\n\r\n\rYou know of the following songs:\r\n");     send_to_char(ch, "---------------------------------------------------------------------------\n\r");     for (i = ZERO_SONGS + 1; i <= ZERO_SONGS + NUM_SONGS; i++)     {       if ((GET_LEVEL(ch) >= spell_info[i].min_level[GET_CLASS(ch)]) || GET_LEVEL(ch) > LVL_IMMORT)       {         send_to_char(ch, "%-17s %3d %%   ", spell_info[i].name, GET_SKILL(ch, i));         num += 1;         if ((num % 3) == 0)           send_to_char(ch, "\n\r");       }     }   }   send_to_char(ch, "\n\r\n\rYou know of the following skills:\r\n");   send_to_char(ch, "---------------------------------------------------------------------------\n\r");   num = 0;   /*  Begin counting Skills */   for (i = ZERO_SKILLS + 1; i <= ZERO_SKILLS + NUM_SKILLS; i++)   {     if ((GET_LEVEL(ch) >= spell_info[i].min_level[(int)GET_CLASS(ch)]) || GET_LEVEL(ch) > LVL_IMMORT)     {       send_to_char(ch, "%-17s %3d %%   ", spell_info[i].name, GET_SKILL(ch, i));       num += 1;       if ((num % 3) == 0)         send_to_char(ch, "\n\r");     }   }   send_to_char(ch, "\n\r"); }

ZERO_SKILLS, ZERO_SONGS are defined in spells.h and are the lowest value for skills/songs.

I did it this way because my classes can have skills & spells or skills & songs.  At some point I'd like to alphabetize or spell_level() sort the lists but the function currently works.

Example of output from a Wizard
Code:
You have 995 practice sessions remaining. You know of the following spells: --------------------------------------------------------------------------- armor              81 %   blindness         100 %   charm person       84 % curse             100 %   enchant weapon    100 %   energy drain      100 % fireball           91 %   invisibility       88 %   locate object      93 % magic missile     100 %   strength           80 %   blood mana        100 % word of recall     80 %   identify          100 %   fly                80 % haste             100 %   stone skin        100 %   steel skin        100 % quickcast         100 %   missile spray      85 %   mage armor        100 % astral walk       100 %   mirror image      100 %   fireblast         100 % paralyze          100 %   betrayal          100 %   improved invis     82 % locate char       100 %   pass door          80 %   imp pass door      88 % group pass dooor   77 %   slow              100 %   mana transfer     100 % reappear           93 %   wither            100 %   eldritch blast    100 % nova              100 %   enchant armor     100 %   disruption        100 % portal            100 %   clone object       98 % You know of the following skills: --------------------------------------------------------------------------- magic recovery    100 %   spell twinning    100 %   spell tripling    100 % spell critical    100 %

Output from a Bard:
Code:
You have 995 practice sessions remaining. You know of the following songs: --------------------------------------------------------------------------- ballad of bless   100 %   resist rock       100 %   minuet of mending  83 % hymn of heal      100 %   banquet bop        80 %   recall refrain    100 % hasty hymnal      100 %   rebirth refrain   100 %   cromlech chorus   100 % bardic fury       100 %   anthem of armor    92 %   rallying cry      100 % storm of swords   100 %   march of miracle  100 % You know of the following skills: --------------------------------------------------------------------------- track              80 %   2nd attack        100 %   3rd attack        100 % dodge             100 %   magic recovery    100 %   tumble            100 % chant             100 %   battle rythm      100 %   magical melody    100 % ritual            100 %   scorn             100 %   war dance         100 % slow dance        100 %   tone mastery      100 %
Last edit: 28 Apr 2025 15:49 by Salty.

Please Log in or Create an account to join the conversation.

More
28 Apr 2025 15:57 #10692 by Salty
My skills are assigned at level with a base percentage of 60% and can be increased via usage.  Skills/spells/songs used more often increase at a slower rate than those used less frequently.
Code:
void check_improve(struct char_data *ch, int sn, bool success) {   int need, gain, roll_s, roll_f, base;   /* NPC doesn't have skills */   if (IS_NPC(ch))     return;   /* PC doesn't have level required for the skill */   if (GET_LEVEL(ch) < spell_info[sn].min_level[GET_CLASS(ch)])     return;   /* Skill is not practiced or skill is maxed */   if (GET_SKILL(ch, sn) == 0 || GET_SKILL(ch, sn) == MAX_SKILL(ch))     return;   /* Base rate of increase for spells */   if (sn > 0 && sn <= NUM_SPELLS)   {     if (spell_info[sn].violent)       base = 5 * MAX_SKILL(ch);     else       base = 3 * MAX_SKILL(ch);   }   /* Base rate of increase for songs */   if (sn > ZERO_SONGS && sn <= ZERO_SONGS + NUM_SONGS)   {     if (spell_info[sn].routines == MAG_AFFECTS)       base = 3 * MAX_SKILL(ch);     else if (spell_info[sn].routines == MAG_POINTS)       base = 5 * MAX_SKILL(ch);     else       base = 5 * MAX_SKILL(ch);   }   /* Base rate of increase for skills */   if (sn > ZERO_SKILLS && sn <= ZERO_SKILLS + NUM_SKILLS)     base = 5 * MAX_SKILL(ch);   else     base = 5 * MAX_SKILL(ch);   if (GET_CLASS(ch) == CLASS_ROGUE)     need = MAX_SKILL(ch) - GET_SKILL(ch, sn) + GET_LUCK(ch) * 2;   else     need = MAX_SKILL(ch) - GET_SKILL(ch, sn);   /*     Size for successful roll     GET_TOTAL(ch) is GET_LEVEL(ch) + an endgame rank   */   roll_s = MAX(0, base - (2 * GET_TOTAL(ch)));   /*     Size for failure roll     GET_TOTAL(ch) is GET_LEVEL(ch) + an endgame rank   */   roll_f = MAX(0, base - (3 * GET_TOTAL(ch)));   /* Was the skill check a success? */   if (success)   {     if (need > rand_number(0, roll_s))     {       gain = GET_SKILL(ch, sn);       gain++;       SET_SKILL(ch, sn, MIN(MAX_SKILL(ch), gain));       send_to_char(ch, "You have become better at %s! (%d%%)\n\r", spell_info[sn].name, GET_SKILL(ch, sn));       if (GET_SKILL(ch, sn) >= MAX_SKILL(ch))         send_to_char(ch, "You are now learned in at %s.\r\n", spell_info[sn].name);     }   }   else /* Whatever skill, we failed it.  Lets try to learn from our mistakes. */   {     if (need > rand_number(0, roll_f))     {       gain = GET_SKILL(ch, sn);       gain += dice(1, 4) + 1;       SET_SKILL(ch, sn, MIN(MAX_SKILL(ch), gain));       send_to_char(ch, "You learn from your mistakes, and your %s skill improves. (%d%%)\n\r", spell_info[sn].name, GET_SKILL(ch, sn));       if (GET_SKILL(ch, sn) >= MAX_SKILL(ch))         send_to_char(ch, "You are now learned in at %s.\r\n", spell_info[sn].name);     }   } }

Please Log in or Create an account to join the conversation.

Time to create page: 0.204 seconds