[MUD-Dev] New topic: AI and NPCs

Adam Wiggins nightfall at user2.inficad.com
Sat Aug 30 15:15:49 New Zealand Standard Time 1997

> Jeff Kesselman <jeffk at tenetwork.com> wrote:
> Something that gets me about many-on-one combat situations is how often
> people forget what may be the more numerous side's greatest advantage:
> the ability to surround their foes and attack from all sides.  All too
> often, in muds and in paper RPGs, four orcs conveniently line up and
> attack a foe one at a time, or all stay in front of their foe.  If the 
> orcs really want to win, and aren't concerned with ideas like "honor," 
> they'd come at their foe from all four directions at once.

Agreed.  Not only that, but even if they are all in front of you, you can
only parry or dodge so many attacks at once (unless, of course, you're
one of the Three Musketeers or Jackie Chan, in which case this rule does not
apply).  By the same token, however, in a tight space the attackers
can end up hindering each other.  At the very least, only so many can
effectively attack at once, dependant on the terrain/layout of the nearby
area, and in some cases they may end up injuring each other - particuarly
with projectile weapons.  As they say, "Friendly fire - isn't."

> Well... AD&D does consider such things, but few GMs seem to utilize
> the rules that relate to it.  An overbearing attack can be a group
> of small monster's best tactic in many cases.

Yup.  We've found that size is one of the most important factors in combat.
Small has the advantage of being hard to hit, and making it easier for
a whole bunch of them to gang up on one opponent.  Large is good for
strength, sheer body mass which is pretty much the #1 factor in any
sort of wrestling/ground fighting/judo maneuvers, and in some cases it actually
makes it more difficult for your opponent to hit 'critical' areas, though
they may certain trip you and then start clubbing your now easily-reachable
cranium from there.

> To address Caliban's original question... some people have made attempts
> to make monsters use more intelligent tactics and strategy.  It's pretty
> easy to set up special tactics in fixed settings -- i.e., having the 
> monsters take advantage of the layout and special features of the areas
> they're in.  This usually requires some custom coding, though.

Which is what we do.  Downside, of course, is that any fixed set of algorithms
(don't adapt or 'learn') will eventually become predictable.

> Adding intelligent tactics for monsters which wander over a wide area or
> trying to make use of the terrain automatic is harder, but there are a
> few things that can be done:
> - Make monsters take advantage of "rest time."  Many muds allow PCs 
>   access to some form of fast healing.  It's only reasonable that
>   at least some monsters should have it as well.

Generally mobs heal much faster than players anyhow, even in combat or
on their feet, but I've always liked the few muds that make the effort
to have them rest, cure themselves, etc etc when no one is around.

> - Make aggressive monsters follow when their targets run away.  Players
>   don't usually leave a fleeing monster alone, so why should an 
>   aggressive monster be any nicer?

I've seen several muds put in monster tracking.  Sometimes they warn the
players, sometimes not, but usually it results in literally hundreds of
player deaths until people figure out that they actually have to *run*
away, not just take a pit stop in the next room.

> - Make groups of monsters "pile on."  If you have a grid system, you
>   could implement rules for monsters attacking from behind and to the
>   sides.  Without one, it might be good to give the monsters a bonus
>   to hit based on how badly they outnumber their foe -- it's hard to
>   defend against two attackers coming from two different directions,
>   much less five or six!

Also doable without a grid system, like the crude formation systems
that have gotten popular in the last year or two.

> - Don't allow players to control who the monsters are attacking.  In
>   some muds, monsters attack whoever attacked them last, which leads
>   to a practice called "tanking" -- whoever has the most hit points
>   is the last to attack, and soaks damage until he/she gets low.  Then
>   another character will quickly do "kill" on all the monsters, so
>   they'll all start attacking him/her while the first character heals.

Yup.  With some very simple code you can make fighting much more nasty.
Some things I've seen are:
- Monster automatically tries to 'switch' to the most wounded member of the
part.  Means that if you rescue someone when they are low on health, that
person should LEAVE the premesis immediately.
- Monsters go after the person who does the most damage, which is quite
frequently not the tank.  Thus a thief circles and does a big-damage
backstab, the mob turns on them.  A mage casts a fireball, all the monsters
in the room go after them.
- Again, from the size/number of attackers stuff above; only three or four
people can effectively fight against a single, normal sized opponent at
once.  Means splitting up your efforts - "Bubba, Boffo, and Buffy take out
the necromancer, everyone else kill all his undead guards."

We have it set up so that there is no such thing as a 'tank'.  A character
is fighting a (potentially unlimited, except by size) number of other
characters.  In a two-on-one situation, the single fighter will actually
be fighting (meaning both attacking and defending) both targets simutaneously.
As it works out, he will tend to focus on whichever of the attackers is
the most intense with her attacks.  This actually can cause a strange
side-effect somewhat similar to the circle/backstab trick (though the mechansim
is entirely different) whereby a single attacker presses hard, causing
the defender to concentrate almost entirely on them.  The second attack hangs
back and moves around to the side, then slips her blade between the poor
fellow's ribs while he's busy focusing on attacker #1.

> - Try to use weapons and armor intelligently.  Comparing weapons and
>   armor on some mud setups can be tricky, but I think it's worth the
>   effort to make monsters loot their dead foes and pick up better 
>   armor and weapons.  If you have weapon breakage rules, a smart monster

Typically they are assigned some sort of 'value' or 'quality' field, which
may be some meassure of its monetary worth, and makes comparissons quite easy.
Of course, any sort of complex system has to take into account the mobile
themselves - a minotaur barbarian isn't going to ditch his 20 kg spiked club
in exchange for a jeweled rapier just because it's technically a better

>   should carry more than one weapon.  (BTW, it's also worth it to make
>   monsters wear armor and wield weapons automatically, just to give
>   coders building monsters one less thing to forget.)

No kidding.  Of course, there are still plenty of pitfalls.  For the longest
time on an early mud I played we all thought that a certain weapon (which
happened to be anti-good) loaded on an alley cat.  As it actually worked out,
the guy who had it was good-aligned, tried to wield his weapon, it zapped him,
a cat walked by and picked it up.
Similarly you have creatures trying to wear armor that is the wrong size or
doesn't fit them (a minotaur trying to wear a helm or some boots, for example).

> More advanced ideas would include making monsters use hit-and-run 
> tactics, having them yell for help if they're in their own area (and
> having other nearby monsters respond), and having monsters in groups
> step away from combat to heal while their compatriots keep the PCs
> busy.

I'd love to see this.  Requires some pretty careful group organization;
we're planning on making hidden 'master objects' which have scripts attached
to them which actually direct the actions of their citizens.  Thus the
kobold master script may broadcast a message like 'I need three kobolds
in this location right now' and the tree most eligable (in terms of distance
and whatever else they are currently doing) kobolds will show up.

> Things get extra fun if you add in missile weapons -- monsters can then
> have snipers, support their compatriots from another room, shoot at
> foes as they close or run away, etc.  Of course, this also requires
> a lot of added complexity in the monsters, if you're to avoid PCs
> sitting in the next room and safely killing monsters with their missile
> weapons.

Well, it's simple enough to take a copy of Merc and make the mobs quite
a bit more deadly with some simple stuff like tracking.  If your combat
system is complex, however, you've already got a lot more work to do to
make mobs 'smart'.  Group AI is a whole other level; now you have to
coordinate things like deciding who should flee, who should stay, and
who should get the spoils of war.

More information about the MUD-Dev mailing list