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!
Hello guys, sorry to bother again. i would like to know if you guys could make this "Cone Shape Dummies Behavior"? it'll be a great help for my character from my map.
Thank you for always helping me.
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
If you are using Lua as your map script language then some of this will need syntax changes.
Sector is considerably easier with almost no visible difference, since you only need to compare angles between some minimum/maximum. To do triangle you will need to implement a custom script function into your map header (literally just paste it there or in another blank trigger) which computes if some XY coordinates are within a triangle defined by (x1,y1) (x2, y2) (x3,y3). Then you use a boolean variable to store the value of this function output (via custom script) and can then use it as a Condition. A thread with information about this and an example can be found here.
To find the other two vertices of the triangle (I assume one is the caster origin) you'll have to polar project two points and then use them in the triangle computation.
Set T_Length = 300.00 //length of sides
Set T_AngWidth = 45.00 //how many degrees wide the triangle should be
Set T_CastAng = (Facing of (Triggering Unit)) //this may not be always correct, especially if the unit can cast instantly without turning. A better approach is to get the cast target point/unit and then calculate the angle between the caster and that point directly.
Set T_V[1] = (Position of (Triggering Unit))
Set T_V[2] = T_V[1] offset by T_Length towards (T_CastAng + (T_AngWidth / 2)) degrees
Set T_V[3] = T_V[1] offset by T_Length towards (T_CastAng - (T_AngWidth / 2)) degrees
Set T_X[1] = (X-coordinate of T_V[1])
Set T_Y[1] = (Y-coordinate of T_V[1])
Set T_X[2] = (X-coordinate of T_V[2])
Set T_Y[2] = (Y-coordinate of T_V[2])
Set T_X[3] = (X-coordinate of T_V[3])
Set T_Y[3] = (Y-coordinate of T_V[3])
Custom script: call RemoveLocation(udg_T_V[1])
Custom script: call RemoveLocation(udg_T_V[2])
Custom script: call RemoveLocation(udg_T_V[3])
-------- --------
Set SearchGroup = (Units within T_Length of T_V[1]) //filter here if you want to
Unit Group - Pick every unit in SearchGroup and do (Actions)
If (All conditions are true) then do (Then actions) else do (Else actions)
If - Conditions
T_Boolean equal to False
Then - Actions
Unit - Remove (Picked Unit) from SearchGroup
Else - Actions
-------- --------
-------- By the time you get here, SearchGroup only contains units with their origin inside the defined triangle --------
In the other thread I said:
Note that this will not consider unit collision, so a unit very close to the edge of a triangle might not have its center inside the triangle even though it appears to overlap with it. Just consider that.
(Yeah I know doing Polar Projection with locations and then extracting the coordinates is so ass-backwards but this is GUI and y'all understand that it would be more confusing if I didn't do it this way.)
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
If you are using Lua as your map script language then some of this will need syntax changes.
Sector is considerably easier with almost no visible difference, since you only need to compare angles between some minimum/maximum. To do triangle you will need to implement a custom script function into your map header (literally just paste it there or in another blank trigger) which computes if some XY coordinates are within a triangle defined by (x1,y1) (x2, y2) (x3,y3). Then you use a boolean variable to store the value of this function output (via custom script) and can then use it as a Condition. A thread with information about this and an example can be found here.
To find the other two vertices of the triangle (I assume one is the caster origin) you'll have to polar project two points and then use them in the triangle computation.
Set T_Length = 300.00 //length of sides
Set T_AngWidth = 45.00 //how many degrees wide the triangle should be
Set T_CastAng = (Facing of (Triggering Unit)) //this may not be always correct, especially if the unit can cast instantly without turning. A better approach is to get the cast target point/unit and then calculate the angle between the caster and that point directly.
Set T_V[1] = (Position of (Triggering Unit))
Set T_V[2] = T_V[1] offset by T_Length towards (T_CastAng + (T_AngWidth / 2)) degrees
Set T_V[3] = T_V[1] offset by T_Length towards (T_CastAng - (T_AngWidth / 2)) degrees
Set T_X[1] = (X-coordinate of T_V[1])
Set T_Y[1] = (Y-coordinate of T_V[1])
Set T_X[2] = (X-coordinate of T_V[2])
Set T_Y[2] = (Y-coordinate of T_V[2])
Set T_X[3] = (X-coordinate of T_V[3])
Set T_Y[3] = (Y-coordinate of T_V[3])
Custom script: call RemoveLocation(udg_T_V[1])
Custom script: call RemoveLocation(udg_T_V[2])
Custom script: call RemoveLocation(udg_T_V[3])
-------- --------
Set SearchGroup = (Units within T_Length of T_V[1]) //filter here if you want to
Unit Group - Pick every unit in SearchGroup and do (Actions)
If (All conditions are true) then do (Then actions) else do (Else actions)
If - Conditions
T_Boolean equal to False
Then - Actions
Unit - Remove (Picked Unit) from SearchGroup
Else - Actions
-------- --------
-------- By the time you get here, SearchGroup only contains units with their origin inside the defined triangle --------
(Yeah I know doing Polar Projection with locations and then extracting the coordinates is so ass-backwards but this is GUI and y'all understand that it would be more confusing if I didn't do it this way.)
i see, i would need to know how do i Move those dummies starting from the position of T_Unit towards the Final_Direction=700 line base where the dummies from the picture i've provided? i believe this needs a loop, but i don't know how in this kind of situation.
I guess it would help if I read the notes on your diagram. You don't need triangle detection at all, you just need to search in a radius around each dummy for targets while moving them in lines. Frankly you could probably get away with issuing the dummies a movement command instead of periodically moving them (as long as they have Locust and flying movement in the OE). Depending on what you're trying to achieve visually, it might even be enough to order dummies that have hit something simply to follow that targeted unit instead of moving them then, too.
To start making spells that work over a period of time you will need to become familiar with indexing spell instances. Read this tutorial and learn from it because you will need to use this method many times: Visualize: Dynamic Indexing.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.