Re: extra attacks

From: Greg Alexander Irvine (s9211947@arcadia.cs.rmit.edu.au)
Date: 08/21/95


> Which reminds me... my coder is still working on figuring out Multi 
> Attacks - as in, one player/mob doing 2/3 attacks per round.  Does anyone 
> know how that can be done?  By my understanding, that is what an ogre can 
> do (in some muds, like Perilous Realms, I could do it).

this is an easy one. :)

create the extra skills if you like for pc's, (spello dec's and SKILL_SECOND)
or for mobs i just added in to the mob flags, MOB_SECOND_ATTACK, MOB_THIRD.

this is what my perform_violence and a couple of new ones in fight.c look
like.

-------------------

int skill_is_successful(struct char_data *ch, int skill)
{
  int percent;

  percent = number(1,101);	/* 101 is total failure */
  if (percent > GET_SKILL(ch, skill))
    return 0;
  else
    return 1;
}


int extra_attack_successful(struct char_data *ch, int id)
{
  if (FIGHTING(ch) == NULL || ch->in_room != FIGHTING(ch)->in_room) {
    stop_fighting(ch);
    return 0;
  }
  if (IS_PC(ch))  {
    if (skill_is_successful(ch, id))
      return 1;
    else
      return 0;
  }
  else  {
    if (MOB_FLAGGED(ch, id))
      return 1;
    else
      return 0;
  }
}



/* control the fights going on.  Called every 2 seconds from comm.c. */
void perform_violence(void)
{
  struct char_data *ch, *leader;
  extern struct index_data *mob_index;
  struct follow_type *f;

  for (ch = combat_list; ch; ch = next_combat_list) {
    next_combat_list = ch->next_fighting;

    if (FIGHTING(ch) == NULL || ch->in_room != FIGHTING(ch)->in_room) {
      stop_fighting(ch);
      continue;
    }

    if (IS_NPC(ch)) {
      if (GET_MOB_WAIT(ch) > 0) {
	GET_MOB_WAIT(ch) -= PULSE_VIOLENCE;
	continue;
      }
      GET_MOB_WAIT(ch) = 0;
      if (GET_POS(ch) < POS_FIGHTING) {
	GET_POS(ch) = POS_FIGHTING;
	act("$n scrambles to $s feet!", TRUE, ch, 0, 0, TO_ROOM);
      }
    }

    if (GET_POS(ch) < POS_FIGHTING) {
      send_to_char("You can't fight while sitting!!\r\n", ch);
      continue;
    }

    hit(ch, FIGHTING(ch), TYPE_UNDEFINED);

    if (IS_PC(ch))  {
      if (extra_attack_successful(ch, SKILL_SECOND_ATTACK))
        hit(ch, FIGHTING(ch), TYPE_UNDEFINED);

      if (extra_attack_successful(ch, SKILL_THIRD_ATTACK))
        hit(ch, FIGHTING(ch), TYPE_UNDEFINED);
    }
    else  {
      if (extra_attack_successful(ch, MOB_SECOND_ATTACK))
        hit(ch, FIGHTING(ch), TYPE_UNDEFINED);

      if (extra_attack_successful(ch, MOB_THIRD_ATTACK))
        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, "");

  }

	/* check for autoassist flags */
	/* i dont know if this bit works or not, i only just put it in and
	   havent tested it yet. if anyone sees a possible bug, lemme know
	   please. :)  */
  if (IS_PC(ch) && FIGHTING(ch) && IS_GROUPED(ch))  {
    if (!(leader=ch->master))
      leader = ch;

    for (f=leader->followers; f; f=f->next)
      if (PRF_FLAGGED(f->follower, PRF_AUTOASS))
        if (!FIGHTING(f->follower))
          if (FIGHTING(ch) && (IN_ROOM(f->follower) == IN_ROOM(FIGHTING(ch))))
            hit(f->follower, FIGHTING(ch), TYPE_UNDEFINED);
          else
            stop_fighting(ch);
  }
}



Hope this helps.  Note that in attack_is_successful it checks that the
mpb/player hasnt already fled or died in previous attacks during the
current attack round.  As far as I know this works fine, but, knowing
me... :)

Regards,
	Greg.



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