Jump to content

[LE] When the player jumps


jim555511

Recommended Posts

Maybe the next script is what you are looking for. This way (to trigger AnimationEvents) was taken by mod "Footprints".

You could also use an own quest, which has a script attached to the PlayerAlias, In that case use OnInit() event to register for animations.

 

Sample_MGEFScript

 

Scriptname Sample_MGEFScript extends ActiveMagicEffect
{written by ReDragon 2017}    ; just a sample to demonstrate the using of AnimationEvents within papyrus scripts

; https://forums.nexusmods.com/index.php?/topic/6173163-when-the-player-jumps/
; jim555511 wrote: "I'm going to script something like that but i'm having a bit of trouble finding out how to find out when the player jumps."

  ObjectReference target

; -- EVENTs --

EVENT OnEffectStart(Actor akTarget, Actor akCaster)
IF (akTarget == Game.GetPlayer())
ELSE
    self.Dispel()
    RETURN    ; - STOP - not the player, remove MagicEffect immediately
ENDIF
;---------------------
    target = akTarget as ObjectReference                ; we assume target is the player, make him persistent for a while

    gotoState("Waiting")            ; ### STATE ###
    RegisterForAnimationEvent(target, "JumpUp")
    RegisterForAnimationEvent(target, "JumpDown")
ENDEVENT


;==============================
state Waiting
;============
EVENT OnAnimationEvent(ObjectReference akSource, String asEventName)
IF (akSource == target)
ELSE
    gotoState("Done")                ; ### STATE ### invalid registration or target is None
    RETURN    ; - STOP -
ENDIF
;=====================
IF (asEventName == "JumpUp")
    myF_Action(akSource, TRUE)
    RETURN    ; - STOP - player jumps up
ENDIF
;---------------------
IF (asEventName == "JumpDown")
    myF_Action(akSource, False)
    RETURN    ; - STOP - player jumps down
ENDIF
;---------------------
    gotoState("Done")                ; ### STATE ###    unknown animation triggered, just in case
ENDEVENT


;EVENT OnDying(Actor akKiller)                                ; when target begins dying
;    gotoState("Done")                ; ### STATE ###
;ENDEVENT


EVENT OnDeath(Actor akKiller)                                ; when target finishes dying
     gotoState("Done")                ; ### STATE ###
ENDEVENT


EVENT OnEffectFinish(Actor akTarget, Actor akCaster)
    target = None
    gotoState("Done")                ; ### STATE ###
ENDEVENT
;=======
endState


;==============================
state Done
;=========
EVENT OnBeginState()
IF ( target )
    target = None
    Utility.Wait(0.1)
    self.Dispel()
ENDIF
ENDEVENT
;=======
endState


; -- FUNCTION --

;------------------------------------------------------
FUNCTION myF_Action(ObjectReference akSource, Bool bUp)
;------------------------------------------------------
IF ( bUp )
    ; your code here (up)

ELSE
    ; your code here (down)

ENDIF

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

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