Top Mud Sites Forum

Top Mud Sites Forum (http://www.topmudsites.com/forums/index.php)
-   Newbie Help (http://www.topmudsites.com/forums/forumdisplay.php?f=11)
-   -   New Spell Installation (http://www.topmudsites.com/forums/showthread.php?t=612)

Nostrum 07-02-2002 10:23 PM

Once again this may have been a post for the coder's but i am a newbie so....anyways, the codebase is SMAUG1.4. I cannot get a clean compile after i Imp'd a new spell here is the code:
ch_ret spell_fyreball( int sn, int level, CHAR_DATA *ch, void *vo )
{
   CHAR_DATA *vch;
   CHAR_DATA *vch_next;
   int dam;
   int hpch;
   bool ch_died;
   
   ch_died = FALSE;

   if ( IS_SET( ch->in_room->room_flags, ROOM_SAFE ) )  
   {
       set_char_color( AT_MAGIC, ch );
       send_to_char( "You fail to cast your spell.\n\r", ch );
       return rNONE;
   }

   for ( vch = ch->in_room->first_person; vch; vch = vch_next )
   {
       vch_next = vch->next_in_room;
if ( !IS_NPC( vch ) && xIS_SET( vch->act, PLR_WIZINVIS )      
       && vch->pcdata->wizinvis >= LEVEL_IMMORTAL )
         continue;

       if ( IS_NPC(ch) ? !IS_NPC(vch) : IS_NPC(vch) )
       {
   act( AT_MAGIC, "A seering ball of flame from $n"
                       ", engulfs $N.",  
         ch, ch, vch, TO_ROOM );
           act( AT_MAGIC, "A seering ball of flame from you,"
                       " engulfs  $N",
         ch, ch, vch , TO_CHAR );

           hpch = UMAX( 10, ch->hit );
           dam  = number_range( hpch/14+1, hpch/7 );
           if ( saves_breath( level, vch ) )
               dam /= 2;
           if ( damage( ch, vch, dam, sn ) == rCHAR_DIED ||
char_died(ch) )
             ch_died = TRUE;
       }
   }

   if ( ch_died )
return rCHAR_DIED;
   else
return rNONE;  
}
the error msg. says that for each it can only be declared once in fight.c here is what i put in fight.c:

case ATCK_FYREBALL: retcode = spell_fyreball( skill_lookup( "fyreball" ),ch->level, ch, victim ); break;        

what did i miss to get such an error message? i thought this was a clean function.

Nostrum 07-04-2002 02:06 AM

this is the exact error message:
fight.c: In function `violence_update':
> fight.c:491: `ATCK_FYREBALL' undeclared (first use in this function)
> fight.c:491: (Each undeclared identifier is reported only once
> fight.c:491: for each function it appears in.)
> make[1]: *** [fight.o] Error 1

Dre 07-04-2002 02:43 AM

Well like it said, you didn't declare the function. This normally happens in smaug.h I think. I say check out another spell and check in which files it all is.

Greetings Dre

Nostrum 07-04-2002 03:21 AM

this is my first spell...but i placed an identifier in mud.h...i thought that is where i was supposed to put it...i cannot seem to find any other comments pointing out where i missed it..i grep'd the heck out of some other spells i cannot find what i did wrong...thanks for any help you offer *smiles*

erdos 07-04-2002 03:41 AM

The problem is you need to add ATCK_FYREBALL to the enumeration of mob attacks in mud.h.  Ie, add it to this list, but before MAX_ATTACK_TYPE:

/*
* Attack types
*/
typedef enum
{
 ATCK_BITE, ATCK_CLAWS, ATCK_TAIL, ATCK_STING, ATCK_PUNCH, ATCK_KICK,
 ATCK_TRIP, ATCK_BASH, ATCK_STUN, ATCK_GOUGE, ATCK_BACKSTAB, ATCK_FEED,
 ATCK_DRAIN,  ATCK_FIREBREATH, ATCK_FROSTBREATH, ATCK_ACIDBREATH,
 ATCK_LIGHTNBREATH, ATCK_GASBREATH, ATCK_POISON, ATCK_NASTYPOISON, ATCK_GAZE,
 ATCK_BLINDNESS, ATCK_CAUSESERIOUS, ATCK_EARTHQUAKE, ATCK_CAUSECRITICAL,
 ATCK_CURSE, ATCK_FLAMESTRIKE, ATCK_HARM, ATCK_FIREBALL, ATCK_COLORSPRAY,
 ATCK_WEAKEN, ATCK_SPIRALBLAST, MAX_ATTACK_TYPE
} attack_types;

Youll notice that this list already has 32 entries... fortunately, mob attacks are an extended bitvector, meaning you are no longer limited to 32 flags.

Of course, youll also need to add "fyreball" to the attack_flags string array in build.c. The order of the above enumeration and the attack_flags string array must be preserved: thus, if you added ATCK_FYREBALL between ATCK_CURSE and ATCK_EARTHQUAKE, then you must add "fyreball" between "curse" and "earthquake".

I highly recommend that you add ATCK_FYREBALL at the very end (but still before MAX_ATTACK_TYPE): this will ensure that mobs whose attacks were saved before the change, will keep the same attacks.

There are other problems in the code you posted too.

When it loops through the room, it skips players who have wizinvis set to LEVEL_IMMORTAL (51). however, it is possible for imms to set their wizinvis to a mortal level higher than the caster (IE:  caster is level 20, imm is wizinvis level 30).  So you should change ">= LEVEL_IMMORTAL" to "> get_trust(ch)".

Furthermore, this code uses the act function badly... i quote:
act( AT_MAGIC, "A seering ball of flame from you,"
                      " engulfs  $N",
        ch, ch, vch , TO_CHAR );

The 4th argument of the act function is supposed to be a pointer to an object (or to NULL if the echo has nothing to do with objects).  So you should change the above to
act( AT_MAGIC, "A seering ball of flame from you,"
                      " engulfs  $N",
        ch, NULL, vch , TO_CHAR );

Also, you call act twice, once with TO_CHAR as the 6th arg, and once with TO_ROOM as the 6th arg.  This means the victim will see "A seering ball of flame from Bob, engulfs Joe", but they ought to see "A seering ball of flame from Bob, engulfs you"..  note the YOU.  this is a common error.

To correct it, use 3 acts:  one with TO_CHAR as arg 6, one with TO_VICT as arg 6, and one with TO_NOTVICT as arg 6.  TO_VICT will go only to the victim and TO_NOTVICT is the same as TO_ROOM except that it skips the victim.  The one with TO_NOTVICT should be like the one you posted with TO_ROOM, the one with TO_VICT should replace "$N" with "you".

Hope this helps...

Nostrum 07-04-2002 10:26 PM

yes it did help. thanks guys for everything!


All times are GMT -4. The time now is 11:07 PM.

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Top Mud Sites.com 2022