• 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.

[Trigger] Unit in Unit Group Check Problem

Status
Not open for further replies.
Level 4
Joined
Sep 6, 2012
Messages
88
Hi everyone !

Currently I'm making an ability that fires a projectile that travels pretty far. For each ally unit it meets on its way, the projectile power is increased a bit. The trigger below shows how I did this.

  • Events
    • Time - Every 0.03 seconds of game time
  • Conditions
    • (Unit-type of EmpoweredArrow_ArrowUnit) Equal to Empowered Arrow
  • Actions
    • Set Temp_Point = (Position of EmpoweredArrow_ArrowUnit)
    • Set Temp_Point_2 = (Temp_Point offset by 30.00 towards EmpoweredArrow_FacingAngle degrees)
    • Unit - Move EmpoweredArrow_ArrowUnit instantly to Temp_Point_2, facing EmpoweredArrow_FacingAngle degrees
    • Set EmpoweredArrow_TargetGroup = (Units within 100.00 of Temp_Point matching (((((Matching unit) Not equal to EmpoweredArrow_ArrowOwner) and ((((Matching unit) belongs to an ally of (Owner of EmpoweredArrow_ArrowUnit)) Equal to True) and (((Matching unit) is in EmpoweredArrow_TargetGroupUsed
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (EmpoweredArrow_TargetGroup is empty) Equal to False
      • Then - Actions
        • Unit Group - Pick every unit in EmpoweredArrow_TargetGroup and do (Actions)
          • Loop - Actions
            • Set EmpoweredArrow_BaseDamage = (EmpoweredArrow_BaseDamage + EmpoweredArrow_DamageStep)
            • Unit Group - Add (Picked unit) to EmpoweredArrow_TargetGroupUsed
        • Custom script: call DestroyGroup (udg_EmpoweredArrow_TargetGroup)
      • Else - Actions
I tried to add "counted" units to a separate groups and checked the condition so they don't add up to the projectile's power more than once (0.03s is a short time interval so it's easy for an unit to be counted many times unless I do this). The problem here is that this method didn't work for me, each ally unit still adds up more than once. So, can anyone take a look at this and help me point out how to fix this ?

Thank you very much !

P/S: I'm aware of leaks and they're not the main concern at the moment, so let's ignore them for now :) !
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Your unit group condition line is too long and cuts off in your post, so I can't see if you are going wrong or not.

A method you could use:
1. Add all units not equal to EmpoweredArrow_ArrowUnit to the group.
2. Remove all unallied units from the group.
3. Remove units that are in the other group from the group.
4. etc for all your conditions.

It does the same thing, uses more space, but is visually easier to follow and spot where you went wrong.
 
Level 4
Joined
Sep 6, 2012
Messages
88
I'm really sorry for the inconvenience. The full matching condition is like this:

-Matching unit is not equal to EmpoweredArrow_ArrowOwner (i.e the unit who casts the ability).

-Matching unit is not equal to EmpoweredArrow_ArrowUnit (i.e the projectile itself).

-Matching unit is a structure equals to False (only alive units count).

-Matching unit belongs to an ally of Owner of Empowered_ArrowUnit (to collect all allies in range).

-Matching unit is in EmpoweredArrow_TargetGroupUsed equals to False (check whether if the unit is in the group specifically used to store units who were counted once).

I'm not sure if this is clear enough, but please help me. I'm pretty clueless at the moment ! Thank you very much !
 
Level 4
Joined
Sep 6, 2012
Messages
88
So you mean we have to intentionally leave a leak uncleared ?

Update: I've managed to fix the ability and it works like I wanted now. The problem was clearly as you said, rulerofiron99. Instead of destroy the group, I only remove all units from the group. I think the leak's gonna remain, but well, it's only one unit group, I think it's not going to cause a lot of problems. Thank you very much for your support ! I really appreciate it.
 
Last edited:
Status
Not open for further replies.
Top