Thanks but, maybe i should of mentioned that this is being performed within the units lua, not via the games UI.
Have a look...
Init_Shadow_Step = function(self, target)
if myDebug then WARN('Init_Shadow_Step, Target: ', target:GetBlueprint().BlueprintId or 'failed to pull Blueprint for target unit') end
if not self:IsDead() then
--Get the location and size data
local myPos = self:GetPosition()
if myDebug then WARN(' myPos: '..repr(myPos)) end
local tPos = target:GetPosition()
if myDebug then WARN(' tPos: '..repr(tPos)) end
local mSizeZ = self:GetBlueprint().SizeZ
if myDebug then WARN(' My Size Z: ', mSizeZ) end
local tSizeZ = target:GetBlueprint().SizeZ
if myDebug then WARN(' Target Size Z: ', tSizeZ) end
--Calc dist to target
local tDist = VDist2(myPos[1], myPos[3], tPos[1], tPos[3])
local wpnMax = self:GetWeaponByLabel('DoubleLaser'):GetBlueprint().MaxRadius
local minRange = wpnMax
if myDebug then WARN(' Mix range: ', minRange,' Target dist: ', tDist) end
local maxRange = wpnMax * 3
if myDebug then WARN(' Max range: ', maxRange,' Target dist: ', tDist) end
local sizeAdjDist = (tSizeZ + mSizeZ * 5) - tDist
if myDebug then WARN(' Adjusted teleport distance: ', sizeAdjDist) end
--Only warp out if within the right range
if tDist > minRange and tDist <= maxRange then
--Set the flag so that the warp can not happen more than once without first running Warpclock
self.WarpReady = false
--Prep the unit for warp
self:SetImmobile(true)
self:PlayUnitSound('WarpOut')
self:PlayTeleportOutEffects()
self:HideBone(0, true)
self:SetVizToAllies('Never')
self:SetVizToFocusPlayer('Never')
self:SetVizToNeutrals('Never')
self:SetVizToEnemies('Never')
--Snap our unit to face towards the target (can act buggy at times, hence the delay before the warp takes place)
local vector = utilities.GetDirectionVector(tPos, myPos)
if myDebug then WARN(' vector: '..repr(vector)) end
self:SetOrientation( OrientFromDir( vector ),true)
--Keep the unit from dying during the transition
self:SetCanTakeDamage(false)
WaitTicks(5)
local checkPos = nil
local warpPos = nil
local terrain = nil
--These checks ensure that our unit can path to the warp location and that its destination isn't below the ground
while self and not checkPos do
warpPos = self:CalculateWorldPositionFromRelative({ utilities.GetRandomFloat(-5.0, 5.0), 0.1, -sizeAdjDist })
if myDebug then WARN(' warpPos: ', warpPos[1], warpPos[2], warpPos[3]) end
terrain = GetTerrainHeight(warpPos[1], warpPos[3])
if myDebug then WARN(' terrain height ', terrain) end
if terrain > warpPos[2] then
if myDebug then WARN(' adj warpPos height') end
warpPos[2] = terrain + 0.1
end
checkPos = import('/lua/AI/aiutilities.lua').CheckUnitPathingEx(warpPos, myPos, self)
WaitTicks(Random(1,2))
end
--Violently warp in
if myDebug then WARN(' WARP!') end
Warp(self, warpPos, OrientFromDir( vector ))
self:StopUnitAmbientSound('AmbientMove')
self:PlayUnitSound('WarpIn')
self:PlayTeleportInEffects()
for k, v in self.WarpFxFiles do
CreateAttachedEmitter(self, 'url0305', self:GetArmy(), v ):ScaleEmitter(2.0):OffsetEmitter(0,-0.5,0)
end
self:ShakeCamera(2, 1, 0.5, 0.5)
DamageRing(self, warpPos, 1, 5, 250, 'Force', false)
self:ShowBone(0, true)
self:SetVizToAllies('Always')
self:SetVizToFocusPlayer('Always')
self:SetVizToNeutrals('Always')
self:SetVizToEnemies('Intel')
self:SetCanTakeDamage(true)
self:SetImmobile(false)
else
--Warp was aborted due to improper distance to target, so reseting the flag
if myDebug then WARN(' Warp aborted due to ranged') end
end
end
if not self.WarpReady then
--Restart warp engine
self:ForkThread(self.WarpClock)
end
end,