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!
is it possible to make a spell count the number of units/corpses around the caster without using jass? or make a spell which only targets a specific number of targets.
You need an integer variable. And then here is the code:
Code:
set variable = 0
Pick up Every unit within area matching conditions and do actions
-> set variable = variable + 1
Now to explain. You pick up every unit around the caster, at which range. Conditions are so that you can select the type of units you want to count. In case of corpses I think unit must be dead. In case of building, you check if unit is equal with building... and so on. Now, everwhere after this action, the number of units is equal with the variable.
2. Targeting a specific number of units
Again, we will need a unit variable and a unit group variable. And here is the code:
Pick up every unit within ((Position of (casting Unit)) offset by x) matching conditions and do actions
-> add (Picked Unit) to group
Code:
FOR (Integer A) from 1 to y do actions
-> set unit = Random Unit From group
-> Remove unit from group
//This is where you put the effect of the spell
Again to explain, x is equal with the area around the caster. Conditions are used to pick certain units (for example, only enemies, or only allies, or only organic etc). And now, you add all the valid targets (aka all the picked unit) to the group.
In the for, y is equal with the number of targets affected by the spell. You get a random unit from the group, and then you remove that unit from the group, so that next time the loop repeats, there isn't a chance to pick the same unit and make the spell affect it twice.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.