Skip to content

BG2:EE Scripting Enhancements

horredtheplaguehorredtheplague Member, Developer Posts: 186
These are some notes I included in the BP Series changelog, but I thought some scriptors might find it handy. This is far from a complete list of new functions; one is new, one has been there since BG2 but hidden in code. Please, feel free to add more insights to this thread, dev's and modders alike. Nicer to keep them in one place, if possible. :-)
SCRIPTORS: Look for the new ACTION.IDS entry described above, installed by BP Series:

34 UseItemExt(S:Item*,O:Object,I:Slot*SLOTS,I:Abil*)

--First 2 entries, just like UseItem("potn08",Myself). Slot set to 0 by default, means Any Slot. Haven't tested non-zero. Ability is the item extended effect number (0=main,1,2). Works for weapons and also items with > 1 ability.

This works in BG:EE, BG2:EE, and BG2:ToB (the code was there all along, who knew until now?) *Thanks go out to Avenger_TeamBG, for this fine discovery!*

You can add this on your own, or to your own mod as you desire. Hopefully by posting it here, we can keep the same nomenclature between mods. It gets messy when you have > 1 name for the same function. This might be officially added to EE some day (???), but for now here it is.

TRIGGER.IDS (Available in BG2:EE, installed by default)

0x40E0 NextTriggerObject(O:Object*)

This is a VERY handy function. It allows you to check things like Globals, Range, etc etc on another creature! Things are now possible, that could only be dreamt of before. And there may be more goodies to come, in the future.

Example of use:

IF
HaveSpell(WIZARD_FIREBALL) // Locked & loaded
See(NearestEnemyOf(Myself)) // My fireball target, there they are
!Range(NearestEnemyOf(Myself),15) // Am I w/in the fireball's range?
NextTriggerObject(SecondNearestMyGroupOfType([PC])) //My second nearest buddy
!Range(NearestEnemyOf(Myself),15) //Is my buddy in fireball range?
THEN
RESPONSE #100
Spell(NearestEnemyOf(Myself),WIZARD_FIREBALL) //Blast them!
END
This also works in an OR() function, and does not require an extra count on the OR's.
1 set of NextTriggerObject & Conditional Check = 1 count of OR

Comments

  • prophet1prophet1 Member Posts: 172
    Nice. Going to give this a bump.

    Is NextTriggerObject available in BG1EE as well?
  • WispWisp Member Posts: 1,102
    If you compile with WeiDU you can also use TriggerOverride() as syntactical sugar for NextObjectTrigger().

    !TriggerOverride(SecondNearestMyGroupOfType([PC]),Range(NearestEnemyOf(Myself),15))
    compiles into the equivalent of

    NextTriggerObject(SecondNearestMyGroupOfType([PC]))
    !Range(NearestEnemyOf(Myself),15)
  • horredtheplaguehorredtheplague Member, Developer Posts: 186
    @Wisp: What is the ACTION.ids format you're using for TriggerOverride? Best to keep consistent, if anybody includes it before it's officially in.

    Was actually posting because I noticed a little touchiness with UseItemExt(). It works, and it also is confirmed as working for multiple item abilities. The quirkiness comes into play when it's using the effect Cast Spell at Object (and maybe others?). I found that you have to put the UseItemExt line first, before any other actions. Else, it doesn't actually fire. Odd? Sure, but I did quite a bit of testing to resolve this. My testing item was Dorn's special mask, The Visage. The following is for the Domination effect:

    This works:

    RESPONSE #100
    UseItemExt("OHDMASK",LastSeenBy(Myself),SLOT_HELMET,1)
    SetGlobalTimer("SPL_CAST","LOCALS",6)
    SetGlobal("ZDMASK_B","LOCALS",1)
    SetGlobal("INTERUPT","LOCALS",0)
    DisplayStringHead(Myself,81615)
    END

    This didn't:

    RESPONSE #100
    SetGlobalTimer("SPL_CAST","LOCALS",6)
    UseItemExt("OHDMASK",LastSeenBy(Myself),SLOT_HELMET,1)
    SetGlobal("ZDMASK_B","LOCALS",1)
    SetGlobal("INTERUPT","LOCALS",0)
    DisplayStringHead(Myself,81615)
    END

    Just a simple setting of a global timer, first, was enough to botch the spell.
  • WispWisp Member Posts: 1,102
    @horredtheplague
    TriggerOverride() does not exist outside of WeiDU (i.e., it is not listed in trigger.ids). AFAIK, it's not planned to be officially included anywhere. EE and ToBEx both implement NextObjectTrigger() instead.
Sign In or Register to comment.