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

[Trigger] Problematic Motion Order

Status
Not open for further replies.
Level 3
Joined
Feb 5, 2011
Messages
17
Hi guys, I've got a weird problem with making unit move specific distance.
I want him to march SMOOTHLY and EXACTLY into middle of nearby tile after pressing an arrow key. At the moment unit is moving too short.

There goes the trigger: (there are separate triggers for each arrow and player)

  • Red Up
    • Events
      • Player - Player 1 (Red) Presses the Up Arrow key
    • Conditions
    • Actions
      • Set TempLoc1 = (Position of Footman 0000 <gen>)
      • Set TempLoc2 = (TempLoc1 offset by (0.00, 128.00))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain type at TempLoc2) Not equal to Lordaeron Summer - Rock
        • Then - Actions
          • Trigger - Turn off Red Left <gen>
          • Trigger - Turn off Red Right <gen>
          • Trigger - Turn off Red Down <gen>
          • Trigger - Turn off Red Up <gen>
          • Unit - Order Footman 0000 <gen> to Move To TempLoc2
          • Wait (128.00 / (Current movement speed of Footman 0000 <gen>)) seconds
          • Game - Display to (All players) the text: (Debug Message: Distance to Circle of Power: + (String((Distance between (Position of Footman 0000 <gen>) and (Position of Circle of Power 0001 <gen>)))))
          • Trigger - Turn on Red Left <gen>
          • Trigger - Turn on Red Right <gen>
          • Trigger - Turn on Red Down <gen>
          • Trigger - Turn on Red Up <gen>
        • Else - Actions
          • Unit - Make Footman 0000 <gen> face 90.00 over 0.50 seconds
      • Custom script: call RemoveLocation(udg_TempLoc1)
      • Custom script: call RemoveLocation(udg_TempLoc2)
I tried many different solutions - none satisfy me enough. Any ideas?
 

Attachments

  • Arrow Movement.w3x
    20.6 KB · Views: 54
Level 3
Joined
Feb 5, 2011
Messages
17
Noticed another problem. After expanding the trigger i fount out that killing an enemy makes unit return to its starting position. Issuing Stop order every tile doesn't help, but its required to abandon attacking.

Also: sometimes for unknown reason units start march and never stops.

