Author Topic: AI_Script request  (Read 286 times)

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
AI_Script request
« on: February 08, 2018, 02:41:46 PM »
I would liketo request a new function foruse in AI_Script.BLK.
I would like a combatant function, something like C:Class, which would look in the class of the combatant for an SA called "$AI_Class" so that the parameter can be examined to determine if an action should be taken. If you think that baseclass is more appropriate, I would be fine with that in leiu of this suggestion.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2271
Re: AI_Script request
« Reply #1 on: March 20, 2018, 06:15:20 PM »
It seems to me right now that any attribute that can be
assigned to a baseclsss (versus a class) should be assigned
to a baseclass.  So let us put it there.

Send me a mini-mod that uses this C:AIBaseclass.  The function
will return the SpecialAbility parameter or, in the case such a
SpecialAbility does not exist or the parameter exceeds the
limits -32767 to 32767, then -32768;

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: AI_Script request
« Reply #2 on: March 22, 2018, 12:26:43 PM »
Good afternoon, Paul.

The mini-mod shows a combat with two types of enemy combatants: Bugbears with baseclass fighter, Mind Flayer with baseclasses fighter and magicUser. The magicUser has an SA called $AI_Baseclass with a value of 1. The AIScript.blk TestAdvance section has been modified to read:
   : TestAdvance   
      \ The action of advancing on an enemy comes next
      Me A A:Type B A:Type A:T:Advance =
      IF
         A:T:Advance =
         IF
            C:AIBaseclass 0 <
         ELSE -1 THEN
      ELSE
         A:T:Advance =
         IF 1 ELSE 0 THEN 
      THEN ; 1 SP+-

What I am trying to achieve is that combatants with said SA with a positive value will not advance on enemies in combat.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2271
Re: AI_Script request
« Reply #3 on: March 22, 2018, 04:59:55 PM »
Unfortunately, it appears that you have modified the
code that compares two actions.  This won't work well.
As an extreme example, it may be the case that only one
action is possible (advance on the only opponent).

What you want to do is remove 'Advance' from the list of
possible actions.  You do this in the 'AdvanceFilter'.

See:
http://dianneandpaul.net/UAF/Help/CombatScripts.html
How the engine goes about using the scripts (item 7)

Not to worry.  I know what you are trying and I will fix things up.
I'll post my version of the filter.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: AI_Script request
« Reply #4 on: March 22, 2018, 06:03:00 PM »
D'oh! I should know better than to have done that. ;) I am glad that you were still ableto understand what I meant.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2271
Re: AI_Script request
« Reply #5 on: March 22, 2018, 06:39:30 PM »
Next.....I want to change the way this works
and the value returned when the Special Ability
is missing.

The combatant may have several baseclasses.
If more than one has this Special Ability, then I will
provide the logical (bitwise) OR of all of them.
If none has this Special Ability then the result will
be 0.  Alternative???

So.....I recommend that you use this Special Ability as
a source of flags.
Bit 0 means cannot advance
Bit 1 means cannot use melee weapon
Bit 2 means sight distance limited to 3 cells.
Bit 3 means sight distance limited to 6 cells.
etc.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: AI_Script request
« Reply #6 on: March 22, 2018, 07:19:50 PM »
Ikay. You will have to refresh my memory of how bit flags work, because I am having trouble seeing how this can work with an unknown number of baseclasses, by which I mean that we do not know in adance how many baseclasses a designer will use for a particular for the combatants. Hmmm, I guess if it is OR it doesn't matter how many baseclasses because any not 0 is 1, so one baseclass or five will work the same.

This sounds good to me. It will allow designers, myself included to more easily customize the AI script.

Offline Nol Drek

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2235
    • Nol Drek's Web Site
Re: AI_Script request
« Reply #7 on: March 22, 2018, 08:29:11 PM »
Bit Flags work like this:

1111 = sight limited to 6, sight limited to 3, cannot use melee, and cannot advance are all true
1010 = sight limited to 6 and cannot use melee are true, the others are false
0001 = cannot advance is true, the others are all false

Doing a bitwise OR on each column will result in a 1 if any of them are true. In other words, if a flag is true for any one of the base classes, then the condition is true. The condition will only be false if the flags are false for all baseclasses.

For example:

 1001 OR 0101 = 1101

 0001 OR 0010 OR 0100 OR 1000 = 1111
"Into the Drachensgrab Mountains!"

http://www.noldrek.com

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2271
Re: AI_Script request
« Reply #8 on: March 23, 2018, 09:12:34 AM »
Engine version 3.59.

I added a single line to the existing AdvanceFilter:
Code: [Select]
:
AdvanceFilter \ Remove actions against invalid targets
     Me C:AIBaseclass 1 AND ?EXIT
    FGDP? ; 1 SP+-

I added a single line to the definition of baseclass magicUser:
Code: [Select]
Special Ability = $AIBaseclass,1

Your Mind Flayer no longer advances.

I updated documentation at:
http://dianneandpaul.net/UAF/Help/CombatScripts.html

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: AI_Script request
« Reply #9 on: March 23, 2018, 05:14:39 PM »
Thank you, Paul. I will download the engine and help and try it out this weekend.

Thanks for the clear explanation, Nol. :D

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: AI_Script request
« Reply #10 on: March 27, 2018, 05:46:52 PM »
Okay, I am getting an error, and sometimes the Mind Flayer advances and sometimes not. I added the lines to the scripts exactly as you said to. New mini-mod attached.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2271
Re: AI_Script request
« Reply #11 on: March 27, 2018, 06:38:09 PM »
I suspect it is because you said:
Code: [Select]
<tab>Me C:AIBaseclass 1 AND ?EXIT
<tab>FGDP? ; 1 SP+-

and the compiler does not recognize a <tab> as whitespace.
Try putting spaces in there and see if it helps.

Meanwhile, I will try to encourage the compiler to be
more accepting.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: AI_Script request
« Reply #12 on: March 27, 2018, 07:26:05 PM »
I suspect it is because you said:
Code: [Select]
<tab>Me C:AIBaseclass 1 AND ?EXIT
<tab>FGDP? ; 1 SP+-

and the compiler does not recognize a <tab> as whitespace.
Try putting spaces in there and see if it helps.

Meanwhile, I will try to encourage the compiler to be
more accepting.

I had not even thought of that.  I went <tab> crazy with the script.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2271
Re: AI_Script request
« Reply #13 on: March 30, 2018, 11:08:44 AM »
Engine version 3.60 is supposed to allow tabs where spaces
are expected.  I even tested it a little bit.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: AI_Script request
« Reply #14 on: March 30, 2018, 01:32:47 PM »
Thank you, Paul

 

anything