Warcraft III resources & community, 2003–2006 · archived

Spell Trouble: Order unit to target a RANDOM unit?

11 posts
#1

Spell Trouble: Order unit to target a RANDOM unit?

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:
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))
#2
You have the spell set to pick every unit, thats probably why.
#3
leissaKYou have the spell set to pick every unit, thats probably why.


Okay. How do I fix this? I can't find a "pick random unit in unit group" to replace 'pick all units in unit group".
#4
Are you using a Fixed Random Seed?

~The_Raven
#5
The_RavenAre you using a Fixed Random Seed?

~The_Raven


A what to the whom from the what now? :shock:

I don't believe my seed is any of your business, good sir. >:[



No seriously. What? o_O
#6
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
#7
Is it enabled standardly? Like, initially? Because I don't recall ever changing anything like that.
#8
Yes. The seed will be the same for each set of rnadom integers, so it will always do the same effect, but only in tests. What else I can say is to pick the units, and give them a chance to be in a unit group. Then add them, bolt them, and clear the group
#9
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.
#10
And a removal action when they die to remove that telltale "Largest Army" manipulation. although only players who don't have a life look, but just to reduce technicality :)
#11
Thanks folks, I'm sure this'll help me greatly. And I'll try them out tomorrow, too. :)