BG2:EE Scripting Enhancements
horredtheplague
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. :-)
1 set of NextTriggerObject & Conditional Check = 1 count of OR
SCRIPTORS: Look for the new ACTION.IDS entry described above, installed by BP Series:This also works in an OR() function, and does not require an extra count on the OR's.
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
1 set of NextTriggerObject & Conditional Check = 1 count of OR
1
Comments
Is NextTriggerObject available in BG1EE as well?
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.
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.