• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Spell] Making a unit face an angel or direction

Status
Not open for further replies.
Level 2
Joined
Nov 5, 2014
Messages
23
Im working on a spell that summons a visible dummy unit behind the caster and follows the caster around during its duration but the problem is how to make the "dummy unit" face into the direction of the caster every second using custom scripts?
 
Last edited:
Level 10
Joined
Apr 4, 2010
Messages
509
  • Melee Initialization
    • Events
    • Conditions
    • Actions
      • Set Point[1] = (Position of Caster)
      • Set Point[2] = (Position of Follower)
      • Set Angle = (Angle from Point[1] to Point[2])
      • Unit - Make Follower face Angle over 0.00 seconds
      • -------- -------------------------------- --------
      • Set Point[1] = (Position of Caster)
      • Unit - Make Follower face Point[1] over 0.00 seconds
      • -------- -------------------------------- --------
      • Unit - Make Follower face Caster over 0.00 seconds
      • -------- -------------------------------- --------
      • Set Point[1] = (Position of Caster)
      • Set Point[2] = (Position of Follower)
      • Unit - Move Follower instantly to Point[2], facing Point[1]
      • -------- -------------------------------- --------
      • Set Point[1] = (Position of Caster)
      • Set Point[2] = (Position of Follower)
      • Set Angle = (Angle from Point[1] to Point[2])
      • Unit - Move Follower instantly to Point[2], facing Angle degrees
I didn't clear the leaks.
 
Level 2
Joined
Nov 5, 2014
Messages
23
  • Melee Initialization
    • Events
    • Conditions
    • Actions
      • Set Point[1] = (Position of Caster)
      • Set Point[2] = (Position of Follower)
      • Set Angle = (Angle from Point[1] to Point[2])
      • Unit - Make Follower face Angle over 0.00 seconds
      • -------- -------------------------------- --------
      • Set Point[1] = (Position of Caster)
      • Unit - Make Follower face Point[1] over 0.00 seconds
      • -------- -------------------------------- --------
      • Unit - Make Follower face Caster over 0.00 seconds
      • -------- -------------------------------- --------
      • Set Point[1] = (Position of Caster)
      • Set Point[2] = (Position of Follower)
      • Unit - Move Follower instantly to Point[2], facing Point[1]
      • -------- -------------------------------- --------
      • Set Point[1] = (Position of Caster)
      • Set Point[2] = (Position of Follower)
      • Set Angle = (Angle from Point[1] to Point[2])
      • Unit - Move Follower instantly to Point[2], facing Angle degrees
I didn't clear the leaks.


gonna try this for now, ill take care of the leaks

