function WildAxesSpell takes nothing returns boolean
return GetSpellAbilityId()=='A000'
endfunction
function WildAxesTreeCut takes nothing returns nothing
call KillDestructable(GetEnumDestructable())
endfunction
function WildAxesDamage takes unit pWho,real pxx,real pyy,group pVictims returns nothing
local group lGroup=CreateGroup()
local unit lTMP
local rect lMx=Rect(pxx-150,pyy-150,pxx+150,pyy+150)
call GroupEnumUnitsInRange(lGroup,pxx,pyy,150,null)
loop
set lTMP=FirstOfGroup(lGroup)
exitwhen lTMP==null
if(IsUnitInGroup(lTMP,pVictims)==false and IsUnitEnemy(lTMP,GetOwningPlayer(pWho))and IsUnitVisible(lTMP,GetOwningPlayer(pWho)))then
if(GetUnitAbilityLevel(lTMP,'A04R')!=1 and GetUnitState(lTMP,UNIT_STATE_LIFE)>0 and IsUnitType(lTMP,UNIT_TYPE_STRUCTURE)==false)then
call GroupAddUnit(pVictims,lTMP)
call UnitDamageTarget(pWho,lTMP,60+GetUnitAbilityLevel(pWho,'A0O1')*30,true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_METAL_HEAVY_SLICE)
call AddSpecialEffectTarget("Objects\\Spawnmodels\\Human\\HumanBlood\\BloodElfSpellThiefBlood.mdl",lTMP,"overhead")
endif
endif
call GroupRemoveUnit(lGroup,lTMP)
endloop
call EnumDestructablesInRect(lMx,null,function WildAxesTreeCut)
call RemoveRect(lMx)
call DestroyGroup(lGroup)
endfunction
function WildAxesTimer takes nothing returns nothing
local string lTable=H2Tx(GetExpiredTimer())
local unit lAxe=GetUnit(lTable,"Axe")
local unit lCaster=GetUnit(lTable,"Hero")
local real lAx=GetReal(lTable,"Ax")
local real lAy=GetReal(lTable,"Ay")
local real lCx=GetReal(lTable,"Cx")
local real lCy=GetReal(lTable,"Cy")
local real lBx=GetReal(lTable,"Bx")
local real lBy=GetReal(lTable,"By")
local real laa=GetReal(lTable,"a")
local real lbb=1-laa
local boolean lIsPassed=GetBoolean(lTable,"FirstPass")
local group lCheckGroup=GetGroup(lTable,"AlreadyDamaged")
call SetUnitX(lAxe,SafeX(lAx*laa*laa+lBx*2*laa*lbb+lCx*lbb*lbb))
call SetUnitY(lAxe,SafeY(lAy*laa*laa+lBy*2*laa*lbb+lCy*lbb*lbb))
call WildAxesDamage(lCaster,GetUnitX(lAxe),GetUnitY(lAxe),lCheckGroup)
if(lIsPassed)then
call SetReal(lTable,"a",laa-.02)
else
call SetReal(lTable,"a",laa+.02)
call SetReal(lTable,"Ax",GetUnitX(lCaster))
call SetReal(lTable,"Ay",GetUnitY(lCaster))
endif
if(laa<0 and lIsPassed)then
call SetBoolean(lTable,"FirstPass",false)
call SetReal(lTable,"Bx",lAx+300*Cos(Atan2(lCy-lAy,lCx-lAx)+GetReal(lTable,"AngleOffset")))
call SetReal(lTable,"By",lAy+300*Sin(Atan2(lCy-lAy,lCx-lAx)+GetReal(lTable,"AngleOffset")))
endif
if(laa>1 and lIsPassed==false)then
call PauseTimer(GetExpiredTimer())
call DestroyGroup(lCheckGroup)
call FastFlush(lTable)
call RemoveUnit(lAxe)
call DestroyTimer(GetExpiredTimer())
endif
endfunction
function WildAxesSettings takes nothing returns nothing
local unit lCaster=GetTriggerUnit()
local real lCasterX=GetUnitX(lCaster)
local real lCasterY=GetUnitY(lCaster)
local real lTargetX=GetLocationX(GetSpellTargetLoc())
local real lTargetY=GetLocationY(GetSpellTargetLoc())
local unit lAxe1=CreateUnit(GetOwningPlayer(lCaster),'e01T',lCasterX,lCasterY,270.)
local unit lAxe2=CreateUnit(GetOwningPlayer(lCaster),'e01T',lCasterX,lCasterY,270.)
local string lTable1
local string lTable2
local timer lTimer1=CreateTimer()
local timer lTimer2=CreateTimer()
if GetSpellTargetUnit()!=null then
set lTargetX=GetUnitX(GetSpellTargetUnit())
set lTargetY=GetUnitY(GetSpellTargetUnit())
endif
call UnitAddAbility(lAxe1,'Amrf')
call UnitRemoveAbility(lAxe1,'Amrf')
call SetUnitFlyHeight(lAxe1,150,0)
call UnitAddAbility(lAxe2,'Amrf')
call UnitRemoveAbility(lAxe2,'Amrf')
call SetUnitFlyHeight(lAxe2,150,0)
set lTable1=H2Tx(lTimer1)
call SetHandle(lTable1,"Hero",lCaster)
call SetHandle(lTable1,"Axe",lAxe1)
call SetHandle(lTable1,"AlreadyDamaged",CreateGroup())
call SetReal(lTable1,"Ax",lCasterX)
call SetReal(lTable1,"Ay",lCasterY)
call SetReal(lTable1,"Cx",lTargetX)
call SetReal(lTable1,"Cy",lTargetY)
call SetReal(lTable1,"Bx",lCasterX+300*Cos(Atan2(lTargetY-lCasterY,lTargetX-lCasterX)+45))
call SetReal(lTable1,"By",lCasterY+300*Sin(Atan2(lTargetY-lCasterY,lTargetX-lCasterX)+45))
call SetReal(lTable1,"a",1)
call SetReal(lTable1,"AngleOffset",-45)
call SetBoolean(lTable1,"FirstPass",true)
set lTable2=H2Tx(lTimer2)
call SetHandle(lTable2,"Hero",lCaster)
call SetHandle(lTable2,"Axe",lAxe2)
call SetHandle(lTable2,"AlreadyDamaged",CreateGroup())
call SetReal(lTable2,"Ax",lCasterX)
call SetReal(lTable2,"Ay",lCasterY)
call SetReal(lTable2,"Cx",lTargetX)
call SetReal(lTable2,"Cy",lTargetY)
call SetReal(lTable2,"Bx",lCasterX+300*Cos(Atan2(lTargetY-lCasterY,lTargetX-lCasterX)-45))
call SetReal(lTable2,"By",lCasterY+300*Sin(Atan2(lTargetY-lCasterY,lTargetX-lCasterX)-45))
call SetReal(lTable2,"a",1)
call SetReal(lTable2,"AngleOffset",45)
call SetBoolean(lTable2,"FirstPass",true)
call TimerStart(lTimer1,.025,true,function WildAxesTimer)
call TimerStart(lTimer2,.025,true,function WildAxesTimer)
endfunction
function WildAxesInit takes nothing returns nothing
local trigger ltt=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(ltt,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(ltt,Condition(function WildAxesSpell))
call TriggerAddAction(ltt,function WildAxesSettings)
endfunction