Genamine Posted October 11, 2016 Share Posted October 11, 2016 Scriptname ARMA_DisableSprintEffectScript extends ActiveMagicEffect Group Settings bool Property DisableSprinting const auto bool Property DisableRunning const auto EndGroup InputEnableLayer inputLayer Event OnEffectStart(Actor akTarget, Actor akCaster) inputLayer = InputEnableLayer.Create() if DisableRunning inputLayer.EnableRunning(false) elseif DisableSprinting inputLayer.EnableSprinting(false) endif EndEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) inputLayer.EnableRunning(true) inputLayer.EnableSprinting(true) EndEvent Script is a part of MagicEffect with archetype script; constant effect; selfMagicEffect has condition of AVIF [x] == 5MagicEffect is part of spell [y]Spell [y] is applied to actor via perk (perk entry Ability) With the perk active on actor (player in this case), and AVIF [x] set to 5 (on the actor), I am still able to sprintNow.. I was wondering where Im going wrong, am I going wrong with the script?, possibly the event type?Or am I messing something up in the CK? Got it to work just the way I wanted it to, all done :) Link to comment Share on other sites More sharing options...
steve40 Posted October 12, 2016 Share Posted October 12, 2016 Fixed it for you. Scriptname ARMA_DisableSprintEffectScript extends ActiveMagicEffect Group Settings bool Property DisableSprinting const auto bool Property DisableRunning const auto EndGroup InputEnableLayer inputLayer Event OnEffectStart(Actor akTarget, Actor akCaster) inputLayer = InputEnableLayer.Create() if DisableRunning inputLayer.EnableRunning(false) endIf if DisableSprinting inputLayer.EnableSprinting(false) endif EndEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) inputLayer.EnableRunning(true) inputLayer.EnableSprinting(true) EndEvent Link to comment Share on other sites More sharing options...
Genamine Posted October 12, 2016 Author Share Posted October 12, 2016 That simple?, guess theres always more to learn huh Link to comment Share on other sites More sharing options...
steve40 Posted October 12, 2016 Share Posted October 12, 2016 The way you had it written, whenever DisableRunning was True, running would get disabled but the ElseIf statement would be skipped, so sprinting would never be disabled. Link to comment Share on other sites More sharing options...
Genamine Posted October 12, 2016 Author Share Posted October 12, 2016 Tried it, still doesnt work sadly I believe the issue is with the condition in the magic effectIf I were to instead incorporate that into the script, would that be possible at all? (I dont believe so, considering the script only extends ActiveMagicEffect?) EDIT: Got it to work, no more help needed :) Link to comment Share on other sites More sharing options...
timtimman Posted October 12, 2016 Share Posted October 12, 2016 (edited) This is not a very good practice, even if it does work. When the effect finishes you just remove the layer you created and not just change the settings. Also, making the properties 'const' will make them stick the way they are the first time the mod loaded, and not change even if you were to update the mod with new values (if a user made a save with the current mod version). Got it ass backwards on that part, corrected by steve40. 'const' cannot be modified by scripts, only in the CK (editor), See wiki Const. I suggest your script be like this: ("fixed" your first check) Scriptname ARMA_DisableSprintEffectScript extends ActiveMagicEffect Group Settings bool Property DisableSprinting auto bool Property DisableRunning auto EndGroup InputEnableLayer inputLayer Event OnEffectStart(Actor akTarget, Actor akCaster) inputLayer = InputEnableLayer.Create() if DisableRunning inputLayer.EnableRunning(false) inputLayer.EnableSprinting(false) ; If we disable running, we have to disable sprinting as well elseIf DisableSprinting inputLayer.EnableSprinting(false) endIf EndEvent Event OnEffectFinish(Actor akTarget, Actor akCaster) inputLayer.Delete() inputLayer = None EndEvent Edit: corrected my wrongful remark on how 'const' properties work. Edited October 13, 2016 by timtimman Link to comment Share on other sites More sharing options...
steve40 Posted October 13, 2016 Share Posted October 13, 2016 Unnecessary because the layer will cease to exist when the magic effect finishes.If the properties are const they will be ignored in the savegame and their value can be changed using the editor, so your advice is wrong. Link to comment Share on other sites More sharing options...
timtimman Posted October 13, 2016 Share Posted October 13, 2016 Unnecessary because the layer will cease to exist when the magic effect finishes.If the properties are const they will be ignored in the savegame and their value can be changed using the editor, so your advice is wrong. Well, in the case of Magic Effects and Quests (maybe some other once I can't think of now) then the last OnEffectFinish is unnecessary then. But in all other cases, my approach is the "correct" one, and should be included for good measure (even if not necessary in this case). As for 'const', I've apparently got that ass backwards. I'll redact that part in my comment to avoid further confusion. And thanks for pointing it out so nicely with references! Link to comment Share on other sites More sharing options...
Genamine Posted October 13, 2016 Author Share Posted October 13, 2016 Well, beyond good measure, the script does what its meant to do Aside from the script, not so much though The idea is to disable sprinting when wearing 5 pieces of heavy armour, which is exactly what it doesWhat it doesnt do though is enable sprinting again when unequipping a heavy armour piece that wasnt the last one you equipped, because only the last equipped armour piece applies the effect, and doesnt change anything until you unequip said piece Ill probably leave it at that thoughBeyond Lua I have no coding experience, and even that is all self-taughtFeel like Im reaching in the dark with this I had first tried [scriptname ARMA_DisableSprintEffectScript extends Actor], but quickly learned that [Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)] doesnt work without a native flag, and with a native flag it wont let you call [inputEnableLayer inputLayer] Link to comment Share on other sites More sharing options...
timtimman Posted October 13, 2016 Share Posted October 13, 2016 I think we are all self taught when it comes to Papyrus. Don't let that hold you back and give up! You shouldn't use the 'native' flag as we cannot make anything native. The native flag on a script tells the compiler that you've added new events (which you won't be able to use). And native scripts won't let you use properties or variables (not storing information) as they are intended to be extended (and never actually attached to an object). You have to extend the script which events you want to use (or one with inheritance of the script with the event). As for the function you wish to achieve. Just make a check on your effect to see if one of the armor pieces was unequipped (attached magiceffects receives events from the actor it's attached to), in which case Dispel the effect. If your not leaving it as is, try to implement that. If you don't succeed, return for more help! Happy modding! Link to comment Share on other sites More sharing options...
Recommended Posts