Mattiewagg Posted September 13, 2014 Share Posted September 13, 2014 (edited) So I have a script to damage the player's stamina when a weapon is swung. The condition is on the spell the MGEF (no duration, no area, hide in UI, script archetype) is attached to, and it registers correctly. However, when I swing my fists, or sword, the stamina damage registers but is delayed by about a second. I want the values to be modifiable, but not if there is this much delay. This doesn't happen if I just use. This is the script on the MGEF: Scriptname FFDamageFatigueScript extends activemagiceffect GlobalVariable Property FFUseUS Auto {FightingFatigueUseUserSettings} GlobalVariable Property FFOneHandDam Auto {Amount of stamina drain for one handed attacks, if FFUseUS is enabled.} GlobalVariable Property FFTwoHandDam Auto {Amount of stamina drain for two handed attacks, if FFUseUS is enabled.} Actor Property PlayerREF Auto Event OnEffectStart(Actor akTarget, Actor akCaster) If FFUseUS.GetValue() If PlayerREF.GetEquippedItemType(0) >= 0 && PlayerREF.GetEquippedItemType(0) <= 4 || PlayerREF.GetEquippedItemType(1) >= 0 && PlayerREF.GetEquippedItemType(1) <= 4 ;if user settings enabled and player has 1handed or hand to hand PlayerREF.DamageAV("Stamina", FFOneHandDam.GetValueInt()) ElseIf PlayerREF.GetEquippedItemType(0) >= 5 && PlayerREF.GetEquippedItemType(0) <= 6 || PlayerREF.GetEquippedItemType(1) >= 5 && PlayerREF.GetEquippedItemType(1) <= 6 ;if user settings enabled and player has 2 handed PlayerREF.DamageAV("Stamina", FFTwoHandDam.GetValueInt()) EndIf Else If PlayerREF.GetEquippedItemType(0) >= 0 && PlayerREF.GetEquippedItemType(0) <= 4 || PlayerREF.GetEquippedItemType(1) >= 0 && PlayerREF.GetEquippedItemType(1) <= 4 ;user settings not enabled PlayerREF.DamageAV("Stamina", 10) ElseIf PlayerREF.GetEquippedItemType(0) >= 5 && PlayerREF.GetEquippedItemType(0) <= 6 || PlayerREF.GetEquippedItemType(1) >= 5 && PlayerREF.GetEquippedItemType(1) <= 6 PlayerREF.DamageAV("Stamina", 25) EndIf EndIf EndEvent Is there something I'm doing that is blatantly wrong? (I know DamageAV is slower than DamageActorValue, but would that really affect it this much?) And if you do it too many times in a row it doesn't even register the extra hits. Edited September 13, 2014 by Matthiaswagg Link to comment Share on other sites More sharing options...
lofgren Posted September 13, 2014 Share Posted September 13, 2014 (edited) Well there are quite a few conditions there that have to be checked before the script decides to execute. You might consider moving those conditions into condition functions on the magic effect and creating multiple effects on the same spell (one for two handed weapons, one for one handed weapons or unarmed). GetValue is much faster than GetValueInt. You can cast the float value retrieved by GetValue() to an int if you need an int, although I don't think you do since DamageActorValue takes a float so the engine is just converting your int to a float. You might as well just get the value of the global as a float rather than cast it to an int and then back to a float. Faster still than GlobalVariable.GetValue() is to just use GlobalVariable.Value. Getting a property just refers to a number stored by the game, while GetValue() executes a function. This will also reduce any issues you might be having due to multithreading. Also this might be a silly question, but why do you need to know if user settings are enabled? Why not just assume that user settings are enabled, but make the default user settings 10 and 25? That will reduce your conditions by one. Edited September 13, 2014 by lofgren Link to comment Share on other sites More sharing options...
Mattiewagg Posted September 13, 2014 Author Share Posted September 13, 2014 Well there are quite a few conditions there that have to be checked before the script decides to execute. You might consider moving those conditions into condition functions on the magic effect and creating multiple effects on the same spell (one for two handed weapons, one for one handed weapons or unarmed). GetValue is much faster than GetValueInt. You can cast the float value retrieved by GetValue() to an int if you need an int, although I don't think you do since DamageActorValue takes a float so the engine is just converting your int to a float. You might as well just get the value of the global as a float rather than cast it to an int and then back to a float. Faster still than GlobalVariable.GetValue() is to just use GlobalVariable.Value. Getting a property just refers to a number stored by the game, while GetValue() executes a function. This will also reduce any issues you might be having due to multithreading. Also this might be a silly question, but why do you need to know if user settings are enabled? Why not just assume that user settings are enabled, but make the default user settings 10 and 25? That will reduce your conditions by one.True, true. I'll try that. Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts