• 🏆 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!
  • ✅ HD Level Design Contest #1 POLL is now OPEN! Check out the stunning visuals of the final entries. 🔗Click here to cast your vote!

[Solved] Translating 46 degrees into this formula

Not open for further replies.
Level 11
May 16, 2020
Hi guys,

I'm using the explanation from here (below the trigger) to identify a secondary target that is within a facing angle of a primary target.

@Dr Super Good wrote that one should rather use this formula:

It should be
  • (Cos((Sector facing - (Angle from Loc1 to Loc2)))) Greater than or equal to 0.766
Yes the simplification holds true but the 2 lines of code given do not produce the same result.

Can someone who understands how to calculate angles in WC3 explain what "0.766" in degrees is please?
I want the "angle of sector origin" to be 46 degrees. What value is the equivalent of this with the formula above?
(and can I somehow calculate this in Excel for next time?)


Anyway, here's how to pick units within circular sector
  • Set Loc1 = <Circle origin point>
  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Units within 600.00 (<Circle radius>) of Loc1 matching (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)) and do (Actions)
    • Loop - Actions
      • Set Loc2 = (Position of (Picked unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Acos((Cos((<Circular sector facing> - (Angle from Loc1 to Loc2)))))) Less than or equal to <40.00> - half of the angle at sector origin
        • Then - Actions
          • //Put actions for units within sector here
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Loc2)
  • Custom script: call RemoveLocation(udg_Loc1)

Not open for further replies.