Skip to content

Scripting State?

AbelAbel Member Posts: 785
I'm currently looking at the Whirlwind spell resource (SPCL900).
I see there's an effect that modify the scripting state. What are scripting state and what are they used for?
For this file, opcode #282 is used:
#282 (0x282) Script: Scripting State Modifier [282]
Parameter #1: Value
Parameter #2: Scripting State
Description:
Modifies Scripting state to the given value. Scripting State range from 0 to 35. The scripting state can be checked via scripts (see stats.ids), subtract 156 from the stat value to get the scripting state.
This effect does not have proper bounds checking, and can therefore be used in unintended ways. For example scripting state 13 equals with the NO_CIRCLE attribute (stat=169), and scripting state 1139 ties to PICKPOCKET (stat=29).
What was the base value and what do we obtain once we activate Whirlwind?
Value = 4; Scripting State = 3 in the file.

Comments

  • argent77argent77 Member Posts: 3,428
    You can think of scripting states as flags that you can set for a specific creature. The scripting state can then be checked via CheckStat() in scripts. That way you can, for example, let the enemy AI know whether your character has applied certain buffs or activated special abilities, so they can react to it. Or you can simulate new status effects that are handled by scripts. Since you are setting scripting states via spell effect, you can also specify a duration or delay (depending on the timing mode) to it.

    In the case of innate abilities such as Whirlwind Attack, the scripting state 4 (SCRIPTINGSTATE4 in stats.ids) is set while it's active. This is also true for other abilities like Quivering Palm (SPCL820) or Power Attack (SPCL906). Another case is the spell 'Spell Immunity' which sets the scripting state WIZARD_SPELL_IMMUNITY. You can find a lot of checks for this state in mage-related combat scripts.
    AbelPecca
  • AbelAbel Member Posts: 785
    edited January 2014
    @argent77 I see! Insightful :) !
    In the case of Whirlwind I see the value is 4 and in the case of Greater Whirlwing 5. So if I understand well, both use scripting state 3 but set it to a different value.
    So I guess a same scripting state can be used for various things if you use different values.
    What I don't understand is the IESDP description mentions states from 0 to 35, but I only see 1 to 6 in STATS.IDS.
    Also, what has the STATE.IDS to do with anything?
  • argent77argent77 Member Posts: 3,428
    edited January 2014
    Abel said:

    @argent77 I see! Insightful :) !
    In the case of Whirlwind I see the value is 4 and in the case of Greater Whirlwing 5. So if I understand well, both use scripting state 3 but set it to a different value.
    So I guess a same scripting state can be used for various things if you use different values.

    Exacty.
    Abel said:

    What I don't understand is the IESDP description mentions states from 0 to 35, but I only see 1 to 6 in STATS.IDS.
    Also, what has the STATE.IDS to do with anything?

    Hmm, my BG2:EE installation provides a STATS.IDS that is filled with at least 200 entries. Maybe a mod has modified the file? If you mean the names SCRIPTINGSTATE1..SCRIPTINGSTATE6 defined in STATS.IDS; they are arbitrarily chosen and don't affect the games in any way.
    Anyways, the STATS.IDS is only needed to link numeric values (which are used by the game engine internally) with symbolic names (which are shown in decompiled scripts as a programming aid). Unlisted entries in the STATS.IDS shouldn't affect the game in any way, but it makes it more difficult for the modder to keep track of the correct scripting states.

    The STATE.IDS defines bitmasks over one or more hardcoded states (e.g. poisoned, stunned, hasted, under bless effect). For example, the identifier CD_STATE_NOTVALID which is commonly used in mods covers all mental and physical states that prevent a character from interacting with their environment. Those states only have on/off switches, in contrast to scripting states which can be set to arbitrary numeric values.
    Post edited by argent77 on
  • AbelAbel Member Posts: 785
    edited January 2014
    Abel said:

    What I don't understand is the IESDP description mentions states from 0 to 35, but I only see 1 to 6 in STATS.IDS.
    Also, what has the STATE.IDS to do with anything?

    argent77 said:

    Hmm, my BG2:EE installation provides a STATS.IDS that is filled with at least 200 entries. Maybe a mod has modified the file? If you mean the names SCRIPTINGSTATE1..SCRIPTINGSTATE6 defined in STATS.IDS; they are arbitrarily chosen and don't affect the games in any way.
    Anyways, the STATS.IDS is only needed to link numeric values (which are used by the game engine internally) with symbolic names (which are shown in decompiled scripts as a programming aid). Unlisted entries in the STATS.IDS shouldn't affect the game in any way, but it makes it more difficult for the modder to keep track of the correct scripting states.

    @argent77 Yes, that's what I meant.
    I don't understand what you're saying. You say that Whirlwind use the SCRIPTINGSTATE, yet that it's chosen arbitrarily?
    Also, what will happen if I use the Script: Scripting State Modifier [282] to set a value for a state 100?
    So, I'm looking at Spell Immunity and I don't see this opcode in the effect. Does that mean that the WIZARD_SPELL_IMMUNITY state you spoke about doesn't need to be set in that case?
  • argent77argent77 Member Posts: 3,428
    edited January 2014
    Abel said:

    I don't understand what you're saying. You say that Whirlwind use the SCRIPTINGSTATE, yet that it's chosen arbitrarily?

    I was only referring to the names of the scripting states defined in the STATS.IDS. You can rename them to anything you want or even remove the whole entry from the file. In fact, you'll probably see this in a heavily modded game where the state is called something else. That's because some mods add entries on their own to the STATS.IDS.
    Abel said:

    Also, what will happen if I use the Script: Scripting State Modifier [282] to set a value for a state 100?

    IESDP states that only scripting states ranging from 0 to 35 are valid, so I guess using state 100 will set some hardcoded effect on your character or does nothing. You have to try it out yourself. Anyway, the opcode Scripting State Modifier [282] can be used for some interesting effects, as you can see in its IESDP description.
    Abel said:

    So, I'm looking at Spell Immunity and I don't see this opcode in the effect. Does that mean that the WIZARD_SPELL_IMMUNITY state you spoke about doesn't need to be set in that case?

    Spell Immunity is a rather complex spell since you are able to choose a specific immunity from a list of spells. It uses the effect opcode 214 (Select spell) which refers to the file SPWI510.2DA that contains the names of the real spells that apply the respective spell immunities to your character. In the case of Spell Immunity: Conjuration, it casts SPWI591 on your character. This spell also applies the WIZARD_SPELL_IMMUNITY state (with the value of 2).
    A script of an enemy wizard might check for this specific state to determine whether his attack will be effective. It might look something like this:
    IF
    See([ENEMY])
    HPLT(LastSeenBy(Myself),60)
    !CheckStat(LastSeenBy(Myself),2,WIZARD_SPELL_IMMUNITY) // checks for Spell Immunity: Conjuration
    CheckStatGT(LastSeenBy(Myself),7,SAVEVSDEATH)
    CheckStatLT(LastSeenBy(Myself),75,RESISTMAGIC)
    THEN
    RESPONSE #100
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_NPC_SYMBOL_DEATH)
    END
    Since Symbol: Death is a conjuration spell, it will be ineffective if cast on a character that is protected by Spell Immunity: Conjuration. This script ensures that the spell will only be used on your character when he is vulnerable to it.
  • AbelAbel Member Posts: 785
    @argent77 Haha, I think I get it better with your explanation :) ! Thanks!
    By the way, you seem to know a lot. Are you an old modder?
  • argent77argent77 Member Posts: 3,428
    Yes, I'm modding for quite some time now (although most of my projects are still waiting to be finished :P ). I'm also one of the developers of NearInfinity.
    Abel
Sign In or Register to comment.