• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Question about invisible platforms

Status
Not open for further replies.
Level 14
Joined
Apr 20, 2009
Messages
1,543
Hey all,

I've got a question about the usage of the invisible platforms.

Okay, let's say for example that I have a bridge between 2 cliffs and a path between the cliffs. I used invisible platforms and raised them so that the unit can walk over the bridge.

At this moment I used rects in the cliff path. Whenever a unit enters it, it takes all the invisible platforms and kills them. Then I created some rects at the top of the cliff before entering the bridge, which resurrects the invisible platforms again.

The problem is that it's now impossible to have 1 unit walking on the bridge while simultaniously having 1 unit walking under the bridge. And I asked myself the following question:

Is it possible to create a pathing blocker which removes the pathing on the ground, causing the invisible platforms to still have their pathing in mid-air while the cliff path has none?

I guess not since the pathing is projected on the terrain, but if it is possible then that would be a genius intervention right :D?

EDIT: I could of course teleport the unit from one region to the other when it's trying to move under the bridge, but this would look unnatural and would make it impossible for the unit to stay underneath the bridge.

I really need some suggestions on how to do this properly and realistically.

EDIT 2: I just need to know exactly how the invisible platforms work.
When you put them high above the ground, then that would be the height the unit would be walking on the platform.
But the pathing is on the ground, making it possible for the unit to walk on top of the invisible platform right?
So if I could keep the invisible platform alive and keep the pathing, while putting a custom pathing blocker on the ground underneath the invisible platform which has no pathing, then would the rule apply for the invisible platform or for the custom pathing blocker when it's ordered to move underneath the bridge?

EDIT3: What if I gave the unit who enters the region at the cliff path the locust ability, then it would ignore the pathing right? But then how would I be abled to make the unit stay underneath the bridge while maintaining the ability to order the unit to move? When locust is removed I suppose the unit will be put on top of the bridge again.

EDIT4: Another take on this: What if I add crow form to the unit who enters the bridge so that I won't need to use invisible platforms at all? I would only need to set it's flying height and remove it whenever it enters the other side of the bridge. I'll try this and see if it works.
 
Last edited:
Level 26
Joined
Aug 18, 2009
Messages
4,097
Is it possible to create a pathing blocker which removes the pathing on the ground, causing the invisible platforms to still have their pathing in mid-air while the cliff path has none?

Pathings are not 3D but a feature of cells in the x-y-plane. So the z-coordinate does not matter at all, the pathing is not "on the ground" but counts for all heights on that cell. Infact, units do not even have a gameplay-relevant height other than cliff level, which is however location-based.

I really need some suggestions on how to do this properly and realistically.

You cannot have pathing and no pathing at the same location at the same time. What you could maybe do would be to trick the movement algorithm by temporarily adding pathing, then removing it again. I do not know when it updates searching for paths other than reordering.

Well, another idea would be to neglect the normal movement, redirect orders and such, set the graphical height with SetUnitFlyHeight/Stormcrow bug and generally reset the unit's position via trigger when it tries to take unwanted ways.

Third suggestion: Replace the units to be blocked by different pathing types. See here. Then give the exits of the bridge different pathings.

The elevating feature of Invisible Platforms has nothing to do with pathing. It derives from the destructable feature "Is walkable" and just adds to the terrain's graphical height. Bridges, in contrast, use the "cliff height" field to alter the gameplay-relevant cliff height and to paint their own pathing maps over those of cliff edges.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Waterknight said:
Pathings are not 3D but a feature of cells in the x-y-plane. So the z-coordinate does not matter at all, the pathing is not "on the ground" but counts for all heights on that cell. Infact, units do not even have a gameplay-relevant height other than cliff level, which is however location-based.

Thanks for the explenation, I completely understand now.

Waterknight said:
Well, another idea would be to neglect the normal movement, redirect orders and such, set the graphical height with SetUnitFlyHeight/Stormcrow bug and generally reset the unit's position via trigger when it tries to take unwanted ways.

Third suggestion: Replace the units to be blocked by different pathing types. See here. Then give the exits of the bridge different pathings.

Yes, this is a good idea.

