[jass=Jass]
function Trig_Futon_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A005'
endfunction
function SR2 takes real xa, real ya, real xb, real yb returns real
return SquareRoot((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb))
endfunction
function Trig_Futon_Actions2 takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local unit u = LoadUnitHandle(udg_Hash,id,0)
local unit d = LoadUnitHandle(udg_Hash,id,1)
local real x = GetUnitX(d)
local real y = GetUnitY(d)
local real x1 = LoadReal(udg_Hash,id,4)
local real y1 = LoadReal(udg_Hash,id,5)
local real a = Atan2(y1-y,x1-x)
local real a2
local unit e
local group g = CreateGroup()
local real r
local real an
local boolean b = LoadBoolean(udg_Hash,id,8)
local player p = GetOwningPlayer(u)
local real f = GetUnitFacing(u)
if GetUnitState(d,UNIT_STATE_LIFE) > 0 then
if SR2(x,y,x1,y1) > 30 then
call SetUnitX(d,x+35*Cos(a))
call SetUnitY(d,y+35*Sin(a))
call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\NightElf\\NEDeathSmall\\NEDeathSmall.mdl",x,y))
call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl",x,y))
call UnitApplyTimedLife(CreateUnit(GetOwningPlayer(u),'h002',x,y,f),'B001',0.5)
call GroupEnumUnitsInRange(g,x,y,200,null)
loop
set e = FirstOfGroup(g)
exitwhen e == null
if IsUnitEnemy(e,p) then
set a2 = Atan2(GetUnitY(e)-y,GetUnitX(e)-x)
call SetUnitX(e,GetUnitX(e)-45*Cos(a2))
call SetUnitY(e,GetUnitY(e)-45*Sin(a2))
endif
call GroupRemoveUnit(g,e)
endloop
else
if b == false then
call SaveUnitHandle(udg_Hash,id,7,CreateUnit(p,'h005',x,y,f))
call SaveBoolean(udg_Hash,id,8,true)
call SetUnitScale(d,3.3,3.3,3.3)
call SaveUnitHandle(udg_Hash,id,9,CreateUnit(p,'h006',x,y,f))
endif
call GroupEnumUnitsInRange(g,x,y,400,null)
set r = GetRandomReal(0,400)
set an = GetRandomReal(0,359)
call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl",x+r*Cos(an*bj_DEGTORAD),y+r*Sin(an*bj_DEGTORAD)))
loop
set e = FirstOfGroup(g)
exitwhen e == null
if IsUnitEnemy(e,p) then
set a2 = Atan2(GetUnitY(e)-y,GetUnitX(e)-x)
call SetUnitX(e,GetUnitX(e)-10*Cos(a2))
call SetUnitY(e,GetUnitY(e)-10*Sin(a2))
call UnitDamageTarget(u,e,0.1*GetUnitAbilityLevel(u,'A001')*GetHeroStr(u,true),true,false,null,null,null)
endif
call GroupRemoveUnit(g,e)
endloop
endif
else
call RemoveUnit(LoadUnitHandle(udg_Hash,id,7))
call RemoveUnit(LoadUnitHandle(udg_Hash,id,9))
call DestroyTimer(t)
call FlushChildHashtable(udg_Hash,id)
call AddUnitAnimationProperties(u,"Spell Channel Five",false)
endif
call DestroyGroup(g)
set g = null
set d = null
set u = null
set e = null
set t = null
endfunction
function Trig_Futon_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit d
local timer t = CreateTimer()
local integer id = GetHandleId(t)
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real f = GetUnitFacing(u)
local player p = GetOwningPlayer(u)
local effect e = AddSpecialEffectTarget("war3mapImported\\RasurikenbyValk_2nd.mdx",u,"right hand")
call AddUnitAnimationProperties(u,"Spell Channel Five",true)
call SaveUnitHandle(udg_Hash,id,0,u)
call SaveReal(udg_Hash,id,4,GetSpellTargetX())
call SaveReal(udg_Hash,id,5,GetSpellTargetY())
//-------------------------------------------------
set d = CreateUnit(GetOwningPlayer(u),'h003',x+100*Cos((f-90)*bj_DEGTORAD),y+100*Sin((f-90)*bj_DEGTORAD),f)
call SetUnitFacingToFaceUnitTimed(d,u,0)
call UnitApplyTimedLife(d,'B001',1.5)
call UnitApplyTimedLife(CreateUnit(p,'h002',x,y,f),'B001',0.5)
call DestroyEffect(AddSpecialEffectTarget("war3mapImported\\shadowclone.mdx",d,"origin"))
call AddUnitAnimationProperties(u,"Spell One",true)
call SetUnitAnimationByIndex(d,9)
set d = null
//-------------------------------------------------
set d = CreateUnit(p,'h003',x+100*Cos((f+90)*bj_DEGTORAD),y+100*Sin((f+90)*bj_DEGTORAD),f)
call SetUnitFacingToFaceUnitTimed(d,u,0)
call UnitApplyTimedLife(d,'B001',1.5)
call UnitApplyTimedLife(CreateUnit(p,'h002',x,y,f),'B001',0.5)
call DestroyEffect(AddSpecialEffectTarget("war3mapImported\\shadowclone.mdx",d,"origin"))
call AddUnitAnimationProperties(u,"Spell One",true)
call SetUnitAnimationByIndex(d,9)
set d = null
//-------------------------------------------------
call TriggerSleepAction(1.00)
set d = CreateUnit(p,'h004',x,y,f)
call UnitApplyTimedLife(d,1,8)
call SaveUnitHandle(udg_Hash,id,1,d)
call UnitAddAbility(d,'Arav')
call DestroyEffect(e)
call SetUnitAnimationByIndex(u,4)
call TimerStart(t,0.025,true,function Trig_Futon_Actions2)
set d = null
set t = null
set u = null
set e = null
set p = null
endfunction
//===========================================================================
function InitTrig_Futon takes nothing returns nothing
set gg_trg_Futon = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Futon, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Futon, Condition( function Trig_Futon_Conditions ) )
call TriggerAddAction( gg_trg_Futon, function Trig_Futon_Actions )
endfunction
[/code]