Teleport scriptMoveTo(offset) sanity checking

Post » Sat Jun 07, 2014 9:06 pm

I recently came up with the idea for a random telport spell, ala Orchendor or Vals Veran. The idea is that if an opponent gets within melee range, the caster can cast the spell and reappear at random spot on the battlefield, hopefully out of danger. The problem with the existing telport effect for Orchendor, Vals Veran and the Caller depend on having pre-existing markers in the worldspace. At first, using

xAxis = Utility.RandomFloat(-3000,3000)yAxis = Utility.RandomFloat(-3000,3000)zAxis = 0akCaster.MoveTo(akCaster, xAxis, yAxis, zAxis)

worked, but would also sometimes end up with the caster in a wall or a door. So I hit on the idea of creating a marker at a random location, checking if akCaster.hasLoS(TelportMarker) is true, then executing the MoveTo. So final code looks like this:

Scriptname FWC_Escape_script extends activemagiceffectObjectReference TeleportMarkerfloat xAxisfloat yAxisfloat zAxisint i = 0int maxSearch = 20Event OnEffectStart(Actor akTarget, Actor akCaster)        TeleportMarker = akCaster.PlaceAtMe(Game.GetFormFromFile(0x00000034, "Skyrim.ESM"))        while i < maxSearch        xAxis = Utility.RandomFloat(-3000,3000)        yAxis = Utility.RandomFloat(-3000,3000)        zAxis = Utility.RandomFloat(-50,50)        TeleportMarker.MoveTo(akCaster, xAxis, yAxis, zAxis)        if akCaster.hasLoS(TeleportMarker) == FALSE                i = i + 1        else                akCaster.MoveTo(TeleportMarker)                i = maxSearch        endif        endwhileEndEvent

Fairly simple, but it works most of the time. The caster (usually the player) now does not end up telporting in to/through doors or walls. However, there are three remaining problems. One, it only works in the direction the caster is looking in as a consequence (I assume) of using akCaster.hasLoS. Two, it doesn't work very well if the caster is looking uphill. Thirdly, it's quite possible to teleport off a cliff. Another concern I have is that it will leave a bunch of markers in the world, causing save game bloat.

Is there any way to do "sanity checking" with the akCaster.MoveTo(akCaster, x, y, z) function? In other words, make sure that the caster appears with his feet on the ground and not inside another object? And also, do I need to clean up that TeleportMarker to make sure I avoid save game bloat? How would I do that?

User avatar
Budgie
 
Posts: 3518
Joined: Sat Oct 14, 2006 2:26 pm

Return to V - Skyrim