• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Checking a point in a triangle

Status
Not open for further replies.
Level 3
Joined
Aug 26, 2020
Messages
12
Hello, i am trying to create a spell which selects units who are in a triangle inside a 1200 unit radius.

So far i have read up about it and found this thread: [vJASS] - Is Point In Triangle and i've chosen this script
JASS:
function IsPointInTriangle takes real px, real py, real ax, real ay, real bx, real by, real cx, real cy returns boolean

local boolean b1 = (px - bx) * (ay - by) - (ax - bx) * (py - by) < 0.0

local boolean b2 = (px - cx) * (by - cy) - (bx - cx) * (py - cy) < 0.0

local boolean b3 = (px - ax) * (cy - ay) - (cx - ax) * (py - ay) < 0.0

return b1 == b2 and b2 == b3

endfunction
Thing is, i do not know how to use this custom script to check whether the point of the unit is within the triangle shape.

The trigger looks like this, the point of the spell is to push Hero units who are within the triangle away from the hero casting, the test map is attached below. The version of Warcraft 3 i am using is 1.26, if it matters.

image.png
 

Attachments

  • triangle.w3x
    17.7 KB · Views: 5
Status
Not open for further replies.
Top