• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Counting units hit by AoE

Status
Not open for further replies.
Level 14
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:

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
 
Status
Not open for further replies.
Top