Name | Type | is_array | initial_value |
Player | player | No | |
SoR_Area | real | No | |
SoR_BurstSFX | unitcode | No | |
SoR_DataTable | hashtable | No | |
SoR_Dmg_Burst | real | No | |
SoR_Dmg_Percent | boolean | No | |
SoR_Dmg_Repeat | boolean | No | |
SoR_Dmg_Ring | real | No | |
SoR_Group | group | No | |
SoR_RingDetail | real | No | |
SoR_Rings | integer | No | |
SoR_RingSFX | string | No | |
SoR_Speed_Max | real | No | |
SoR_Speed_Min | real | No | |
SoR_Spell | abilcode | No | |
Unit | unit | No |
function SoR_BurstSFX takes nothing returns nothing
local timer t=GetExpiredTimer()
local integer id=GetHandleId(t)
call RemoveUnit(LoadUnitHandle(udg_SoR_DataTable,id,0))
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(udg_SoR_DataTable,id)
set t=null
endfunction
function SoR_Rings takes nothing returns nothing
local timer t=GetExpiredTimer()
local integer id=GetHandleId(t)
local unit it
local real newx
local real newy
local real dmg
local real step
local real angle
local integer curring=0
local boolean isgood=false
//ring Metadata
local unit caster=LoadUnitHandle(udg_SoR_DataTable,id,-3)
local integer rings=LoadInteger(udg_SoR_DataTable,id,-2)
local string SFX=LoadStr(udg_SoR_DataTable,id,-1)
//Ring Data
local real x
local real y
local real speed
local real distance
local group targets
loop // Ring Loop
exitwhen curring==rings
set distance=LoadReal(udg_SoR_DataTable,id,3+5*curring)
set targets=LoadGroupHandle(udg_SoR_DataTable,id,4+5*curring)
if distance<udg_SoR_Area then
//Get Ring Data
set x=LoadReal(udg_SoR_DataTable,id,0+5*curring)
set y=LoadReal(udg_SoR_DataTable,id,1+5*curring)
set speed=LoadReal(udg_SoR_DataTable,id,2+5*curring)
//Set Other Data
set angle=0
set step=udg_SoR_RingDetail/distance
//Create Rings
set isgood=true
loop // Point on Ring Loop
exitwhen angle>=6.2831
//Ring
set newx=x+Cos(angle)*distance
set newy=y+Sin(angle)*distance
call DestroyEffect(AddSpecialEffect(SFX,newx,newy))
call GroupEnumUnitsInRange(udg_SoR_Group,newx,newy,udg_SoR_RingDetail,null)
loop // Damage Point on Ring Loop
set it=FirstOfGroup(udg_SoR_Group)
exitwhen it==null
if IsUnitInGroup(it,targets)==false then
if udg_SoR_Dmg_Repeat==false then
call GroupAddUnit(targets,it)
endif
if GetWidgetLife(it)>.405and IsUnitType(it,UNIT_TYPE_DEAD)==false and false==IsUnitAlly(it,GetOwningPlayer(caster))then
set dmg=udg_SoR_Dmg_Ring
if udg_SoR_Dmg_Percent then
set dmg=dmg*GetUnitState(it,UNIT_STATE_MAX_LIFE)
endif
call UnitDamageTarget(caster,it,dmg,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_MAGIC,null)
endif
endif
call GroupRemoveUnit(udg_SoR_Group,it)
endloop // Damage Point on Ring Loop
//-----
set angle=angle+step
endloop // Point on Ring Loop
call SaveReal(udg_SoR_DataTable,id,3+5*curring,distance+speed)
//call SaveGroupHandle(udg_SoR_DataTable,id,4+5*curring,targets)
else
call DestroyGroup(targets)
endif // distance<udg_SoR_Area
set curring=curring+1
endloop // Ring Loop
if isgood==false then
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(udg_SoR_DataTable,id)
else
call TimerStart(t,0.2,false,function SoR_Rings)
endif
set t=null
set it=null
set caster=null
set targets=null
endfunction
function Trig_SoR_Actions takes nothing returns boolean
//----- Variables -----
local real X=GetSpellTargetX()
local real Y=GetSpellTargetY()
local unit SFX=null
local unit caster=GetSpellAbilityUnit()
local timer T=null
local timer R=null
local integer id=0
local unit targets=null
local integer r=0
local real dmg=udg_SoR_Dmg_Burst
if GetSpellAbilityId()==udg_SoR_Spell then
//----- Actions -----
//Burst damage
call GroupEnumUnitsInRange(udg_SoR_Group,X,Y,udg_SoR_Area,null)
loop
set targets=FirstOfGroup(udg_SoR_Group)
exitwhen targets==null
if GetWidgetLife(targets)>.405and IsUnitType(targets,UNIT_TYPE_DEAD)==false and false==IsUnitAlly(targets,GetOwningPlayer(caster))then
if udg_SoR_Dmg_Percent then
set dmg=udg_SoR_Dmg_Burst*GetUnitState(targets,UNIT_STATE_MAX_LIFE)
endif
call UnitDamageTarget(caster,targets,dmg,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_MAGIC,null)
endif
call GroupRemoveUnit(udg_SoR_Group,targets)
endloop
//BurstSFX
set T=CreateTimer()
set SFX=CreateUnit(Player(15),udg_SoR_BurstSFX,X,Y,0)
call TimerStart(T,5,false,function SoR_BurstSFX)
call SaveUnitHandle(udg_SoR_DataTable,GetHandleId(T),0,SFX)
//Rings
set R=CreateTimer()
call TimerStart(R,0.2,false,function SoR_Rings)
set id=GetHandleId(R)
//meta ring data
call SaveUnitHandle(udg_SoR_DataTable,id,-3,caster)
call SaveInteger(udg_SoR_DataTable,id,-2,udg_SoR_Rings)
call SaveStr(udg_SoR_DataTable,id,-1,udg_SoR_RingSFX)
//ring data
loop
exitwhen r==udg_SoR_Rings
call SaveReal(udg_SoR_DataTable,id,0+r*5,X)
call SaveReal(udg_SoR_DataTable,id,1+r*5,Y)
call SaveReal(udg_SoR_DataTable,id,2+r*5,(udg_SoR_Speed_Max-udg_SoR_Speed_Min)*I2R(r+1)/I2R(udg_SoR_Rings)+udg_SoR_Speed_Min)
call SaveReal(udg_SoR_DataTable,id,3+r*5,1)
if udg_SoR_Dmg_Repeat==false then
call SaveGroupHandle(udg_SoR_DataTable,id,4+r*5,CreateGroup())
endif
set r=r+1
endloop
endif
//----- Cleanup -----
set T=null
set targets=null
set caster=null
set SFX=null
return false
endfunction
function InitTrig_SoR takes nothing returns nothing
local integer i=0
set gg_trg_SoR=CreateTrigger()
loop
exitwhen i==12
call TriggerRegisterPlayerUnitEvent(gg_trg_SoR,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
set i=i+1
endloop
call TriggerAddCondition(gg_trg_SoR,Condition(function Trig_SoR_Actions))
endfunction