jags78 Posted September 17, 2018 Posted September 17, 2018 Hey Scripters I'm trying to use the 'CastAs' function to trigger regis2k's outfit switcher mod. Here a snippet from my test-script:If akTarget == PlayerRef && akCaster == PlayerRef && akEffect == WDC_PillMagicEffect ScriptObject scrOutfitSwitcher = PlayerRef.CastAs("OutfitSwitcher") If scrOutfitSwitcher int loadout = 1 bool silent = false bool force = false Var[] param = new Var[3] param[0] = loadout param[1] = silent param[2] = force scrOutfitSwitcher.CallFunction("ApplyLoadout", param) Else Debug.Notification("Ups...") EndIf RegisterForMagicEffectApplyEvent(PlayerREF, PlayerREF, WDC_PillMagicEffect, true) EndIfThe Event get triggered, but i get the "Ups..." notification. Does someone c the error? Does this even work with quest-related scripts?
Reneer Posted September 17, 2018 Posted September 17, 2018 You need to get the script from the other mod by using GetFormFromFile then use CastAs on that found form, not simply on the player.
jags78 Posted September 17, 2018 Author Posted September 17, 2018 Jep... That was it... Thx Reneer. You're the man. I case somebody cares what the test-code looks like:Event OnMagicEffectApply(ObjectReference akTarget, ObjectReference akCaster, MagicEffect akEffect) If akTarget == PlayerRef && akCaster == PlayerRef && akEffect == WDC_PillMagicEffect If Game.IsPluginInstalled("OutfitSwitcher.esp") Quest qOutfitSwitcher = Game.GetFormFromFile(0x00000802, "OutfitSwitcher.esp") as Quest ScriptObject scrOutfitSwitcher = qOutfitSwitcher.CastAs("OutfitSwitcher") If scrOutfitSwitcher int loadout = 1 bool silent = false bool force = false Var[] param = new Var[3] param[0] = loadout param[1] = silent param[2] = force scrOutfitSwitcher.CallFunction("ApplyLoadout", param) Else Debug.Notification("Ups...") EndIf RegisterForMagicEffectApplyEvent(PlayerREF, PlayerREF, WDC_PillMagicEffect, true) Else Debug.Notification("OutfitSwitcher not installed") RegisterForMagicEffectApplyEvent(PlayerREF, PlayerREF, WDC_PillMagicEffect, true) EndIf EndIf EndEventC u when the next problem arises ;)
Recommended Posts