Jump to content


Photo

What does StateCheck(Myself,STATE_NOT_VISIBLE) match?


  • Please log in to reply
8 replies to this topic

#1 i30817

i30817
  • Member
  • 611 posts

Posted 26 October 2011 - 09:27 AM

So i thought this would match any character that currently was either in stealth, invisible or improved invisible.

Apparently it also (only?) matches non-detectable characters, if they are visible or not.

Is this a bug?
I ask because i have a trigger for auto attack with

!StateCheck(Myself,STATE_NOT_VISIBLE)

Not auto attack with not visible. But a char with a nondetection cloak is not attacking even when visible (others seem ok).


Ah forget it. It's a bug with the potion routine somehow (healing the char made things go back to normal).


Can you tell why one of these would trigger, and yet not quaff the potion?
IF

  ActionListEmpty()

  HPPercentLT(Myself,80)

  HasItem("POTN55",Myself)  // ~Potion of Superior Healing~

  !GlobalTimerNotExpired("Cast","LOCALS")

THEN

  RESPONSE #100

    UseItem("POTN55",Myself)  // ~Potion of Superior Healing~

END



IF

  ActionListEmpty()

  HPPercentLT(Myself,80)

  HasItem("POTN52",Myself)  // ~Potion of Extra Healing~

THEN

  RESPONSE #100

    UseItem("POTN52",Myself)  // ~Potion of Extra Healing~

END



IF

  ActionListEmpty()

  HPPercentLT(Myself,80)

  HasItem("POTN08",Myself)  // ~Potion of Healing~

THEN

  RESPONSE #100

    UseItem("POTN08",Myself)  // ~Potion of Healing~

END

Edited by i30817, 26 October 2011 - 09:48 AM.


#2 Sasha Al'Therin

Sasha Al'Therin
  • Modder
  • 615 posts

Posted 26 October 2011 - 02:47 PM

to answer any way...

STATE_NOT_VISIBLE is an IDS reference located in the state.ids file
it is a custom (i.e. mod added) state and is a combination of the various states which one would typically check for when not wanting a thief in hiding, a character having taking an invisibility potion or a character under the effects of an invisibility spell to accidentally perform and subsequently be removed from the hidden state.

I'm not exactly sure of which game you are referring to, but as an example from BG:ToTSC

0x00400010 STATE_NOT_VISIBLE
combines
0x00000010 STATE_INVISIBLE
0x00400000 STATE_IMPROVEDINVISIBILITY

for future reference for your own modding purposes (public or private) you can combine any states that you wish by adding together the hex number and giving it a meaningful label.

As an example I made one that isn't typical, but since I am some day planning to make a party script that will install as necessary based upon the given game I created 0x00084000 STATE_POISONDISEASE which by it's name combines STATE_POISONED & STATE_DISEASED. I did that since IWD doesn't have poison, but rather has disease. Since the items used are scripted similarly, I can use a singular check for both BG & IWD and apply a variable to the item/spell reference as needed.

My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altheri...s.com/index.htm


#3 i30817

i30817
  • Member
  • 611 posts

Posted 26 October 2011 - 02:55 PM

Yeah i understand all of that and bitwise or-ing.

I just misdiagnoized the reason the script stopped responding for a char and not the others (the potions).

It seems really weird that - the script stopped on those blocks and never got further if i had less than 80% HP (so they were triggering) and yet, the potions weren't drunk.

Maybe because potions aren't drunk immediately it was trying again and again (then again they have ActionListEmpty() so that makes no sense either).

Regardless, removing those auto-drink blocks "fixed" it.

#4 Sasha Al'Therin

Sasha Al'Therin
  • Modder
  • 615 posts

Posted 26 October 2011 - 03:13 PM

to answer your second question...

not too sure myself, doesn't look like it would tho earlier today in testing my own set of party scripts I had one character repeating a single block over and over and over and over without performing any action. Only thing I could tell was that it was returning true minus the timer being expired so it was running the block but not, restarting the script, running the block but not, etc... till the timer expired.

this was my offending code:
IF
  //  ActionListEmpty()                                                  //not doing any user commands
  HPPercentLT(MostDamagedOf(GroupOf(Myself)),80)                     //an injured party member
  HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)                                //have spell
  CheckStatLT(Myself,50,SPELLFAILUREPRIEST)                          //good chance of casting spell
  //these potions are all better than this spell make sure that they are used first
  !PartyHasItem("POTN08")   //9hp
  !PartyHasItem("POTN17")   //10hp
  !PartyHasItem("POTN42")   //2hp/round for 3 turns - 10 rounds/turn - 2hp * 30 rounds = 60hp max
  GlobalTimerExpired("ab_heal_spell","GLOBAL")                       //global timer so certain spells don't overlap by multiple casters
  GlobalTimerExpired("ab_cast_a_spell","LOCALS")                     //local timer for any spells
  GlobalTimerExpired("ab_used_potion","GLOBAL")                      //used a potion timer expired
THEN
  RESPONSE #100
    SetGlobalTimer("ab_heal_spell","GLOBAL",ONE_ROUND)                       //start healing timer to prevent spell overlap
    SetGlobalTimer("ab_cast_a_spell","LOCALS",ONE_ROUND)                     //start personal timer
    Spell(MostDamagedOf(GroupOf(Myself)),CLERIC_CURE_LIGHT_WOUNDS)   //cast spell
