Author Topic: Possible bug in the combat AI (or is it a feature?)  (Read 243 times)

Online Mechanaut

  • Full Member
  • ***
  • Posts: 124
Possible bug in the combat AI (or is it a feature?)
« on: August 13, 2017, 04:38:48 PM »
I have noticed that at times the enemy AI will not attack PCs that step away from them. In FRUA/and all GB games, the enemy will always attack the PC if they step away from an adjacent square.  (currently using version 305)

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9763
Re: Possible bug in the combat AI (or is it a feature?)
« Reply #1 on: August 14, 2017, 01:06:18 PM »
It depends on the number of guarding attacks available to the combatant. A combatant with 2 attacks per round can make up to 2 guard attacks per round. If they have used their 2 attacks previously in the round, they do not get a guarding attack.

Online Mechanaut

  • Full Member
  • ***
  • Posts: 124
Re: Possible bug in the combat AI (or is it a feature?)
« Reply #2 on: August 14, 2017, 08:14:05 PM »
That makes sense, but it's not what I was I was describing...  Guarded attacks happen (afaik) when the enemy (or PC) is approached—while guarding.  What I meant above, is the attack of opportunity that happens when an adjacent opponent steps away from their enemy. 


Do you mean that in DC this only happens when the combatant ended their turn with a guard action? 

Offline Nol Drek

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2157
    • Nol Drek's Web Site
Re: Possible bug in the combat AI (or is it a feature?)
« Reply #3 on: August 14, 2017, 09:38:19 PM »
That makes sense, but it's not what I was I was describing...  Guarded attacks happen (afaik) when the enemy (or PC) is approached—while guarding.  What I meant above, is the attack of opportunity that happens when an adjacent opponent steps away from their enemy. 


Do you mean that in DC this only happens when the combatant ended their turn with a guard action?

I agree with you that monsters should get a free attack of opportunity whenever a PC moves away from them, regardless of how many attacks they have previously taken in the current round.
"Into the Drachensgrab Mountains!"

http://www.noldrek.com

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9763
Re: Possible bug in the combat AI (or is it a feature?)
« Reply #4 on: August 15, 2017, 01:58:44 PM »
That makes sense, but it's not what I was I was describing...  Guarded attacks happen (afaik) when the enemy (or PC) is approached—while guarding.  What I meant above, is the attack of opportunity that happens when an adjacent opponent steps away from their enemy. 


Do you mean that in DC this only happens when the combatant ended their turn with a guard action?

My misunderstanding. You mean free atttacks. :)
These are also scripted in DC.

Here is the code, followed by some explanation:
Code: [Select]
[FreeAttack-AttackOver] = $SET_HOOK_PARAM(7,"0");
-$RETURN;
[FreeAttack-CanFreeAttack] = $VAR rangeWpn; $VAR par8;
-rangeWpn = $GET_ITEM_SA($GET_CHAR_Ready($AttackerContext(), "WEAPON", 0),"item_CombatAim");
-par8 = $GET_HOOK_PARAM(8);
-$IF (rangeWpn != "-?-?-"){$RETURN "N";};
-$RETURN par8;

In the "FreeAttack-AttackOver" script, parameter 7 is the number of free attacks that the combatant has subtracted from their number of available attacks. It is set to 0, because they should get a free attack each time an adjacent combatant moves away from them.
In the "FreeAttack-CanFreeAttack" script, parameter 8 is the number of attacks allowed per turn for this combatant. For PCs and NPCs, it is usually one, but may be up to two for high level fighters, paladins and rangers. For monster combatants, it is equal to the number of attacks they have listed in their record in the monster database.

Speculation:
I am guessing that the number of free attacks is used up for the turn when it is not occurring but you think it should be. By which I mean that a Giant Rat, which has only one attack, can free attack against the first combatant moving awar from it, but not the second one moving away from it in the same turn. The next turn, the Giant Rat will have one free attack again.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2220
Re: Possible bug in the combat AI (or is it a feature?)
« Reply #5 on: August 15, 2017, 02:31:22 PM »
Is there any documentation for these hooks:
FreeAttack-AttackOver
FreeAttack-CanFreeAttack

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9763
Re: Possible bug in the combat AI (or is it a feature?)
« Reply #6 on: August 15, 2017, 02:57:02 PM »
Is there any documentation for these hooks:
FreeAttack-AttackOver
FreeAttack-CanFreeAttack

