Re: NEWBIE: Code patch fix: weapon spells

From: Professor Hoopster (hoopy@notfoo.res.cmu.edu)
Date: 07/01/96


On Wed, 26 Jun 1996, Frank Linares wrote:
> Grettings all!
> 
> This is extremly newbie, so bare with me and indulge me a little. 
> 
> I have just installed weapon spells on pl11, and am using oasisOLC, is 
> there a way to add a menu option on oasisolc in order to make weapon 
> spells easy to add to an obj? Furthermore, I haven't been able to add any 
> ws to any obj? am I missing something extremly easy here?
> 
> Thanks, flames to me plz!

I did a quick patch to oedit.c for just this purpose...it's rather brute 
force, but pretty simple. Make sure you have a char *spelllist somewhere 
that contains the raw string of spell number->name mappings, and it 
SHOULD patch in easily (My codebase is set up for up to three spells per 
object, so keep in mind that you might not need the level of 'Which 
weaponspell do you want to edit?' type of questions). I haven't run into 
any problems with running the code on my mud, but YMMV.

--- cut here for oedit.diff ---
363a364,371
>       for (counter2 = 0; counter2 < MAX_SPELL_AFFECT; counter2++)
>         if ((obj->spell_affect[counter].spelltype)!=0)
>           fprintf(fp,	"S\n"
> 			"%d %d %d\n",
> 			obj->spell_affect[counter2].spelltype,
> 			obj->spell_affect[counter2].level,
> 			obj->spell_affect[counter2].percentage
>           );
446a455,479
> /* Ask for *which* spell to edit */
> void oedit_disp_prompt_spell_menu(struct descriptor_data * d)
> {
>   int counter;
> 
>   get_char_cols(d->character);
>   send_to_char("", d->character);
>   for (counter = 0; counter < MAX_SPELL_AFFECT; counter++) {
>     if (OLC_OBJ(d)->spell_affect[counter].spelltype) {
>       sprinttype(OLC_OBJ(d)->spell_affect[counter].spelltype, spells, buf2);
>       sprintf(buf, " %s%d%s) %3d%% %s(%d)\r\n", 
>       	  	grn, counter + 1, nrm,
> 		OLC_OBJ(d)->spell_affect[counter].percentage, buf2,
> 		OLC_OBJ(d)->spell_affect[counter].level
>       );
>       send_to_char(buf, d->character);
>     } else {
>       sprintf(buf, " %s%d%s) None.\r\n", grn, counter + 1, nrm);
>       send_to_char(buf, d->character);
>     }
>   }
>   send_to_char("\r\nEnter spell to modify (0 to quit): ", d->character);
>   OLC_MODE(d) = OEDIT_PROMPT_SPELL;
> }
> 
763a797
> 	"%sG%s) Weaponspell menu\r\n"
777c811
<         grn, nrm, grn, nrm, grn, nrm
---
>         grn, nrm, grn, nrm, grn, nrm, grn, nrm
790a825
>   extern char *spelllist;
903a939,942
>     case 'g':
>     case 'G':
>       oedit_disp_prompt_spell_menu(d);
>       break;
1138a1178,1227
>   case OEDIT_PROMPT_SPELL:
>     number = atoi(arg);
>     if (number == 0)
>       break;
>     else if (number < 0 || number > MAX_SPELL_AFFECT) 
>     { oedit_disp_prompt_spell_menu(d);
>       return;
>     }
>     OLC_VAL(d) = number - 1;
>     send_to_char("Spell num ('list' for list): ", d->character);
>     OLC_MODE(d) = OEDIT_SPELL;
>     return;
> 
>   case OEDIT_SPELL:
>     if (!strcmp(arg,"list"))
>     {
>       send_to_char(spelllist, d->character);
>       send_to_char("Spell num ('list' for list): ", d->character);
>       return;
>     }
>     number = atoi(arg);
>     if (number == 0)
>     { OLC_OBJ(d)->spell_affect[OLC_VAL(d)].spelltype = 0;
>       OLC_OBJ(d)->spell_affect[OLC_VAL(d)].level = 0;
>       OLC_OBJ(d)->spell_affect[OLC_VAL(d)].percentage = 0;
>       OLC_MODE(d) = OEDIT_PROMPT_SPELL;
>       oedit_disp_prompt_spell_menu(d);
>     } else if (number < 0 || number > MAX_SPELLS)
>       send_to_char("Spell num ('list' for list): ", d->character);
>     else 
>     { OLC_OBJ(d)->spell_affect[OLC_VAL(d)].spelltype = number;
>       send_to_char("Spell Level: ", d->character);
>       OLC_MODE(d) = OEDIT_SPELL_LEVEL;
>     }
>     return;
> 
>   case OEDIT_SPELL_LEVEL:
>     number = atoi(arg);
>     OLC_OBJ(d)->spell_affect[OLC_VAL(d)].level = number;
>     send_to_char("Spell Probability: ", d->character);
>     OLC_MODE(d) = OEDIT_SPELL_CHANCE;
>     return;
> 
>   case OEDIT_SPELL_CHANCE:
>     number = atoi(arg);
>     OLC_OBJ(d)->spell_affect[OLC_VAL(d)].percentage = number;
>     OLC_MODE(d) = OEDIT_PROMPT_SPELL;
>     oedit_disp_prompt_spell_menu(d);
>     return;
> 
--- end of oedit.diff ---



This archive was generated by hypermail 2b30 : 12/07/00 PST