Re: [SNIPPET] Merciful Mobs

From: Christopher Avans (parka@CDC.NET)
Date: 10/16/98


On Fri, 16 Oct 1998, Mulder wrote:

> Merciful Mob Snippet
> Michael J. Fara <mulder@cloud9.net>
>
> This will implement a mercy flag for mobs. If a mob is mercy flagged,
> combat will end when the player/mob fighting the flagged mob is
> mortally wounded. What might this be useful for? Cleric interaction,
> more excitingn combat, rescue missions. You name it. If you are honest,
> you will give me some credit :P

As always I thank anyone that donates code. But I will do same with a
twist. A toggle named vicious. It works for mobs and players. And with a
twist can make it easier for builders...... This is same code with checks
for players and even mobs with memory etc. Heh I said I would start
mailing code a little. Even if you dont want your mud to do this, below is
some nice utility type functions. If you give it please add this to
credits, choke.
"The Hubis Group" hubis.eushc.org:4000 www.cdc.net/~parka/

*snip*

void StopMercAttackers(struct char_data *ch)
{
  struct char_data *t_ch;
  struct char_data *hold;

  if (!ch)
    return;

  for (t_ch = combat_list; t_ch; t_ch = hold) {
    hold = t_ch->next_fighting;
    if ((t_ch->char_specials.fighting == ch) &&
       ((!IS_NPC(t_ch) && !PRF_FLAGGED(t_ch, PRF_VICIOUS)) ||
         (IS_NPC(t_ch) && !is_aggr_to(t_ch, ch))))
      stop_fighting(t_ch);
  }
}

bool is_aggr_to(struct char_data *ch,struct char_data *target)
{
  /* common checks first */

  if ((!ch) || (!target) || (ch == target) ||
  (ch->in_room != target->in_room) ||
 (FIGHTING(target) != ch) || (!AWAKE(ch)) || (!CAN_SEE(ch, target)))
    return FALSE;

if (IS_AFFECTED2(ch, AFF2_MINOR_PARALYSIS) ||
IS_AFFECTED(ch,AFF_MAJOR_PARA))
    return FALSE;

/* pets or charmed mobs now needs a master to inhibit aggression Banyal*/
  if (IS_AFFECTED(ch, AFF_CHARM) || (IS_NPC(ch) && MOB_FLAGGED(ch,
MOB_PET)))
    return FALSE;

  /* now different checks for pcs/npcs */

  if (IS_NPC(ch)) {

/* after the above check, we are dealing with a pet, PC, switched PC, or
shapechanged Banyal */


    /* if target in memory, then it acts as if it's agg, even if it's not
  aggro, but of course they would Banyal */
    if (!IS_NPC(target) && MOB_FLAGGED(ch, MOB_MEMORY) &&
 (MEMORY(ch) != NULL) &&
        mem_inMemory(ch, target))
      return TRUE;

/*ALL MOBS ARE VICIOUS UNLESS SET NOVICOUS BANYAL */
 if(!MOB_FLAGGED(ch, MOB_NOVICIOUS))
        return TRUE;

/* not trigger, so it's not aggr */
    return FALSE;

  } else {

 if (!IS_NPC(target))
      return FALSE;


    if (GET_WIMP_LEV(ch) > GET_HIT(ch))    /* not agg and wimpy both */
      return FALSE;

    if (!PRF_FLAGGED(ch, PRF_VICIOUS)) {
      if (!AWAKE(target) || IS_AFFECTED2(target, AFF2_MINOR_PARALYSIS) ||
          IS_AFFECTED(target, AFF_MAJOR_PARA))
        return FALSE;
    }

/*THIS IS AGGR CODE FOR PC'S MIGHT WANT TO CUT OUT BANYAL*/
if ((ch->player_specials->saved.aggressive != -1) &&
(ch->player_specials->saved.aggressive < GET_HIT(ch)) &&
is_aggr_to(target, ch))
    return TRUE;
  }

  return FALSE;
}

/* Return 0 if "name" is not in memory "mem", otherwise, */

int mem_inMemory(struct char_data *ch, struct char_data *vict)
{
  memory_rec *names;
  bool found;

  if (MEMORY(ch) == NULL)
    return 0;

for (names = MEMORY(ch); names && !found; names = names->next)
  if(names->id == GET_IDNUM(vict)) {
  found = TRUE;
  return 1;
}

  return 0;
}

/*SNIP*/ okay go to update position heh and add this */
/* At top of update pos add this*/

if (!AWAKE(victim) || IS_AFFECTED2(victim, AFF2_MINOR_PARALYSIS)
|| IS_AFFECTED(victim, AFF_MAJOR_PARA) ||
IS_AFFECTED2(victim, AFF2_KNOCKED_OUT) || (GET_POS(victim) <
POS_SLEEPING)) {
    if (IS_FIGHTING(victim))
      stop_fighting(victim);
    StopMercAttackers(victim);
  }

/*Then in this check add stopmercattackers*/
else if (GET_HIT(victim) <= HIT_MORTALLYW) {
    GET_POS(victim) = POS_MORTALLYW;
    StopMercifulAttackers(victim);
/*and this check*/
} else if (GET_HIT(victim) <= HIT_INCAP) {
    GET_POS(victim) = POS_INCAP;
    StopMercifulAttackers(victim);

/*Then have to add flags in struct.h plf_vicious and mob_novicous
 and prob have to cut out some the aff_ and aff2_ checks but this not a
drop in snippet*/


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



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