Name | Type | is_array | initial_value |
GDS_ABIL | abilcode | Yes | |
GDS_BUFF | buffcode | Yes | |
GDS_cDISARM_B | integer | No | |
GDS_cDISARM_M | integer | No | |
GDS_cDISARM_R | integer | No | |
GDS_cENTANGLE | integer | No | |
GDS_cETHEREAL | integer | No | |
GDS_cSILENCE | integer | No | |
GDS_cSLEEP | integer | No | |
GDS_cSNARE | integer | No | |
GDS_cSTUN | integer | No | |
GDS_cSUPERSILENCE | integer | No | |
GDS_DebuffEvent | real | No | |
GDS_DUMMY | unit | Yes | |
GDS_Duration | real | No | |
GDS_Hashtable | hashtable | No | |
GDS_ORDERS | string | Yes | |
GDS_Permanent | boolean | No | |
GDS_RegisterDisable | boolean | No | true |
GDS_Remaining | real | No | |
GDS_Target | unit | No | |
GDS_Type | integer | No | |
GDS_zMIN | real | No | |
Test | real | No | |
zEXAMPLE_DurAdd | real | No | |
zEXAMPLE_DurMul | real | No | |
zEXAMPLE_group | group | No | |
zEXAMPLE_MinDuration | real | No | |
zEXAMPLE_ModifierSpecific | trigger | Yes |
function GDSDebuffApplied takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tHandle = GetHandleId(t)
local integer stunType = LoadInteger(udg_GDS_Hashtable, tHandle , 1)
local unit u = LoadUnitHandle(udg_GDS_Hashtable, tHandle , 0)
if GetUnitAbilityLevel( u , udg_GDS_BUFF[stunType]) != 0 then
call FlushChildHashtable(udg_GDS_Hashtable, GetHandleId(t))
call PauseTimer(t)
call DestroyTimer(t)
set udg_GDS_DebuffEvent = stunType
set udg_GDS_Target = u
set udg_GDS_DebuffEvent = 0.5
else
call TimerStart(t, udg_GDS_zMIN, false, function GDSDebuffApplied)
endif
set u = null
set t = null
endfunction
function GDSDebuffEnd takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tHandle = GetHandleId(t)
local integer stunType = LoadInteger(udg_GDS_Hashtable, tHandle , 2)
local unit u = LoadUnitHandle(udg_GDS_Hashtable, tHandle , 0)
local integer uHandle = LoadInteger(udg_GDS_Hashtable, tHandle , 1)
call UnitRemoveAbility(u, udg_GDS_BUFF[stunType])
call FlushChildHashtable(udg_GDS_Hashtable, GetHandleId(t))
call PauseTimer(t)
call DestroyTimer(t)
call RemoveSavedHandle(udg_GDS_Hashtable, uHandle , stunType)
set u = null
set t = null
endfunction
function GDSMain takes nothing returns nothing
local timer t
local timer timerOld = LoadTimerHandle(udg_GDS_Hashtable, GetHandleId(udg_GDS_Target) , udg_GDS_Type )
local real duration = udg_GDS_Duration
local boolean hadTimer = timerOld != null
set udg_GDS_Remaining = TimerGetRemaining(timerOld)
//Check if user wants a permanent debuff
if udg_GDS_Permanent then
set udg_GDS_Permanent = false
if hadTimer then
call FlushChildHashtable(udg_GDS_Hashtable, GetHandleId(timerOld))
call PauseTimer(timerOld)
call DestroyTimer(timerOld)
call RemoveSavedHandle(udg_GDS_Hashtable, GetHandleId(udg_GDS_Target) , udg_GDS_Type)
set timerOld = null
else
if IssueTargetOrder( udg_GDS_DUMMY[udg_GDS_Type], udg_GDS_ORDERS[udg_GDS_Type], udg_GDS_Target ) or GetUnitAbilityLevel(udg_GDS_Target , udg_GDS_BUFF[udg_GDS_Type]) != 0 then
set udg_GDS_Remaining = -1 //-1 for infinite duration
else
set udg_GDS_Remaining = 0
endif
endif
if udg_GDS_RegisterDisable then
set t = CreateTimer()
call SaveUnitHandle(udg_GDS_Hashtable, GetHandleId(t) , 0 , udg_GDS_Target)
call SaveInteger(udg_GDS_Hashtable , GetHandleId(t) , 1 , udg_GDS_Type)
call TimerStart(t, udg_GDS_zMIN, false, function GDSDebuffApplied)
set t = null
endif
return
endif
//Check if user wants to reduce duration of stun (check for negative duration)
if duration < -udg_GDS_zMIN and udg_GDS_Remaining > udg_GDS_zMIN then //Check for reduction
if -duration > udg_GDS_Remaining then //Check if reduction goes below 0
call UnitRemoveAbility(udg_GDS_Target , udg_GDS_BUFF[udg_GDS_Type])
set duration = 0
else
set duration = udg_GDS_Remaining - duration //Change duration so it passes the checks
endif
endif
//Check if the desired duration is higher than remaining time
if udg_GDS_Remaining < duration and duration > udg_GDS_zMIN and hadTimer then
if hadTimer then
set t = timerOld
else
set t = CreateTimer()
set timerOld = null
endif
else
//Check if unit has buff, clean hashtable, destroy timer and set remaining time to 0
if GetUnitAbilityLevel(udg_GDS_Target, udg_GDS_BUFF[udg_GDS_Type]) == 0 then
call FlushChildHashtable(udg_GDS_Hashtable, GetHandleId(timerOld))
call PauseTimer(timerOld)
call DestroyTimer(timerOld)
call RemoveSavedHandle(udg_GDS_Hashtable, GetHandleId(udg_GDS_Target) , udg_GDS_Type)
set timerOld = null
if duration < udg_GDS_zMIN then
set udg_GDS_Remaining = 0
return
endif
set t = CreateTimer()
else
if hadTimer then
set timerOld = null
else
set udg_GDS_Remaining = -1
endif
return
endif
endif
//Check was successful, proceed to attempt to stun
if not IssueTargetOrder( udg_GDS_DUMMY[udg_GDS_Type], udg_GDS_ORDERS[udg_GDS_Type], udg_GDS_Target ) and GetUnitAbilityLevel(udg_GDS_Target , udg_GDS_BUFF[udg_GDS_Type]) == 0 then
set timerOld = null
set udg_GDS_Remaining = 0
return //unable to stun, do nothing
endif
//Check again for duration reduction (negative duration)
if udg_GDS_Duration < 0 then
set duration = duration + 2*udg_GDS_Duration //Change duration to reduced duration
endif
//Save Hashtable values only if a new timer has been created
if not hadTimer then
call SaveUnitHandle(udg_GDS_Hashtable, GetHandleId(t) , 0 , udg_GDS_Target)
call SaveInteger(udg_GDS_Hashtable , GetHandleId(t) , 1 , GetHandleId(udg_GDS_Target))
call SaveInteger(udg_GDS_Hashtable , GetHandleId(t) , 2 , udg_GDS_Type)
call SaveTimerHandle(udg_GDS_Hashtable, GetHandleId(udg_GDS_Target) , udg_GDS_Type , t)
endif
call TimerStart(t, duration , false, function GDSDebuffEnd)
set udg_GDS_Remaining = duration
if udg_GDS_RegisterDisable then
set t = CreateTimer()
call SaveUnitHandle(udg_GDS_Hashtable, GetHandleId(t) , 0 , udg_GDS_Target)
call SaveInteger(udg_GDS_Hashtable , GetHandleId(t) , 1 , udg_GDS_Type)
call TimerStart(t, 2*udg_GDS_zMIN, false, function GDSDebuffApplied)
endif
set timerOld = null
set t = null
endfunction
//===========================================================================
function InitTrig_GDS_Main takes nothing returns nothing
set gg_trg_GDS_Main = CreateTrigger( )
call TriggerAddAction( gg_trg_GDS_Main, function GDSMain )
endfunction
function GDSTimerDestroy takes timer t returns nothing
call FlushChildHashtable(udg_GDS_Hashtable, GetHandleId(t))
call PauseTimer(t)
call DestroyTimer(t)
endfunction
function GDSDebuffApplied takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tHandle = GetHandleId(t)
local integer stunType = LoadInteger(udg_GDS_Hashtable, tHandle , 1)
local unit u = LoadUnitHandle(udg_GDS_Hashtable, tHandle , 0)
if GetUnitAbilityLevel( u , udg_GDS_BUFF[stunType]) != 0 then
//call BJDebugMsg("asd" )
call GDSTimerDestroy(t)
set udg_GDS_DebuffEvent = stunType
set udg_GDS_Target = u
set udg_GDS_DebuffEvent = 0.5
else
call TimerStart(t, udg_GDS_zMIN, false, function GDSDebuffApplied)
endif
set u = null
set t = null
endfunction
function GDSDebuffEnd takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tHandle = GetHandleId(t)
local integer stunType = LoadInteger(udg_GDS_Hashtable, tHandle , 2)
local unit u = LoadUnitHandle(udg_GDS_Hashtable, tHandle , 0)
local integer uHandle = LoadInteger(udg_GDS_Hashtable, tHandle , 1)
call UnitRemoveAbility(u, udg_GDS_BUFF[stunType])
call GDSTimerDestroy(t)
call RemoveSavedInteger(udg_GDS_Hashtable, uHandle , stunType)
set u = null
set t = null
endfunction
function GDSMain takes nothing returns nothing
local timer t
local timer timerOld = LoadTimerHandle(udg_GDS_Hashtable, GetHandleId(udg_GDS_Target) , udg_GDS_Type )
local real duration = udg_GDS_Duration
set udg_GDS_Remaining = TimerGetRemaining(timerOld)
//Check if user wants a permanent debuff
if udg_GDS_Permanent then
set udg_GDS_Permanent = false
if timerOld != null then
call FlushChildHashtable(udg_GDS_Hashtable, GetHandleId(timerOld))
call RemoveSavedHandle(udg_GDS_Hashtable, GetHandleId(udg_GDS_Target) , udg_GDS_Type)
call PauseTimer(timerOld)
call DestroyTimer(timerOld)
set timerOld = null
else
if IssueTargetOrder( udg_GDS_DUMMY[udg_GDS_Type], udg_GDS_ORDERS[udg_GDS_Type], udg_GDS_Target ) or GetUnitAbilityLevel(udg_GDS_Target , udg_GDS_BUFF[udg_GDS_Type]) != 0 then
set udg_GDS_Remaining = -1
endif
endif
if udg_GDS_RegisterDisable then
set t = CreateTimer()
call SaveUnitHandle(udg_GDS_Hashtable, GetHandleId(t) , 0 , udg_GDS_Target)
call SaveInteger(udg_GDS_Hashtable , GetHandleId(t) , 1 , udg_GDS_Type)
call TimerStart(t, udg_GDS_zMIN, false, function GDSDebuffApplied)
set t = null
endif
return
endif
//Check if user wants to reduce duration of stun (check for negative duration)
if duration < -udg_GDS_zMIN and udg_GDS_Remaining > udg_GDS_zMIN then //Check for reduction
if -duration > udg_GDS_Remaining then //Check if reduction goes below 0
call UnitRemoveAbility(udg_GDS_Target , udg_GDS_BUFF[udg_GDS_Type])
set duration = 0
else
set duration = udg_GDS_Remaining - duration //Change duration so it passes the checks
endif
endif
//Check if the desired duration is higher than remaining time
if udg_GDS_Remaining < duration and duration > udg_GDS_zMIN then
if timerOld != null then
set t = timerOld
else
set t = CreateTimer()
set timerOld = null
endif
else
//Check if unit has buff, clean hashtable, destroy timer and set remaining time to 0
if GetUnitAbilityLevel(udg_GDS_Target, udg_GDS_BUFF[udg_GDS_Type]) == 0 then
call GDSTimerDestroy(timerOld)
call RemoveSavedHandle(udg_GDS_Hashtable, GetHandleId(udg_GDS_Target) , udg_GDS_Type)
set timerOld = null
if duration < udg_GDS_zMIN then
set udg_GDS_Remaining = 0
return
endif
set t = CreateTimer()
else
if timerOld == null then
set udg_GDS_Remaining = -1
else
set timerOld = null
endif
return
endif
endif
//Check was successful, proceed to attempt to stun
if not IssueTargetOrder( udg_GDS_DUMMY[udg_GDS_Type], udg_GDS_ORDERS[udg_GDS_Type], udg_GDS_Target ) and GetUnitAbilityLevel(udg_GDS_Target , udg_GDS_BUFF[udg_GDS_Type]) == 0 then
set timerOld = null
return //unable to stun, do nothing
endif
//Check again for duration reduction (negative duration)
if udg_GDS_Duration < 0 then
set duration = duration + 2*udg_GDS_Duration //Change duration to reduced duration
endif
//Save Hashtable values only if a new timer has been created
if timerOld != t then
call SaveUnitHandle(udg_GDS_Hashtable, GetHandleId(t) , 0 , udg_GDS_Target)
call SaveInteger(udg_GDS_Hashtable , GetHandleId(t) , 1 , GetHandleId(udg_GDS_Target))
call SaveInteger(udg_GDS_Hashtable , GetHandleId(t) , 2 , udg_GDS_Type)
call SaveTimerHandle(udg_GDS_Hashtable, GetHandleId(udg_GDS_Target) , udg_GDS_Type , t)
endif
call TimerStart(t, duration , false, function GDSDebuffEnd)
set udg_GDS_Remaining = duration
if udg_GDS_RegisterDisable then
set t = CreateTimer()
call SaveUnitHandle(udg_GDS_Hashtable, GetHandleId(t) , 0 , udg_GDS_Target)
call SaveInteger(udg_GDS_Hashtable , GetHandleId(t) , 1 , udg_GDS_Type)
call TimerStart(t, 2*udg_GDS_zMIN, false, function GDSDebuffApplied)
endif
set timerOld = null
set t = null
endfunction
//===========================================================================
function InitTrig_GDS_Main_Copy takes nothing returns nothing
set gg_trg_GDS_Main_Copy = CreateTrigger( )
call TriggerAddAction( gg_trg_GDS_Main_Copy, function GDSMain )
endfunction