I was thinking about using flying only pathing blockers next to the bridge, then use SetUnitFlyHeight to set the height accordingly.
I would then need to create a boolean array that would be set to true for the unit who enters the region before entering the bridge.
And also replace the unit with a dummy flying unit of the same type.
So that it would detect the pathing blockers. Including adding the walk animation to the dummy.
Then use a periodic timer to check the z height of the terrain on the position of the unit in order to set the flying height accordingly to the terrain the unit is moving on with an offset. But only when the boolean is true ofcourse.
I would however need to find a way of calculating the difference between z-height of the terrain and applying it to the flying height correctly. (I don't think this would be such a big deal though...)
Then set the boolean to false whenever it re-enters the region or enters the region on the other side of the bridge.
And ofcourse replace the unit back to the original ground unit.

In theory this should work right?
Using Stormcrow would mean that the pathing blockers will not be detected by the "flying" unit because it doesn't change the movement type.

EDIT: I do find it a pain in the @ss to create a dummy flying unit for every unit >.<

generally reset the unit's position via trigger when it tries to take unwanted ways.
I could also do it this way, but how would I then check if the unit position is off the bridge?
Do I then have to check if the unit is within a range of positions?
This could also be a pain in the @ss since the bridge is positioned diagonally.
How would I be abled to do this?
 
Last edited:
Level 17
Joined
Nov 13, 2006
Messages
1,814
rofl, u read from my mind, in work i thought about this too coz once i watched a pic with bridge between 2 cliff :D

seems dont have a really good solution if i dont want replace the unit (just annoying i i must put every attachment to another unit :D)

so moveing below a flying island and on flying island also must be tricky
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Okay, so these are the positions of my bridge:

Code:
top left
x 4700
y -22100

top right
x 5100
y -22500

bottom right
x 4400
y -23200

bottom left
x 4000
y -22800

Now how would I check if the unit goes off the bridge on the top, bottom and the sides?
So for example when the unit is to much to the right it should be put back on top of the bridge, if it's to far to the left it should be put back, if the unit goes off the bridge (top or bottom) it should stop the re-positioning triggers. Which include flying height...

exampleht.png


Now how can I calculate if the unit walks off the red edges and green edges?

Lol if my bridge wasn't diagonal this would've been easy cake...

Really, I'm having a braindead moment >.< Haven't done math in a while :S

shadowvzs said:
rofl, u read from my mind, in work i thought about this too coz once i watched a pic with bridge between 2 cliff :D

seems dont have a really good solution if i dont want replace the unit (just annoying i i must put every attachment to another unit :D)

so moveing below a flying island and on flying island also must be tricky
It indeed is tricky, but if I could manage to make it work I'll try to create a template for other people so that they can use it in their map too :)

I need a mathematical equation that checks the co-ordinates of these lines in any angle when given 2 x and y co-ordinates in the x y pane.

This way I would be abled to create "fake" regions in any angle by using co-ordinates...

EDIT: thanks shadowvzs for my third green gem :D A shame I can't spread rep to you yet :(

EDIT 2: My dad helped me out on this equation:
Code:
y = a + b * x
where y is the y co-ordinate, x is the x co-ordinate and a and b need to be extracted and checked.

So let's say for example I have these 4 co-ordinates:
Code:
y = 17, x = 3
y = -11, x = 7

example:
Code:
 17 = a + b * 3
-11 = a + b * 7

Now in order to extract it let's multiply the second equation with -1:
11 = -a - b * 7

This is still the first equation:
17 = a + b * 3

Now we can say:
28 = 0 + b * (3 - 7)

Which leaves us with:
28 / (3 - 7) = 28 / -4 = -7 = b

Then we use b in order to extract a:
11 = -a - (-7 * 7)
11 = -a + 49
a + 11 = 0 + 49
a = 49 - 11 = 38

Now to check if it's correct:
y = 38 - 7 * x
-11 = 38 - 7 * 7
17 = 38 - 7 * 3

And yes indeed it is :D!

However this would only define the lines so far, not the actual co-ordinates within these lines in order to create a region. I'll try to figure this out.

As soon as I'm done finishing the script I'll submit it in the Jass resource section as a system, hopefully someone will find use for it :)
When everything works as expected I'll create a small tutorial on how to use it so that it'll be easy to use for both Jass and GUI users.

Please, don't steal this submission from me :(
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,243
JASS:
// Returns a boolean that tells whether the point is inside a rectangle.
// (px , py) = Point to check
// (cx , cy) = lower left corner of the rect
// (ax , ay) = upper left corner
// (bx , by) = lower right corner
function IsPointInRect takes real px , real py , real cx , real cy , real ax , real ay , real bx , real by returns boolean        
    local real dot1 = (px-cx)*(ax-cx) + (py-cy)*(ay-cy)
    local real dot2 = (ax-cx)*(ax-cx) + (ay-cy)*(ay-cy)
    local real dot3 = (px-cx)*(bx-cx) + (py-cy)*(by-cy)
    local real dot4 = (bx-cx)*(bx-cx) + (by-cy)*(by-cy)

    return dot1 >= 0 and dot1 <= dot2 and dot3 >= 0 and dot3 <= dot4
endfunction
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
JASS:
// Returns a boolean that tells whether the point is inside a rectangle.
// (px , py) = Point to check
// (cx , cy) = lower left corner of the rect
// (ax , ay) = upper left corner
// (bx , by) = lower right corner
function IsPointInRect takes real px , real py , real cx , real cy , real ax , real ay , real bx , real by returns boolean        
    local real dot1 = (px-cx)*(ax-cx) + (py-cy)*(ay-cy)
    local real dot2 = (ax-cx)*(ax-cx) + (ay-cy)*(ay-cy)
    local real dot3 = (px-cx)*(bx-cx) + (py-cy)*(by-cy)
    local real dot4 = (bx-cx)*(bx-cx) + (by-cy)*(by-cy)

    return dot1 >= 0 and dot1 <= dot2 and dot3 >= 0 and dot3 <= dot4
endfunction

give false alerts :p map uploaded

JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local boolean b
set udg_target =  GroupPickRandomUnit(GetUnitsSelectedAll(Player(0)))
set b = IsPointInRect (GetUnitX(udg_target), GetUnitY(udg_target) , GetUnitX(udg_c) , GetUnitY(udg_c) ,  GetUnitX(udg_b) , GetUnitY(udg_b), GetUnitX(udg_a) , GetUnitY(udg_a))
if b then
    call DisplayTextToForce( GetPlayersAll(), "inside" )
else
    call DisplayTextToForce( GetPlayersAll(), "outside" )
endif
endfunction

//===========================================================================
function InitTrig_check takes nothing returns nothing
    set gg_trg_check = CreateTrigger(  )
    call TriggerRegisterPlayerSelectionEventBJ( gg_trg_check, Player(0), true )
    call TriggerAddAction( gg_trg_check, function Trig_Untitled_Trigger_001_Actions )
endfunction
if it is rectabgle then dont need the upper right corner?

i also thought on this today, and if u can calculate the degrees then indifferent what is the area form, u can calculate without problem

(just theory but check the pic)
points.jpg
 

Attachments

  • point.w3x
    20.2 KB · Views: 80
Level 17
Joined
Nov 13, 2006
Messages
1,814
its give wrong result sometimes in ur example if it is a not regulare rect like
Code:
  __
 / /
--

i made this, i tryed and 100% accurated and area can be anything what got 4 point and with this u can do for anything (octogon, triangle etc)

JASS:
function InsideInRect takes real x1, real y1,real x2, real y2,real x3, real y3,real x4, real y4,real px, real py returns boolean
local real d1 = SquareRoot((x1-px) * (x1-px) + (y1-py) * (y1-py))
local real d2 = SquareRoot((x2-px) * (x2-px) + (y2-py) * (y2-py))
local real d3 = SquareRoot((x3-px) * (x3-px) + (y3-py) * (y3-py))
local real d4 = SquareRoot((x4-px) * (x4-px) + (y4-py) * (y4-py))
local real s1 = SquareRoot((x1-x2) * (x1-x2) + (y1-y2) * (y1-y2))
local real s2 = SquareRoot((x2-x3) * (x2-x3) + (y2-y3) * (y2-y3))
local real s3 = SquareRoot((x3-x4) * (x3-x4) + (y3-y4) * (y3-y4))
local real s4 = SquareRoot((x4-x1) * (x4-x1) + (y4-y1) * (y4-y1))
local real cos1 = (d1*d1+d2*d2-s1*s1)/ (2 * (d1*d2))
local real cos2 = (d2*d2+d3*d3-s2*s2)/ (2 * (d2*d3))
local real cos3 = (d3*d3+d4*d4-s3*s3)/ (2 * (d3*d4))
local real cos4 = (d4*d4+d1*d1-s4*s4)/ (2 * (d4*d1))
local real output = cos1+cos2+cos3+cos4
return output < 0
endfunction

and function

JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local boolean b
local unit u = GroupPickRandomUnit(GetUnitsSelectedAll(Player(0)))
local real x1 = GetUnitX(udg_a)
local real y1 = GetUnitY(udg_a)
local real x2 = GetUnitX(udg_b)
local real y2 = GetUnitY(udg_b)
local real x3 = GetUnitX(udg_c)
local real y3 = GetUnitY(udg_c)
local real x4 = GetUnitX(udg_d)
local real y4 = GetUnitY(udg_d)
local real px = GetUnitX(u)
local real py = GetUnitY(u)

//call InsideInRect(x1,y1,x2,y2,x3,y3,x4,y4,px,py)