Thnx for replying heres what i did

  • Dr 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Drone
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Drone_Has[Drone_LastRecycled] Equal to True
        • Then - Actions
          • Set Drone_Max = (Drone_Max + 1)
          • Set Drone_Index = Drone_Max
        • Else - Actions
          • Set Drone_Index = Drone_LastRecycled
          • Set Drone_LastRecycled = Drone_RecycledList[Drone_LastRecycled]
      • -------- ----------------------------------- --------
      • Set Drone_Caster[Drone_Index] = (Triggering unit)
      • Set Drone_Point[Drone_Index] = (Position of Drone_Caster[Drone_Index])
      • -------- ----------------------------------- --------
      • Unit - Create 1 Drone Dummy for (Owner of Drone_Caster[Drone_Index]) at (Drone_Loc[Drone_Index] offset by 300.00 towards 180.00 degrees) facing Default building facing degrees
      • -------- ----------------------------------- --------
      • Set Drone_TempUnit[Drone_Index] = (Last created unit)
      • Set Drone_Loc[Drone_Index] = (Position of Drone_TempUnit[Drone_Index])
      • -------- ----------------------------------- --------
      • Set Drone_Angel[Drone_Index] = (Angle from Drone_Loc[Drone_Index] to Drone_Point[Drone_Index])
      • -------- ----------------------------------- --------
      • Unit - Make Drone_TempUnit[Drone_Index] face Drone_Angel[Drone_Index] over 0.00 seconds
      • Unit - Make Drone_TempUnit[Drone_Index] face Drone_Point[Drone_Index] over 0.00 seconds
      • -------- ----------------------------------- --------
      • Set Drone_Has[Drone_Index] = True
      • Set Drone_Count = (Drone_Count + 1)
      • Set Drone_Timer[Drone_Index] = (10.00 x (Real((Level of Drone for Drone_Caster[Drone_Index]))))
      • -------- ----------------------------------- --------
      • Custom script: call RemoveLocation (udg_Drone_Point[udg_Drone_Index])
      • Custom script: call RemoveLocation (udg_Drone_Loc[udg_Drone_Index])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Dr Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Dr Loop <gen>
        • Else - Actions
  • Dr Loop 2
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Drone_Integer) from 0 to Drone_Max, do (Actions)
        • Loop - Actions
          • Set Drone_Point[Drone_Integer] = (Position of Drone_Caster[Drone_Integer])
          • Set Drone_Loc[Drone_Integer] = (Position of Drone_TempUnit[Drone_Integer])
          • Set Drone_Angel[Drone_Integer] = (Angle from Drone_Loc[Drone_Integer] to Drone_Point[Drone_Integer])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Drone_Has[Drone_Integer] Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Drone_Timer[Drone_Integer] Greater than 0.00
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Drone_Caster[Drone_Index] is dead) Equal to True
                    • Then - Actions
                      • Set Drone_Timer[Drone_Index] = 0.00
                    • Else - Actions
                      • Set Drone_Timer[Drone_Integer] = (Drone_Timer[Drone_Integer] - 0.03)
                      • Unit - Make Drone_TempUnit[Drone_Integer] face Drone_Angel[Drone_Integer] over 0.00 seconds
                      • Unit - Make Drone_TempUnit[Drone_Integer] face Drone_Point[Drone_Integer] over 0.00 seconds
                      • Unit - Move Drone_TempUnit[Drone_Integer] instantly to Drone_Point[Drone_Integer], facing Drone_Angel[Drone_Integer] degrees
                      • Custom script: call RemoveLocation (udg_Drone_Point[udg_Drone_Integer])
                      • Custom script: call RemoveLocation (udg_Drone_Loc[udg_Drone_Integer])
                • Else - Actions
                  • -------- ----------------------------------- --------
                  • Set Drone_Count = (Drone_Count - 1)
                  • Set Drone_Has[Drone_Integer] = False
                  • Set Drone_RecycledList[Drone_Integer] = Drone_LastRecycled
                  • Set Drone_LastRecycled = Drone_Integer
                  • -------- ----------------------------------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Drone_Count Equal to 0
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                      • For each (Integer A) from 0 to Drone_Max, do (Set Drone_RecycledList[(Integer A)] = 0)
                      • Set Drone_LastRecycled = 0
                      • Set Drone_Max = 0
                    • Else - Actions
            • Else - Actions
not sure if all leaks are clear now but
It works but i got new problems now
1st is when "Caster" attacks a enemie unit, The "Follower" faces back behind the "Caster".
2nd is how do i determine the location in which the "Follower" spawns? cause i wanted it to be atleast 100 behind the "Caster" but in this trigger it spawns Above the "Caster"..
 
Last edited by a moderator:
Level 24
Joined
Aug 1, 2013
Messages
4,657
DEE-BOO gave you 5 examples of how you could do it.
You should pick only one instead of using multiple of those.

So you pick one out of these:
  • Set Point[1] = (Position of Caster)
  • Set Point[2] = (Position of Follower)
  • Set Angle = (Angle from Point[1] to Point[2])
  • Unit - Make Follower face Angle over 0.00 seconds
  • Set Point[1] = (Position of Caster)
  • Unit - Make Follower face Point[1] over 0.00 seconds
  • Unit - Make Follower face Caster over 0.00 seconds
  • Set Point[1] = (Position of Caster)
  • Set Point[2] = (Position of Follower)
  • Unit - Move Follower instantly to Point[2], facing Point[1]
  • Set Point[1] = (Position of Caster)
  • Set Point[2] = (Position of Follower)
  • Set Angle = (Angle from Point[1] to Point[2])
  • Unit - Move Follower instantly to Point[2], facing Angle degrees
So every time that you make the unit face a certain direction or point and then make it face that same direction, then you do all the work multiple times.
 
Status
Not open for further replies.
Top