Jump to content

How to determine how high the character is falling from?


Azazellz

Recommended Posts

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

I sure hope everything besides height and damage is a constant or something close to...and can you even capture damage as an input?

 

fJumpFallHeightMin = min

fJumpFallHeightMulti = multi

fJumpFallHeightExponent = exp

modifiers = mod

falling damage = dmg

height = h

 

If I am reading it right the equation is dmg = mod*{[multi*(h-min)]^exp}

 

log(multi) = a

log(mod) = b

 

{[log(dmg) - b] / exp} - a = log(h-min)

 

10^x both sides and then add min

So something like....

 

h = min + 10^{{[log(dmg) - b] / exp} - a}

 

It has been more than a decade since I fuss around with these, someone more familiar might be able to express each part individually and makes it look nicer or easier to apply in a mod.

Link to comment
  • 2 weeks later...

Well, I can't say that I am an expert on scripts... but if your script can determine when the falling has started,  cant you just use Getpos Z at the start and end of the fall?

 

https://www.creationkit.com/index.php?title=GetPos

https://www.creationkit.com/index.php?title=ObjectReference.GetPositionZ_(Papyrus)

Yes, this works - but only for third person view.

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
endEVENT

From first person it seems this animation events do no work correctly ("landing spell" do not fire).

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use