• 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.

[Trigger] Need help detecting facing angle of picked units!

Status
Not open for further replies.
Level 7
Joined
Jul 21, 2019
Messages
177
Hello, i am working on a spell with the following effect:

Caster casts the spell, units within 500 radius of caster have their movement speed reduced (via dummy unit + ability)
only if they are facing away from the caster.

What im trying to do is to detect if the picked units are facing away from the position of the caster, no matter the facing angle of the caster (picked units can even be behind the caster, but if they are facing away from the point where the caster is they are slowed)

Here is a shitty drawing i made in paint:

paint.gif


And here is my trigger:

  • MS Slow
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Mocking Shout
    • Actions
      • Set MS_Point = (Position of (Casting unit))
      • Set MS_Group = (Units within 500.00 of MS_Point)
      • Unit Group - Pick every unit in MS_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is Magic Immune) Equal to False
              • ((Picked unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True
            • Then - Actions
              • Unit - Create 1 Dummy Unit for Neutral Passive at MS_Point facing Default building facing degrees
              • Unit - Set level of Dummy Slow (Mocking Shout) for (Last created unit) to (Level of (Ability being cast) for (Triggering unit))
              • Unit - Order (Last created unit) to Human Sorceress - Slow (Picked unit)
              • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
            • Else - Actions
      • Custom script: call DestroyGroup(udg_MS_Group)
      • Custom script: call RemoveLocation(udg_MS_Point)
I know i have to shove a condition somewhere there, but i'm a rookie editor and i don't even know where to start!

Thanks in advance
 
Level 29
Joined
Feb 18, 2014
Messages
3,592
  • MS Slow
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Mocking Shout
    • Actions
      • Set MS_Point = (Position of (Casting unit))
      • Set MS_Group = (Units within 500.00 of MS_Point)
      • Unit Group - Pick every unit in MS_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to TRUE
              • ((Picked unit) is A structure) Equal to FALSE
              • ((Picked unit) is Magic Immune) Equal to FALSE
              • ((Picked unit) belongs to an enemy of (Owner of (Casting unit))) Equal to TRUE
            • Then - Actions
              • Set MS_Picked = (Position of (Picked unit))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Acos((Cos(((Angle from MS_Point to MS_Picked) - (Facing of (Picked unit))))))) Lesser than 90.00
                • Then - Actions
                  • Unit - Create 1 Dummy Unit for Neutral Passive at MS_Point facing Default building facing degrees
                  • Unit - Set level of Dummy Slow (Mocking Shout) for (Last created unit) to (Level of (Ability being cast) for (Triggering unit))
                  • Unit - Order (Last created unit) to Human Sorceress - Slow (Picked unit)
                  • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
                • Else - Actions
            • Else - Actions
      • Custom script: call RemoveLocation (udg_MS_Point)
      • Custom script: call RemoveLocation (udg_MS_Picked)
      • Custom script: call DestroyGroup (udg_MS_Group)
 
Last edited:
Level 7
Joined
Jul 21, 2019
Messages
177
Hello and thanks for answering!, i added that variable and condition, but it doesn't seem to work as intended, units get slowed all the time, even when they are facing the caster, here is my trigger and a screenshot:

  • MS Slow
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mocking Shout
    • Actions
      • Set MS_Point = (Position of (Casting unit))
      • Set MS_Group = (Units within 500.00 of MS_Point)
      • Unit Group - Pick every unit in MS_Group and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is Magic Immune) Equal to False
              • ((Picked unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True
            • Then - Actions
              • Set MS_Picked = (Position of (Picked unit))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Acos((Cos((Angle from MS_Point to MS_Picked))))) - (Facing of (Picked unit))) Less than 90.00
                • Then - Actions
                  • Unit - Create 1 Dummy Unit for Neutral Passive at MS_Point facing Default building facing degrees
                  • Unit - Set level of Dummy Slow (Mocking Shout) for (Last created unit) to (Level of (Ability being cast) for (Triggering unit))
                  • Unit - Order (Last created unit) to Human Sorceress - Slow (Picked unit)
                  • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
                • Else - Actions
            • Else - Actions
      • Custom script: call DestroyGroup(udg_MS_Group)
      • Custom script: call RemoveLocation (udg_MS_Picked)
      • Custom script: call RemoveLocation(udg_MS_Point)
Screenshot:

mass slow.gif

*units with a chicken on their head are slowed*

please help!


EDIT: further testing gave me new results:

Here it worked for an enemy who was directly facing the caster:
mass slow3.png


I don't really know what's going on in this one
mass slow2.gif
 
Last edited:
Level 10
Joined
Dec 11, 2009
Messages
234
  • (Acos((Cos(((Angle from MS_Point to MS_Picked) - (Facing of (Picked unit))))))) Lesser than 90.00
  • ((Acos((Cos((Angle from MS_Point to MS_Picked))))) - (Facing of (Picked unit))) Less than 90.00
You got it in the wrong order:
JASS:
AcosBJ( CosBJ(angle - facing) ) // <-- from example above
AcosBJ( CosBJ(angle) ) - facing // <-- yours
 
Level 7
Joined
Jul 21, 2019
Messages
177
Huh my bad, i'm new at this i know i'm prone to make retarded mistakes, thank you, will report back if i still can't figure it out lol

EDIT: IT WORKS NOW THANKS!!!!
 
Last edited:
Status
Not open for further replies.
Top