function Trig_Exchange_Conditions takes nothing returns boolean
local integer u
set u = GetUnitTypeId(GetTriggerUnit())
if ( ( u == 'h00S' ) or (u == 'h00Y') or (u == 'h00B') or ( u== 'h00T') or (u == 'h00X' )) then
return true
endif
return false
endfunction
function Trig_Exchange_Actions takes nothing returns nothing
local integer tmp
local integer value
set value = GetUnitUserData(GetTriggerUnit()) + 1
call SetUnitUserData(GetTriggerUnit(),value)
set tmp = GetRandomInt(0,2)
if (tmp != 0) then
set tmp = tmp + 2 * (value - 1)
call ReplaceUnitBJ(GetTriggerUnit(),udg_LuckDips[tmp],bj_UNIT_STATE_METHOD_MAXIMUM)
call SetUnitUserData(GetLastReplacedUnitBJ(),value)
call SelectUnitForPlayerSingle( GetLastReplacedUnitBJ(), Player(0) )
endif
endfunction
//===========================================================================
function InitTrig_Exchange takes nothing returns nothing
set gg_trg_Exchange = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Exchange, EVENT_PLAYER_UNIT_UPGRADE_FINISH )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Exchange, EVENT_PLAYER_UNIT_CONSTRUCT_FINISH )
call TriggerAddCondition( gg_trg_Exchange, Condition( function Trig_Exchange_Conditions ) )
call TriggerAddAction( gg_trg_Exchange, function Trig_Exchange_Actions )
endfunction