Genamine Posted October 14, 2016 Author Share Posted October 14, 2016 Scriptname ARMA_DisableSprintEffectScript extends ActiveMagicEffect Group Settings bool Property DisableSprinting auto bool Property DisableRunning auto actorvalue Property CountObject auto actor Property EffectOwner auto EndGroup InputEnableLayer inputLayer Event OnEffectStart(Actor akTarget, Actor akCaster) Utility.Wait(1) ;lets not run a count check before the count is actually raised float fCount = akTarget.GetValue(CountObject) EffectOwner = akTarget if fCount > 4 inputLayer = InputEnableLayer.Create() if DisableRunning inputLayer.EnableRunning(false) inputLayer.EnableSprinting(false) elseif DisableSprinting inputLayer.EnableSprinting(false) endif endif EndEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) inputLayer.Delete() inputLayer = None float fCount = 0 EndEvent Event OnItemUnequipped(Form akBaseObject, ObjectReference akReference) if akBaseObject as Armor Utility.Wait(1) ;once more, we dont want to run a count check before the count is actually lowered if EffectOwner ;this event shouldnt happen without the first event having taken place, but nonetheless, lets check if we actually have an actor reference float fCount = EffectOwner.GetValue(CountObject) if fCount < 5 inputLayer.EnableSprinting(true) inputLayer.EnableRunning(true) Dispel() endif endif endif EndEvent Based on that new information, how does this look? (it compiled, so Ill be giving it a shot ingame)I added the wait calls because previously.. it was checking the counts before the count was actually raised or lowered, I also clarified this in the script EDIT: It works, flawlessly .. thanks for the advice! Link to comment Share on other sites More sharing options...
EveningTide Posted October 14, 2016 Share Posted October 14, 2016 I'm thinking that may not always work. So if you run into consistency issues, keep these notes on OnEffectFinish in mind: By the time this event is called, the active magic effect may have already been deleted by the game. Any native calls to this active magic effect may fail.Also, since the game forcibly deletes ActiveMagicEffects, if the script has a circular reference to itself (via a local variable - either directly or via a struct/array) that circular reference will be forcibly cleared by the Papyrus garbage collector, resulting in the value receiving a None value. Link to comment Share on other sites More sharing options...
Genamine Posted October 14, 2016 Author Share Posted October 14, 2016 Should that technically not matter?, the only thing you need when the effect finishes is to enable running/sprinting again, which it does From what Ive gathered, the script is run from scratch when removing and re-adding the magiceffectMeaning you dont technically need to do anything other than re-enabling running/sprinting in OnEffectFinish (which is precisely what it does) If you are referring to float fCount, thats not a variable controlled by the magiceffect scriptfCount only retrieves the value of an actor value that keeps track of the amount of equipped pieces of heavy armour, the value of this actor value is controlled elsewhere Link to comment Share on other sites More sharing options...
steve40 Posted October 15, 2016 Share Posted October 15, 2016 (edited) You can delete the line "float fCount = 0" as it serves no purpose whatsoever. It does not affect the other 'fCount' variables that were declared within different events, they are completely isolated from each other. Doing so would only work if the variable was declared at the top of the script (script-wide). The variable will cease to exist as soon as the magic effect expires, so declaring it within OnEffectFinish is pointless. Edited October 15, 2016 by steve40 Link to comment Share on other sites More sharing options...
Recommended Posts