I'm trying to make a weapon that will pick a unit at random and then attack it. The weapon picks a new target every time it attacks. It shouldn't prioritize closer units - it should just pick a random unit, attack it once, and repeat.
Never done it on a weapon but I would make a search effect for the ability and under the search tab you can set the maximum count to 1 so that it will only hit one unit in the area. Best way that I can think of.
Why would you need a behavior? TSRandom on a search area effect, throw that on your weapon, the Search Effect triggered by the search area effect being your damage/launch missile effect.
This was the first thing I did - it works, but the animation is wonky because the unit will be facing at one unit but attack another. The unit doing this is a spine crawler, so it would turn to face one unit and then stab another.
Well, but he won't have the random target acquiration as well.
I tried this out quite a while, and I did not get random targets to work for a weapon, without adding a search effect, which searches for a random target, which will however always result in a kind of messed up animation/facing and can only be used for units, where animation or facing does not matter that much.
What I did not try was adding a search with some delay, which changes the order of the unit to attack another target. This would not randomize the first target but the second. Also it messes up manually given commands and order queues, but maybe thats not a big deal for your application
Hi,
I'm trying to make a weapon that will pick a unit at random and then attack it. The weapon picks a new target every time it attacks. It shouldn't prioritize closer units - it should just pick a random unit, attack it once, and repeat.
Is this doable? How would I do this?
Thanks!
@nagnazul: Go
Never done it on a weapon but I would make a search effect for the ability and under the search tab you can set the maximum count to 1 so that it will only hit one unit in the area. Best way that I can think of.
@theCwinLuvsYou: Go
Yeah, that was the first thing I did and it doesn't actually work. It'll target the same one every time.
I tried a few things - in the end, what I went with was this:
-The weapon doesn't attack on its own (has scan filters that disallow attacking anything)
-The unit has a behavior with a periodic effect
-The periodic effect searches for a random unit (maximum of 1). To make the search actually random, set the "Target Sorts - Sorts" field to TSRandom
-The periodic effect has an effect that orders the unit to attack (so that the unit properly animates, making it face its target.
Works about as well as I could hope, it seems to have a vague bias for closer targets but I'm happy enough with it.
This thread has already covered the answers to some degree.
http://forums.sc2mapster.com/development/data/13501-unit-reaquiring-random-target-after-each-shot/#p13
Contribute to the wiki (Wiki button at top of page) Considered easy altering of the unit textures?
https://www.sc2mapster.com/forums/resources/tutorials/179654-data-actor-events-message-texture-select-by-id
https://media.forgecdn.net/attachments/187/40/Screenshot2011-04-17_09_16_21.jpg
@nagnazul: Go
Why would you need a behavior? TSRandom on a search area effect, throw that on your weapon, the Search Effect triggered by the search area effect being your damage/launch missile effect.
@BorgDragon: Go
This was the first thing I did - it works, but the animation is wonky because the unit will be facing at one unit but attack another. The unit doing this is a spine crawler, so it would turn to face one unit and then stab another.
@nagnazul: Go
Well just undo what you did, and fix it up and you won't have wonky attack animation because of the facing.
Well, but he won't have the random target acquiration as well.
I tried this out quite a while, and I did not get random targets to work for a weapon, without adding a search effect, which searches for a random target, which will however always result in a kind of messed up animation/facing and can only be used for units, where animation or facing does not matter that much.
What I did not try was adding a search with some delay, which changes the order of the unit to attack another target. This would not randomize the first target but the second. Also it messes up manually given commands and order queues, but maybe thats not a big deal for your application