1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

detecting ledges

Discussion in 'World Editor Help Zone' started by n00b, May 10, 2018.

  1. n00b

    n00b

    Joined:
    Mar 21, 2008
    Messages:
    343
    Resources:
    3
    Maps:
    3
    Resources:
    3
    how would i go about detecting ledges? in this map if you try to go up a slope that's too steep, it just pushes the unit back; and if you try to go down a steep slope, the unit jumps off

    sry if this question is really vague/broad but i'm a clueless mongrel

    anyway i don't really want a fully-fledged physics system in my map, but i just want to accomplish two things:
    - being able to detect ledges (i.e. steep slopes)
    - pushing units away if they try to go up a steep slope

    how do
     
  2. nedio95

    nedio95

    Joined:
    Mar 24, 2011
    Messages:
    1,060
    Resources:
    1
    Spells:
    1
    Resources:
    1
    You could use the system itself as it is pending for trivial reasons.
    It has only one breaking feature, which you won't be using for the slopes, the rest looks like trivial matters.

    Otherwise, you could dig up the code out from the system and apply it for your needs.
    Edit// I had put a function here, but it is a lil bit more required for this to work.
     
    Last edited: May 10, 2018
  3. n00b

    n00b

    Joined:
    Mar 21, 2008
    Messages:
    343
    Resources:
    3
    Maps:
    3
    Resources:
    3
    yea seems like ledge detection involves a bunch of functions that are intertwined with each other

    if i wasn't 90% jass illiterate i could probably just cherrypick the functions that i need but yeah i'm dumb :ugly:

    i just sent a message to the guy who made the system so hopefully he'll respond
     
  4. Kazeon

    Kazeon

    Joined:
    Oct 12, 2011
    Messages:
    3,298
    Resources:
    38
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    3
    JASS:
    4
    Resources:
    38
    To detect terrain slope at a location you can use a function from the system:
    Code (vJASS):
            static method GetTiltness takes real x1, real y1, real x2, real y2 returns real
                return Sin(GetTerrainZ(x1, y1)-GetTerrainZ(x2, y2))/SLOPE_DETECTION_RADIUS
            endmethod

    where x1 & y1 is the location you want to detect. x2 & y2 is the location at which direction you want to detect the terrain slope.
    Code (vJASS):
    x2 = x1 + SLOPE_DETECTION_RADIUS*Cos(direction)
    y2 = y1 + SLOPE_DETECTION_RADIUS*Sin(direction)


    It returns terrain's slope in radians.
    The function will return 0 if the ground is even. Positive result means it's an uphill, and vice versa.

    If you want to push unit back if the terrain is too steep, then the code will look something like this:
    Code (vJASS):

    x1 = GetUnitX(main)
    y1 = GetUnitY(main)
    direction = GetUnitFacing(main)*bj_DEGTORAD
    x2 = x1+ SLOPE_DETECTION_RADIUS*Cos(direction)
    y2 = y1+ SLOPE_DETECTION_RADIUS*Sin(direction)
    if GetTiltness(x1, y1, x2, y2) > MAXIMUM_WALKABLE_TILTNESS then
        // Push unit back
    endif
     
  5. n00b

    n00b

    Joined:
    Mar 21, 2008
    Messages:
    343
    Resources:
    3
    Maps:
    3
    Resources:
    3
    Hey thanks for the reply

    it works pretty gud but there's an issue where i can still ascend a steep slope if i just walk through it diagonally (if that makes any sense)

    should i be using getLowestPoint instead?
     
  6. Kazeon

    Kazeon

    Joined:
    Oct 12, 2011
    Messages:
    3,298
    Resources:
    38
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    3
    JASS:
    4
    Resources:
    38
    Yes. Searching for lowest point enables you to slip the unit down when standing on downhill as well.