library Selection initializer init
globals
unit array CurrentSelection
unit array TechUnit
integer array TechType
endglobals
private function Selection takes nothing returns boolean
local boolean CityWasSelected = false
local unit u = GetTriggerUnit()
local player owner = GetOwningPlayer(u)
local player clicker = GetTriggerPlayer()
local integer pID = GetPlayerId(clicker)
local integer i = 0
local real x
local real y
local integer array b_count
loop
exitwhen CityType[i] == null
if (GetUnitTypeId(u) == CityType[i]) then
set CityWasSelected = true
endif
set i = i + 1
endloop
if (CityWasSelected == true) then
if (owner == clicker) then
set x = GetUnitX(u)
set y = GetUnitY(u)
set CurrentSelection[pID] = u
call SetUnitPosition(CityController[pID],x,y)
call ShowUnit(CityController[pID], true)
if (GetLocalPlayer() == clicker) then
call ClearSelection()
call SelectUnit(CityController[pID], true)
endif
call SetUnitPosition(CityController[pID],x,y)
call ShowUnit(CityController[pID], true)
set i = 0
loop
exitwhen Building_order[i] == null
set b_count[i] = CountBuildings(GetUnitUserData(u), i)
set i = i + 1
endloop
// TECH-TREE // OLD
// instead of (u) use TechUnit[formula]
if (b_count[6] > 0 and u == null) then
set u = CreateUnit(clicker, HOUSE_1_TECH, 0,0,0)
elseif (b_count[6] = 0 and u != null) then
call UnitApplyTimedLife(u,'BTLF', 0.1)
set u = null
endif
if (b_count[4] > 1) then
set u = CreateUnit(clicker, HOUSE_2_TECH, 0,0,0)
endif
if (b_count[4] > 2) then
set u = CreateUnit(clicker, HOUSE_3_TECH, 0,0,0)
endif
if (b_count[4] > 3) then
set u = CreateUnit(clicker, HOUSE_4_TECH, 0,0,0)
endif
if (b_count[6] > 0) then
set u = CreateUnit(clicker, WELL_TECH, 0,0,0)
endif
if (b_count[7] > 0) then
set u = CreateUnit(clicker, GRANARY_TECH, 0,0,0)
endif
// House
// Granary 6
// Well 7
endif
endif
return false
endfunction
//===========================================================================
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerSelectionEventBJ( t, Player(0), true )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(1), true )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(2), true )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(3), true )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(4), true )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(5), true )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(6), true )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(7), true )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(8), true )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(9), true )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(10), true )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(11), true )
call TriggerAddCondition( t, Condition( function Selection) )
set t = null
set TechType[0] = 'n002' // WELL_TECH
set TechType[1] = 'n003' // GRANARY_TECH
set TechType[2] = 'n004' // HOUSE_1_TECH
set TechType[3] = 'n005' // HOUSE_2_TECH
set TechType[4] = 'n006' // HOUSE_3_TECH
set TechType[5] = 'n00D' // HOUSE_4_TECH
set TechType[6] = 'n008' // AGORA_TECH
set TechType[7] = 'n00C' // BARRACK_TECH
set TechType[8] = 'n001' // ARCHERY_RANGE_TECH
set TechType[9] = 'n00A' // STABLE_TECH
set TechType[9] = 'n009' // BLACKSMITH_TECH
set TechType[10] = 'n007' // TEMPLE TECH
endfunction
endlibrary