RavenRed: Just a quick idea starter...
Currently there are two basic states of AI, Awake and attacking the player (or its other factionally defined foes) or asleep. This is just to suggest a few alternate states in between. With the new ways in which AI works, these can transition to other AI states by whatever defined logic exists. I'd like to suggest that there be two "default" AIs for awake monsters. One for a monster not awakened to hostile action and the other for a monster in a "combat" situation. The below are just a couple of examples of how this might work.
Scavenger
If the monster has ANIMAL=true, it heads for the nearest corpse in LOS. Upon arriving, it devours the corpse (deleting it). This may be important for summoners or necromancers to keep that Lone Wolf away from your precious Unique Corpse. If ANIMAL=false then the monster heads for the nearest non-corpse item and picks it up. If there is no corpse or item within LOS, it moves randomly until returns to a "Sleeping" AI within 1d100 turns. If attacked or becomes aware of a factional enemy, it switches to its combat AI.
Guarding
Like Sleeping (immobile), except the monster immediately goes to its combat mode if a factional hostile monster comes within LOS. Returns to sleeping mode within 100d20 turns.
Seeking
Monster moves steadily across a room in a straight line from the door. If it comes up against a solid object, it picks the nearest door at random and heads through that until it reaches a room and the logic re-starts. Returns to sleeping mode or Guarding mode (equal chance) within 100d50 turns. Immediately goes to combat mode if a hostile comes into LOS.
Patrolling
Monster moves in a predictable pattern. This could be achieved by giving it starting point X,Y and by telling it to return to this point by never returning through the same doorway unless number of other available doorways = 0. By this means, you could determine a relatively predictable pattern. With the new BATTLE_AI, I'd be surprised if this couldn't be made to work for squadrons as well as individuals.
_
So how could these work in practice?
Well think of our old Moria Friend Evil Iggy. Evil Iggy could be created with ai.SLEEP. Unfortunately, the noisy dwarf warrior in the next room wakes Iggy up. He decides to go for a wander to find what he can find. Therefore, ai.SEEKING comes into effect. He does this for a while and gets bored. Therefore he stops and decides to wait. Borin', son of Tedium walks into the room. Iggy immediately switches to ai.SMART_CAST and starts to pepper Borin' with spells. Borin reads a teleport spell and flees. Having lost LOS, Iggy switches back to ai.SEEKING. He wanders around the dungeon for a while, and then, satisfied with his vigilance and irritating power, he re-engages ai.SLEEP.
I would think that these could be nested within each other fairly effectively (though I'd suspect they'd be done within the lua AI files rather than "on-the-fly" within the monster descriptions.
This would create somewhat more varied monster behaviour, especially if the term "LOS" could become mosnter-centric (using "aaf") rather than being based on the player seeing the monsters.
2c worth and counting...
DarkGod: Yeah I was thinking of that for a while. In Bone to be Wild monsters are on a Guard AI, they become active when in LOS (but then they stay active forever). Thing is to ensure that monsters can "switch off" a combat AI it would need a new "meta" AI that selects if it wants to combat or seek/guard/whatever. Without ever switching fomr this meta AI as the main AI. Something like:
AI = ai.COMBAT_NON_COMBAT
AI_STATES =
{
NON_COMBAT_AI = ai.PATROL
COMBAT_AI = ai.SPELL_AND_MOVE
CAST_AI = ai.SMART_CAST
MOVE_AI = ai.SNAKE
...
...
}
Obviously PATROL/SEEK/SCAVAGE/... would need to use the underlying MOVE_AI to do the actual movement.
RavenRed: Well I would have thought that it replaced the existing (combat related) move AI, whilst also disabling ALL casting AIs. Also, unless you wanted to have monsters that have a chance of doing ALL the AIs, you'd need to either define the non-combat AIs in the monster list or create some probably quite elaborate rules to govern which monsters do what. I'm not sure horses (for example) should really eat the carrion of fallen monsters.
DarkGod: ? Each monsters would define their meta AI and sub AIs, as in my example
RavenRed: Also, as I said, it needs a monster-centric LOS to be really usable (modifiable by AAF, invisibility and possibly even stealth).
DarkGod: Yeah that's fine, it could be a tad slow but i'm not so sure, we can optimise it latter if it really is
NeilStevens: Monster LoS? Oh my, I may want that very very very very very badly for E-Team. I mean, I'm already going to start faking it, to a degree, with some checks for smoke blockage as it is.
DarkGod: You can compute it easily: if los(y1, x1, y2, x2) then ... end This should be fine for the AIs, they could do it once in a while, but this might not be practical for everything
BucketMan: I make no claims regarding code quality, but some of the concepts discussed here have been succesfully implemented in Dragonball T. The RRA snow patrol performs a 'patrol' effect, and a number of uniques vary their behavior whether the player is in los. Some other interesting effects as well: Yamcha can hunt down the player and initiate dialogue, Lunch changes her ai based on semi-random sneezes, baby mice follow King Mouse in a long congo-line rather than a clump, some monsters who only appear on special levels have waypoints based on the map, etc. Again, no promises no code quality, but it might be worth taking a look.
ToME Wiki