- Joined
- Sep 19, 2006
- Messages
- 152
This trigger runs about every second, so it needs to be as slick as possible. I guess I just wanted a second set (or multiple sets) of eyes to look it over for any inefficiencies and leaks:
JASS:
function Every1Seconds_Action01 takes nothing returns nothing
local multiboard Mb = udg_Multiboard
local multiboarditem Mbi
local integer q = 1
local integer q_1120 = bj_randDistID [1120]
local integer n_TC = udg_TimerCount + 1
local unit misc_unit
local real misc_unitL
local real misc_unitLx
local real misc_unitX
local real misc_unitY
local real m
local rect r
local group g
//
if q_1120 > 0 then
if q_1120 > 1 then
set bj_randDistID [1120] = q_1120 - 1
else
set bj_randDistID [1120] = 0
call ReviveHero (gg_unit_Ulic_0023, 5488.000, 9296.000, true)
endif
endif
loop
exitwhen q > 11
set q_1120 = bj_randDistID [q + 1120]
if q_1120 > 0 then
if q_1120 > 1 then
set bj_randDistID [q + 1120] = q_1120 - 1
set Mbi = MultiboardGetItem (Mb, q - 1, 0)
call MultiboardSetItemValue (Mbi, udg_PlayerString [q + 40] + " (" + I2S (q_1120 - 1) + ")...|r")
else
set bj_randDistID [q + 1120] = 0
set misc_unit = bj_ghoul [q + 1120]
set bj_ghoul [q + 1120] = null
if bj_randDistID [q + 1900] == 0 then
set misc_unitX = 5488.000
set misc_unitY = 9296.000
else
set misc_unitX = GetUnitX (misc_unit)
set misc_unitY = GetUnitY (misc_unit)
endif
call RemoveUnit (misc_unit)
if GetPlayerSlotState (Player (q)) == PLAYER_SLOT_STATE_LEFT then
set Mb = udg_Multiboard
set Mbi = MultiboardGetItem (Mb, q - 1, 0)
call MultiboardSetItemValue (Mbi, "|cffef453ac: Player " + I2S (q) + "|r")
set Mbi = MultiboardGetItem (Mb, q - 1, 1)
call MultiboardSetItemValue (Mbi, "|cffef453aleft|r")
set Mbi = MultiboardGetItem (Mb, q - 1, 2)
call MultiboardSetItemValue (Mbi, "|cffef453a" + I2S (bj_randDistID [q + 1300]) + "|r")
set Mb = null
set Mbi = null
else
call ReviveHero (bj_ghoul [q + 1000], misc_unitX, misc_unitY, false)
endif
endif
endif
set q = q + 1
endloop
set misc_unit = null
set Mb = null
set Mbi = null
set udg_TimerCount = n_TC
if n_TC - ((n_TC / 2) * 2) == 0 then
call TriggerExecute (gg_trg_Every3Seconds)
elseif n_TC == 7 or n_TC == 15 then
set r = gg_rct_NeutralRegion
set g = CreateGroup ()
call GroupEnumUnitsInRect (g, r, null)
loop
set misc_unit = FirstOfGroup (g)
exitwhen misc_unit == null
call GroupRemoveUnit (g, misc_unit)
if GetUnitAbilityLevel (misc_unit, 'BOhx') == 0 then
set misc_unitL = GetUnitState (misc_unit, UNIT_STATE_LIFE)
set misc_unitLx = GetUnitState (misc_unit, UNIT_STATE_MAX_LIFE)
if misc_unitL < misc_unitLx then
set m = (misc_unitLx - misc_unitL) * 0.20
call SetUnitState (misc_unit, UNIT_STATE_LIFE, misc_unitL + m)
call DestroyEffect (AddSpecialEffectTarget ("Abilities\\Spells\\Undead\\VampiricAura\\VampiricAuraTarget.mdl", misc_unit, "origin"))
endif
endif
endloop
call DestroyGroup (g)
set g = null
set r = null
elseif n_TC > 17 then
set udg_TimerCount = 0
call TriggerExecute (gg_trg_Every15Seconds)
endif
endfunction
function InitTrig_Every1Seconds takes nothing returns nothing
set gg_trg_Every1Seconds = CreateTrigger ()
call DisableTrigger (gg_trg_Every1Seconds)
call TriggerRegisterTimerEvent (gg_trg_Every1Seconds, 1.20, true)
call TriggerAddAction (gg_trg_Every1Seconds, function Every1Seconds_Action01)
endfunction