Author Topic: Monster item use  (Read 341 times)

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Monster item use
« on: February 06, 2018, 07:10:27 PM »
I have forgotten the answer to this - is there a function/Hook to make a monster or NPC under computer control, use a particular item in its inventory?

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2271
Re: Monster item use
« Reply #1 on: February 07, 2018, 12:41:05 AM »
In combat the engine depends on the 'Artificial Intelligence'
scripts to decide what a monster should do.

See:

http://dianneandpaul.net/UAF/Help/CombatScripts.html

So you can prioritize any weapon you choose.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: Monster item use
« Reply #2 on: February 07, 2018, 01:17:49 PM »
In combat the engine depends on the 'Artificial Intelligence'
scripts to decide what a monster should do.

See:

http://dianneandpaul.net/UAF/Help/CombatScripts.html

So you can prioritize any weapon you choose.

Thank you, Paul. This is exactly what I needed.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: Monster item use
« Reply #3 on: February 08, 2018, 02:30:18 PM »
Okay, re-familiarizing myself with FORTH is going well, but I can't seem to find definitions of "?EXIT" and "SP+-".

Any help would be appreciated. :)

Offline Milos Gulan

  • Hero Member
  • *****
  • Posts: 3225
Re: Monster item use
« Reply #4 on: February 08, 2018, 03:15:07 PM »
Very interesting, I will have to learn this ;D

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2271
Re: Monster item use
« Reply #5 on: February 08, 2018, 07:15:23 PM »
Are the available functions documented anywhere that you know?
If more than one person is going to use this capability, then I
suppose it should be documented.   :(

The documentation for me exists in the file Forth.cpp.

?EXIT  (0)    means   DROP
?EXIT (non-zero)    means   EXIT

See Forth.cpp  "Kf_QuestionExit"


SP+-    is a debugging aid.  It tells how many entries are
added to or removed from the data stack by the previously
defined word.  The interpreter checks this and thereby discovers
some of the most common and difficult bugs.
« Last Edit: February 08, 2018, 07:18:24 PM by Paul R. Stevens »

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: Monster item use
« Reply #6 on: February 09, 2018, 03:21:15 PM »
Thank you, Paul.

I don't have the source code on this computer, so was going to download  it from SourceForge, but they have decided that they are no longer supporting VVS and as such it can't be accessed via the web site - I would need to dowload a VS viewer and go in through FTP. So, I am not getting the source code, at least not today.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: Monster item use
« Reply #7 on: February 09, 2018, 03:30:04 PM »
Additional questions:

The following lines appear -
Code: [Select]
: SpellCasterFilter \ Remove actions against invalid targets 
FGDP? ?EXIT TooFar? ; 1 SP+-
\
: SpellLikeAbilityFilter \ Remove actions against invalid targets
FGDP? ?EXIT TooFar? ; 1 SP+-
\
: AdvanceFilter \ Remove actions against invalid targets
FGDP? ; 1 SP+-
\
: RangedWeaponFilter \ Remove actions against invalid targets 
FGDP? ?EXIT TooFar? TooNear? OR ; 1 SP+-
\
: MeleeWeaponFilter \ Remove actions against invalid targets 
FGDP? ?EXIT TooFar? ; 1 SP+-
\
: JudoFilter \ Remove actions against invalid targets
FGDP? ?EXIT NotAdjacent? ; 1 SP+-

Are these 'filters' being run at time of definition? I don't see them called later, such as in THINK.

Since they are not called later, should I call them in THINK, or should I reduce them down to a filter?
The reduced filter would be:
Code: [Select]
: Filter \ Remove actions against invalid targets
FGDP? ?EXIT TooFar? TooNear? NotAdjacent? OR OR ; 1 SP+-

It seems to me that the only reason to have separate filters is if they are bing called at different times.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2271
Re: Monster item use
« Reply #8 on: February 09, 2018, 06:01:04 PM »
Oh, my.  I have no idea.   I will dig into the
code and see if I can document how it works.

Meanwhile, I have posted the file Forth.cpp in
the UAF folder:
http://dianneandpaul.net/UAF/Forth.cpp

It is a bit ugly to read but you might find a hint
here and there as to how it works.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2271
Re: Monster item use
« Reply #9 on: February 09, 2018, 07:00:48 PM »

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: Monster item use
« Reply #10 on: February 10, 2018, 03:18:01 PM »
Thank you, Paul. I am looking at both of them now.

I have a further quesstion about filters - are the ones listed the only ones allowed? I don't really need one, but I am curious.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2271
Re: Monster item use
« Reply #11 on: February 10, 2018, 06:35:08 PM »
I added JudoFilter and AdvanceFilter to the documentation.
That is now a complete list.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: Monster item use
« Reply #12 on: February 10, 2018, 06:42:08 PM »
I added JudoFilter and AdvanceFilter to the documentation.
That is now a complete list.

Thank you, Paul.

Offline Nol Drek

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2235
    • Nol Drek's Web Site
Re: Monster item use
« Reply #13 on: February 11, 2018, 11:57:38 AM »
Code: [Select]
: THINK \ Return int <action A> minus <action B>
    \ This is the main decision-making portion of the AI
    \ Two actions, A and B, are given
    \ If A - B if positive, action A is preferred
    \ If A - B is negative, action B is preferred
    \ If A - B is zero, the preference cannot be determined
    \ Any attack using a SpellCaster item takes precedence over any attack
    \ not using a SpellCaster item.
    TestSpellCaster ?EXIT
    TestSpellLikeAbility ?EXIT
    \ Neither (or both) attacks is a SpellCaster item.  So we proceed.
    \ Any action using a ranged weapon takes precedence over
    \ a non-ranged attack action
    TestRanged ?EXIT
    \ Melee attacks come next
    TestMelee ?EXIT
    TestMeleeVersusMelee ?EXIT
    \ Unarmed (Judo) attacks come next
    TestUnarmed ?EXIT
    \ Advancing on an enemy comes next
    TestAdvance ?EXIT
    TestAdvanceVersusAdvance ?EXIT
    \ The only action left is to guard
    0 ; 1 SP+-

The filters are all called in the THINK function shown above.
"Into the Drachensgrab Mountains!"

http://www.noldrek.com

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9971
Re: Monster item use
« Reply #14 on: February 12, 2018, 01:40:55 PM »
Sorry Nol, I actually meant filters that  had the word "filter" in them - the ones defined towards the top of hte file.

 

anything