azazellz Posted October 6, 2017 Share Posted October 6, 2017 So, for one of my scripts, I need to determine how high the character is falling from. We have several game parameters and a formula by which we can calculate the damage from falling. falling damage = ((height - fJumpFallHeightMin) * fJumpFallHeightMult)fJumpFallHeightExponent * modifiers fJumpFallHeightMin, fJumpFallHeightMult and fJumpFallHeightExponent coded into game settings and can be changed via scripts.But how we can get height from this formula?Any ideas? Link to comment Share on other sites More sharing options...
steve40 Posted October 7, 2017 Share Posted October 7, 2017 The only way I can think of would be to register for the JumpFall and JumpDown animation events. When the JumpFall event fires, record the players z position, then when the JumpDown event fires, record z again and calculate the difference.. Link to comment Share on other sites More sharing options...
azazellz Posted October 7, 2017 Author Share Posted October 7, 2017 The only way I can think of would be to register for the JumpFall and JumpDown animation events. When the JumpFall event fires, record the players z position, then when the JumpDown event fires, record z again and calculate the difference..Sounds like good idea. I will try It, thanks. Link to comment Share on other sites More sharing options...
azazellz Posted October 7, 2017 Author Share Posted October 7, 2017 (edited) Yep, it kinda works, but no so stable as I intended.Glitches appears mostly in first person mode. Looks like while you play in first person mode, theese events works different from 3rd person (it seems that they are sent with a delay).Here my script. Scriptname JumpFall extends activemagiceffect Spell Property LandingSpell Auto Actor Property PlayerRef Auto float Zpos1 float Zpos2 float Zpos3 Event OnEffectStart(Actor akTarget, Actor akCaster) registerForAnimationEvent(PlayerRef, "JumpFall") registerForAnimationEvent(PlayerRef, "JumpDown") endEvent Event OnAnimationEvent(ObjectReference akSource, string EventName) if (eventName == "JumpFall") Zpos1 = PlayerRef.GetPositionZ() elseif (eventName == "JumpDown") Zpos2 = PlayerRef.GetPositionZ() Zpos3 = math.abs (Zpos1 - Zpos2) if (Zpos3 > 250) LandingSpell.Cast(PlayerRef, PlayerRef) endif endif endEVENTMaybe I missed something? Edited October 7, 2017 by azazellz Link to comment Share on other sites More sharing options...
azazellz Posted October 15, 2017 Author Share Posted October 15, 2017 Up. Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 16, 2017 Share Posted October 16, 2017 (edited) Yep, that will do the trick. well done for working it out. :thumbsup: If your a Reader looking for more information the first Event is "JumpUp" Edited October 16, 2017 by PeterMartyr Link to comment Share on other sites More sharing options...
azazellz Posted October 16, 2017 Author Share Posted October 16, 2017 Yep, that will do the trick. well done for working it out. :thumbsup: If your a Reader looking for more information the first Event is "JumpUp" Nope, this works only for third person view.If we use first person - then, for example, if char jumps to 250 points and then land on that place from that he jumped - "landing spell" do not fire. But if char jump onto rock with 240 points of height - "landing spell" will fire, despite the fact that the character fell by only 10 points. And "JumpUp", I think, is very first moment of the jump - we don't need this moment. because at this moment character goes up, not down. Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 16, 2017 Share Posted October 16, 2017 (edited) I move the code into my player alias testing scenario quest, then I moved the floats into the Event & simplified, I ran some tests, both 1st & 3rd. Well, I got consistence result. But the float amounts to me didn't seem reasonable, but they were consistence. Event OnSit(ObjectReference akFurniture) ObjectReference akSelf = self.GetReference() registerForAnimationEvent(akSelf, "JumpFallDirectional") registerForAnimationEvent(akSelf, "JumpDown") ;BlendJump ;RegisterForAnimationEvent(akSelf, "JumpDirectionalStart") EndEvent float afJumpFall1 Event OnAnimationEvent(ObjectReference akSource, string EventName) If (eventName == "JumpFallDirectional" ;/|| eventName == "JumpDirectionalStart"/;) afJumpFall1 = akSource.GetPositionZ() debug.MessageBox("# 1\nResult1 " + afJumpFall1) ElseIf (eventName == "JumpDown") Float afJumpFall2 = akSource.GetPositionZ() debug.MessageBox("# 2\nRResult1 " + afJumpFall1 + "\nResult2 " + afJumpFall2) Float afJumpFall3 = afJumpFall1 - afJumpFall2 debug.MessageBox("# 3\nRResult1 " + afJumpFall1 + "\nResult2 " + afJumpFall2 + "\nResult3 " + afJumpFall3) afJumpFall1 = 0 EndIf EndEvent I find using ME for testing or debugging, not to be a good idea since they Auto-Unregister for every thing, & that makes it painful during testing. I just sat down to register the Event, & the Fell to heart content. I couldn't seem to to find out of my 3078 event which one was walking off a cliff. Edited October 16, 2017 by PeterMartyr Link to comment Share on other sites More sharing options...
azazellz Posted October 17, 2017 Author Share Posted October 17, 2017 (edited) I find using ME for testing or debugging, not to be a good idea since they Auto-Unregister for every thing, & that makes it painful during testing. I just sat down to register the EventI use "togglable" lesser power for this.Use power - add spell with script - register events. Use again - remove spell - unregister events. Btw, in formula "afJumpFall3 = afJumpFall1 - afJumpFall2" Fall1 and Fall2 can be negative. So, I think, we need to use math.abs() for second value. Because, for example, "-500 - (-500)" give us a zero, but "-500 - math.abs(-500)" give us -1000.And also, I think it's be better, if result also be "positive" number, so we need to use math.abs() on afJumpFall3 too. Also, event "jump fall directional" uses only during directional fall. If you just jump up without moving - it's not fire at all. And, I think, it's be good to add "land" events to script (JumpLand, JumpLandEnd, JumpLandDirectional), but when I do so, script fires multiple times, as it fires twice if you change direction of your jimp while mid-air.Interesting, in which conditions Skyrim uses "Land" and "JumpDown" events? Now script looks like Event OnEffectStart(Actor akTarget, Actor akCaster) registerForAnimationEvent(akTarget, "JumpFallDirectional") registerForAnimationEvent(akTarget, "JumpFall") registerForAnimationEvent(akTarget, "JumpDown") registerForAnimationEvent(akTarget, "JumpLandEnd") registerForAnimationEvent(akTarget, "JumpLand") registerForAnimationEvent(akTarget, "JumpLandDirectional") endEvent Event OnAnimationEvent(ObjectReference akSource, string EventName) If (eventName == "JumpFallDirectional") || (eventName == "JumpFall") afJumpFall1 = akSource.GetPositionZ() debug.MessageBox("# 1\nResult1 " + afJumpFall1) ElseIf (eventName == "JumpDown") || (eventName == "JumpLandEnd") || (eventName == "JumpLand") || (eventName == "JumpLandDirectional") Float afJumpFall2 = akSource.GetPositionZ() debug.MessageBox("# 2\nRResult1 " + afJumpFall1 + "\nResult2 " + afJumpFall2) Float afJumpFall3 = afJumpFall1 - math.abs(afJumpFall2) Float afJumpFallAbs = math.abs(afJumpFall3) debug.MessageBox("# 3\nRResult1 " + afJumpFall1 + "\nResult2 " + afJumpFall2 + "\nResult3 " + afJumpFall3 + "\nResult4 " + afJumpFallAbs) afJumpFall1 = 0 EndIf EndEventBut we still need to improve it. Edited October 17, 2017 by azazellz Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 17, 2017 Share Posted October 17, 2017 (edited) Totally, I tried, but could not find an Event for: walk/runs off a cliff. Which what I was looking for. And there thousands of Animations Event on my list. (3078) I used the Animation Event List that comes with Fore FNIS mod. I don't remember exactly what it called, there is a utility that Captures Animation Events in real time, so all you need do Run/Walk of a cliff, & it will confirm or denial, if such an Event Exists. I know that much help. But it all I got ATM. Edit I have to admit I didn't read the directions, so I know if it will help. https://www.nexusmods.com/skyrim/mods/38382/? Edited October 17, 2017 by PeterMartyr Link to comment Share on other sites More sharing options...
Recommended Posts