if InsideInRect(x1,y1,x2,y2,x3,y3,x4,y4,px,py) then
    call DisplayTextToForce( GetPlayersAll(), "Cosinus of the 4 degree is negative so u are inside this crap" )
else
    call DisplayTextToForce( GetPlayersAll(), "Cosinus of the 4 degree is positive so u are outside from this crap" )
endif
endfunction

Notice: select unit on test map and u will see if u get inside or outside msg :p


about this region, things, if u make 2 normal region before and after bridge then when unit enter to region then add him to a unit list array and save his coord every sec to X,Y,Height variable and if make trigger with oder unit to a point, if order string = smart and order target point outside from birdge region and it isnt inside the 2 region what is before/after bridge then move back to last x,y coordinate.

when u enter to before/after bridge region u can save unit height with GetLocationZ and when unit ordered inside the bridge region (what could be a custom area and with i posted u can check if target point is inside) then u set flying height to that height what u got when u entered the before/after bridge region, if u enter again to before after region and height>0 then set flying height to 0 and height variable to = 0

so something like this
 

Attachments

  • point.w3x
    21 KB · Views: 78
Level 14
Joined
Apr 20, 2009
Messages
1,543
its give wrong result sometimes in ur example if it is a not regulare rect like
Code:
  __
 / /
--

i made this, i tryed and 100% accurated and area can be anything what got 4 point and with this u can do for anything (octogon, triangle etc)

JASS:
function InsideInRect takes real x1, real y1,real x2, real y2,real x3, real y3,real x4, real y4,real px, real py returns boolean
local real d1 = SquareRoot((x1-px) * (x1-px) + (y1-py) * (y1-py))
local real d2 = SquareRoot((x2-px) * (x2-px) + (y2-py) * (y2-py))
local real d3 = SquareRoot((x3-px) * (x3-px) + (y3-py) * (y3-py))
local real d4 = SquareRoot((x4-px) * (x4-px) + (y4-py) * (y4-py))
local real s1 = SquareRoot((x1-x2) * (x1-x2) + (y1-y2) * (y1-y2))
local real s2 = SquareRoot((x2-x3) * (x2-x3) + (y2-y3) * (y2-y3))
local real s3 = SquareRoot((x3-x4) * (x3-x4) + (y3-y4) * (y3-y4))
local real s4 = SquareRoot((x4-x1) * (x4-x1) + (y4-y1) * (y4-y1))
local real cos1 = (d1*d1+d2*d2-s1*s1)/ (2 * (d1*d2))
local real cos2 = (d2*d2+d3*d3-s2*s2)/ (2 * (d2*d3))
local real cos3 = (d3*d3+d4*d4-s3*s3)/ (2 * (d3*d4))
local real cos4 = (d4*d4+d1*d1-s4*s4)/ (2 * (d4*d1))
local real output = cos1+cos2+cos3+cos4
return output < 0
endfunction

and function

JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local boolean b
local unit u = GroupPickRandomUnit(GetUnitsSelectedAll(Player(0)))
local real x1 = GetUnitX(udg_a)
local real y1 = GetUnitY(udg_a)
local real x2 = GetUnitX(udg_b)
local real y2 = GetUnitY(udg_b)
local real x3 = GetUnitX(udg_c)
local real y3 = GetUnitY(udg_c)
local real x4 = GetUnitX(udg_d)
local real y4 = GetUnitY(udg_d)
local real px = GetUnitX(u)
local real py = GetUnitY(u)

//call InsideInRect(x1,y1,x2,y2,x3,y3,x4,y4,px,py)

if InsideInRect(x1,y1,x2,y2,x3,y3,x4,y4,px,py) then
    call DisplayTextToForce( GetPlayersAll(), "Cosinus of the 4 degree is negative so u are inside this crap" )
else
    call DisplayTextToForce( GetPlayersAll(), "Cosinus of the 4 degree is positive so u are outside from this crap" )
endif
endfunction

Notice: select unit on test map and u will see if u get inside or outside msg :p


about this region, things, if u make 2 normal region before and after bridge then when unit enter to region then add him to a unit list array and save his coord every sec to X,Y,Height variable and if make trigger with oder unit to a point, if order string = smart and order target point outside from birdge region and it isnt inside the 2 region what is before/after bridge then move back to last x,y coordinate.

when u enter to before/after bridge region u can save unit height with GetLocationZ and when unit ordered inside the bridge region (what could be a custom area and with i posted u can check if target point is inside) then u set flying height to that height what u got when u entered the before/after bridge region, if u enter again to before after region and height>0 then set flying height to 0 and height variable to = 0

so something like this

