- Joined
- Nov 25, 2008
- Messages
- 76
I have managed this partially but I'm stuck at one point. Here is how the system works: The user selects the castle and right clicks the location that they want to build after they have selected the building they wish to erect then an unselectable peasant appears and builds the wanted building at the targeted location. Only I have a problem here: if the location already contains a building (or anything else that blocks the construction) the trigger still fires. So the question is, how do I make my function check if the given location is buildable or not?
I'm writing the code below in case I couldn't explain it correctly. It probably sucks as I'm very new to this but please bear with me.
Help is really appreciated as I'm dumbfounded on how to progress... +rep will also be given for anything constructive.
I'm writing the code below in case I couldn't explain it correctly. It probably sucks as I'm very new to this but please bear with me.
JASS:
//Builds the building specified at Building variable on the Target variable location
//Sets the building and target variables to empty after issuing the order
function StartConstruction takes nothing returns nothing
call IssueBuildOrderById(udg_Builder, udg_Building, GetLocationX(udg_Target), GetLocationY(udg_Target))
set udg_Builder_Busy = true
set udg_Target= null
set udg_Building= null
endfunction
//When the castle has been selected and issued a point order, check if there is an existing builder.
//If there is no builder, create a peasent and designate him as the builder. Then start construction.
//Else, use the existing builder to start the construction.
//Done: If the builder is building something, do not start the construction of a new project.
function Trig_Test_Actions takes nothing returns nothing
set udg_Target = GetOrderPointLoc()
if udg_Builder == null then
call CreateNUnitsAtLocFacingLocBJ( 1, 'hpea', Player(0), GetPlayerStartLocationLoc(Player(0)), udg_Target )
set udg_Builder=GetLastCreatedUnit()
call StartConstruction()
elseif udg_Builder_Busy == false then
call StartConstruction()
else
call DisplayTextToForce(GetPlayersAll(),"Your loyal subjects are busy at the construction site sire. Please wait until they are free.")
endif
endfunction
//===========================================================================
function InitTrig_Construction takes nothing returns nothing
set gg_trg_Construction = CreateTrigger( )
call TriggerRegisterUnitEvent( gg_trg_Construction, gg_unit_htow_0000, EVENT_UNIT_ISSUED_POINT_ORDER )
call TriggerAddAction( gg_trg_Construction, function Trig_Test_Actions )
endfunction
Help is really appreciated as I'm dumbfounded on how to progress... +rep will also be given for anything constructive.