• 🏆 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!
  • ✅ HD Level Design Contest #1 POLL is now OPEN! Check out the stunning visuals of the final entries. 🔗Click here to cast your vote!

Set unit X/Y

Status
Not open for further replies.
Level 13
Joined
Oct 16, 2010
Messages
731
So I have an interesting bug...

I have used the set x/y custom scripts to make some dummy units circle my caster but still be able to attack as their commands won't be changed.

This is all functioning correctly minus that the actual dummies don't move, well... they do.. but they don't? I can see their shadows moving correcly and they shoot from the correct locations, but their physical models don't move?? I've put my trigger below...

  • Drone Swarm Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • For each (Integer DroneSwarm_LoopInt) from 1 to DroneSwarm_MaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DroneSwarm_Duration[DroneSwarm_LoopInt] Less than or equal to 0.00
            • Then - Actions
              • -------- DEINDEX --------
              • Unit - Add a 0.01 second Generic expiration timer to DroneSwarm_DummyUnit[DroneSwarm_LoopInt]
              • Set VariableSet DroneSwarm_Angle[DroneSwarm_LoopInt] = DroneSwarm_Angle[DroneSwarm_MaxIndex]
              • Set VariableSet DroneSwarm_CasterUnit[DroneSwarm_LoopInt] = DroneSwarm_CasterUnit[DroneSwarm_MaxIndex]
              • Set VariableSet DroneSwarm_DummyUnit[DroneSwarm_LoopInt] = DroneSwarm_DummyUnit[DroneSwarm_MaxIndex]
              • Set VariableSet DroneSwarm_Duration[DroneSwarm_LoopInt] = DroneSwarm_Duration[DroneSwarm_MaxIndex]
              • Set VariableSet DroneSwarm_MaxIndex = (DroneSwarm_MaxIndex - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DroneSwarm_MaxIndex Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
                  • Set VariableSet DroneSwarm_LoopInt = (DroneSwarm_LoopInt - 1)
            • Else - Actions
              • Set VariableSet DroneSwarm_Duration[DroneSwarm_LoopInt] = (DroneSwarm_Duration[DroneSwarm_LoopInt] - 0.05)
              • Set VariableSet DroneSwarm_Angle[DroneSwarm_LoopInt] = (DroneSwarm_Angle[DroneSwarm_LoopInt] + 1.00)
              • Set VariableSet TempPoint = (Position of DroneSwarm_CasterUnit[DroneSwarm_LoopInt])
              • Set VariableSet TempPoint2 = (TempPoint offset by 300.00 towards DroneSwarm_Angle[DroneSwarm_LoopInt] degrees.)
              • Custom script: call SetUnitX(udg_DroneSwarm_DummyUnit[udg_DroneSwarm_LoopInt], GetLocationX(udg_TempPoint2))
              • Custom script: call SetUnitY(udg_DroneSwarm_DummyUnit[udg_DroneSwarm_LoopInt], GetLocationY(udg_TempPoint2))
              • Custom script: call RemoveLocation(udg_TempPoint)
              • Custom script: call RemoveLocation(udg_TempPoint2)
 
Level 23
Joined
Apr 3, 2018
Messages
456
SetUnitPosition is "move unit" that interrupts attacks, which is why I only do it once every few seconds, and use SetUnitX/Y otherwise.

Moving the unit properly in this way not only stops whatever it was doing, but also resets the unit's AI's countdown for returning after straying from its position. So long as I keep resetting the countdown before it expires, the dummies wont run back.
 
Level 23
Joined
Apr 3, 2018
Messages
456
It's because units don't get orders for automatic actions from their AI. Like acquiring targets, attacking, returning to guard position, etc.

You can have a unit running or fighting someone all the while its current order being empty "". Or a unit ordered to attack will have the "attack" order even while running in pursuit if its target, not actually attacking.
 
Status
Not open for further replies.
Top