• 🏆 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!

CIRCLES, WHY DO YOU NOT WORK /begforhelpthread

Status
Not open for further replies.
Level 12
Joined
Oct 10, 2009
Messages
438
Righto, So I'm trying to make a "Homing missile" attack, which in this case is a golden beardfist. The problem is that it just does not work.

Now then, my logic may be worse than a mules ass (Not talking about its parents). So this is where I come to ask you guys for some help.

Basically, I'm trying to simulate a homing effect on this (Non mui) missile so that it slowly turns to face what it is hitting, while it is flying. I cannot use "Make unit face X over Y" for several different reasons, and unless you could allow it to loop around the unit and hit it several times, I'm afraid it wont do...

ANYWAY, ONWARDS WITH THE TRIGGERS!

Map is attached. Requires UMSWE
  • Golden Beardfist
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Golden Beardfist
    • Actions
      • Do Multiple ActionsFor each (Integer A) from 0 to 12, do (Actions)
        • Loop - Actions
          • Set GBFint[(Integer A)] = 0
          • Set GBFtarget[(Integer A)] = No unit
      • Set GBFtarget[0] = (Triggering unit)
      • Set GBFtarget[1] = (Target unit of ability being cast)
      • Set Point[0] = (Position of GBFtarget[0])
      • Set Point[1] = (Position of GBFtarget[1])
      • Unit - Create 1 NeckFist for (Owner of (Triggering unit)) at Point[0] facing Point[1]
      • Set GBFtarget[2] = (Last created unit)
      • Custom script: call RemoveLocation(udg_Point[0])
      • Custom script: call RemoveLocation(udg_Point[1])
      • Trigger - Turn on Golden Bearfist Loop <gen>
  • Golden Bearfist Loop
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Set GBFint[0] = (GBFint[0] + 1)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • DBInt[1] Equal to (==) 150
          • Then - Actions
          • Else - Actions
            • Set GBFint[1] = (GBFint[1] + 1)
      • Set Point[0] = (Position of GBFtarget[0])
      • Set Point[1] = (Position of GBFtarget[1])
      • Set Point[2] = (Position of GBFtarget[2])
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • GBFint[2] Equal to (==) 0
            • GBFint[3] Not equal to (!=) 3
          • Then - Actions
            • Set Point[3] = (Point[2] offset by ((Real(GBFint[1])) / 4.00) towards (Facing of GBFtarget[2]) degrees)
            • Set TempReal[0] = ((Angle from Point[3] to Point[1]) - (Facing of GBFtarget[2]))
            • Game - Display to (All players) the text: (String(TempReal[0]))
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Multiple ConditionsOr - Any (Conditions) are true
                    • Conditions
                      • TempReal[0] Greater than (>) 0.00
                        • Multiple ConditionsAnd - All (Conditions) are true
                          • Conditions
                            • TempReal[0] Less than (<) -360.00
                            • TempReal[0] Greater than (>) -720.00
                        • Multiple ConditionsAnd - All (Conditions) are true
                          • Conditions
                            • TempReal[0] Less than (<) -1440.00
                            • TempReal[0] Greater than (>) -1800.00
                • Then - Actions
                  • Unit - Move GBFtarget[2] instantly to Point[3], facing ((Facing of GBFtarget[2]) + 5.00) degrees
                • Else - Actions
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • TempReal[0] Less than (<) 0.00
                    • Then - Actions
                      • Unit - Move GBFtarget[2] instantly to Point[3], facing ((Facing of GBFtarget[2]) - 5.00) degrees
                    • Else - Actions
                      • Unit - Move GBFtarget[2] instantly to Point[3], facing (Facing of GBFtarget[2]) degrees
            • Unit - Create 1 Flying Fist FX 1 for (Owner of GBFtarget[1]) at Point[3] facing Point[2]
            • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between Point[3] and Point[1]) Less than or equal to (<=) 90.00
                  • GBFint[4] Greater than or equal to (>=) 360
                • Then - Actions
                  • Game - Display to (All players) the text: Pre
                  • Set GBFint[2] = 1
                • Else - Actions
                  • Set GBFint[4] = (GBFint[4] + ((Integer(((Real(GBFint[1])) / 3.00))) + 0))
            • Custom script: call RemoveLocation(udg_Point[3])
          • Else - Actions
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • GBFint[2] Equal to (==) 1
              • Then - Actions
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • GBFint[3] Equal to (==) 3
                  • Then - Actions
                    • Game - Display to (All players) the text: End
                    • Unit - Remove GBFtarget[2] from the game
                    • Trigger - Turn off (This trigger)
                  • Else - Actions
                    • Sound - Play MetalHeavyBashStone1 <gen> at 100.00% volume, located at Point[1] with Z offset 0.00
                    • Game - Display to (All players) the text: HIT!
                    • Set GBFint[2] = 0
                    • Set GBFint[3] = (GBFint[3] + 1)
                    • Game - Display to (All players) the text: (String(GBFint[3]))
                    • Set GBFint[4] = 0
                    • Unit - Cause GBFtarget[0] to damage GBFtarget[1], dealing 80.00 damage of attack type Spells and damage type Magic
              • Else - Actions
      • Custom script: call RemoveLocation(udg_Point[0])
      • Custom script: call RemoveLocation(udg_Point[1])
      • Custom script: call RemoveLocation(udg_Point[2])
 

