- Joined
- Nov 30, 2007
- Messages
- 1,202
JASS:
library Selection initializer init
globals
unit array CurrentSelection
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 BJDebugMsg(GetUnitName(CurrentSelection[pID]))
call DisableTrigger(deselect)
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 EnableTrigger(deselect)
call ShowUnit(CityController[pID], true)
set i = 0
//call BJDebugMsg("----------------------")
call BJDebugMsg(I2S(GetUnitUserData(u)))
loop
exitwhen Building_order[i] == null
set b_count[i] = CountBuildings(GetUnitUserData(u), i)
//call BJDebugMsg("BUILDING_" + I2S(i) + " = " + I2S(b_count[i]))
set i = i + 1
endloop
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
endfunction
endlibrary
JASS:
library Deselection initializer init
globals
trigger deselect
endglobals
function Deselection takes nothing returns boolean
local unit u = GetTriggerUnit()
local integer pID = GetPlayerId(GetTriggerPlayer())
call BJDebugMsg("DESELECTION RUN")
if (u == CityController[pID]) then
call ShowUnit(u, false)
set CurrentSelection[pID] = null
call BJDebugMsg("DESELECTED CityController")
elseif (u == CurrentSelection[pID]) then
set CurrentSelection[pID] = null
call BJDebugMsg("DESELECTED Town (probably)")
endif
set u = null
return false
endfunction
//===========================================================================
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
set deselect = t
call TriggerRegisterPlayerSelectionEventBJ( t, Player(0), false )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(1), false )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(2), false )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(3), false )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(4), false )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(5), false )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(6), false )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(7), false )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(8), false )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(9), false )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(10), false )
call TriggerRegisterPlayerSelectionEventBJ( t, Player(11), false )
call TriggerAddCondition( t, Condition( function Deselection) )
set t = null
endfunction
endlibrary
I tried to make so the deselection trigger not run while the player is selecting a City, but sadly to no avail. It still prints "DESELECTION RUN". I though I disabled the trigger? :>
Last edited: