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

Spell Trouble: Order unit to target a RANDOM unit?

Status
Not open for further replies.
Level 23
Joined
Jul 18, 2004
Messages
1,862
Okay, I'm making this spell which makes a dummy unit target an enemy unit in range with a modified Storm Bolt.

My problem is that this happens about two or three times in a row, and each time, a newly created dummy unit will target the same! friggin! unit! in range! Never another one, oooh no. Always the same one.

How do I force these units, which're created one after another with intervals of one second, to target ~random~ units, rather then constantly the same one?

What I have:
Code:
Unit Group - Pick every unit in (Units in (Region centered at (Position of (Entering unit)) with size (900.00, 900.00)) matching (((Matching unit) belongs to an enemy of (Owner of (Entering unit))) Equal to True)) and do (Unit - Order (Entering unit) to Human Mountain King - Storm Bolt (Picked unit))
 
Level 9
Joined
Jun 10, 2004
Messages
594
Under Preferences, there is an option about it. If a Fixed Random Seed is enabled, then when you test your map, everything that is suppoesed to be random isn't. For example, when you use Pick a Random Unit, the same unit will be picked everytime you run the trigger.

~The_Raven
 
Level 10
Joined
Apr 9, 2004
Messages
502
First, set it too last created or designate the SB dummy unit as a vairable unit. Entering unit is only for entering a region that has already existed right from the beginning.

Secondly, the intervals are low enough so what you do is this trigger instead:

For ever integer A from 1 to X do actions

Pick random unit within range of (your guy) and do actions

(it's under picking units in unit groups, just pick random unit within 900 of your guy matching blah conditions and that should work.)

If unit is alive equal to true

Then order (Dummy SBer) to SB picked unit

Otherwise
Do nothing

Wait 1 second.



That's pretty much all you need for what you're doing. Now if you want that to happen independantly because you want another separate action going on, i'd recommend this as i find it's easier to do and less bothersome afterwards.

Event: Periodic event--> every 1 seconds in game time


Action:

Pick random unit within range of (your guy) and do actions

(it's under picking units in unit groups, just pick random unit within 900 of your guy matching blah conditions and that should work.)

If unit is alive equal to true

Then order (Dummy SBer) to SB picked unit

Otherwise
Do nothing




And there you have it; two ways to solve your problem. Then only thing i can see with it.

Oh yeah, since you're making multiple dummy units, i suggest you create/order/set timer on them all at once to prevent mem leaks and since you have more than a couple and uyou don't need to keep track of them, it's easier just to give them an expiring timer and let them die "naturally" without creating problems.
 
Status
Not open for further replies.
Top