function LandRandom_izer takes player p, integer w, integer u, integer b, integer r, integer g, integer slandn, unit sland, unit sland2, unit sland3, unit sland4, unit sland5 returns nothing
local integer randomn = GetRandomInt(1,100)
local integer srandomn = GetRandomInt(1,slandn)
local location loc = GetUnitLoc(GetConstructedStructure())
if 1 <= randomn and randomn <= w then
call RemoveUnit(GetConstructedStructure())
call CreateUnitAtLoc(p, 'h001', loc, 0.0)
elseif (w+1) <= randomn and randomn <= (w+u) then
call RemoveUnit(GetConstructedStructure())
call CreateUnitAtLoc(p, 'h002', loc, 0.0)
elseif (w+u+1) <= randomn and randomn <= (w+u+b) then
call RemoveUnit(GetConstructedStructure())
call CreateUnitAtLoc(p, 'h003', loc, 0.0)
elseif (w+u+b+1) <= randomn and randomn <= (w+u+b+r) then
call RemoveUnit(GetConstructedStructure())
call CreateUnitAtLoc(p, 'h004', loc, 0.0)
elseif (w+u+b+r+1) <= randomn and randomn <= (w+u+b+r+g) then
call RemoveUnit(GetConstructedStructure())
call CreateUnitAtLoc(p, 'h005', loc, 0.0)
else
if srandomn == slandn then
call RemoveUnit(GetConstructedStructure())
call CreateUnitAtLoc(p, sland, loc, 0.0)
elseif srandomn == (slandn-1) then
call RemoveUnit(GetConstructedStructure())
call CreateUnitAtLoc(p, sland2, loc, 0.0)
elseif srandomn == (slandn-2) then
call RemoveUnit(GetConstructedStructure())
call CreateUnitAtLoc(p, sland3, loc, 0.0)
elseif srandomn == (sland-3) then
call RemoveUnit(GetConstructedStructure())
call CreateUnitAtLoc(p, sland4, loc, 0.0)
elseif srandomn == (sland-4) then
call RemoveUnit(GetConstructedStructure())
call CreateUnitAtLoc(p, sland5, loc, 0.0)
endif
endif
function LandRandom_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'h000'
endfunction
function Trig_LandRandom_Actions takes nothing returns nothing
//!textmacro playerheroif takes PLAYER, PLAYERDATAVARIABLE
if GetOwningPlayer(GetConstructedStructure()) == $PLAYER$ then
call LandRandom_izer($PLAYERDATAVARIABLE$.p, $PLAYERDATAVARIABLE$.w, $PLAYERDATAVARIABLE$.u, $PLAYERDATAVARIABLE$.b, $PLAYERDATAVARIABLE$.r, $PLAYERDATAVARIABLE$.g, $PLAYERDATAVARIABLE$.slandn, $PLAYERDATAVARIABLE$.sland, $PLAYERDATAVARIABLE$.sland2, $PLAYERDATAVARIABLE$.sland3, $PLAYERDATAVARIABLE$.sland4, $PLAYERDATAVARIABLE$.sland5)
endif
//!endtextmacro
//!runtextmacro playerheroif("Player(0)","udg_player0")
//!runtextmacro playerheroif("Player(1)","udg_player1")
//!runtextmacro playerheroif("Player(2)","udg_player2")
//!runtextmacro playerheroif("Player(3)","udg_player3")
//!runtextmacro playerheroif("Player(4)","udg_player4")
//!runtextmacro playerheroif("Player(5)","udg_player5")
//!runtextmacro playerheroif("Player(6)","udg_player6")
//!runtextmacro playerheroif("Player(7)","udg_player7")
//!runtextmacro playerheroif("Player(8)","udg_player8")
endfunction
//===========================================================================
function InitTrig_LandRandom takes nothing returns nothing
set gg_trg_LandRandom = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(gg/-trg_LandRandom, EVENT_PLAYER_UNIT_CONSTRUCT_FINISH)
call TriggerAddCondition(gg_trg_LandRandom, Condition(function LandRandom_Conditions))
call TriggerAddAction( gg_trg_LandRandom, function Trig_LandRandom_Actions )
endfunction