Script Request: Dynamic Portal

Post » Sun Jun 24, 2012 6:18 am

I need a spell script that can function as a two-way teleporter. However, I'm an idiot when it comes to coding in Papyrus, and most of the tutorials I've read are too unrelated or not specific enough. I don't like asking for help, because I could figure this out for myself in an ideal world, but I've been at this for about a week and have made no progress. I know almost zero Papyrus, and this is my attempt to replicate a script I had once written in Oblivion.

Here is the script I have so far in its simplest form, minus all of the workarounds I wrote that did nothing helpful. I can only get it to work in 1 direction, towards the destination point, but the return point does not work.


Spoiler
Scriptname TeleportScript extends activemagiceffect  ObjectReference property [color=#ff0000]DestinationMarker[/color] autoObjectReference property [color=#00ffff]ReturnMarker[/color] autobool PlayerAtDestinationEvent OnEffectFinish(Actor target, Actor caster)	 if PlayerAtDestination == false		  [color=#00ffff]ReturnMarker[/color].MoveTo(target)		  target.MoveTo([color=#ff0000]DestinationMarker[/color])		  PlayerAtDestination == true	 else		  target.MoveTo([color=#00ffff]ReturnMarker[/color])		  PlayerAtDestination == false	 endifEndEvent

In this instance, ReturnMarker and DestinationMarker are XMarkerHeadings. The goal is for the player to go to the DestinationMarker located in DestinationCell (which is exterior), and at the same time move the ReturnMarker to the player's original location. After casting the spell a second time, the player is moved to the ReturnMarker, and the process repeats. What would be bad is if the check fails, and the ReturnMarker is sent to DestinationCell, trapping the player forever.

I could possibly get it to work if I could figure out how to actually change the values of the boolean flag.


Bonus points:

50 Bonus points if anyone can come up with a script that, instead of directly teleporting the player, spawns a portal object in front of the player that is activated when the player walks into it. The rest of the script's original effect applies, except the player is moved to the location of the portal rather than where they stood while casting the spell.

30 Bonus points each if you can prevent it from working in interiors, during combat, and if companions are able to travel with you.

5,000 bonus points if you can explain it to me so I don't need to ask again :tongue:
User avatar
Claudia Cook
 
Posts: 3450
Joined: Mon Oct 30, 2006 10:22 am

Post » Sun Jun 24, 2012 2:25 pm

to get followers you need to use Game.Fasttravel() instead of moveto

currently this function is only valid when standing on a navmesh in an esm (works fine if that navmesh is skyrim.esm's, but no good if that navmesh is in a custom esp, although you may be able to work around this by teleporting to a dummy empty cell first, then your destination)


use the function IsInInterior() in your condition to query for interiors

for the portal, create an activator object and use the moveto, to move the activator to the player after casting (or if you wanna get fancy, move the teleporter to the point of impact on an aimed spell)



then your teleport script would be applied to the teleporter's object using Event OnActivate()
User avatar
Alessandra Botham
 
Posts: 3440
Joined: Mon Nov 13, 2006 6:27 pm


Return to V - Skyrim