Multi-attack for mobs

From: Donald Louis Karpovich (dlk2@Ra.MsState.Edu)
Date: 10/25/95


I'm stumped.  I am trying to implement multi-attacks for mobs that is 
independent of the skill based multi-attack that PCs have.  I have it set up
as a field in the enhanced mobile field.  I am using Circle3.0 bpl8.
I altered the code in this manner:

In db.c in function interpret_espec I added a case

  CASE("NumAttacks") {
    RANGE(1, 10);
    mob_proto[i].mob_specials.numattacks = num_arg;
  }

In utils.c I added

  #define GET_MOB_ATT(ch)         ((ch)->mob_specials.numattacks)

In structs.h, in the structure mob_special_data, I added a field

  int numattacks;          /* Number of attacks */

And finally, in fight.c, the relevant code in perform_violence looks like 
this:

     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, "");
   }
 }

The added code is between the first hit function and the if (MOB_FLAGGED)
statement.

The first else if is for the player.  It works fine.
The second else if does not work properly.

I sure I defined everything, I can see no flaw in the logic, but I'm getting
unexpected results.

1. I created a hydra with 9 attacks
2. I have the hydra attack Puff
3. Puff gets 9 attacks against the Hydra.  The hydra only gets one.
4. I have the hydra attack Jupiter.  Both only get one attack.

Based on the result from Puff, I tried to reverse the arguments in hit(), but
that caused a segmentation fault.  Normally, I view stuff like this as a good
learning experience (much like my troubles implementing racial maximums), but
this problem makes no sense to me.

Could someone please point out my mistake, or, better yet, tell me a better
way of doing it?

****************************************************************************
Donald Karpovich           *  I am myself alone
****************************  Realise I never need to use No-one
dlk2@ra.msstate.edu        *  Money, Power, Holy Roads,
74547.2546@compuserve.com  *  Freedom puts my faith in None of the above
****************************                        -Duran Duran (1993)
                           *************************************************



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