Yap thanks! ill give +rep if you made it correctly ^_^
function Trig_Timer_Actions takes nothing returns nothing
local integer i = 1
local integer cv
set i = 1
loop
exitwhen i > udg_CombatIndex
set cv = udg_CombatI2CV[i]
set udg_CombatTimer[cv] = udg_CombatTimer[cv] - 1
if udg_CombatTimer[cv] < 1 then
//here u can do something if timer is out
set udg_CombatTimer[cv] = 0
set udg_CombatCount[cv] = 0
if i != udg_CombatIndex then
set udg_CombatI2CV[i] = udg_CombatI2CV[udg_CombatIndex]
set udg_CombatTimer[udg_CombatI2CV[i]] = udg_CombatTimer[udg_CombatI2CV[udg_CombatIndex]]
set udg_CombatCount[i] = udg_CombatCount[udg_CombatIndex]
endif
set udg_CombatIndex = udg_CombatIndex - 1
set i = i - 1
endif
set i = i + 1
endloop
endfunction
//===========================================================================
function InitTrig_Timer takes nothing returns nothing
set gg_trg_Timer = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Timer, 1.00 )
call TriggerAddAction( gg_trg_Timer, function Trig_Timer_Actions )
endfunction
the timeout sytem in your trigger is that it last 5 seconds could you please change the timeout system for the attack speed to whenever it attacks other unit or it stop.
function Trig_Timer_Actions takes nothing returns nothing
local integer i = 1
local integer cV //try to follow Bribe's JPAG on naming variables. first letter of first word is always lowercase.
//after that all first letters are uppercase, makes it more readable.
set i = 1
loop
set cV = udg_CombatI2CV[i]
set udg_CombatTimer[cV] = udg_CombatTimer[cV] - 1
if udg_CombatTimer[cV] < 1 then
//here u can do something if timer is out
set udg_CombatTimer[cV] = 0
set udg_CombatCount[cV] = 0
if i != udg_CombatIndex then
set udg_CombatI2CV[i] = udg_CombatI2CV[udg_CombatIndex]
set udg_CombatTimer[udg_CombatI2CV[i]] = udg_CombatTimer[udg_CombatI2CV[udg_CombatIndex]]
set udg_CombatCount[i] = udg_CombatCount[udg_CombatIndex]
endif
set udg_CombatIndex = udg_CombatIndex - 1
set i = i - 1
endif
set i = i + 1
exitwhen i > udg_CombatIndex //Moved exitwhen to end to make the loop end-point intuitive.
endloop
endfunction
//===========================================================================
function InitTrig_Timer takes nothing returns nothing
local trigger t = CreateTrigger() //Locals are your friend.
call TriggerRegisterTimerEvent(t, 1.00, true ) // Don't use TriggerRegisterTimerEventPeriodic as this will just
// call this function anyways.
call TriggerAddAction( t, function Trig_Timer_Actions )
set t = null //null your trigger when you're done with it so it won't allocate memory.
endfunction
Here are some changes to shadow's code.
There are some other functions in the MapInit and in your damage trigger that I don't see a reason for, but I only glanced over it for now ; ). I'll probably rewrite it later to make it more efficient, like converting all GUI globals to jass globals. I don't like the integration of regular variables and udg_VARIABLE variables, but that's just a preference.
ok let me notice that, this is NOT vjass, so dont have global exclude gui globals, i dont like the vjass and gui mix