OpenDungeons/OpenDungeons — pull request #162 by hwoarangmy (2014-09-19 23:11:53+00:00)
Title: Fixed creature behaviour when fighting. With this patch :

- Workers attack workers only.
- If workers are attacked by something else than a worker (creature, trap, ...), they flee
- When a creature or a worker is weak, he flees from combat
- If a fighter is weak and there are no ennemies around, he tries to sleep
- When a creature flees, it tries to go closer to its dungeon heart. If it cannot reach it, it flees randomly on visible tiles
- When a creature flees near the dungeon heart, it flees randomly on visible tiles
- Creatures always try to go to the farest position (depending on range) they can before engaging (within visible tiles). That means that ranged unit need melee units to avoid running away for ages.
- If a creature is in bad mood, it has 20% chances of fleeing instead of fighting when seeing an ennemy. For now, it is in bad mood if awakness < 10% and hunger > 90% at the same time

fixed #161
fixed #154
fixed #104
fixed #90
fixed #73

To test it, I've changed the map TestSingleplayerSmall.level. Player 1 spawns with 1 BigKnight (range 1) and 1 Advanturer (range 3). Moreover, there is 1 claimed tile in the dungeon bottom right to be able to drop units and see them fight/flee.