Rinpun
Ex TH Member
- Reaction score
- 105
Alright, for some spells for my WotU map, I'm running into an issue.
To put it simply, GroupEnumUnitsOfPlayer seems to be returning an empty group. Why?
To put it simply, GroupEnumUnitsOfPlayer seems to be returning an empty group. Why?
Code:
function Trig_Release_Ships_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00H' or GetSpellAbilityId() == 'A00I'
endfunction
function is_fighter_ship takes nothing returns boolean
return GetUnitTypeId(GetEnumUnit()) == 'u00F' or GetUnitTypeId(GetEnumUnit()) == 'u00G'
endfunction
function Until_Unrelease takes nothing returns nothing
local timer until_unrelease = GetExpiredTimer()
local player owner = Player(GetHandleInt(until_unrelease, "owner_id"))
local group carrier_ships = CreateGroup()
call GroupEnumUnitsOfPlayer(carrier_ships, owner, Condition(function is_fighter_ship))
if (FirstOfGroup(carrier_ships) == null) then // the carrier_ships are not used.
set udg_Carrier_Full[GetPlayerId(owner)] = CreateUnit(owner, 'u00H', 9999, 9999, 0)
call DestroyTimer(until_unrelease)
call FlushHandleLocals(until_unrelease)
endif
call DestroyGroup(carrier_ships)
endfunction
function Trig_Release_Ships_Actions takes nothing returns nothing
local timer until_unrelease = CreateTimer()
local unit carrier = GetTriggerUnit()
local player owner = GetOwningPlayer(carrier)
call RemoveUnit(udg_Carrier_Full[GetPlayerId(owner)])
call SetHandleInt(until_unrelease, "owner_id", GetPlayerId(owner))
call TimerStart(until_unrelease, .05, true, function Until_Unrelease)
set carrier = null
endfunction
//===========================================================================
function InitTrig_Release_Ships takes nothing returns nothing
set gg_trg_Release_Ships = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Release_Ships, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Release_Ships, Condition( function Trig_Release_Ships_Conditions ) )
call TriggerAddAction( gg_trg_Release_Ships, function Trig_Release_Ships_Actions )
endfunction