Awesome bro, it totally works :D!!! +rep if I can ^.^

Time to start working on this bridge thing :D! Thanks a ton!

edit: gotta spread >.>
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Awesome bro, it totally works :D!!! +rep if I can ^.^

Time to start working on this bridge thing :D! Thanks a ton!

edit: gotta spread >.>

oh before i forget u can use maybe the fence's if u raise up in WE for make a designed path blocker coz i think its block coz of collision so if u raise up to air maybe there also work


This might be interesting for you:
Basicly a two floor system. I think its the same you want to achieve:

http://www.thehelper.net/forums/showthread.php/145900-Multi-Floor-System?highlight=floor+system

i check and it work but i dont like that morph thing, simple because i already use 1 morph ability for make unit ranged/melee and useing another for flying unit just make complications :/
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
shadowvzs said:
oh before i forget u can use maybe the fence's if u raise up in WE for make a designed path blocker coz i think its block coz of collision so if u raise up to air maybe there also work

There is no need for this, I'll use an ability that temporarely removes the collision of the units on top of the bride ;)

Zwiebelchen said:
This might be interesting for you:
Basicly a two floor system. I think its the same you want to achieve:

Great, I am in deep needs of such a system. However I'll try to complete my personal code before using this. I really want to take a shot at this.

i check and it work but i dont like that morph thing, simple because i already use 1 morph ability for make unit ranged/melee and useing another for flying unit just make complications :/

Why would it cause complications? Sorry, I don't quite understand how that could :S

In order to do this you would need the Crowform bug...
As far as I understand there is no other way of doing this, so if the cons outweight the pro's for you. Then I guess that's a decision for you to make.
However I wish you good luck, you've helped me a lot here :goblin_good_job:

EDIT: I censerely hope there is someone brilliant who can close this thread for me please :ogre_hurrhurr:?
 
Level 17
Joined
Jul 17, 2011
Messages
1,863
why dont you make a doodad bridge for when a unit is about to walk on it and make a unit with the model of the bridge for when the unit will walk under the bridge so that he wont climb to the top
this way it should look pretty natural, and sorry wc3 is very limited you have to find special ways to solve the problems
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Why would it cause complications? Sorry, I don't quite understand how that could :S

In order to do this you would need the Crowform bug...
As far as I understand there is no other way of doing this, so if the cons outweight the pro's for you.

it is obviusly cant get same 2 bear form ability coz of base order, so must be 1 metamorph and 1 bear form but i also use metamorph too on my map, so kinda again can have conflict with ordering but another side u really want do 1 bear form to each unit what can travel on bridge?

then still better to create a dummy unit (same unit type), hide the original and show again if dummy left the bridge
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
it is obviusly cant get same 2 bear form ability coz of base order, so must be 1 metamorph and 1 bear form but i also use metamorph too on my map, so kinda again can have conflict with ordering but another side u really want do 1 bear form to each unit what can travel on bridge?

then still better to create a dummy unit (same unit type), hide the original and show again if dummy left the bridge

I am using the Crowform bug in my script though... I could do it by creating dummy's indeed, but the method doesn't really matter, it works for both.
I'm still having one little problem with it, as soon as I fix it, it should be done. I'll post my version in this topic when it is done.

gorillabull said:
why dont you make a doodad bridge for when a unit is about to walk on it and make a unit with the model of the bridge for when the unit will walk under the bridge so that he wont climb to the top
this way it should look pretty natural, and sorry wc3 is very limited you have to find special ways to solve the problems

Please, do elaborate how one would be abled to do this without scripts nor a workaround? If that's what you're trying saying?
I don't quite follow you on this part:
gorillabull said:
make a unit with the model of the bridge for when the unit will walk under the bridge so that he wont climb to the top
this way it should look pretty natural

And how is that supposed to work??

Please show me how this works!
I am deeply interested.


EDIT: everything works so far, right now the only thing that I haven't done yet is making sure that the unit can not leave the bridge on the sides when the unit is on top of it. For the rest everything works. The units, happy as they are, are now celebrating a big party underneath my bridge. While some other units party on top at the same time :D!
 
Last edited:
You know, the system I linked might have trouble with morphing (actually you could replace all that with autofly, but then you don't have collision anymore and selection circle becomes weird), but it shows an elegant and easy to use solution to the problem.
Basicly all you need to do is place air and ground pathing blockers and the transit area and you are done.
No complicated registering, perfect control, now flaws so far ... it just looks ugly because its damn flying units, which always look ugly because of shadow being still on the ground.

I don't really see a different way of doing this, but thats just me. Good luck.
 
Status
Not open for further replies.
Top