function GetLinebreak takes nothing returns string
return "\n"
endfunction
function SetRegionPathing takes rect r,pathingtype pt,boolean on returns nothing
local real maxx = GetRectMaxX(r)
local real maxy = GetRectMaxY(r)
local real x = GetRectMinX(r)
local real by = GetRectMinY(r)
local real y
set x = x - ModuloReal(x,32)
set by = by - ModuloReal(by,32)
loop
exitwhen x > maxx
set y = by
loop
exitwhen y > maxy
call SetTerrainPathable(x,y,pt,on)
set y = y + 32
endloop
set x = x + 32
endloop
endfunction
function DetermineCondition takes nothing returns boolean
return (GetUnitTypeId(GetFilterUnit()) == 'U001')
endfunction
function DetermineForGroup takes nothing returns nothing
set udg_Units[udg_Index] = GetEnumUnit()
set udg_Index = udg_Index + 1
endfunction
function Determine takes rect r,unit add,unit remove returns boolean
local integer i = 0
local boolean on
set udg_Index = 0
if (add != null) then
set udg_Units[0] = add
set udg_Index = 1
endif
call ForGroup(GetUnitsInRectMatching(r,Condition(function DetermineCondition)),function DetermineForGroup)
loop
exitwhen(i >= udg_Index)
if (udg_Units[i] == remove) then
set udg_Index = udg_Index - 1
exitwhen true
endif
set i = i + 1
endloop
loop
exitwhen(i >= udg_Index)
set udg_Units[i] = udg_Units[i + 1]
set i = i + 1
endloop
set i = 0
set on = (udg_Index == 0)
loop
exitwhen i >= udg_Index
if (TimerGetRemaining(udg_CanStart[GetConvertedPlayerId(GetOwningPlayer(udg_Units[i]))]) > 0) then
set on = true
exitwhen true
endif
set i = i + 1
endloop
call SetRegionPathing(r,PATHING_TYPE_AMPHIBIOUSPATHING,on)
return not(on)
endfunction
function BSS takes boolean b,string t,string f returns string
if b then
return t
endif
return f
endfunction
function SheepInRegion takes rect r,integer i returns boolean
return (CountUnitsInGroup(GetUnitsInRectOfPlayer(r,ConvertedPlayer(i))) > 0)
endfunction
function SwapWait takes unit u,player p returns nothing
call TriggerSleepAction(udg_SwitchTime)
call SetUnitInvulnerable(u,false)
call CreateNUnitsAtLoc(1,'U000',p,udg_Center,bj_UNIT_FACING)
call SelectUnitForPlayerSingle(GetLastCreatedUnit(),p)
endfunction
function GetHost takes nothing returns player
local gamecache g = InitGameCache("Map.w3v")
local player p
call StoreInteger(g,"Map","Host",GetPlayerId(GetLocalPlayer()))
call TriggerSyncStart()
call SyncStoredInteger(g,"Map","Host")
call TriggerSyncReady()
set p = Player(GetStoredInteger(g,"Map","Host"))
call FlushGameCache(g)
set g = null
return p
endfunction
Name | Type | is_array | initial_value |
Angle | real | No | |
Append | string | No | |
BaseTimeout | real | No | 30.00 |
Boolean | boolean | No | |
CanStart | timer | Yes | |
Captured | group | No | |
Center | location | No | |
Closed | timerdialog | Yes | |
Continue | boolean | No | |
CurrentIndex | integer | No | |
Dialog | dialog | No | |
DialogButtons | button | Yes | |
Dier | player | No | |
EndGame | timer | No | |
EndGameWindow | timerdialog | No | |
FirstHalf | boolean | No | |
FreeRadius | real | No | 512.00 |
GAME_MODE_NORMAL | integer | No | 0 |
GAME_MODE_SWAP | integer | No | 1 |
GameMode | integer | No | |
GameTime | real | No | 1800.00 |
Half | force | No | |
Host | player | No | |
InBase | timer | Yes | |
Index | integer | No | |
Killer | player | No | |
LimitTreeCount | integer | Yes | |
LimitTreeMax | integer | No | 32 |
LimitTrees | unit | Yes | |
Linebreak | string | No | |
Multiboard | multiboard | No | |
MultiboardIndex | integer | Yes | |
Open | timerdialog | Yes | |
Players | player | Yes | |
POLL_MODE_HOST | integer | No | 2 |
POLL_MODE_NORMAL | integer | No | 0 |
POLL_MODE_RANDOM | integer | No | 1 |
PollMode | integer | No | |
Prepend | string | No | |
Restart | boolean | No | |
Sheep | force | No | |
SheepRadius | real | No | 768.00 |
StartTimer | timer | No | |
StartTimerWindow | timerdialog | No | |
SwitchTime | real | No | 4.00 |
TEAM_MODE_HOST | integer | No | 2 |
TEAM_MODE_NORMAL | integer | No | 0 |
TEAM_MODE_RANDOM | integer | No | 1 |
TeamMode | integer | No | |
TempPlayer | player | No | |
Units | unit | Yes | |
VoteGameMode | boolean | No | |
VotePollMode | boolean | No | |
Votes | integer | Yes | |
VoteTeamMode | boolean | No | |
VoteTime | real | No | 16.00 |
VoteTimer | timer | No | |
WolfDelay | real | No | 30.00 |
WolfRadius | real | No | 256.00 |
Wolves | force | No |
function LimitTreeDies takes nothing returns nothing
local unit u = GetDyingUnit()
local integer p = GetPlayerId(GetOwningPlayer(u))
local integer offset = p * udg_LimitTreeMax
local integer i = 0
local integer e = udg_LimitTreeCount[p] - 1
set udg_LimitTreeCount[p] = e
call DestroyTrigger(GetTriggeringTrigger())
loop
exitwhen udg_LimitTrees[offset + i] == u or i > e
set i = i + 1
endloop
loop
exitwhen i > e
set udg_LimitTrees[offset + i] = udg_LimitTrees[offset + i + 1]
set i = i + 1
endloop
set udg_LimitTrees[offset + i] = null
endfunction
function TreeDies takes nothing returns nothing
local destructable d = GetDyingDestructable()
local location l = GetDestructableLoc(d)
local group g = GetUnitsInRangeOfLocAll(32,l)
call DestroyTrigger(GetTriggeringTrigger())
call RemoveLocation(l)
call KillUnit(FirstOfGroup(g))
call GroupClear(g)
call TriggerSleepAction(4)
call RemoveDestructable(d)
endfunction
function PlantTree takes unit u,boolean destroy returns destructable
local destructable d = CreateDestructable('LTlt',GetUnitX(u),GetUnitY(u),bj_UNIT_FACING,GetRandomReal(0.8,1.2),GetRandomInt(1,10))
local trigger t
if (destroy) then
call RemoveUnit(u)
else
call SetUnitInvulnerable(u,true)
call SetUnitVertexColor(u,255,255,255,0)
set t = CreateTrigger()
call TriggerRegisterDeathEvent(t,d)
call TriggerAddAction(t,function TreeDies)
endif
call SetDestructableAnimation(d,"birth")
return d
endfunction
function KillEnum takes nothing returns nothing
call KillDestructable(GetEnumDestructable())
endfunction
function Trig_Plant_Trees_Actions takes nothing returns nothing
local integer i
local unit u = GetConstructingStructure()
local destructable d
local trigger t
local real x
local real y
local rect r
if (GetUnitTypeId(u) == 'u002') then
set d = PlantTree(u,true)
call TriggerSleepAction(16)
call KillDestructable(d)
call TriggerSleepAction(4)
call RemoveDestructable(d)
elseif (GetUnitTypeId(u) == 'u003') then
set i = GetPlayerId(GetOwningPlayer(u))
set d = PlantTree(u,false)
set t = CreateTrigger()
call TriggerRegisterUnitEvent(t,u,EVENT_UNIT_DEATH)
call TriggerAddAction(t,function LimitTreeDies)
set udg_LimitTrees[i * udg_LimitTreeMax + udg_LimitTreeCount[i]] = u
set udg_LimitTreeCount[i] = udg_LimitTreeCount[i] + 1
loop
exitwhen udg_LimitTreeCount[i] <= udg_LimitTreeMax
set u = udg_LimitTrees[i * udg_LimitTreeMax]
set x = GetUnitX(u)
set y = GetUnitY(u)
set r = Rect(x - 32,y - 32,x + 32,y + 32)
call EnumDestructablesInRect(r,null,function KillEnum)
call RemoveRect(r)
endloop
endif
endfunction
//===========================================================================
function InitTrig_Plant_Trees takes nothing returns nothing
set gg_trg_Plant_Trees = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Plant_Trees,EVENT_PLAYER_UNIT_CONSTRUCT_START)
call TriggerAddAction(gg_trg_Plant_Trees,function Trig_Plant_Trees_Actions)
endfunction
function TurnOn_Actions takes integer i returns nothing
local rect r
local boolean InBase = false
call TimerDialogDisplayForPlayerBJ(false,udg_Closed[i],ConvertedPlayer(i))
if SheepInRegion(gg_rct_Top_Base,i) then
set r = gg_rct_Top_Base
set InBase = true
elseif SheepInRegion(gg_rct_Left_Base,i) then
set r = gg_rct_Left_Base
set InBase = true
elseif SheepInRegion(gg_rct_Right_Base,i) then
set r = gg_rct_Right_Base
set InBase = true
elseif SheepInRegion(gg_rct_Bottom_Base,i) then
set r = gg_rct_Bottom_Base
set InBase = true
endif
if InBase then
if Determine(r,null,null) then
call TimerDialogDisplayForPlayerBJ(true,udg_Open[i],ConvertedPlayer(i))
call StartTimerBJ(udg_InBase[i],false,30)
endif
endif
endfunction
function TurnOn_1_Actions takes nothing returns nothing
call TurnOn_Actions(1)
endfunction
function TurnOn_2_Actions takes nothing returns nothing
call TurnOn_Actions(2)
endfunction
function TurnOn_3_Actions takes nothing returns nothing
call TurnOn_Actions(3)
endfunction
function TurnOn_4_Actions takes nothing returns nothing
call TurnOn_Actions(4)
endfunction
function TurnOn_5_Actions takes nothing returns nothing
call TurnOn_Actions(5)
endfunction
function TurnOn_6_Actions takes nothing returns nothing
call TurnOn_Actions(6)
endfunction
function TurnOn_7_Actions takes nothing returns nothing
call TurnOn_Actions(7)
endfunction
function TurnOn_8_Actions takes nothing returns nothing
call TurnOn_Actions(8)
endfunction
function TurnOn_9_Actions takes nothing returns nothing
call TurnOn_Actions(9)
endfunction
function TurnOn_10_Actions takes nothing returns nothing
call TurnOn_Actions(10)
endfunction
function TurnOn_11_Actions takes nothing returns nothing
call TurnOn_Actions(11)
endfunction
function TurnOn_12_Actions takes nothing returns nothing
call TurnOn_Actions(12)
endfunction
function ShutOff_Actions takes integer i returns nothing
call TimerDialogDisplayForPlayerBJ(false,udg_Open[i],ConvertedPlayer(i))
call TimerDialogDisplayForPlayerBJ(true,udg_Closed[i],ConvertedPlayer(i))
call StartTimerBJ(udg_CanStart[i],false,30)
if SheepInRegion(gg_rct_Top_Base,i) then
call SetRegionPathing(gg_rct_Top_Base,PATHING_TYPE_AMPHIBIOUSPATHING,true)
elseif SheepInRegion(gg_rct_Left_Base,i) then
call SetRegionPathing(gg_rct_Left_Base,PATHING_TYPE_AMPHIBIOUSPATHING,true)
elseif SheepInRegion(gg_rct_Right_Base,i) then
call SetRegionPathing(gg_rct_Right_Base,PATHING_TYPE_AMPHIBIOUSPATHING,true)
elseif SheepInRegion(gg_rct_Bottom_Base,i) then
call SetRegionPathing(gg_rct_Bottom_Base,PATHING_TYPE_AMPHIBIOUSPATHING,true)
endif
endfunction
function ShutOff_1_Actions takes nothing returns nothing
call ShutOff_Actions(1)
endfunction
function ShutOff_2_Actions takes nothing returns nothing
call ShutOff_Actions(2)
endfunction
function ShutOff_3_Actions takes nothing returns nothing
call ShutOff_Actions(3)
endfunction
function ShutOff_4_Actions takes nothing returns nothing
call ShutOff_Actions(4)
endfunction
function ShutOff_5_Actions takes nothing returns nothing
call ShutOff_Actions(5)
endfunction
function ShutOff_6_Actions takes nothing returns nothing
call ShutOff_Actions(6)
endfunction
function ShutOff_7_Actions takes nothing returns nothing
call ShutOff_Actions(7)
endfunction
function ShutOff_8_Actions takes nothing returns nothing
call ShutOff_Actions(8)
endfunction
function ShutOff_9_Actions takes nothing returns nothing
call ShutOff_Actions(9)
endfunction
function ShutOff_10_Actions takes nothing returns nothing
call ShutOff_Actions(10)
endfunction
function ShutOff_11_Actions takes nothing returns nothing
call ShutOff_Actions(11)
endfunction
function ShutOff_12_Actions takes nothing returns nothing
call ShutOff_Actions(12)
endfunction
//===========================================================================
function InitTrig_Timeout takes nothing returns nothing
local trigger array TurnOn
local trigger array ShutOff
local integer i = 1
loop
exitwhen(i > 12)
set TurnOn[i] = CreateTrigger()
set ShutOff[i] = CreateTrigger()
call TriggerRegisterTimerExpireEventBJ(TurnOn[i],udg_CanStart[i])
call TriggerRegisterTimerExpireEventBJ(ShutOff[i],udg_InBase[i])
set i = i + 1
endloop
call TriggerAddAction(TurnOn[1],function TurnOn_1_Actions)
call TriggerAddAction(TurnOn[2],function TurnOn_2_Actions)
call TriggerAddAction(TurnOn[3],function TurnOn_3_Actions)
call TriggerAddAction(TurnOn[4],function TurnOn_4_Actions)
call TriggerAddAction(TurnOn[5],function TurnOn_5_Actions)
call TriggerAddAction(TurnOn[6],function TurnOn_6_Actions)
call TriggerAddAction(TurnOn[7],function TurnOn_7_Actions)
call TriggerAddAction(TurnOn[8],function TurnOn_8_Actions)
call TriggerAddAction(TurnOn[9],function TurnOn_9_Actions)
call TriggerAddAction(TurnOn[10],function TurnOn_10_Actions)
call TriggerAddAction(TurnOn[11],function TurnOn_11_Actions)
call TriggerAddAction(TurnOn[12],function TurnOn_12_Actions)
call TriggerAddAction(ShutOff[1],function ShutOff_1_Actions)
call TriggerAddAction(ShutOff[2],function ShutOff_2_Actions)
call TriggerAddAction(ShutOff[3],function ShutOff_3_Actions)
call TriggerAddAction(ShutOff[4],function ShutOff_4_Actions)
call TriggerAddAction(ShutOff[5],function ShutOff_5_Actions)
call TriggerAddAction(ShutOff[6],function ShutOff_6_Actions)
call TriggerAddAction(ShutOff[7],function ShutOff_7_Actions)
call TriggerAddAction(ShutOff[8],function ShutOff_8_Actions)
call TriggerAddAction(ShutOff[9],function ShutOff_9_Actions)
call TriggerAddAction(ShutOff[10],function ShutOff_10_Actions)
call TriggerAddAction(ShutOff[11],function ShutOff_11_Actions)
call TriggerAddAction(ShutOff[12],function ShutOff_12_Actions)
endfunction