Wednesday, 5 August 2009

Sprucing up Monster AI #1

Monster behaviour in Kharne is currently pretty dumb. I'm not talking about (the not-implemented) special attacks and behaviour for each creature, but rather they will currently stand and fight even though the player is butchering them.

I've been thinking about this and I can achieve what's known in software engineering as a 'quick win' which will enchance AI considerably.

Put simply:

Allow certain monsters to flee away from the player if they are sufficiently injured. If there are other monsters visible that belong to the same ecology, then flee towards them. Else flee directly away from the player. If a fleeing monster cannot move away from the player, then it turns and fights.

Print fleeing/unfleeing messages as appropriate ("the wibbly flees!", "the wibbly turns and fights!")

Now, there is some additional subtlety I intend to code. If there is a Unique Monster within line of sight, injured monsters don't flee but instead shout something along the lines of "We will die for you, Wibbly the Doomy!"

Perhaps the opposite effect could also occur - when a Unique dies, all sentient monsters within view flee with a "Seeing its Champion dead, the wibbly runs away". Obviously this would not be a permanent fleeing, but of time-limited duration.

(cross-posted at r.g.r.d.)

No comments: