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

Random Attack

Status
Not open for further replies.
Level 10
Joined
May 20, 2008
Messages
433
I've tried this many times, and nothing works. I'm trying to get a unit that enters the map randomly go and attack a random unit in a group, like in kodo tag, where a Kodo will randomly select a player to attack when it spanws. Here is what I have:
  • Unit Attack
    • Events
      • Unit - A unit enters Map <gen>
    • Conditions
      • Or-Any (Conditions) are true
        • Conditions
          • (Unit-type of (Entering unit)) Equal to UnitTypes[1]
          • (Unit-type of (Entering unit)) Equal to UnitTypes[2]
          • (Unit-type of (Entering unit)) Equal to UnitTypes[3]
          • (Unit-type of (Entering unit)) Equal to UnitTypes[4]
          • (Unit-type of (Entering unit)) Equal to UnitTypes[5]
          • (Unit-type of (Entering unit)) Equal to UnitTypes[6]
          • (Unit-type of (Entering unit)) Equal to UnitTypes[7]
    • Actions
      • Set Triggering_Unit = (Entering unit)
      • Unit - Order Triggering_Unit to Attack (Random unit from UnitForce1)
Map <gen> is just a region that is the entire map
UnitTypes is a variable containing multiple kinds of units (so if the unit happens to be one of them, the trigger will continue)
Triggering_Unit is a variable that replaces the normal Triggering Unit (for various reasons)
UnitForce1 is a unit group containing all the player units on the map.
For some reason, the unit will go to the location the unit it picks was at when it was picked, but when it gets there and the unit it was targeting isn't, it will go back to were it spawned and does nothing.
In short, the unit goes to the picked units location at the time of the trigger, but then goes back and does nothing. Help?
 
Level 4
Joined
May 4, 2008
Messages
113
Could you set the 'kodo's' target to a variable, and then use a periodic trigger to constantly order him to attack that target?

Code:
Events
 Every 1.00 seconds of game time

Actions
 Order <your unit> to attack KodoTarget

And if you need it to be MUI you can use this when setting the target

Code:
Events
 Unit enters map area

Conditions
 Your conditions

Actions
 If: KodoInt Equal to 1000
 Then: Set KodoInt = 1
 Else: Set KodoInt = KodoInt + 1
 Set Triggering_Unit[KodoInt] = (Entering unit)
 Set Target_Unit[KodoInt] = Random unit from UnitForce1

KodoInt being an integer array variable of course.

Hope that helps.
 
Level 10
Joined
May 20, 2008
Messages
433
I dont think being in sight has anything to do with it, but no they don't. Also, at Ziggy, I don't quite understand what you give. It includes KodoInt, but I don't see how that would fit in (what is it/would it be?).
Anyways, the trigger works better with later units in the game, but not units early on. Its strange, I spawn a few units using a test trigger (time elapsed=##, spawn unit in region for player) near the beginning of the game, and they go to where you were, and the units that spawn later go to you, kill you, then go back. So I'm going to need a trigger that activates once you die, so the units attack another target. Anyways, I'm open to suggestions on either subject.
 
Level 4
Joined
May 4, 2008
Messages
113
KodoInt is so you can do this

Code:
Events
 Every 1.00 seconds of game time

Actions
 For each Integer A between 1 and 1000, do
  Loop - Actions
   If/Then/Else
   If: Triggering_Unit[Integer A] Not equal to No unit
   Then: Order Triggering_Unit[Integer A] to attack KodoTarget[Integer A]
   Else:

Also, to make them go somewhere else
Code:
Events
 A unit dies

Conditions
 Your conditions

Actions
 Remove (Dying unit) from UnitForce1
 If: KodoInt Equal to 1000
 Then: Set KodoInt = 1
 Else: Set KodoInt = KodoInt + 1
 Set Triggering_Unit[KodoInt] = (Killing unit)
 Set Target_Unit[KodoInt] = Random unit from UnitForce1

That should work, I would hope :p.
Edit: Also, line of sight actually probably is what was stopping them from continually following the unit. It's worth testing.
 
Level 36
Joined
Feb 5, 2009
Messages
4,630
  • Unit Attack
    • Events
      • Unit - A unit enters Map <gen>
    • Conditions
      • Or-Any (Conditions) are true
        • Conditions
          • (Unit-type of (Entering unit)) Equal to UnitTypes[1]
          • (Unit-type of (Entering unit)) Equal to UnitTypes[2]
          • (Unit-type of (Entering unit)) Equal to UnitTypes[3]
          • (Unit-type of (Entering unit)) Equal to UnitTypes[4]
          • (Unit-type of (Entering unit)) Equal to UnitTypes[5]
          • (Unit-type of (Entering unit)) Equal to UnitTypes[6]
          • (Unit-type of (Entering unit)) Equal to UnitTypes[7]
    • Actions
      • Set Triggering_Unit = (Entering unit)
      • Unit - Order Triggering_Unit to Attack (Random unit from UnitForce1)

BAH, you're conditions are all wrong. How did no one pick up that you are checking if the entering unit is UnitTypes[1-7]? What you have to do is a whole series of Or conditions, until it says If unit-type is equal to UnitTypes[1] OR UnitTypes[2] OR etc.

Basically, that's all I can see that is wrong. Good luck!
 
Level 10
Joined
May 20, 2008
Messages
433
I did test it again. Because of the map its for, I have been using various ways of revealing the map (to check other triggers and all that). I tried it, and I got the same negative results. How could I fix that? There is no "disable black mask for player", so its difficult.
Also @ Ziggy: thanks for the help with the continual attacking.
 
Status
Not open for further replies.
Top