- Joined
- Jul 26, 2008
- Messages
- 1,009
So I'm making a spell that heals the caster depending on how many enemies were hit by the spell. It's a Point targeted AoE.
Problem is, as I'm triggering this I'm running through the function list and I can't seem to find the right Functions to do this. Likely it has to do with me not knowing the name is Add instead of Group or something like that.
Anyways, what's the best way of counting units so that A) You don't hit more than X units with the spell and B) You know how many units were hit by the spell.
I got this far in before I couldn't figure it out:
See, GroupEnum...Counted() lets me set a max, but I don't believe it counts how many are in the group. whereas GroupAddUnit() with a loop will let me count it and to a limit, but I need booleans and a way to get if the Unit is in a range, only thing I found was a BJ to do that though.
I think damaging each unit in range that max the conditions would be the easiest way :\
Ahh, ahh, found it. FirstOfGroup(). Had to go back to a tutorial for that one :X
Problem is, as I'm triggering this I'm running through the function list and I can't seem to find the right Functions to do this. Likely it has to do with me not knowing the name is Add instead of Group or something like that.
Anyways, what's the best way of counting units so that A) You don't hit more than X units with the spell and B) You know how many units were hit by the spell.
I got this far in before I couldn't figure it out:
JASS:
local unit caster = GetTriggerUnit()
local unit targ
local real rad = 350. + 100. * GetUnitAbilityLevel(caster, 'sang')
local integer maxtargs = 2 + 1 * GetUnitAbilityLevel(caster, 'sang')
local integer x
local group SG = CreateGroup()
set GroupEnumUnitsInRangeOfLocCounted(SG, GetSpellTargetLoc(), rad, Condition(function IsEnemy), maxtargs )
loop
call GroupAddUnit(SG, targ)
set x = x + 1
exitwhen x >= maxtargs
set caster = null
set SG = null
set targ = null
See, GroupEnum...Counted() lets me set a max, but I don't believe it counts how many are in the group. whereas GroupAddUnit() with a loop will let me count it and to a limit, but I need booleans and a way to get if the Unit is in a range, only thing I found was a BJ to do that though.
I think damaging each unit in range that max the conditions would be the easiest way :\
Ahh, ahh, found it. FirstOfGroup(). Had to go back to a tutorial for that one :X