Saturday, April 9, 2011 - 08:25
I have had a long thought about AI.
Here are my suggestions how it can be improved:
1. Fear. I would like to have monsters that run away. This could be under the following circumstances:
- Being damaged a lot. (Lets say 50%)
- Being a higher level than the monsters.
- Monsters usually run away to friends (who are not yet triggered)
2. Communication between monsters.
- When a monster notices you, all creatures near him will notice and attack you as well. (At least those on the same team, see below)
- A monster will also “scream for help” when they are fleeing. (See fear) This can cause a lot of monsters to get triggered. Not sure yet, if they should attack or contignue fleeing.
3. Non-target specific AI code. At the current moment, monsters can only attack players. I would like to see that different.
- All creatures are put inside a team. (1 byte, at first: 0 = player, 1 = monsters)
- This allows for making friendly creatures, summons and henchmen.
- It is (almost) a must for multiplayer.
4. Better path-finding. In the current situation monsters try to run towards you. If they got blocked, they stop moving. I do not have one solution for this problem, but 3 ones (and all in some way or another flawed).
- A* is a bit of an overkill, and often uses too many resources for a simple game. [difficult code, resourse high, perfect patfinding]
- The labyrinth / follow the right (or left) wall mechanism. [moderate code, resource low, improved pathfinding]
- Moving a few steps in a random direction when getting stuck. (I think that we can do a bit better than random but you get the idea) [simple code, resource low, improved pathfinding]
PS: Clint, I do not post this to give you more work. I am confident enough in my coding skills that I can probably implent these AI improvements myself.
I was thinking the same things for the two firsts points during my last game (I agree with the third, and know nothing about pathfinding...). I would just add that these better AI may be depending on the subject: I can't imagine a minotaur, a zombie or a spider fleing or screaming for help. But a goblin, yes.
Completely True.
Some monsters are loners, others are team-workers, so most AI parts should be configurable. (You'll have a hard time scaring off a minotaur)
I forgot to mention that I want to make variables in the AI code. (E.g. Courage, Cooperative skills, melee-ranged preference). I hope that will improve the feel that every monster is different.
AI gets into a long discussion, I think we should figure stuff out before code gets written/changed.
Pathfinding
Currently the pursuit AI is dead simple: face the hero and walk forward. It is supplemented by one main feature: If the enemy loses Line of Sight on the creature, the enemy instead pursues where it last saw the hero. This works surprisingly well for most situations.
I think this could be supplemented by A* in the following way: If the enemy has Line of Movement, use the simple pursuit (face hero, move forward). If the enemy loses Line of Movement but can still see the target, calculate an A* path once and follow that path until Line of Movement is re-established (then abandon the A* path and continue with simple pursuit).
Fear
This can be done simply: face away from the hero and move forward. A chance_flee could be used, and checked when certain situations occur (e.g. another nearby enemy dies, the enemy takes damage, etc). Spells could also have a fear_duration added (War Cry was intended to have an AOE fear component).
Monster Packs
One simple way that monster packs can be done: enemies in combat could emit an AOE pulse that targets creatures (e.g. source Neutral). It could have no damage component but still have an attack roll. Basically, if a creature is attacked (even if missed) it automatically enters combat. Dropping an invisible AOE hazard could be an easy way to get nearby creatures into combat.
Non-Target Specific AI
This might be too far outside the scope of Flare 1.0. Save it for another time. Flare 1.0 won't have henchmen, pets, multiplayer, creatures attacking each other, etc.
Here is a pathfinding algorithm I made
Is this a good idea for FLARE?
PS: I am aware that flare is written in C++ and this application in C#. I am willing to rewrite it.