New map uploaded to this reply.

  • Initalization
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Hero[1] = Footman 0000 <gen>
      • Set Hero[2] = Footman 0001 <gen>
      • Set Hero[3] = Footman 0005 <gen>
      • Set Hero[4] = Footman 0006 <gen>
      • Unit - Create 1 Cursor for Player 11 (Dark Green) at (Position of Hero[1]) facing Default building facing degrees
      • Set Cursor[(Custom value of Hero[1])] = (Last created unit)
      • Unit - Create 1 Cursor for Player 11 (Dark Green) at (Position of Hero[2]) facing Default building facing degrees
      • Set Cursor[(Custom value of Hero[2])] = (Last created unit)
      • Unit - Create 1 Cursor for Player 11 (Dark Green) at (Position of Hero[3]) facing Default building facing degrees
      • Set Cursor[(Custom value of Hero[3])] = (Last created unit)
      • Unit - Create 1 Cursor for Player 11 (Dark Green) at (Position of Hero[4]) facing Default building facing degrees
      • Set Cursor[(Custom value of Hero[4])] = (Last created unit)
      • Unit Group - Add Hero[1] to PassableUnits
      • Unit Group - Add Hero[2] to PassableUnits
      • Unit Group - Add Hero[3] to PassableUnits
      • Unit Group - Add Hero[4] to PassableUnits
      • Camera - Apply Camera 001 <gen> for Player 1 (Red) over 0.00 seconds
      • Camera - Apply Camera 001 <gen> for Player 2 (Blue) over 0.00 seconds
      • Camera - Apply Camera 001 <gen> for Player 3 (Teal) over 0.00 seconds
      • Camera - Apply Camera 001 <gen> for Player 4 (Purple) over 0.00 seconds
      • Camera - Lock camera target for Player 1 (Red) to Hero[1], offset by (0.00, 0.00) using Default rotation
      • Camera - Lock camera target for Player 2 (Blue) to Hero[2], offset by (0.00, 0.00) using Default rotation
      • Camera - Lock camera target for Player 3 (Teal) to Hero[3], offset by (0.00, 0.00) using Default rotation
      • Camera - Lock camera target for Player 4 (Purple) to Hero[4], offset by (0.00, 0.00) using Default rotation
      • Unit - Change color of Hero[1] to Red
      • Unit - Change color of Hero[2] to Blue
      • Unit - Change color of Hero[3] to Teal
      • Unit - Change color of Hero[4] to Purple
      • Set Speed[(Custom value of Hero[1])] = 10.00
      • Set Speed[(Custom value of Hero[2])] = 8.00
      • Set Speed[(Custom value of Hero[3])] = 6.00
      • Set Speed[(Custom value of Hero[4])] = 4.00
      • Player - Make Player 11 (Dark Green) treat Player 1 (Red) as an Ally with shared vision
      • Player - Make Player 1 (Red) treat Player 11 (Dark Green) as an Ally with shared vision
  • Order Left
    • Events
      • Player - Player 1 (Red) Presses the Left Arrow key
      • Player - Player 2 (Blue) Presses the Left Arrow key
      • Player - Player 3 (Teal) Presses the Left Arrow key
      • Player - Player 4 (Purple) Presses the Left Arrow key
      • Player - Player 5 (Yellow) Presses the Left Arrow key
      • Player - Player 6 (Orange) Presses the Left Arrow key
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Hero[(Player number of (Triggering player))] is in MovingUnits) Equal to False
        • Then - Actions
          • Set TempUnit = Hero[(Player number of (Triggering player))]
          • Set TempInteger = (Custom value of TempUnit)
          • Set TempLoc1 = (Position of TempUnit)
          • Set MoveTo[TempInteger] = (TempLoc1 offset by (-128.00, 0.00))
          • Set TempUnitGroup = (Units within 60.00 of MoveTo[TempInteger] matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) is in PassableUnits) Equal to False)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in TempUnitGroup) Equal to 0
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain type at MoveTo[TempInteger]) Not equal to Lordaeron Summer - Rock
                • Then - Actions
                  • Game - Display to (All players) the text: (Player + ((String((Player number of (Triggering player)))) + ( has triggered + ((Name of the current trigger) + and succesfuly moved.))))
                  • Unit - Order TempUnit to Stop
                  • Unit - Move Cursor[TempInteger] instantly to MoveTo[TempInteger]
                  • Set Angle[TempInteger] = Pi
                  • Trigger - Turn on Motion <gen>
                  • Unit Group - Add TempUnit to MovingUnits
                  • Unit - Make TempUnit face MoveTo[TempInteger] over 0.00 seconds
                  • Custom script: call SetUnitAnimationByIndex(udg_TempUnit, 6)
                • Else - Actions
                  • Game - Display to (All players) the text: (Player + ((String((Player number of (Triggering player)))) + ( has triggered + ((Name of the current trigger) + and hit the rock.))))
            • Else - Actions
              • Set TempUnit2 = (Random unit from TempUnitGroup)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of TempUnit2) Equal to Player 12 (Brown)
                • Then - Actions
                  • Unit - Order TempUnit to Attack TempUnit2
                  • Game - Display to (All players) the text: (Player + ((String((Player number of (Triggering player)))) + ( has triggered + ((Name of the current trigger) + and attacked an enemy.))))
                • Else - Actions
                  • Game - Display to (All players) the text: (Player + ((String((Player number of (Triggering player)))) + ( has triggered + ((Name of the current trigger) + and spoted obstacle.))))
          • Custom script: call DestroyGroup(udg_TempUnitGroup)
          • Custom script: call RemoveLocation(udg_TempLoc1)
        • Else - Actions
          • Game - Display to (All players) the text: (Player + ((String((Player number of (Triggering player)))) + ( has triggered + ((Name of the current trigger) + and seem to be already moving))))
  • Motion
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in MovingUnits and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • Set TempInteger = (Custom value of TempUnit)
          • Set TempLoc3 = (Position of TempUnit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between MoveTo[TempInteger] and TempLoc3) Less than or equal to Speed[TempInteger]
            • Then - Actions
              • Custom script: call SetUnitX(udg_TempUnit, GetLocationX(udg_MoveTo[udg_TempInteger]))
              • Custom script: call SetUnitY(udg_TempUnit, GetLocationY(udg_MoveTo[udg_TempInteger]))
              • Animation - Play TempUnit's stand animation
              • Unit Group - Remove TempUnit from MovingUnits
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in MovingUnits) Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
              • Animation - Queue TempUnit's stand animation
              • Trigger - Turn on Order Left <gen>
              • Trigger - Turn on Order Right <gen>
              • Trigger - Turn on Order Down <gen>
              • Trigger - Turn on Order Up <gen>
              • Custom script: call RemoveLocation(udg_MoveTo[udg_TempInteger])
            • Else - Actions
              • Custom script: call SetUnitX(udg_TempUnit, GetUnitX(udg_TempUnit) + udg_Speed[udg_TempInteger] * Cos(udg_Angle[udg_TempInteger]))
              • Custom script: call SetUnitY(udg_TempUnit, GetUnitY(udg_TempUnit) + udg_Speed[udg_TempInteger] * Sin(udg_Angle[udg_TempInteger]))
      • Custom script: call RemoveLocation(udg_TempLoc3)
 

Attachments

  • Arrow Movement2.w3x
    35.6 KB · Views: 87
Status
Not open for further replies.
Top