Count units in region

Devrak

New Member
Reaction score
17
Hi. I am creating an AoE spell that deals 20*X damage where X is how many units there is in the region. I only have one problem, how would I count every unit in that region? :p

Thanks for any kind of reply!
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Group the units in a unit group and count the number of units in that group (integer action).
 

Reflexar

New Member
Reaction score
12
Pick every unit and the region and set a integer variable +1 for every picked unit

Then you use it for the calculations
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
set Group = units in <region>
set UnitCount = number of units in Group
call DestroyGroup(udg_Group)
.....
cause <unit> to damage <unit> dealing 20 x UnitCount damage of type...

where:

Group is a unit group variable
and
UnitCount is a integer variable

EDIT: ups Larcenist already suggested that xd
 

Devrak

New Member
Reaction score
17
Hmm, this is how I did it..

Trigger:
  • AoE Ability
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to AoE Ability
    • Actions
      • Set AoE_Point = (Target point of ability being cast)
      • Unit Group - Pick every unit in (Units in (Region centered at AoE_Point with size (400.00, 400.00)) matching (((Owner of (Picked unit)) is an enemy of (Owner of (Casting unit))) Equal to True)) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Matching unit) to AoE_Group
      • Set Integer = (Number of units in AoE_Group)
      • Game - Display to (All players) the text: (String(Integer))
      • Unit Group - Pick every unit in AoE_Group and do (Actions)
        • Loop - Actions
          • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - (20.00 x (Real(Integer))))


However, the text only displays one or zero units and the units doesn't take any damage. What's wrong?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top