Re: [code] [question] [newbie] Mob Attacks

From: Daniel Koepke (
Date: 03/02/97

On Sun, 2 Mar 1997, Count Zero wrote:

> Looking for a way to make a mob attack several chars in a givin fight,
> stead of just attacking the same "lead" character every round...  Want the
> mob to attack a char at random from the list of chars fighting in the room.
> I checked the fight.c code, and didn't really see anything that pointed me
> towards figuring out what part of the code told the mob who to attack... 
> Any pointers as to what section of the source controls which chars the mob
> will attack would be helpfull...  I am not the greatest at coding C... but
> have made several major mods to my mud already, so just giving me some
> ideas on where to start looking should be enough... hehe

FIGHTING(ch) is a macro that...errrmmm...points to the pointer that
points to the character the mob is fighting (whew, that was a strange
sentence). Anyway, fooling with this is best done in perform_violence()
[the bottom of fight.c] before the 'hit()' call.

Now, as for finding out who is attacking the mob, there is two good
ways. The first would be to scan by FIGHTING(ch)'s group. This is a
bit strange and it wouldn't cover someone ungrouped hitting the mob.
The second is easier and catches everyone hitting the mob:

  for (vict = world[ch->in_room].people; vict; vict = vict->next_in_room)
    if (FIGHTING(vict) == ch && !number(0, 4))
  if (!vict)
    vict = FIGHTING(ch);

That scans the room and picks someone fighting the mob at random to
attack. Now, it'd be better to use some way to determine who the
mob would attack. I had it setup so that mobs would keep track of
who was hitting them the hardest or doing the most damage to them
every few rounds. After I had mobiles beating on the people that were
the greatest threat physically to them, I went and did the same for
those that were dangerous because of spell-casting (eg., clerics
would get beat up to if they healed the people the mob was fighting).
Also, make mobiles turn and beat up people that are badly injured to
kill as many as they can. :)

Daniel Koepke
Forgive me father, for I am sin.

| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   |
|    Or send 'info circle' to     |

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