Yes. They are in the Guarding Hooks section.

http://www.dianneandpaul.net/UAF/Help/SAGuardingScripts.html

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2220
Re: Possible bug in the combat AI (or is it a feature?)
« Reply #7 on: August 15, 2017, 03:06:31 PM »
Thanks much.  I was searching for "Free" and found
nothing.  I have added "Free Attacks" to the
"Guarding Atacks" in the SASpecialAbilitiesScripts.html
index so I can find it myself next time.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9763
Re: Possible bug in the combat AI (or is it a feature?)
« Reply #8 on: August 15, 2017, 03:32:37 PM »
I will do that in my copy of the Help as well. I only knew to looking in the Guarding SAs help page because I had first looked at the Competing SA and saw them together. :D

Offline steve_mcdee

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 1945
Re: Possible bug in the combat AI (or is it a feature?)
« Reply #9 on: August 15, 2017, 05:19:46 PM »
I believe that in FRUA and gold box games, enemies would have a free attack every time a character moves away from them. I think those of us familiar with FRUA would prefer that system to apply in DC as well. Otherwise, once an enemy has used up their attacks of opportunity for the round, there is nothing to stop you just walking past them as though they were not even there.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9763
Re: Possible bug in the combat AI (or is it a feature?)
« Reply #10 on: August 15, 2017, 06:14:46 PM »
I believe that in FRUA and gold box games, enemies would have a free attack every time a character moves away from them. I think those of us familiar with FRUA would prefer that system to apply in DC as well. Otherwise, once an enemy has used up their attacks of opportunity for the round, there is nothing to stop you just walking past them as though they were not even there.

Actually, there is. :)
Free attacks do not subtract from regular or guard attacks.

When nologgie was here, we spent a long time debating these scripts, and other people were involved. This is what we settled on.
For your design, however, you can set the free attack number to something like 99999 and that should cover your concern.

Offline steve_mcdee

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 1945
Re: Possible bug in the combat AI (or is it a feature?)
« Reply #11 on: August 16, 2017, 04:18:25 AM »
... that should cover your concern.

Yes, that should suffice. I suppose I was suggesting that something like 99999 should be the default value.

Offline Nol Drek

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2157
    • Nol Drek's Web Site
Re: Possible bug in the combat AI (or is it a feature?)
« Reply #12 on: August 16, 2017, 07:08:00 PM »
99999 seems like too small a number. I think the number of free attacks should be infinity.

Change these two scripts in the "Competing" Special Ability. This should allow for unlimited free attacks, unless the combatant is holding a ranged weapon.

Code: [Select]
[FreeAttack-AttackOver] = $RETURN;

[FreeAttack-CanFreeAttack] = $VAR rangeWpn; $VAR par8;
rangeWpn = $GET_ITEM_SA($GET_CHAR_Ready($AttackerContext(), "WEAPON", 0),"item_CombatAim");
par8 = $GET_HOOK_PARAM(8);
$IF (rangeWpn != "-?-?-"){$RETURN "N";}
$ELSE {$RETURN "Y";};
"Into the Drachensgrab Mountains!"

http://www.noldrek.com

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2220
Re: Possible bug in the combat AI (or is it a feature?)
« Reply #13 on: August 16, 2017, 07:16:59 PM »
Quote
number of free attacks should be infinity.

'Infinity' is not a number.  :angel:

Offline Nol Drek

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2157
    • Nol Drek's Web Site
Re: Possible bug in the combat AI (or is it a feature?)
« Reply #14 on: August 16, 2017, 07:33:03 PM »
'Infinity' is not a number.  :angel:

I apologize for my lack of precision.

I meant to say that the cardinality of the set of free attacks should be aleph-null.
"Into the Drachensgrab Mountains!"

http://www.noldrek.com