Monsters and AI

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting. You may Image to help finance the hosting costs of this forum.
Post Reply
User avatar
Joramun
Mon Master
Posts: 927
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

Monsters and AI

Post by Joramun »

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.
What Is Your Quest ?
User avatar
Sophia
Concise and Honest
Posts: 4307
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Monsters and AI

Post by Sophia »

Joramund wrote:If a monster has an "open door attack" but the door chosen cannot be broken/opened, will the monster still shoot ?
Yes.
Joramund wrote:- how does [perception] behave exactly ? can it be "lua-modified" ?
Right now, the formula is just:
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...
Joramund wrote:how does [bravery] behave ? can it be "lua-modified" ?
Yes.
Look in method_causefear, in base/methods.lua. This is used by war cry etc., and is where the bravery value is used.
Joramund wrote:Then suggestions :
- having an "alliance system" :
I'll have to think a bit more about this one, and how to do it without completely losing my mind. ;)
User avatar
Parallax
DMwiki contributor
Posts: 424
Joined: Mon Aug 28, 2006 7:56 pm
Location: Back in New Jersey

Re: Monsters and AI

Post by Parallax »

Sophia wrote:
Joramund wrote:Then suggestions :
- having an "alliance system" :
I'll have to think a bit more about this one, and how to do it without completely losing my mind. ;)
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.

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.
User avatar
beowuuf
Archmastiff
Posts: 20686
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post by beowuuf »

Yeah, I mean if that 'if != side kill' is implemented, there is nothign to stop the designer interrupting the side check and comparing it in an and funciton as you suggetsed (so 5 belows to side 4 and 1, so you could interrupt a side 4 monster checking a side 5 and returning 4) etc
User avatar
Joramun
Mon Master
Posts: 927
Joined: Thu May 25, 2006 7:05 pm
Location: The Universe

Post by Joramun »

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.
What Is Your Quest ?
Tom Hatfield
Ee Master
Posts: 688
Joined: Mon May 07, 2001 7:00 pm
Location: Indiana, USA
Contact:

Post by Tom Hatfield »

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.
Post Reply