- Joined
- Oct 4, 2016
- Messages
- 210
Hello everyone, I am trying to make a code that fixes the vision of the units when they are in Low or High Ground, in a map that is made of the Raise Terrain Tool, as the whole map is done in the same Cliff Level , A unit that is down a hill can see above this.
The first solution is to put LOS blockers at the feet of the hills. But this also blocks vision when the unit is on top.
Another solution is to ask in a periodic event if the Z of the position of the unit is above 300 (which is the approximate height of the hill), then create a flying dummy unit that follows the unit. The problem with this method is that the flying unit does not respect Occluder Height of trees that are above the hill. Without these solutions I decided to make a code that is this.
Basically what it does is, is picks the destructibles of the type of Line of Sight Bloquer, in the vision area of the unit, if the unit is with a z greater than 300 Set the occluder height of the bloquers to 0, but this it I do Locally for player 1. If a bloquer leaves the range of vision, set the occluder Height to its default value. I test it in Multiplayer, works but sometimes it causes Desync (not exactly why) Change the Occluder Height of a destructible locally causes Desync?
Look at this image.
The enemy peon does not see beyond the LOS blockers, but the Test Hero can see it.
the Line of Sight Bloquers do not have the Pathing Texture, because that part of the terrain is a ramp, the trigger works very well in this part. But it causes Desync when I approach this part.
The code works perfectly in Single Player. I hope you have understood me, sorry for the possible mistakes, English is not my native language.
Thanks in advance.
The first solution is to put LOS blockers at the feet of the hills. But this also blocks vision when the unit is on top.
Another solution is to ask in a periodic event if the Z of the position of the unit is above 300 (which is the approximate height of the hill), then create a flying dummy unit that follows the unit. The problem with this method is that the flying unit does not respect Occluder Height of trees that are above the hill. Without these solutions I decided to make a code that is this.
JASS:
function LoopEnum takes nothing returns nothing
local real xu = GetUnitX(gg_unit_HDG1_0020)
local real yu = GetUnitY(gg_unit_HDG1_0020)
local location l = GetUnitLoc(gg_unit_HDG1_0020)
local destructable d = GetEnumDestructable()
local integer id = GetDestructableTypeId(d)
local real xd = GetDestructableX(d)
local real yd = GetDestructableY(d)
local real occ = 250
local real vision = 1300
local real z = GetLocationZ(l)
if id == 'B00D' then
if GetLocalPlayer() == Player(0) then
if z >= 300 then
if Distance(xu,yu,xd,yd) <= vision then
set occ = 0
endif
endif
call SetDestructableOccluderHeight(d,o)
endif
endif
call RemoveLocation(l)
set l = null
set d = null
endfunction
function PickDes takes nothing returns nothing
local location l = GetUnitLoc(gg_unit_HDG1_0020)
call EnumDestructablesInCircleBJ( 1500.00, l, function LoopEnum )
call RemoveLocation(l)
set l = null
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
set gg_trg_Untitled_Trigger_002 = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Untitled_Trigger_002, 0.25 )
call TriggerAddAction( gg_trg_Untitled_Trigger_002, function PickDes )
endfunction
Basically what it does is, is picks the destructibles of the type of Line of Sight Bloquer, in the vision area of the unit, if the unit is with a z greater than 300 Set the occluder height of the bloquers to 0, but this it I do Locally for player 1. If a bloquer leaves the range of vision, set the occluder Height to its default value. I test it in Multiplayer, works but sometimes it causes Desync (not exactly why) Change the Occluder Height of a destructible locally causes Desync?
Look at this image.
The enemy peon does not see beyond the LOS blockers, but the Test Hero can see it.
the Line of Sight Bloquers do not have the Pathing Texture, because that part of the terrain is a ramp, the trigger works very well in this part. But it causes Desync when I approach this part.
The code works perfectly in Single Player. I hope you have understood me, sorry for the possible mistakes, English is not my native language.
Thanks in advance.
Attachments
Last edited: