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

Modulo for behind a unit

Status
Not open for further replies.
Level 8
Joined
Apr 30, 2009
Messages
338
I am not very sure about how to use Modulo, and I want my ability to do 35 damage normally, 75 from behind (a backstab attack).

I want to use modulo to check if the casting unit's location is relative to the target's facing angle. Like this:

fx5dvo.jpg
 
I'd do something like this:
  • Bleh
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Death Coil
    • Actions
      • Set CastLoc = (Position of (Triggering unit))
      • Set TarLoc = (Position of (Target unit of ability being cast))
      • Set Angle = (Angle from CastLoc to TarLoc)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • Angle Greater than or equal to (((Facing of (Triggering unit)) + 105.00) mod 360.00)
              • Angle Less than or equal to (((Facing of (Triggering unit)) - 105.00) mod 360.00)
        • Then - Actions
        • Else - Actions
      • Custom script: call RemoveLocation(udg_CastLoc)
      • Custom script: call RemoveLocation(udg_TarLoc)
Untested though. I might've made some mistake, not sure.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
You should be doing "Greater than (Facing of unit) - 105" and "Less than (Facing of unit) + 105", though 105 (times 2, for each interval) is way too large of a range. Perhaps something around 40 would be more suitable (means 80 degrees of leniency).
 
Level 8
Joined
Apr 30, 2009
Messages
338
I need to use Modulo though, because unit facing is 0 to 360 and angle between points is -180 to 180
 
I need to use Modulo though, because unit facing is 0 to 360 and angle between points is -180 to 180

Use:
  • Set Ang = ((Angle from (Position of (Triggering unit)) to (Position of (Triggering unit))) mod 360.00)
Leaks, but it is just an example. Basically, "angle" mod 360 is the function you're looking for.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
I haven't tested that modulo thingy, but this should work also.

  • (Cos(((Temp_Real_1) - (Angle from Temp_Loc_1 to Temp_Loc_2)))) Less than (Cos(105.00))
If this is true, then the unit is inside the area, backstabbing.

Temp_Real_1 = Facing of the unit to be backstabbed
Temp_Loc_1 = Position of the unit whose facing you use
Temp_Loc_2 = Position of the backstabbing unit
 
Status
Not open for further replies.
Top