Facing Angle and Angle Between Points

Zurtrogx

Active Member
Reaction score
24
When using "Facing Angle" it gives you a value between 0 and 360.
When using "Angle Between Points" it gives you a value between -180 and 180.

Is there a simple way to make "Angle Between Points" return a value between 0 to 360?
(Simple, as in not using If/Then/Else to check if it is between -180 and 0, then converting it to the appropriate value between 180 to 360)

EDIT: Preferably in GUI since I don't use JASS
EDIT: Actually, only GUI solutions. I've done a search and found a few JASS solutions, so no need to post them here.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
I think you want a IsUnitBehindUnit checker?
I quick Jass-->Gui convertion I made:

Trigger:
  • Actions:
    • Set TempReal1 = (Facing of UnitA)
    • Custom script: set udg_TempReal2 = bj_RADTODEG*Atan2(GetUnitY(udg_UnitB)-GetUnitY(udg_UnitA),GetUnitX(udg_UnitB)-GetUnitX(udg_UnitA))
    • Custom script: set udg_IsUnitBehindUnit = not (RAbsBJ(udg_TempReal1-udg_TempReal2) < 90 or RAbsBJ(udg_TempReal1-udg_TempReal2-360) < 90)

This sets the variable IsUnitBehindUnit to true or false, depending on the outcome.

You also need the real variables called TempReal1 and TempReal2, such as two unit variables UnitA and UnitB. The code checks wether UnitB is behind UnitA.

I recommend not to rebuild this with GUI directly and use this Custom Script variant, because it doesn't leak locations.
 

Zurtrogx

Active Member
Reaction score
24
Thanks, but that isn't what I was looking for.

Anyway, I managed to do it myself:
Trigger:
  • SPELL Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to SPELL
    • Actions
      • Set caster_point = (Position of (Triggering unit))
      • Set caster_point_offset = (caster_point offset by 1.00 towards (Facing of (Triggering unit)) degrees)
      • Set caster_angle = (Angle from caster_point to caster_point_offset)
      • Set targeted_units = (Units within 500.00 of caster_point matching ...
      • Unit Group - Pick every unit in targeted_units and do (Actions)
        • Loop - Actions
          • Set target_point = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Angle from caster_point to target_point) - caster_angle) Less than or equal to (0.00 + angle_variation)
              • ((Angle from caster_point to target_point) - caster_angle) Greater than or equal to (0.00 - angle_variation)
            • Then - Actions
              • Unit - Create 1 dummy for (Owner of (Triggering unit)) at caster_point facing (Facing of (Triggering unit)) degrees
              • Unit - Add SPELL (Unit) to (Last created unit)
              • Unit - Set level of SPELL (Unit) for (Last created unit) to (Level of SPELL for (Triggering unit))
              • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
              • Unit - Order (Last created unit) to USE AN APPROPRIATE ACTION (Picked unit)
            • Else - Actions
          • Custom script: call RemoveLocation (udg_target_point)
      • Custom script: call RemoveLocation (udg_caster_point)
      • Custom script: call RemoveLocation (udg_caster_point_offset)
      • Custom script: call DestroyGroup (udg_targeted_units)


angle_variation has a default value of 40.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
Why don't you learn Jass? It seems you are familiar with leaking and stuff. Why not try the next step?
 

Zurtrogx

Active Member
Reaction score
24
Why don't I learn JASS?
-I am in Year 12 at the moment, and will be having my end-of-year exams in about 3 weeks
-It takes too long
-Starcraft II is going to be released soon and it may (although I don't know for sure) take away lots of people from Warcraft 3, which may mean there won't be much point making Warcraft 3 maps

However, I did consider it, but never went through with it.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
Why don't I learn JASS?
-I am in Year 12 at the moment, and will be having my end-of-year exams in about 3 weeks
And still you got the time to map ...:D

-It takes too long
This is simply not true. Jass is not that much different from GUI, if you have Jasshelper. Just browse the function list and you can get everything you need.
GUI is just JASS in disguise.

-Starcraft II is going to be released soon and it may (although I don't know for sure) take away lots of people from Warcraft 3, which may mean there won't be much point making Warcraft 3 maps
Hmm, but you will map when SC2 releases? Isn't it practical to get experience with coding before SC2 comes out so you don't have to stick to SC2's GUI?
 

Grymlax

Probably not around
Reaction score
138
When using "Facing Angle" it gives you a value between 0 and 360.
When using "Angle Between Points" it gives you a value between -180 and 180.

Is there a simple way to make "Angle Between Points" return a value between 0 to 360?

just do ((Angle from point1 to point2) + 180.00) that should do the trick.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top