Multi-attack for mobs (fwd)

From: Billy H. Chan (~{3B:FH;~}) (bhchan@csua.berkeley.edu)
Date: 10/26/95


> From: Donald Louis Karpovich <dlk2@Ra.MsState.Edu>
> 
> 
>      hit(ch, FIGHTING(ch), TYPE_UNDEFINED);
>      if (FIGHTING(ch) == NULL || ch->in_room != FIGHTING(ch)->in_room) {
>        stop_fighting(ch);
>        continue;
>      } else if (!IS_NPC(ch)) {
>        percent = number(1, 101); /* 101% is complete failure */
>        if (percent < GET_SKILL(ch, SKILL_SECOND_ATTACK))
>            hit(ch, FIGHTING(ch), TYPE_UNDEFINED);
>      } else if (IS_NPC(ch) && GET_MOB_ATT(ch) > 1) {
>        for (j = 2; j < (GET_MOB_ATT(ch) + 1); j++)
>          hit(ch, FIGHTING(ch), TYPE_UNDEFINED);
>      }
>      if (MOB_FLAGGED(ch, MOB_SPEC) && mob_index[GET_MOB_RNUM(ch)].func != 
> NULL)
>        (mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, "");
>    }
>  }
> 

It doesn't seem like you're checking for the validity of the victim
during your for loops, which would cause major unhappiness for the
mud when it tries to attack a corpse or things of such ilk.  I'm sure
you're not interested in a hand-down-this-is-it solution (else, I'd
go into my fight.c and cut/paste what I have (it works with no bugs) :)

As for the logic... I reindented your code for my own reading (if
you haven't noticed you do something very very weird in that for
loop... you start the index at 2, and you go up to GET_MOB_ATT(ch) +1.
Of course, you could do a j <= GET_MOB_ATT(ch) and save a +1... or,
if you like J < GET_MOB_ATT(ch), you could just start at 1... hope
you don't mind my nitpicking (I wish someone would nitpick my code for
me :)...
As for why mobs are doing strange things, I didn't understand which
part of the mob you stuck the new variable in... for reference, I stuck
it in where the BareHandAttack variable is saved... puff getting 9 
attacks while hydra getting 1 seems like some ssort of 'global' variable
is being "looked at", which may be the cause... are you sure you wouldn't
just like a cut/paste ? :)  (btw, you may find it in demand for a third
attack, esp if mobs are gonna be doing more than 2 :).
Anyway, there should be a check before the first hit(ch, FIGHTING(ch)...)
and you need that directly before any calls to hit(...), else your code
may not be fully portable (linux I think pukes on a call to hit a corpse).
YMMV.
-Billy H. Chan	~{3B:FH;~}		    <bhchan@csua.berkeley.edu> 
 For more, check out http://www.csua.berkeley.edu/~bhchan
 NovaCmdr. 'Suicide Strom' of Clan Wolf | FiestyFly FireMoth Variant
 "If you're going under 100kph, you might as well stand still"



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