Re: Weapons that cast spells (was SpecProcs on weapons)

From: Christopher J. Dickey (cdickey@texas.net)
Date: 07/23/95


On Sun, 23 Jul 1995, Mark Crichton wrote:

> the hit() function.  I am trying to check to see if my test object has a spell
> attached to it, but when the test tries to do the same thing for a npc, I'm
> getting what appears to be a deref. of a NULL pointer.  Here is where my code
> is crashing:
> 
> in fight.c:
> 
> void hit(struct char_data * ch, struct char_data * victim, int type)
> {
>   struct obj_data *wielded = GET_EQ(ch, WEAR_WIELD);
>   int w_type, victim_ac, calc_thaco, dam, diceroll;
> 
>   extern int thaco[NUM_CLASSES][LVL_IMPL+1];
>   extern byte backstab_mult[];
>   extern struct str_app_type str_app[];
>   extern struct dex_app_type dex_app[];
> 
> /*This is HACK code thru here...I wanna see if I can deref the Lbolt correctly*//* THIS LINE SIGSEVS WHEN IT HITS A NPC...NO IDEA WHY.... */
> fprintf(stderr, "The spell being used is: %d\n",
>                        wielded->spell_affect[0].spelltype);
> 
> /*END OF HACK!!*/
> 

THe problem looks to be that you are not checking to see if the char is 
wielding or not.  If they aren't wielding a weapon, then wielded points 
to NULL.  Solution is something basically like this:

if (wielded) {
   code here
}

				CJD



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