Author Topic: AI_Script question  (Read 412 times)

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
AI_Script question
« on: February 06, 2018, 06:03:35 PM »
Te current AI_Script block  works pretty good for enemy combatants, but not so good for friendly monsters.

my question is, can the Ai_Script.blk do this as it currently is? i.e. do we just need to add a new script (part)? If so, will Nol or Paul point in the right directin? If not, I will create a mini-mod to submit through normal channels. ;)
« Last Edit: February 06, 2018, 06:10:49 PM by manikus »

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2271
Re: AI_Script question
« Reply #1 on: February 07, 2018, 12:44:46 AM »
Quote
but not so good for friendly monsters.

Why not? 

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: AI_Script question
« Reply #2 on: February 07, 2018, 01:21:21 PM »
Quote
but not so good for friendly monsters.

Why not?

The friendly monsters just guard, unless they are adjacent to an enemy combatant, then they will attack the enemy. It doesn't always happen this ay, but I owuld say 95% of the time.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2271
Re: AI_Script question
« Reply #3 on: February 07, 2018, 02:40:35 PM »
I have not done any of the combat AI scripting myself.

If the folks who did the scripting have no solution to
your problem then you could submit a mini-mod
demonstrating the problem and I could step through
the combat and at least tell you why the monsters
act the way they do.  After that, we could work out
a reasonable solution.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: AI_Script question
« Reply #4 on: February 07, 2018, 03:02:10 PM »
This is exactly the way I as thinking it through. :) I will let Nol have a try at answering and then if necessary will create a mini-mod.

Offline Nol Drek

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2235
    • Nol Drek's Web Site
Re: AI_Script question
« Reply #5 on: February 11, 2018, 12:02:10 PM »
If a friendly monster is not in melee range, then I assume you want their default behavior to be to move closer to the nearest enemy.

Does AI_Script.blk control both friendly and unfriendly monsters? If so, why do friendly monsters guard while unfriendly monsters move closer to targets?
"Into the Drachensgrab Mountains!"

http://www.noldrek.com

Offline Nol Drek

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2235
    • Nol Drek's Web Site
Re: AI_Script question
« Reply #6 on: February 11, 2018, 12:20:12 PM »
They both (friendly and unfriendly) seem to use the FGDP filter.

\ FGDP Friendly Gone Dead Dying or Petrified Targets should not be attacked
: FGDP? Friendly? ?EXIT Gone? Dead? Dying? Petrified? OR OR OR ; 1 SP+-
\

What I suspect is that a "friendly monster" is adjacent to a PC, but not adjacent to an enemy, so it chooses to advance. It advances to the nearest target, which is the adjacent PC. Not wanting to harm a friend, the monster guards.
"Into the Drachensgrab Mountains!"

http://www.noldrek.com

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: AI_Script question
« Reply #7 on: February 12, 2018, 01:37:49 PM »
They both (friendly and unfriendly) seem to use the FGDP filter.

\ FGDP Friendly Gone Dead Dying or Petrified Targets should not be attacked
: FGDP? Friendly? ?EXIT Gone? Dead? Dying? Petrified? OR OR OR ; 1 SP+-
\

What I suspect is that a "friendly monster" is adjacent to a PC, but not adjacent to an enemy, so it chooses to advance. It advances to the nearest target, which is the adjacent PC. Not wanting to harm a friend, the monster guards.

You may be right, but it may also be that all AI controlled combatants advance towards the party, but as you mention the FGDP filter is being used, so they do not attack the party, but just end up guarding. However, if they have a ranged weapon, they will use it on enemy combatants.
I think the friendly combatants move toward the party because I have seen them move from one space away to be adjacent to a party member instead of moving toward enemy combatants.

Offline Nol Drek

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2235
    • Nol Drek's Web Site
Re: AI_Script question
« Reply #8 on: February 12, 2018, 10:18:55 PM »
I think the friendly combatants move toward the party because I have seen them move from one space away to be adjacent to a party member instead of moving toward enemy combatants.

If that's the case, then it should be fixed. "Friendly" monsters should only consider Advance actions which advance them towards the enemy, not towards their own side. I know that NPCs behave correctly, maybe Monsters don't notice that they themselves are "Friendly Monsters".

Here is the AdvanceFilter:
Code: [Select]
: AdvanceFilter \ Remove actions against invalid targets
    He C:Friendly ?EXIT
    Dead? ?EXIT
    Dying? ?EXIT
    Gone? ?EXIT
    Petrified?  ; 1 SP+-
\
"Into the Drachensgrab Mountains!"

http://www.noldrek.com

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: AI_Script question
« Reply #9 on: February 13, 2018, 03:04:52 PM »
I didn't see anyplace in the AI_Script.BLK where it mentioned who should be advanced towards, and I also looked in Forth.cpp and don't think I saw it there, either (I may be wrong on that).

I will test this with NPCs, too. If needed, I will make a mini-mod for Paul. :)

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: AI_Script question
« Reply #10 on: February 14, 2018, 12:46:48 PM »
Okay, did some testing. Friendly NPCs and monsters do attack the enemy - following the same AI as the enemy. However, the pathfinding is causing them not to go around a friendly that lies in their path towards what the AI determines is the best target.

Offline Nol Drek

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2235
    • Nol Drek's Web Site
Re: AI_Script question
« Reply #11 on: February 14, 2018, 06:51:05 PM »
Does the pathfinding use straight lines only, or would a monster who is trying to move east select one of the following directions (in order):

East
If East is blocked then NE or SE
If East, NE, and SE blocked then North or South
If E, NE, SE, N, and S blocked, then NW or SW
If all other directions except West are blocked, then West
If all 8 directions are blocked, then Guard and end turn

I'd rather have a monster jump back and forth between two locations until they are out of moves before they give up and guard.
"Into the Drachensgrab Mountains!"

http://www.noldrek.com

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2271
Re: AI_Script question
« Reply #12 on: February 15, 2018, 10:56:12 AM »
Quote from: Nol Drek
would a monster who is trying to move east

A monster does not try to move 'east'.

A monster determines the number of steps required to enter
each cell of the battlefield.  If necessary, he will take a
spiral-shaped path.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: AI_Script question
« Reply #13 on: February 15, 2018, 02:03:50 PM »
I will make a mini-mod for this - as soon as I fix my script bugs, which may be causing some of my problems in regards to movement.