function Trig_Distance_Shrink_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00D'
endfunction
function Shrinking takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local integer cv
local unit u = LoadUnitHandle(udg_Spell_Table, id, 1)
local unit pu
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real ang = LoadReal(udg_Spell_Table, id, 2)
local real nx = LoadReal(udg_Spell_Table, id, 5) + 50 * Cos(ang * bj_DEGTORAD)
local real ny = LoadReal(udg_Spell_Table, id, 6) + 50 * Sin(ang * bj_DEGTORAD)
local real distance = LoadReal(udg_Spell_Table, id, 3) - 50
local integer cliff = LoadInteger(udg_Spell_Table, id, 4)
if distance > 0 and IsTerrainWalkable(nx, ny) and cliff==GetTerrainCliffLevel(nx, ny) then
call SaveReal(udg_Spell_Table, id, 3, distance)
call SaveReal(udg_Spell_Table, id, 5, nx)
call SaveReal(udg_Spell_Table, id, 6, ny)
call GroupEnumUnitsInRange(udg_UG, nx, ny, 60, null)
loop
set pu = FirstOfGroup(udg_UG)
exitwhen (pu==null)
if IsUnitEnemy(pu, GetOwningPlayer(u)) then
set cv = GetUnitUserData(pu)
if LoadInteger(udg_Misc_Table, id, cv) == 0 then
call UnitDamageTarget(u, pu, 100.00, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
endif
call SaveInteger(udg_Misc_Table, id, cv, 1)
endif
call GroupRemoveUnit(udg_UG, pu)
endloop
call DestroyEffect(AddSpecialEffect ("Abilities\\Spells\\Orc\\Shockwave\\ShockwaveMissile.mdl", nx , ny))
call TimerStart(t, 0.03, false, function Shrinking)
else
call SetUnitVertexColor(u, 255, 255, 255, 255)
if GetLocalPlayer() == GetOwningPlayer(u) then
call ClearSelection()
call SelectUnit(u, true)
endif
call SetUnitPosition(u, nx, ny)
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(udg_Spell_Table, id)
call FlushChildHashtable(udg_Misc_Table, id)
endif
set t = null
set u = null
set pu = null
endfunction
function Trig_Distance_Shrink_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local real ang = GetUnitFacing(u)
local integer cliff = GetTerrainCliffLevel(GetUnitX(u), GetUnitY(u))
local timer t = CreateTimer()
local integer id = GetHandleId(t)
local real distance = 600.00
call SetUnitVertexColor(u, 255, 255, 255, 0)
call SaveUnitHandle(udg_Spell_Table, id, 1, u)
call SaveReal(udg_Spell_Table, id, 2, ang)
call SaveReal(udg_Spell_Table, id, 3, distance)
call SaveInteger(udg_Spell_Table, id, 4, cliff)
call SaveReal(udg_Spell_Table, id, 5, GetUnitX(u))
call SaveReal(udg_Spell_Table, id, 6, GetUnitY(u))
call TimerStart(t, 0.03, false, function Shrinking)
set u = null
set t = null
endfunction
//===========================================================================
function InitTrig_Distance_Shrink takes nothing returns nothing
set gg_trg_Distance_Shrink = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Distance_Shrink, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Distance_Shrink, Condition( function Trig_Distance_Shrink_Conditions ) )
call TriggerAddAction( gg_trg_Distance_Shrink, function Trig_Distance_Shrink_Actions )
endfunction