Terrain Pathability Trigger Help!

Reflexar

New Member
Reaction score
12
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!




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) == 'h005' or GetUnitTypeId(u) == 'h006' or GetUnitTypeId(u) == 'h00J' then
        call RemoveUnit(udg_SETTLER[GetPlayerId(GetOwningPlayer(u))])
        call CreateUnit(Player(GetPlayerId(GetOwningPlayer(u))),'h00H', GetUnitX(u), GetUnitY(u), 270) 
        call CreateUnit(Player(GetPlayerId(GetOwningPlayer(u))),'h00H', GetUnitX(u), GetUnitY(u), 270)
        call CreateUnit(Player(GetPlayerId(GetOwningPlayer(u))),'h009', 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), 'road', 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), 'road', 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), 'road', 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), 'road', 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
 

ShadowInTheD

Active Member
Reaction score
12
What isn't working about it? Give more information please.

Side note: There's a JASS forum specific to JASS.
 

8uY_YoU

New Member
Reaction score
4
Firstly, sorry i lack of Jass knowledge
Why using an unit instead using a terrain tile..?
If you using an unit that possibly makes the unit doesn't showed, because the height..
 

bOb666777

Stand against the ugly world domination face!
Reaction score
117
Okay, so you want that trigger to make 4 units with some sort of road model at 4 different polar offset locations around the built structure only if it's at the same level?

I think the error could be that youre actually calling CreateUnit
Try adding this at the top of your function: local unit debug
then replace the lines under "//...":
JASS:
local unit debug
//...
        call CreateUnit(Player(GetPlayerId(GetOwningPlayer(u))),'h00H', GetUnitX(u), GetUnitY(u), 270) 
        call CreateUnit(Player(GetPlayerId(GetOwningPlayer(u))),'h00H', GetUnitX(u), GetUnitY(u), 270)
        call CreateUnit(Player(GetPlayerId(GetOwningPlayer(u))),'h009', GetUnitX(u), GetUnitY(u), 270)
        call CreateUnitAtLoc( Player(0), 'road', loc, bj_UNIT_FACING )
        call CreateUnitAtLoc( Player(0), 'road', loc, bj_UNIT_FACING )
        call CreateUnitAtLoc( Player(0), 'road', loc, bj_UNIT_FACING )
        call CreateUnitAtLoc( Player(0), 'road', loc, bj_UNIT_FACING )

by these:
JASS:
local unit debug
//...
        set debug = CreateUnit(Player(GetPlayerId(GetOwningPlayer(u))),'h00H', GetUnitX(u), GetUnitY(u), 270) 
        set debug = CreateUnit(Player(GetPlayerId(GetOwningPlayer(u))),'h00H', GetUnitX(u), GetUnitY(u), 270)
        set debug = CreateUnit(Player(GetPlayerId(GetOwningPlayer(u))),'h009', GetUnitX(u), GetUnitY(u), 270)
        set debug = CreateUnitAtLoc( Player(0), 'road', loc, bj_UNIT_FACING )
        set debug = CreateUnitAtLoc( Player(0), 'road', loc, bj_UNIT_FACING )
        set debug = CreateUnitAtLoc( Player(0), 'road', loc, bj_UNIT_FACING )
        set debug = CreateUnitAtLoc( Player(0), 'road', loc, bj_UNIT_FACING )
 

Reflexar

New Member
Reaction score
12
The thing is that i want the road buildings only to be created if the location where they should be created is normal grass, if it's like cliff and such i don't want them to be created. Can you help me with this? :p


Please!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top