I have several questions / suggestions concerning monsters and AI :
I notice that there are three variables that influence the monster behavior :
1-perception
2-bravery
3-attack types
3 are used in "monster.lua" so, there's no explanation needed really, except one thing : If a monster has an "open door attack" but the door chosen cannot be broken/opened, will the monster still shoot ?
For 1 :
- how does it behave exactly ? can it be "lua-modified" ?
- Do some monsters have some qualities like :
* can see better in light than in darkness (in DM some monsters where totally blind in half-darkness, so it was possible to bypass them using the darkness spell at low power)
* can see as good in darkness as in light
* can see better in darkness / is blinded by light
* can see invisible (like Lord Chaos in O DM)
etc.
Having two types of perception instead of one can also help having very complex behaviors...
For 2 : how does it behave ? can it be "lua-modified" ?
Then suggestions :
- having an "alliance system" :
* each monster has a side (an integer)
* the party is side 0
* each monster has two tabs of booleans : 'foe', 'friend'
* a monster ignores neutrals (side field equals "nil" / "false" in 'foe')
* a monster attacks foes (side field equals "true" in 'foe')
* a monster helps friends (side field equals "true" in 'friend')
If there is a way to distinguish "nil" of "false", you can do the whole thing with one tab.
* allow adding new class of "positive attacks" called by monsters on friends.
* allow adding functions that sets the alliance status in a lua module.
Monsters and AI
Moderator: Sophia
Forum rules
Please read the Forum rules and policies before posting. You may
to help finance the hosting costs of this forum.
Please read the Forum rules and policies before posting. You may

- Sophia
- Concise and Honest
- Posts: 4307
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Monsters and AI
Yes.Joramund wrote:If a monster has an "open door attack" but the door chosen cannot be broken/opened, will the monster still shoot ?
Right now, the formula is just:Joramund wrote:- how does [perception] behave exactly ? can it be "lua-modified" ?
seeing_distance = perception + light_level / 20
This formula is hardcoded. If I change it so that this formula is done by Lua instead, then everything else you've suggested becomes doable, so I'll do that...
Yes.Joramund wrote:how does [bravery] behave ? can it be "lua-modified" ?
Look in method_causefear, in base/methods.lua. This is used by war cry etc., and is where the bravery value is used.
I'll have to think a bit more about this one, and how to do it without completely losing my mind.Joramund wrote:Then suggestions :
- having an "alliance system" :

- Parallax
- DMwiki contributor
- Posts: 424
- Joined: Mon Aug 28, 2006 7:56 pm
- Location: Back in New Jersey
Re: Monsters and AI
It may be an oversimplifcation that makes some of the stuff you want to do impossible, but simply having a side exvar is sufficient to establish factions. If side=0 is the party, then any monster with side=0 is allied with the party.Sophia wrote:I'll have to think a bit more about this one, and how to do it without completely losing my mind.Joramund wrote:Then suggestions :
- having an "alliance system" :
After that you just need to modify the monster AI so that a monster can choose the side-appropriate action. Attack (or cast attack spell or other general nastiness) if target.side!=self.side and do nothing or cast buffs/heal if target.side=self.side.
In a regular dungeon like DM all monsters would be on the same side !=0. In a half-life dungeon scientists would be in side=0, marines in side=1, aliens in side=2, for instance. Since you can change on-the-fly the side of any number of cherry-picked monsters or even all of them at once, I believe most if not all of what you have in mind could be done.
And if you want to do something more complex like have a monster who is friends with two sides at once you can always make the AI more discriminatory than "I am Blue, I kill everything that is Not Blue" whenever a monster has to decide its next action.
Par : ok, basically that's what I thought but then i added the
friend/neutral/foe specification, because I thought of more tangled situation, like a bunch of monsters just doing a melee, or an ecosystem of monsters with predators, preys etc. (speaking of "half-life"...)
Beo : yes, but it means exporting some of the AI in a lua module,
instead of adding some dsb_check_side(id,target) etc. functions.
Anyway, I suppose I'll wait for Sophia's conclusions on this one, since I have no idea of what the hardcoded AI currently does.
friend/neutral/foe specification, because I thought of more tangled situation, like a bunch of monsters just doing a melee, or an ecosystem of monsters with predators, preys etc. (speaking of "half-life"...)
Beo : yes, but it means exporting some of the AI in a lua module,
instead of adding some dsb_check_side(id,target) etc. functions.
Anyway, I suppose I'll wait for Sophia's conclusions on this one, since I have no idea of what the hardcoded AI currently does.
What Is Your Quest ?
-
- Ee Master
- Posts: 688
- Joined: Mon May 07, 2001 7:00 pm
- Location: Indiana, USA
- Contact:
Depending on how many factions you intend to have, a bit-flag might work better. A creature hostile to all factions (including its own) would have a faction of zero (0), so the test "if (self.faction & target.faction)" would return false in all cases. This is not a replacement for your idea so much as an extension of it, for more complicated relationships.