Jump to content

Help with teleport script


Haugerud15328

Recommended Posts

I want this teleport script to open up an options menu when the spell is cast, then whatever option they pick they will teleport to with MoveTo. I know this doesn't support followers, that's not what I'm worried about right now. When I use the spell it doesn't have any effect however.

Scriptname GS_TeleportPlayer extends activemagiceffect  
{Teleport caster}

Message Property Options1 auto
Message Property Options2 auto

ObjectReference Property DestMarkarth auto
ObjectReference Property DestRiften auto
ObjectReference Property DestSolitude auto
ObjectReference Property DestWhiterun auto
ObjectReference Property DestWindhelm auto
ObjectReference Property DestDawnstar auto
ObjectReference Property DestMorthal auto
ObjectReference Property DestWinterhold auto
Actor Property PlayerREF auto

Function MenuTwo(Int bButton = 0)
    bButton = Options2.Show()
    
    If bButton == 0
    Debug.Notification("Canceled")
    
    ElseIf bButton == 1
    PlayerREF.MoveTo(DestDawnstar)
    ElseIf bButton == 2
    PlayerREF.MoveTo(DestMorthal)
    ElseIf bButton == 3
    PlayerREF.MoveTo(DestWinterhold)
    ElseIf bButton == 4
    Menu()
    EndIf
EndFunction

Function Menu(Int aButton = 0)
    aButton = Options1.Show()
    
    If aButton == 0
    Debug.Notification("Canceled")
    ElseIf aButton == 1
    PlayerREF.MoveTo(DestMarkarth)
    ElseIf aButton == 2
    PlayerREF.MoveTo(DestRiften)
    ElseIf aButton == 3
    PlayerREF.MoveTo(DestSolitude)
    ElseIf aButton == 4
    PlayerREF.MoveTo(DestWhiterun)
    ElseIf aButton == 5
    PlayerREF.MoveTo(DestWindhelm)
    ElseIf aButton == 6
    MenuTwo()
    EndIf
EndFunction
    

Event OnEffectStart(Actor akTarget, Actor akCaster)
    Menu()
EndEvent
Edited by Haugerud15328
Link to comment
Share on other sites

The OnEffectStart event is supposed to fire when the active magic effect starts on the target. Thus, if you cast your spell without a target actor, I would expect that nothing happens. To make the event fire when the casting actor starts casting the spell, you must set up the spell's delivery type as "self" in the CK (technically, the event will still fire then when the effect starts on the target, but the traget is now the casting actor).

Link to comment
Share on other sites

I forget to mention I tried OnEffectFinish(Actor akTarget, Actor akCaster) as well. Same thing happened. I already have it set as self and Fire and Forget in the Magic Effect settings. Yes I made sure I included the effect in the spell. I'm pretty sure it has to do with my script.

Link to comment
Share on other sites

I'm not sure if it makes any difference but you have the functions set up with an automatically assigned input value but call the function without any input value such as Menu(0).

Function Menu(Int aButton = 0) ;input value assigned here
;code
EndFunction

Event OnEffectStart(Actor akTarget, Actor akCaster)
Menu() ;function call but no input value
EndEvent

Try moving the variable inside the function like this as you are only changing the value within the function and not outside so it would make more sense.

Function Menu()
Int aButton = 0
;code
EndFunction

Event OnEffectStart(Actor akTarget, Actor akCaster)
Menu()
EndEvent

Also I may be stating the obvious but have you assigned all the properties a value properly. If none of this has worked then what I normally do is debug everything by seeing in game if it returns the correct values. So to see if OnEffectStart() is being called put a notification or message box that confirms that and put a notification or message that displays the value of a variable before and after and see if that comes out correctly. If OnEffectStart() is not called correctly and does not show the message in game you will know that your script is not set up properly and is not being called. If the variables are not showing the correct value then you know that there is a problem there but if everything is showing up as it should then you will know that the problem must lie with the MoveTo() function and probably not being able to find the object reference or having the wrong type of reference. This will massively narrow the cause and make it easier to find.

Link to comment
Share on other sites

Thank you for the response! Perhaps your suggestions are better suited than what I did, but my original does work after all! I was simply making the idiotic mistake of not moving my compiled .pex files over the copy of Skyrim I was running. After that everything was working fine.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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