Jump to content

[LE] Teleport to previous location script help


Recommended Posts

After more than 2 weeks of scouring the internet and these forums, I just can't get my mod to work. I've watched tutorials and tried to follow the instructions I found in these links, but to no avail. Any help would be very much appreciated.

 

I'm creating a portable home that can be accessed by casting a spell. I got the teleport in spell to work but can't get the teleport out to my previous location to work. When I'm in the home and cast the spell to go out, it puts me at the mod entrance again.

 

(I've tried using all of the portable home mods I could find but none of them had everything I wanted in them.)

 

My script said it was compiling properly so I can't figure out where the missing link is to make it work. Here is what I have so far:

 

Scriptname CampTeleportAbility extends activemagiceffect

ObjectReference Property DDMarker001 Auto ;xMarker in mod cell
ObjectReference Property DDTeleportPoint Auto ;xMarker that is supposed to be placed in the world location I teleport from
GlobalVariable Property DDTeleportCount Auto ;Spell cast on count 1 to enter mod, cast on count 2 to exit

Event OnEffectStart(Actor akTarget, Actor akCaster)
if DDTeleportCount.Getvalue() == 0
Utility.Wait(1.5)
DDTeleportPoint.MoveTo(Game.GetPlayer())
Game.FadeOutGame(False, True, 2.0, 1.0)
Game.GetPlayer().MoveTo(DDMarker001)
Game.EnableFastTravel()
Game.FastTravel(DDMarker001)
DDTeleportCount.SetValue(1)

Elseif DDTeleportCount.GetValue() == 1
Game.FadeOutGame(False, True, 2.0, 1.0)
Game.GetPlayer().MoveTo(DDTeleportPoint)
Game.EnableFastTravel()
Game.FastTravel(DDTeleportPoint)
DDTeleportCount.SetValue(0)
Endif
EndEvent

Compiler Output:
Starting 1 compile threads for 1 files...
Compiling "CampTeleportAbility"...
Starting assembly of CampTeleportAbility
0 error(s), 0 warning(s)
Assembly succeeded

Compilation succeeded.

Batch compile of 1 files finished. 1 succeeded, 0 failed.

 

Thank you in advance for your time and assistance!

Evo

Link to comment
Share on other sites

I don't think so. Add some notification statements to see what is going on. The global variable should update but if for some reason it is not, the second cast of the spell would think it is still the first cast.

 

You might want to consider setting up a second magic effect. One magic effect to teleport in and one to teleport out. Since you have a dedicated location to teleport into you could use a condition to determine which magic effect is triggered based upon the current location.

Link to comment
Share on other sites

I'm guessing ... DDTeleportPoint.MoveTo(Game.GetPlayer())
Never actually set the marker in the right spot.

Here is one of mine that works well.


;* Enchanted Ship In a Bottle ...
;* ModelShip - { Coaded by: NexusComa ... 12/03/2015 }
;----------------------------------------------------
Scriptname Ship00_ModelShipTeleport Extends ActiveMagicEffect

Cell Property ModelShip Auto
ObjectReference Property Marking Auto
ObjectReference Property ModelShipMarker Auto
ObjectReference Property ModelShipItem Auto

Event OnEffectStart (Actor Target, Actor Caster)
If (Caster.GetParentCell() != ModelShip)
Marking.MoveTo(Caster)
Caster.MoveTo(ModelShipMarker)
Game.EnableFastTravel()
Game.FastTravel(ModelShipMarker)
EndIf
EndEvent

Event OnEffectFinish (Actor Target, Actor Caster)
Caster.Moveto(Marking)
Game.EnableFastTravel()
Game.FastTravel(Marking)

;*Safety Catch
If Caster.GetItemCount(ModelShipItem) < 1
Caster.AddItem(ModelShipItem)
EndIf
EndEvent

 

Link to comment
Share on other sites

Here's my script for my Shadow Blink Spell as this might be useful to you. In a nutshell casting the spell I have a messagebox pop up with three choices (essentially save my current location, teleport to my saved location, return to the previous location I last used the spell, or cancel)....

scriptName z2018mjhMarkRecallScript extends activemagiceffect

objectreference property z2018mjhMarkRecallMarker auto
activator property SummonTargetFXActivator auto
message property z2018mjhMarkRecallMenu auto
objectreference property z2018mjhMarkRecallReturnMarker auto

Event OnEffectStart(Actor akTarget, Actor akCaster)
	Int mjhChoice = z2018mjhMarkRecallMenu.show(0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000)
	if mjhChoice == 0
		z2018mjhMarkRecallMarker.MoveTo(akCaster as objectreference, 0.000000, 0.000000, 0.000000, true)
		akTarget.PlaceAtMe(SummonTargetFXActivator as form, 1, false, false)
		debug.notification("Shadow Blink - Location Bound.")
	elseIf mjhChoice == 1
		z2018mjhMarkRecallReturnMarker.MoveTo(akCaster as objectreference, 0.000000, 0.000000, 0.000000, true)
		akCaster.MoveTo(z2018mjhMarkRecallMarker, 0.000000, 0.000000, 0.000000, true)
		akTarget.PlaceAtMe(SummonTargetFXActivator as form, 1, false, false)
	elseIf mjhChoice == 2
		akCaster.MoveTo(z2018mjhMarkRecallReturnMarker, 0.000000, 0.000000, 0.000000, true)
		akTarget.PlaceAtMe(SummonTargetFXActivator as form, 1, false, false)
	elseIf mjhChoice == 3
	endIf
endEvent

Essentially, I use 2 xmarkers, 1 that the player can set directly, and the other is set indirectly when the player uses the 2nd option. This allows you to be able to teleport back to the location that you first used the spell, and houses everything in 1 spell.

 

For your effect, I would use 2 xmarkers, 1 being the teleport in point that is never moved, and the other that is set at your location before teleporting to the teleport in marker, so that your teleport out effect, points to your mobile xmarker that is moved when you first cast the spell. You could use akCaster instead of calling Game.GetPlayer(), and you don't really need to use the fast travel stuff, you could just use MoveTo (only difference there if I recall correctly is the fast travel time would add to your game time, as the moveto is instant). Also I agree with Ishara, if you're calling utilitywait, have it after you move the invisible xmarker to your location, as there's no point in waiting before you your effect does anything, might as well have your marker move to you then wait.

 

Hopefully this helps you.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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