Attachments

  • WSBRedone11PROT.w3x
    7.6 MB · Views: 27
Level 37
Joined
Mar 6, 2006
Messages
9,240
Facing angle returns values from 0 to 360.
Angle between points returns values from -180 to 180
You can get angle difference with
  • (Acos((Cos(((Angle from p1 to p2) - (Facing of u1)))))) Greater than x

  • BS3 Copy Copy
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set u1 = Paladin 0003 <gen>
      • Set u2 = Paladin 0002 <gen>
      • 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
          • (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)

Your TempReal[0] conditions are a bit off.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • BS3 Copy Copy
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set u1 = Paladin 0003 <gen>
      • Set u2 = Paladin 0002 <gen>
      • Set p1 = (Position of u1)
      • Set p2 = (Position of u2)
      • Set r1 = (Angle from p1 to p2)
      • Set r2 = ((Facing of u1) - 90.00)
      • Set r3 = (Cos((r1 - r2)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • r3 Less than 0.00
        • Then - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: Turn left
        • Else - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: Turn right
      • Custom script: call RemoveLocation(udg_p1)
      • Custom script: call RemoveLocation(udg_p2)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
:)

Note that if a unit is ordered to face angle x, it will not face it accurately in the end.

For example if a unit is ordered to face an angle of 100, it might have facing of 99.46 after it stops turning. This could lead the unit to wiggle from left to right when it seems to face the unit, but I'm not sure. If this happens, you need to add tolerance to the angle difference.


  • BS3 Copy Copy
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set u1 = Paladin 0003 <gen>
      • Set u2 = Paladin 0002 <gen>
      • Set p1 = (Position of u1)
      • Set p2 = (Position of u2)
      • Set r1 = (Angle from p1 to p2)
      • Set r2 = (Facing of u1)
      • Set r3 = (Cos((r1 - r2)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • r3 Greater than or equal to 0.95
        • Then - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: Facing withing tole...
        • Else - Actions
          • Set r2 = (r2 - 90.00)
          • Set r3 = (Cos((r1 - r2)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • r3 Less than 0.00
            • Then - Actions
              • Game - Display to Player Group - Player 1 (Red) the text: Left
            • Else - Actions
              • Game - Display to Player Group - Player 1 (Red) the text: Right
      • Custom script: call RemoveLocation(udg_p1)
      • Custom script: call RemoveLocation(udg_p2)
 
Status
Not open for further replies.
Top