MineColonies

MineColonies

57M Downloads

[Enhancement] Better guard survival strategy

MattBeard opened this issue · 2 comments

commented

Minecolonies version

version 1.12.2.0.8.9??? onwards?

Expected behavior

  • Guards fight with some common sense

Actual behaviour

  • Guards are happy to wade into a pack of mobs/barbarians and get pulverised

Suggestion

In the guard AI code, probably in getTarget(), where the nearby area is scanned for targets, make a count of all threats to the guard (i.e. mods/barbarians) and if that is greater than a threshold the guard changes AIState to GUARD_RUN_AWAY or similar. This will allow them to get out of no-win situations and regain health for a short while. The threshold used needs to be based on the level of the guard (higher level guards will fight better and so can hang around in the melee longer) and the health state of the guard (the lower the health the more likely to run away). It should be possible to add in the armour level for the guard too - more armour = more brave.

When in the run-away state every few ticks the guard should check health (must be > 50%) and number of mobs in attack range (must be low-ish) and will then switch back to attacking, but will pick a new target in case there is now a better one.

Also, the direction of running away should ideally be picked as soon at the decision is made to run, and it should be in the first direction found to be relatively free of mobs... so perhaps pick random locations about 3 or 5 attack ranges away in random directions and as soon as one is found that is a candidate (perhaps less than half the threshold used before) and is visible from here... run that way. This could perhaps be updated every now and then during the run-away phase.

commented

@Asherslab this is actually a pretty good idea 🗡 !

commented

Perhaps tie such advanced AI behavior into either the intelligence stat, or perhaps the building level?

Better training/smarter guards lead to more survivability.