landsandboat/scripts/effects/teleport.lua
2026-07-21 21:03:22 -06:00

48 lines
1.5 KiB
Lua

-----------------------------------
-- xi.effect.TELEPORT
-----------------------------------
---@type TEffect
local effectObject = {}
effectObject.onEffectGain = function(target, effect)
end
effectObject.onEffectTick = function(target, effect)
end
effectObject.onEffectLose = function(target, effect)
-- Prevents others from teleporting the target out of an event.
if target:isInEvent() and effect:getOriginID() ~= target:getID() then
return
end
if target:isDead() then
-- Retail doesn't port you if you are dead early into the animation.
return
end
local destination = effect:getPower()
if target:isMob() then
DespawnMob(target:getID())
elseif destination == xi.teleport.id.WARP then
target:warp()
elseif destination == xi.teleport.id.ESCAPE then
xi.teleport.escape(target)
elseif destination == xi.teleport.id.OUTPOST then
local region = effect:getSubPower()
xi.teleport.toOutpost(target, region)
elseif destination == xi.teleport.id.LEADER then
xi.teleport.toLeader(target)
elseif destination == xi.teleport.id.HOME_NATION then
xi.teleport.toHomeNation(target)
elseif destination == xi.teleport.id.RETRACE then
xi.teleport.toAlliedNation(target)
elseif destination == xi.teleport.id.TIDAL_TALISMAN then
xi.teleport.tidalTeleport(target)
else
xi.teleport.to(target, destination)
end
end
return effectObject