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

Set unit X/Y

Status
Not open for further replies.
Level 14
Joined
Oct 16, 2010
Messages
749
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 27
Joined
Apr 3, 2018
Messages
499
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 27
Joined
Apr 3, 2018
Messages
499
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