• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Creating a spell that adds MS when running from the engaged unit

Status
Not open for further replies.
Level 8
Joined
Mar 30, 2013
Messages
180
This is passive, it updates whenever the said unit is issued an order

What i want is
-P1 (Unit Location), P2 (Order Location), P3 (Engaged Unit Location)

R1 Is Angle from P3 to P1

R2 Is Angle from P3 to P2

If R2 is Less than (R1+90) and Greater than (R1-90) Then add the moment speed (Done via a item ability)

So my problem stands in that, my math is shite as you can probably guess, and that Angle between points gives a value between 180 and -180 not 0 and 360

Anyone know a better way to do this?

TL;DR, Want to create a spell when the unit is running away from the engaged unit, angle between points doesn't give me the values i need so idk what to do
 
Based on DSG, one can compare 2 angles by subtracting them and puting them into cos.
Then one gains a value from -1 to 1.
-> 1 means they point in the same direction
-> -1 they are pointing in opposite directions

Example trigger, warning this trigger leaks:
  • Runs Away?
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Set AngleToOrder = (Angle from (Position of (Triggering unit)) to (Target point of issued order))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Equal to Bergkönig 0002 <gen>
        • Then - Actions
          • Set AngleToUnit = (Angle from (Position of (Triggering unit)) to (Position of Soldat 0000 <gen>))
        • Else - Actions
          • Set AngleToUnit = (Angle from (Position of (Triggering unit)) to (Position of Bergkönig 0002 <gen>))
      • Game - Display to (All players) the text: (String((Cos((AngleToUnit - AngleToOrder)))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Cos((AngleToUnit - AngleToOrder))) Less than 0.00
        • Then - Actions
          • Game - Display to (All players) the text: Runs Away
        • Else - Actions
          • Game - Display to (All players) the text: Moves to Unit
 
Last edited:
Level 8
Joined
Mar 30, 2013
Messages
180
Based on DSG, one can compare 2 angles by subtracting them and puting them into cos.
Then one gains a value from -1 to 1.
-> 1 means they point in the same direction
-> -1 they are pointing in opposite directions

Example trigger, warning this trigger leaks:
  • Runs Away?
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Set AngleToOrder = (Angle from (Position of (Triggering unit)) to (Target point of issued order))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Triggering unit) Equal to Bergkönig 0002 <gen>
        • Then - Actions
          • Set AngleToUnit = (Angle from (Position of (Triggering unit)) to (Position of Soldat 0000 <gen>))
        • Else - Actions
          • Set AngleToUnit = (Angle from (Position of (Triggering unit)) to (Position of Bergkönig 0002 <gen>))
      • Game - Display to (All players) the text: (String((Cos((AngleToUnit - AngleToOrder)))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Cos((AngleToUnit - AngleToOrder))) Less than 0.00
        • Then - Actions
          • Game - Display to (All players) the text: Runs Away
        • Else - Actions
          • Game - Display to (All players) the text: Moves to Unit

TYVM this works perfectly, was never good at advanced maths so i can never remember what the functions do well, i'll have to remember this for future stuff
 
Status
Not open for further replies.
Top