Can you tell me why this doesn't work?
I want it to create roads around the unit, if it's proper terrain at that spot.
Please help!
I want it to create roads around the unit, if it's proper terrain at that spot.
Please help!
JASS:
scope BuildHQ initializer Init
function Actions takes nothing returns nothing
local unit u
local location loc
local integer Building_Cliff_Level
local integer Road_Cliff_Level
set u = GetConstructedStructure()
if GetUnitTypeId(u) == 039;h005039; or GetUnitTypeId(u) == 039;h006039; or GetUnitTypeId(u) == 039;h00J039; then
call RemoveUnit(udg_SETTLER[GetPlayerId(GetOwningPlayer(u))])
call CreateUnit(Player(GetPlayerId(GetOwningPlayer(u))),039;h00H039;, GetUnitX(u), GetUnitY(u), 270)
call CreateUnit(Player(GetPlayerId(GetOwningPlayer(u))),039;h00H039;, GetUnitX(u), GetUnitY(u), 270)
call CreateUnit(Player(GetPlayerId(GetOwningPlayer(u))),039;h009039;, GetUnitX(u), GetUnitY(u), 270)
call AdjustPlayerStateBJ( 400, GetOwningPlayer(u), PLAYER_STATE_RESOURCE_GOLD )
set loc = GetUnitLoc(u)
set Building_Cliff_Level = GetTerrainCliffLevel(GetLocationX(loc), GetLocationY(loc))
set loc = PolarProjectionBJ(GetUnitLoc(u), 300, 270.00)
set Road_Cliff_Level = GetTerrainCliffLevel(GetLocationX(loc), GetLocationY(loc))
if Building_Cliff_Level == Road_Cliff_Level and IsTerrainPathable(GetLocationX(loc), GetLocationY(loc), PATHING_TYPE_WALKABILITY) == true then
call CreateUnitAtLoc( Player(0), 039;road039;, loc, bj_UNIT_FACING )
endif
set loc = PolarProjectionBJ(GetUnitLoc(u), 250, 180.00)
set Road_Cliff_Level = GetTerrainCliffLevel(GetLocationX(loc), GetLocationY(loc))
if Building_Cliff_Level == Road_Cliff_Level and IsTerrainPathable(GetLocationX(loc), GetLocationY(loc), PATHING_TYPE_WALKABILITY) == true then
call CreateUnitAtLoc( Player(0), 039;road039;, loc, bj_UNIT_FACING )
endif
set loc = PolarProjectionBJ(GetUnitLoc(u), 300, 0.00)
set Road_Cliff_Level = GetTerrainCliffLevel(GetLocationX(loc), GetLocationY(loc))
if Building_Cliff_Level == Road_Cliff_Level and IsTerrainPathable(GetLocationX(loc), GetLocationY(loc), PATHING_TYPE_WALKABILITY) == true then
call CreateUnitAtLoc( Player(0), 039;road039;, loc, bj_UNIT_FACING )
endif
set loc = PolarProjectionBJ(GetUnitLoc(u), 250, 90.00)
set Road_Cliff_Level = GetTerrainCliffLevel(GetLocationX(loc), GetLocationY(loc))
if Building_Cliff_Level == Road_Cliff_Level and IsTerrainPathable(GetLocationX(loc), GetLocationY(loc), PATHING_TYPE_WALKABILITY) == true then
call CreateUnitAtLoc( Player(0), 039;road039;, loc, bj_UNIT_FACING )
endif
endif
set u = null
call RemoveLocation(loc)
endfunction
//===========================================================================
function Init takes nothing returns nothing
set gg_trg_Build_HQ = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Build_HQ, EVENT_PLAYER_UNIT_CONSTRUCT_FINISH )
call TriggerAddAction( gg_trg_Build_HQ, function Actions )
endfunction
endscope