Difference between revisions of "Teleport Recall"
imported>Wrye (→Marker Rats: Living rats) |
imported>Qazaaq m (added to Category: Useful Code) |
||
(One intermediate revision by one other user not shown) | |||
Line 24: | Line 24: | ||
endif | endif | ||
end</pre> | end</pre> | ||
To use this, you would also need to define the exTeleport2G global (a short with initial value of 0). You'll also need the casting spell which uses this spell effect script. The duration of the script effect should be at least one second to give the moveTo in the scripteffectstart time to complete. Finally, you'll need the marker references (exTeleport2Ref0 and exTeleport2Ref1). Previously, these were usually defined as instances of the static XMarker, but there are problems with these -- you should use a [[# | To use this, you would also need to define the exTeleport2G global (a short with initial value of 0). You'll also need the casting spell which uses this spell effect script. The duration of the script effect should be at least one second to give the moveTo in the scripteffectstart time to complete. Finally, you'll need the marker references (exTeleport2Ref0 and exTeleport2Ref1). Previously, these were usually defined as instances of the static XMarker, but there are problems with these -- you should use a [[#Marker_Rats|marker creature]] instead. | ||
===Variations=== | ===Variations=== | ||
Line 57: | Line 57: | ||
* Name the reference (e.g., exTeleport2Ref0) and set it to initially disabled. | * Name the reference (e.g., exTeleport2Ref0) and set it to initially disabled. | ||
* Use reference in scripts as described above. | * Use reference in scripts as described above. | ||
[[Category: Useful Code]] |
Latest revision as of 18:29, 10 January 2008
A teleport recall is quite popular for use with pocket dimensions, mobile tents, etc., but can also be used for mark/recall, multimark, etc. The basic solution is to define a persistent ref object, place it at the mark point, and then later use moveto to return the player to that point.
Two Sided Teleport[edit | edit source]
Here's a two sided teleport spell -- rather than have a separate mark and recall spells, you have a single spell that marks the current spot and then teleports you to the previously marked spot. This is done by having two separate markers and alternating between them.
scn exTeleport2ME begin scriptEffectStart if exTeleport2G == 0 exTeleport2Ref0.moveTo player else exTeleport2Ref1.moveTo player endif end begin scriptEffectFinish playSound DRSOblivionGateOpen if exTeleport2G == 0 set exTeleport2G to 1 player.moveTo exTeleport2Ref1 else set exTeleport2G to 0 player.moveTo exTeleport2Ref0 endif end
To use this, you would also need to define the exTeleport2G global (a short with initial value of 0). You'll also need the casting spell which uses this spell effect script. The duration of the script effect should be at least one second to give the moveTo in the scripteffectstart time to complete. Finally, you'll need the marker references (exTeleport2Ref0 and exTeleport2Ref1). Previously, these were usually defined as instances of the static XMarker, but there are problems with these -- you should use a marker creature instead.
Variations[edit | edit source]
Variation usually comes in how you trigger the teleport effect. a spell (such as above) is probably simplest to implement, but doors may be more fun, or have a better visual/logical appeal, and can be made less uber.
Rather than directly casting a spell, you might somehow establish a doorway in the external world (e.g., raise a tent, which includes a doorway, or else summon a portal). Then activating the doorway would perform the teleportation.
If you're using a tent or pocket dimension metaphor, you will likely have a fixed doorway in the "home" (tent or pocket dimension) cell. The external doorway should be a door object which is moved to the players location along with the external marker ref. (Note that the door should NOT be used as the external marker -- see below.) Using the external doorway would then cause a moveTo the marker in the home cell. (Alternatively you can use positionCell -- but its probably simpler to use a marker in the internal cell as well. Note: In this case a static XMarker will work fine.)
If you summon the external doorway, you'll probably want to place it in front of the player by a given distance. Since you can't do this directly with placeAtMe, you'll instead need to move the object to the player and then reposition it. For info on doing this, see Summon Object.
For a working example of a pocket dimension with summoned doorway, see Salan's Cellar. (Note: This does not yet use a marker rat for the exit. See below.)
Shivering Isles[edit | edit source]
If you're moving to/from Shivering Isles, you'll also need to switch reset a number of flags and quest variables while making the transition. For an example, see the entrance/exit doors in Shivering Isles, or the Shivering Gates in Wrye Shivering. (Note: Wrye Shivering does not yet use Marker creatures as it should. See below.)
Companions[edit | edit source]
Since the door is not a regular doorway, you companions (if any) will not follow you through. If this is not desirable, then an area spell should be cast which causes companions to moveto player after player has arrived.
Note however, companions may not have greetings in Shivering Isles -- this is because the regular greetings topic are turned off in SI (as are most rumors, etc.).
Marker Rats[edit | edit source]
In order to mark points in the world for recall, a reference marker needs to be moved there. In the past, this has been done with XMarkers, but these seem to have problems when they're moved to worldspaces outside of the Tamriel worldspace. It seems that after quitting and reloading, the objects snap back to their original worldspace, while keeping their modified position (x, y, z coordinates). Apparently, the game engine doesn't really expect statics, doors, etc. to move outside of their original cell, and so the information about their movement is not properly recorded.
Solution to this is to use marker actors (creatures or NPCs) instead. (Since the game engine expects these objects to move, changes in worldspaces are correctly recorded.) Thankfully the marker creatures do not have to be visible, thus they can be treated just like regular XMarkers.
Marker Rat Recipe:
- Define a marker rat creature:
- Enable low level processing (just in case).
- Scripted? If the marker rat is scripted, then the rat must be alive. (Scripts on actors won't run unless the actor is alive.)
- Place instance of rat somewhere in world (e.g., at default teleport point or in dummy internal cell).
- Name the reference (e.g., exTeleport2Ref0) and set it to initially disabled.
- Use reference in scripts as described above.