END
ignore the comments as it was modified from a working IWD script some things are bit off (the hp #'s on the negated potions)


to test your own scripts for stuttering or blocks that keep repeating over and over for some unknown reason you can modify the following:
BEGIN ~Test stuttering~
REQUIRE_COMPONENT ~Setup-ab_BG1PartyAI.tp2~ ~0~ @50 //~SKIPPING Required Component not installed~
COPY_EXISTING ~dplayer3.bcs~ ~override~ // be sure to change the file names to point to the relevant ones
	~dplayer2.bcs~ ~override~
	~abparty.bcs~ ~override~
	~ab_figh.bcs~ ~override~
	~ab_pala.bcs~ ~override~
	~ab_prie.bcs~ ~override~
	~ab_mage.bcs~ ~override~
	~ab_cler.bcs~ ~override~
	~ab_drui.bcs~ ~override~
	~scripts\ab_scri.bs~ ~scripts\ab_scri.bs~
	SET x = 0 - 1
	DECOMPILE_BCS_TO_BAF
		REPLACE_EVALUATE ~\(RESPONSE #[0-9]+\)~ BEGIN
			x += 1
		END "\1
		ActionOverride(Myself,DisplayString(Myself,~Running block %x% of %SOURCE_RES%.BCS~))"
	COMPILE_BAF_TO_BCS
all you need do is change the script files to point to every script file that you add or modify. It is best to make it a standalone mod, however you could tack it to the end of your working mod (as I did) as a standalone component and only install it as necessary for testing.


and you posted while I typed this big long thing out :P

ActionListEmpty() prevents 'em from doing things to interrupt whatever user commands are given. Personally, I prefer to have some auto attack and auto life saving potion and spell usage in place... If you were moving the characters about or doing other things with 'em, they wouldn't drink any potions till next script round after having them stop moving.

My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altheri...s.com/index.htm


#5 i30817

i30817
  • Member
  • 611 posts

Posted 26 October 2011 - 05:17 PM

How can i find out what is this spell:
IF
HotKey(F)
THEN
RESPONSE #100
Spell(Myself,4721)
Continue()
END

It's in the auto-buff script and i'd like to know if it's a error (not checking if the char has it) or just a improved alacrity.

Edited by i30817, 26 October 2011 - 05:18 PM.


#6 Sasha Al'Therin

Sasha Al'Therin
  • Modder
  • 615 posts

Posted 26 October 2011 - 05:53 PM

spells that don't have a match in spells.ids don't get converted to a text label.
You'll have to check the actual list of spl files

spell.ids can help you to determine the pattern in naming spells. keep in mind that mod added spells do not follow the bioware naming convention of player used spells.

spprXXX.spl = 1000's <-- priest
spwiXXX.spl = 2000's <-- wizard
spinXXX.spl = 3000's <-- innate

spells in the 4000's must be BG2 as ToTSC doesn't got that high :P
i think it might be kit specific...
there are spells listed in the 4000's in spell.ids that match spclXXX.spl

my best guess:
4721 = spcl721.spl = Storm Shield

I could be wrong tho... you'll need to consult whatever documentation that came with whatever script you are looking at to determine what that block is supposed to be doing. If that hotkey runs pre-battle buffs, then there is a good chance that I'm correct. If it is Storm Shield it only lasts for one round, the script author probably determined that it would be worn off before being passed thru the script again hence no checks for it's presence...

My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altheri...s.com/index.htm


#7 i30817

i30817
  • Member
  • 611 posts

Posted 26 October 2011 - 06:09 PM

Ah ok. Then there's a bug since it is not checking
HaveSpell(4721)

?


"0x4031 HaveSpell(I:Spell*Spell)
Returns true only if the active CRE has the specified spell memorised."

Or does Spell() fail if it isn't memorized anyway and HaveSpell is just a optimization?

Edited by i30817, 26 October 2011 - 06:28 PM.


#8 Sasha Al'Therin

Sasha Al'Therin
  • Modder
  • 615 posts

Posted 26 October 2011 - 06:48 PM

if the creature doesn't have the spell and Spell(O:Target*,I:Spell*Spell) is in use, nothing happens except script block gets executed anyway and starts the script at top again. If ForceSpell(O:Target,I:Spell*Spell) or ReallyForceSpellRES(S:RES*,O:Target) or the like are at work then the spell will be cast even if the creature is normally not able to cast such a spell.


at least that is my understanding...

My working mods:
an AI Party Script for BG2 game engine DOWNLOAD LINK ONLY!
Interactive Tweaks for BG series with some IWD support. DOWNLOAD LINK ONLY!
Rest For 8 Hours an IWD mod
-------------------------------------------
My contributions: BG1Fixpack, BG1Tweaks
On Hold: Solestia an NPC for SOA
-------------------------------------------
My website: http://sasha-altheri...s.com/index.htm


#9 i30817

i30817
  • Member
  • 611 posts

Posted 27 October 2011 - 04:48 AM

Ok, so HasSpell is a optimization, good to know.