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

[Solved] Order a unit to have one target forever?

Status
Not open for further replies.
Level 14
Joined
Aug 8, 2010
Messages
1,022
Hello! Really quick&simple question. Is there a way to give an order to a unit that makes him have one target than never changes (or until one of the units dies)? You know, i give the magical order to a unit and tell it to attack another unit until it dies, no matter what happens to both units.
I know this can be accomplished by periodically ordering the unit to attack but it sometimes stops it's attack animation and looks dumb. The solution it's self is dumb.

Help is appreciated with +rep and stuff..
 
Level 37
Joined
Mar 6, 2006
Messages
9,243

  • KeepTarget
    • Events
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • Custom script: set udg_i = GetHandleId(GetTriggerUnit())
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (0 is stored as a Handle of i in tarht) Equal to True
        • Then - Actions
          • Set u = (Load 0 of i in tarht)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • u Not equal to (Target unit of issued order)
            • Then - Actions
              • Unit - Order (Triggering unit) to Attack u
            • Else - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target unit of issued order) Not equal to No unit
            • Then - Actions
              • Hashtable - Save Handle Of(Target unit of issued order) as 0 of i in tarht
            • Else - Actions
  • Test
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set g = (Units owned by Player 1 (Red))
      • Set u = (Random unit from g)
      • Unit Group - Remove u from g
      • Unit - Order u to Attack (Random unit from g)


Remember to initialize the hashtable. You could use a unit indexer also.
 

Attachments

  • KeepTarget.w3x
    13.2 KB · Views: 45
Status
Not open for further replies.
Top