- Joined
- May 1, 2008
- Messages
- 1,605
Moin moin =)
This is just a general question which comes in my mind and I thought I will ask it here.
Well I know two ways to handle actions for groups and my question is what way is faster or better or has a better performance or are both the same with no difference.
The first way is a normal pick up and all other actions happen in another function:
Now the next way is always store the first of Group unit and do the actions in the same function:
Well I wrote this two triggers very fast now, so possible they contains syntax, but both are clear I think, so what way is faster? or better? or whatever? and ofc WHY!?
Greetings and Peace
Dr. Boom
This is just a general question which comes in my mind and I thought I will ask it here.
Well I know two ways to handle actions for groups and my question is what way is faster or better or has a better performance or are both the same with no difference.
The first way is a normal pick up and all other actions happen in another function:
JASS:
function func2 takes nothing returns boolean
local unit u = GetFilterUnit()
if GetWidgetLife(u) > 0.405 and IsUnitEnemy(u,GetOwningPlayer(GetTriggerUnit()) then
call KillUnit(u)
endif
set u = null
return false
endfunction
function func1 takes nothing returns nothing
local group g = CreateGroup()
local unit t = GetTriggerUnit()
call GroupEnumUnitsInRange(g,GetUnitX(t),GetUnitY(t),500.,Condition(function func2))
set t = null
call DestroyGroup(g)
endfunction
Now the next way is always store the first of Group unit and do the actions in the same function:
JASS:
function func3 takes nothing returns nothing
local group g = CreateGroup()
local unit t = GetTriggerUnit()
local unit u
call GroupEnumUnitsInRange(g,GetUnitX(t),GetUnitY(t),500.,null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if GetWidgetLife(u) > 0.405 and IsUnitEnemy(u,GetOwningPlayer(t)) then
call KillUnit(u)
endif
call GroupRemoveUnit(g,u)
endloop
call DestroyGroup(g)
set t = null
// set u = null - I think this isn't needed because the loop stops first when u is null
endfunction
Well I wrote this two triggers very fast now, so possible they contains syntax, but both are clear I think, so what way is faster? or better? or whatever? and ofc WHY!?
Greetings and Peace
Dr. Boom