Jump to content

Follower will not stay mounted - scripting help


Sanitatem

Recommended Posts

Hi all,

I am trying to get my follower Moranya to ride a horse that teleport to her when the player rides a horse. I have set up a horse riding quest, and placed a script on the player alias. I adapted the script from a smiliar topic I found on the nexus forums. My follower has a horse riding package with min radius set to 300, max radius set to 1000, ride horses if possible set to yes. My horse, Sirora, has Moranya registered as its owner.

At the moment the Moranya is able to get on the horse, but the second my player moves forward (on his horse) she will dismount and run after him. If I stay put after mounting the horse, she will stay mounted and will only dismount when I do. Please help!

Script is below:



Scriptname MR01MountTest extends ReferenceAlias
Faction Property CurrentFollowerFaction Auto
Actor Property Siroria Auto
Actor Property Moranya Auto

Actor Player
ReferenceAlias Property MoranyaRef Auto
Event OnInit()
Player = Game.GetPlayer()
RegisterForAnimationEvent(Game.GetPlayer(), "tailHorseMount")
RegisterForAnimationEvent (Game.GetPlayer(), "tailHorseDismount")
Debug.Notification ("Events registered")
EndEvent

Event OnAnimationEvent (ObjectReference akSource, string asEventName)
If akSource == Player
Else
Return
EndIf

If Moranya.IsInFaction(CurrentFollowerFaction) ==1
If Moranya.GetActorValue("WaitingForPlayer") == 0

If asEventName == "tailHorseMount"
Debug.Notification ("Player mounted")
Siroria.MoveTo(Moranya as objectreference, 50.0000 \* math.sin(Moranya.GetAngleZ() + 90.0000), 50.0000 \* math.cos(Moranya.GetAngleZ() + 90.0000), 0.000000, true)
Moranya.OnAnimationEvent(none, "tailHorseMount")
Siroria.Activate(Moranya)
Moranya.EvaluatePackage()
EndIf



If asEventName == "tailHorseDismount"
Debug.Notification ("Player dismounted")
Moranya.Dismount()
Moranya.EvaluatePackage()
EndIf
Else

Return
EndIf
EndIf
EndEvent

 

To forum moderators: I posted this in the skyrim section erroneously, I am modding for skyrim special edition, I couldn't find a way of deleting my original post! If I need to edit my original, do let me know.

Edited by Sanitatem
Link to comment
Share on other sites

We assume it is a player alias script. Maybe something like this:

 

MR01MountTestAliasScript

 

Scriptname MR01MountTestAliasScript extends ReferenceAlias
; https://forums.nexusmods.com/index.php?/topic/9260488-follower-will-not-stay-mounted-scripting-help/

  Faction PROPERTY CurrentFollowerFaction auto     ; use auto-fill here

  ;ReferenceAlias PROPERTY MoranyaRef auto         ; UnUSED, a filled alias mod created

; mod created actors
  Actor PROPERTY Siroria auto        ; the horse
  Actor PROPERTY Moranya auto        ; the npc


; -- EVENTs -- 4

EVENT OnInit()
;=============
    Debug.Trace(" OnInit() - has been called for " +self)
    RegisterForSingleUpdateGameTime(0.0)
ENDEVENT

;EVENT OnPlayerLoadGame()  ; player alias script only
;;=======================
;    Debug.Trace(" OnPlayerLoadGame() - has been called for " +self)
;    RegisterForSingleUpdateGameTime(0.0)
;ENDEVENT

EVENT OnUpdateGameTime()
;=======================
    Utility.Wait(1.0)
    Debug.Notification ("Events registered")

; https://www.creationkit.com/index.php?title=RegisterForAnimationEvent_-_Form
    objectReference oRef = Game.GetPlayer() as ObjectReference
    self.RegisterForAnimationEvent(oRef, "tailHorseMount")       ; 1
    self.RegisterForAnimationEvent(oRef, "tailHorseDismount")    ; 2
ENDEVENT


EVENT OnAnimationEvent(ObjectReference akSource, String asEventName)
;=====================
IF Moranya.IsInFaction(CurrentFollowerFaction)
ELSE
    RETURN    ; - STOP -    this actor is not players follower
ENDIF
;---------------------
; https://www.creationkit.com/index.php?title=GetActorValue_-_Actor

    IF (Moranya.GetActorValue("WaitingForPlayer") == 0.0)        ; ???
        myF_Action(asEventName == "tailHorseMount")
    ENDIF
ENDEVENT


; -- FUNCTIONs -- 2

;----------------------------
FUNCTION myF_Action(Bool bOK)
;----------------------------
IF ( bOK )                                      ; 1, bOK == TRUE
    Debug.Notification ("Player mounted")
    myF_NpcMountTheHorse()
ELSE                                            ; 2, bOK == False
    Debug.Notification ("Player dismounted")
    Moranya.Dismount()
ENDIF

    Moranya.EvaluatePackage()        ; follower package (riding on/off)
ENDFUNCTION


;------------------------------
FUNCTION myF_NpcMountTheHorse()  ; helper
;------------------------------
; calculate the right teleport place
    float aZ = Moranya.GetAngleZ() + 90.0       ; get angle Z for npc
    float fx = Math.SIN(aZ) * 50.0
    float fy = Math.COS(aZ) * 50.0

; teleport the horse to npc
    Siroia.Disable()
    Siroria.MoveTo(Moranya as ObjectReference, fx, fy, 0.0, TRUE)
    Utility.Wait(0.1)
    Siroia.Enable(TRUE)            ; fade in the horse
    Siroia.EvaluatePackage()

; let npc activate the horse to ride with
    Siroria.Activate(Moranya as ObjectReference)
ENDFUNCTION

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

Thank you for the help! The player mounted debug notifications do not show unfortunately, and the horse is not appearing at all. Do I need to change anything in bool bOK? Is bOK supposed to reference something?

Edited by Sanitatem
Link to comment
Share on other sites

The bool "bOK" is a function parameter and result in

bOK = asEventName == "tailHorseMount"

it can be TRUE (asEventName is tailHorseMount)

or False (asEventName is tailHorseDismount)

 

Why can be this? You only registered two animations (by the same reference) for the OnAnimationEvent().

 

 

In case you do not really have papyrus knowledge take the script you posted and change next part

Siroria.MoveTo(Moranya as objectreference, 50.0000 \* math.sin(Moranya.GetAngleZ() + 90.0000), 50.0000 \* math.cos(Moranya.GetAngleZ() + 90.0000), 0.000000, true)

to this

float f = Moranya.GetAngleZ() + 90.0
Siroria.MoveTo(Moranya as Objectreference, 50.0 * Math.SIN(f), 50.0 * Math.COS(f),  0.0, TRUE)

You wrote: "The player mounted debug notifications do not show.."

Whatever you do with papyrus please inspect the logfile "papyrus.0.log" as well, because of papyrus runtime errors or output of native function Debug.Trace().

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

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