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

Facing units

Status
Not open for further replies.
call SetUnitFacing(unit1, GetUnitFacing(unit2) + 180)

given that one is facing the other

if one isn't facing the other, set angle = Atan2(GetUnitY(unit2) - GetUnitY(unit1), GetUnitX(unit2) - GetUnitX(unit1))*180/bj_PI

then
call SetUnitFacing(unit2, angle)

then do the +180 for unit1

note
I may have them backwards for the angle, so if that's the case, then swap unit1 and unit2 in the SetUnitFacing

edit
doing 3D?

http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/spherical-coordinates-195844/
 
Level 18
Joined
May 11, 2012
Messages
2,103
yeah, i also though i needed to put tht +180. Lemme see how it works

not working :O

  • Intiminating Body Paralyze and Damage
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set IB_TrigUnitLoc = (Position of IB_TrigUnit)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 400.00 of IB_TrigUnitLoc) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Facing of IB_TrigUnit) Equal to ((Facing of (Picked unit)) + 180.00)
              • ((Picked unit) belongs to an enemy of (Owner of IB_TrigUnit)) Equal to True
              • (Level of (Picked unit)) Less than or equal to 10
              • ((Picked unit) is alive) Equal to True
            • Then - Actions
              • Unit - Create 1 Dummy Intiminated Body for (Owner of IB_TrigUnit) at IB_TrigUnitLoc facing Default building facing degrees
              • Unit - Add Dummy Intiminating Body to (Last created unit)
              • Unit - Set level of Dummy Intiminating Body for (Last created unit) to (Level of Intiminating Body for IB_TrigUnit)
              • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A Hero) Not equal to True
                • Then - Actions
                  • For each (Integer A) from 1 to 5, do (Actions)
                    • Loop - Actions
                      • Unit - Cause IB_TrigUnit to damage (Picked unit), dealing (10.00 x (Real((Integer A)))) damage of attack type Spells and damage type Normal
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is A Hero) Equal to True
                    • Then - Actions
                      • For each (Integer A) from 1 to 5, do (Actions)
                        • Loop - Actions
                          • Unit - Cause IB_TrigUnit to damage (Picked unit), dealing (5.00 + (Real((Integer A)))) damage of attack type Spells and damage type Normal
                    • Else - Actions
              • Special Effect - Create a special effect attached to the hand,left of (Picked unit) using Abilities\Spells\Undead\DeathCoil\DeathCoilSpecialArt.mdl
              • Special Effect - Destroy (Last created special effect)
              • Special Effect - Create a special effect attached to the hand,right of (Picked unit) using Abilities\Spells\Undead\DeathCoil\DeathCoilSpecialArt.mdl
              • Special Effect - Destroy (Last created special effect)
              • Special Effect - Create a special effect attached to the overhead of (Picked unit) using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
              • Special Effect - Destroy (Last created special effect)
            • Else - Actions
      • Custom script: call RemoveLocation(udg_IB_TrigUnitLoc)
this:
  • (Facing of IB_TrigUnit) Equal to ((Facing of (Picked unit)) + 180.00)
i need to be like when he faces the picked unit
 
Last edited by a moderator:
Level 37
Joined
Mar 6, 2006
Messages
9,243
Facings are not accurate, if you order a unit to face 90 angle, it might face an angle of 89,45 in the end.

  • BS3 Copy
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set u1 = (Attacking unit)
      • Set u2 = (Attacked unit)
      • Set p1 = (Position of u1)
      • Set p2 = (Position of u2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • // Use one or the other condition
          • (Cos(((Angle from p1 to p2) - (Facing of u1)))) Less than 0.00
          • (Acos((Cos(((Angle from p1 to p2) - (Facing of u1)))))) Greater than 90.00
        • Then - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: Not facing
        • Else - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: Facing
      • Custom script: call RemoveLocation(udg_p1)
      • Custom script: call RemoveLocation(udg_p2)
 
Status
Not open for further replies.
Top