- Joined
- Jul 22, 2015
- Messages
- 3,485
Uhh... why did you create another submission for this? There is an "Edit" button for a reason.
function AAAMPeriodicWE takes nothing returns boolean
local integer i = 0
local integer j = 0
local integer newIndex = udg_AAAM3_newIndex
local boolean leave = true
local integer store_i
local integer array validAuras
local integer max
loop
exitwhen i > udg_Aura_Number
if udg_Aura_AuraCount[i] > 0 then
//call BJDebugMsg(I2S(j))
set validAuras[j] = i
set j = j + 1
//call BJDebugMsg(I2S(i))
endif
set i = i + 1
endloop
set max = j - 1
set i = 0
set j = udg_AAAM3_CycleMin
//call BJDebugMsg(I2S(udg_AAAM3_CycleMin))
//call BJDebugMsg(I2S(udg_AAAM3_CycleMax))
if udg_AAAM3_CycleMin == 1 then
set udg_Aura_Event = 0.3 // Set Event for Starting a new cycle
endif
set udg_Aura_TrigUnit = udg_AAAM3_CycleArray[j]
set udg_Aura_Event = 0.1 //Set Event for Starting checks for 1 unit
loop
exitwhen j > udg_AAAM3_CycleMax
set udg_AAAM3_CycleArray[j] = null
loop
exitwhen i > max
set store_i = i
set i = validAuras[i]
if GetUnitAbilityLevel(udg_Aura_TrigUnit, udg_Aura_BUFFS[i]) > 0 then
if UnitAddAbility( udg_Aura_TrigUnit , udg_Aura_ABILITIES[i] ) then
set udg_Aura_Event = i // Set event for unit aquiring aura ability
endif
set leave = false
else
if UnitRemoveAbility( udg_Aura_TrigUnit , udg_Aura_ABILITIES[i] ) then
set udg_Aura_Event = 1 + udg_Aura_Number + i
endif
endif
set i = store_i + 1
endloop
if not leave then
set udg_AAAM3_CycleArray[newIndex] = udg_Aura_TrigUnit
set newIndex = newIndex + 1
else
if not IsUnitType(udg_Aura_TrigUnit , UNIT_TYPE_DEAD) then
if GetUnitTypeId(udg_Aura_TrigUnit) == 0 then
else
set udg_AAAM3_CycleArray[newIndex] = udg_Aura_TrigUnit
set newIndex = newIndex + 1
endif
else
call UnitRemoveAbility ( udg_Aura_TrigUnit , udg_AAAM3_GROUPABIL )
endif
set udg_Aura_Event = 0.5 //Set Event for unit being kicked out of the CycleAraay
endif
set udg_Aura_Event = 0.2 // Set Event for unit checks are finished
set j = j + 1
set udg_Aura_TrigUnit = udg_AAAM3_CycleArray[j]
set leave = true
set i = 0
set udg_Aura_Event = 0.1 //Set Event for unit checks begin for next unit
endloop
//call BJDebugMsg("Cycle Size: " + I2S(udg_Aura_CycleSize))
if udg_AAAM3_CycleMax + udg_AAAM3_CycleStep < udg_Aura_CycleSize then
set udg_AAAM3_CycleMin = udg_AAAM3_CycleMax+1
set udg_AAAM3_CycleMax = udg_AAAM3_CycleMax + udg_AAAM3_CycleStep
set udg_AAAM3_newIndex = newIndex
//call TriggerEvaluate(GetTriggeringTrigger())
else
if udg_AAAM3_CycleMax < udg_Aura_CycleSize then
set udg_AAAM3_CycleMin = udg_AAAM3_CycleMax+1
set udg_AAAM3_CycleMax = udg_Aura_CycleSize
set udg_AAAM3_newIndex = newIndex
//call TriggerEvaluate(GetTriggeringTrigger())
else
if udg_Aura_CycleSize < udg_AAAM3_CycleStep then
set udg_AAAM3_CycleMax = udg_Aura_CycleSize
else
set udg_AAAM3_CycleMax = udg_AAAM3_CycleStep
endif
set udg_AAAM3_CycleMin = 1
set udg_AAAM3_newIndex = 1
set udg_Aura_CycleSize = newIndex
set udg_Aura_Event = 0.4 //Set Event for Cycle is finished
endif
endif
return true
endfunction
//===========================================================================
function InitTrig_AAAM_Periodic_Intervals takes nothing returns nothing
set gg_trg_AAAM_Periodic_Intervals = CreateTrigger( )
//call TriggerRegisterTimerEvent( gg_trg_AAAM_Periodic_Intervals, 0.03, true )
call TriggerAddCondition( gg_trg_AAAM_Periodic_Intervals, Condition(function AAAMPeriodicWE) )
endfunction
function AAAMPeriodicWE2 takes nothing returns boolean
local integer i = 0
local integer j = 0
local integer newIndex = udg_AAAM3_newIndex
local boolean leave = true
local integer store_i
local integer array validAuras
local integer max
loop
exitwhen i > udg_Aura_Number
if udg_Aura_AuraCount[i] > 0 then
//call BJDebugMsg(I2S(j))
set validAuras[j] = i
set j = j + 1
endif
set i = i + 1
endloop
set max = j - 1
set i = 0
set j = udg_AAAM3_CycleMin
//call BJDebugMsg(I2S(udg_AAAM3_CycleMin))
//call BJDebugMsg(I2S(udg_AAAM3_CycleMax))
set udg_Aura_Event = 0.3 // Set Event for Starting a new cycle
set udg_Aura_TrigUnit = udg_AAAM3_CycleArray[j]
set udg_Aura_Event = 0.1 //Set Event for Starting checks for 1 unit
loop
exitwhen j > udg_AAAM3_CycleMax
set udg_AAAM3_CycleArray[j] = null
loop
exitwhen i > max
set store_i = i
set i = validAuras[i]
if GetUnitAbilityLevel(udg_Aura_TrigUnit, udg_Aura_BUFFS[i]) > 0 then
if UnitAddAbility( udg_Aura_TrigUnit , udg_Aura_ABILITIES[i] ) then
set udg_Aura_Event = i // Set event for unit aquiring aura ability
endif
set leave = false
else
if UnitRemoveAbility( udg_Aura_TrigUnit , udg_Aura_ABILITIES[i] ) then
set udg_Aura_Event = 1 + udg_Aura_Number + i
endif
endif
set i = store_i + 1
endloop
if not leave then
set udg_AAAM3_CycleArray[newIndex] = udg_Aura_TrigUnit
set newIndex = newIndex + 1
else
if not IsUnitType(udg_Aura_TrigUnit , UNIT_TYPE_DEAD) then
if GetUnitTypeId(udg_Aura_TrigUnit) == 0 then
else
set udg_AAAM3_CycleArray[newIndex] = udg_Aura_TrigUnit
set newIndex = newIndex + 1
endif
else
call UnitRemoveAbility ( udg_Aura_TrigUnit , udg_AAAM3_GROUPABIL )
endif
set udg_Aura_Event = 0.5 //Set Event for unit being kicked out of the CycleAraay
endif
set udg_Aura_Event = 0.2 // Set Event for unit checks are finished
set j = j + 1
set udg_Aura_TrigUnit = udg_AAAM3_CycleArray[j]
set leave = true
set i = 0
set udg_Aura_Event = 0.1 //Set Event for unit checks begin for next unit
endloop
//Set Event for Cycle is finished
//call BJDebugMsg("Cycle Size: " + I2S(udg_Aura_CycleSize))
if udg_AAAM3_CycleMax + udg_AAAM3_CycleStep < udg_Aura_CycleSize then
set udg_AAAM3_CycleMin = udg_AAAM3_CycleMax+1
set udg_AAAM3_CycleMax = udg_AAAM3_CycleMax + udg_AAAM3_CycleStep
set udg_AAAM3_newIndex = newIndex
call TriggerEvaluate(GetTriggeringTrigger())
else
if udg_AAAM3_CycleMax < udg_Aura_CycleSize then
set udg_AAAM3_CycleMin = udg_AAAM3_CycleMax+1
set udg_AAAM3_CycleMax = udg_Aura_CycleSize
set udg_AAAM3_newIndex = newIndex
call TriggerEvaluate(GetTriggeringTrigger())
else
if udg_Aura_CycleSize < udg_AAAM3_CycleStep then
set udg_AAAM3_CycleMax = udg_Aura_CycleSize
else
set udg_AAAM3_CycleMax = udg_AAAM3_CycleStep
endif
set udg_AAAM3_CycleMin = 1
set udg_AAAM3_newIndex = 1
set udg_Aura_CycleSize = newIndex
set udg_Aura_Event = 0.4
endif
endif
return true
endfunction
//===========================================================================
function InitTrig_AAAM_Periodic_Instant takes nothing returns nothing
set gg_trg_AAAM_Periodic_Instant = CreateTrigger( )
//call TriggerRegisterTimerEvent( gg_trg_AAAM_Periodic_Instant, 0.3, true )
call TriggerAddCondition( gg_trg_AAAM_Periodic_Instant, Condition(function AAAMPeriodicWE2) )
endfunction
function Nice takes nothing returns nothing
local integer totalProcessed = 0
local integer aId
local unit u
local integer i = 0
local group newGroup
loop
exitwhen aId > udg_GAAS_Number
exitwhen totalProcessed + udg_GAAS_GroupSize[aId]> 4000
set newGroup = CreateGroup()
loop
exitwhen i > udg_GAAS_GroupSize[aId]
set i = i + 1
set udg_GAAS_TrigUnit = FirstOfGroup(udg_GAAS_Groups[aId])
call GroupRemoveUnit(udg_GAAS_Groups[aId] , udg_GAAS_TrigUnit)
if GetUnitAbilityLevel(udg_GAAS_TrigUnit , udg_GAAS_BUFF[aId]) < 0 then
call UnitRemoveAbility(udg_GAAS_TrigUnit, udg_GAAS_ABIL[aId])
set udg_GAAS_RemoveEvent = aId
set udg_GAAS_GroupSize[aId] = udg_GAAS_GroupSize[aId] - 1
else
call GroupAddUnit(newGroup, udg_GAAS_TrigUnit)
endif
endloop
call DestroyGroup(udg_GAAS_Groups[aId])
set udg_GAAS_Groups[aId] = newGroup
set totalProcessed = totalProcessed + udg_GAAS_GroupSize[aId]
set aId = aId + 1
endloop
if aId > udg_GAAS_Number then
else
call ExecuteFunc("Nice")
endif
endfunction
function GAAS_TimerF takes nothing returns nothing
local integer runCount
local timer t = GetExpiredTimer()
local integer tHandle = GetHandleId(t)
local integer aId = LoadInteger(udg_GAAS_Hashtable, tHandle, 1)
local unit u = LoadUnitHandle(udg_GAAS_Hashtable, tHandle, 0)
if GetUnitAbilityLevel(u , udg_GAAS_BUFF[aId] ) > 0 then
call FlushChildHashtable(udg_GAAS_Hashtable, tHandle)
call RemoveSavedHandle(udg_GAAS_Hashtable, GetHandleId(u) , aId)
call PauseTimer(t)
call DestroyTimer(t)
else
set runCount = LoadInteger(udg_GAAS_Hashtable, tHandle, 2) + 1
call SaveInteger(udg_GAAS_Hashtable, tHandle, 2, runCount)
endif
set t = null
set u = null
endfunction
function GAAS_EnterRange takes nothing returns boolean
local unit source
local unit target = GetTriggerUnit()
local integer sourceHandle = GetHandleId(source)
local integer targetHandle = GetHandleId(target)
local integer aId = 0
local timer t
loop
exitwhen aId > udg_GAAS_Number
if LoadBoolean(udg_GAAS_Hashtable, aId, sourceHandle) and GetUnitAbilityLevel(target, udg_GAAS_AURA[aId]) > 0 then
set t = LoadTimerHandle(udg_GAAS_Hashtable, targetHandle, aId)
if t == null then
set t = CreateTimer()
call TimerStart(t, 0.1, true, function GAAS_TimerF)
call SaveTimerHandle(udg_GAAS_Hashtable, targetHandle, aId , t)
call SaveUnitHandle(udg_GAAS_Hashtable, GetHandleId(t), 0 , target)
call SaveInteger(udg_GAAS_Hashtable, GetHandleId(t), 1 , aId)
call SaveInteger(udg_GAAS_Hashtable, GetHandleId(t), 2 , 0)
else
call SaveInteger(udg_GAAS_Hashtable, GetHandleId(t), 2 , 0)
endif
endif
endloop
return false
endfunction
function GAAS_Source takes nothing returns nothing
local trigger trig
local boolean notSource =true
local integer aId = 0
local integer uHandle
//call FlushChild
loop
exitwhen aId > udg_GAAS_Number
if GetUnitAbilityLevel(udg_GAAS_TrigUnit, udg_GAAS_AURA[aId]) > 0 then
set notSource = false
if LoadBoolean(udg_GAAS_Hashtable, aId, uHandle) then
else
call SaveBoolean(udg_GAAS_Hashtable, aId, uHandle, true)
endif
else
if LoadBoolean(udg_GAAS_Hashtable, aId, uHandle) then
call RemoveSavedBoolean(udg_GAAS_Hashtable, aId, uHandle)
endif
endif
endloop
if notSource then
call DestroyTrigger(LoadTriggerHandle(udg_GAAS_Hashtable, uHandle , udg_GAAS_Number + 1))
call RemoveSavedHandle(udg_GAAS_Hashtable, uHandle , udg_GAAS_Number + 1)
else
if not HaveSavedHandle(udg_GAAS_Hashtable, uHandle , udg_GAAS_Number + 1) then
set trig = CreateTrigger()
call TriggerAddCondition(trig, Condition(function GAAS_EnterRange))
call SaveTriggerHandle(udg_GAAS_Hashtable, uHandle , udg_GAAS_Number + 1, trig)
endif
endif
endfunction
//===========================================================================
function InitTrig_AAAM4_Period takes nothing returns nothing
set gg_trg_AAAM4_Period = CreateTrigger( )
endfunction