If anyone has played Aotz, they are familiar with Janis's teleporting bomblike ability.
I'm trying to recreate a simpler version of it for one of my heros.
I have everyting looking decent with the exception of one problem.
The unit will teleport, but it won't stop going past its targeted area. So if the target location is 10 feet away,the maxed out spell will still jump 2000 feet.
Anyway, heres the spell, any comments or insight would be helpful.
(I removed the actual unit positioning for this, prior it was moving the unit to an offmap area and then moving it back to the x/y values)
So I'm not sure what to do/add in terms of code to prevent the unit from going too far.
I'm trying to recreate a simpler version of it for one of my heros.
I have everyting looking decent with the exception of one problem.
The unit will teleport, but it won't stop going past its targeted area. So if the target location is 10 feet away,the maxed out spell will still jump 2000 feet.
Anyway, heres the spell, any comments or insight would be helpful.
(I removed the actual unit positioning for this, prior it was moving the unit to an offmap area and then moving it back to the x/y values)
JASS:
function WFc takes nothing returns boolean
return GetSpellAbilityId() == 'AEbl'
endfunction
function WFa takes nothing returns nothing
local unit u = GetTriggerUnit()
local player p = GetOwningPlayer(u)
local integer a = GetUnitAbilityLevel(u,'AEbl')
local integer i = 1+a/2 //Amount of jumps
local integer h = 0 //Temp integer to control turning
local real f
local location l = GetSpellTargetLoc()
local location l2 = GetUnitLoc(u)
local real x = GetLocationX(l)
local real y = GetLocationY(l)
set f = bj_RADTODEG * Atan2(y - GetLocationY(l2), x - GetLocationX(l2))
//Sets the unit facting the direction of the targetted spell
call SetUnitFacing(u,f)
set x = GetLocationX(l2)
set y = GetLocationY(l2)
loop
exitwhen i <= 0
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\FeralSpirit\\feralspiritdone.mdl",x,y))
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\ManaFlare\\ManaFlareBoltImpact.mdl",x,y))
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl",x,y))
//poor attempt to have the spell effects appear in a zigzag
if(h == 0) then
set f = f+45
set h = 1
elseif(h > 0) then
set f = f+90
else
set f = f-90
endif
set h = h*-1
set x = x +200 * Cos(f * bj_DEGTORAD)
set y = y +200 * Sin(f * bj_DEGTORAD)
set i = i-1
endloop
call SetUnitState(u,UNIT_STATE_MANA, GetUnitState(u,UNIT_STATE_MANA) - a*20)
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Orc\\FeralSpirit\\feralspiritdone.mdl",x,y))
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\ManaFlare\\ManaFlareBoltImpact.mdl",x,y))
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl",x,y))
call RemoveLocation(l)
call RemoveLocation(l2)
set l2 = null
set l = null
set p = null
set u = null
endfunction
//===========================================================================
function InitTrig_W_Fla takes nothing returns nothing
set gg_trg_W_Fla = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_W_Fla, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_W_Fla, Condition( function WFc ) )
call TriggerAddAction( gg_trg_W_Fla, function WFa )
endfunction
So I'm not sure what to do/add in terms of code to prevent the unit from going too far.