• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Why does this trigger fail to put units in a unit group?

Status
Not open for further replies.
Level 5
Joined
May 20, 2008
Messages
138
When the ability Avengers SHield is cast on a target, this trigger is supposed to pick two additional random targets in the vicinity of the targetted unit, and make the ability jump to those two targets as well. But for some reason it doesn't even manage to put nearby units in a unit group! (And so, the ability is broken since only the unit targetted by the player gets hit, but no additional targets)

When I check if any units are in the unit group in the "Integer A from 1-2" loop via the game message, it tells me that there is 0 units in the unit group. If you wondered why I disabled the condition in the loop it is because I wanted it to run regardless and report how many units are in the unit group, and for some extremely odd reason there are 0 units in it. I also disabled a function that removed the unit targetted by the player to ensure that any potential target that should have been saved in GEN_TEMP_GROUP[1] still are there when I make a game message reporting how many units are in the unit group. Why does it fail to put units in GEN_TEMP_GROUP[1]?

  • Paladin Avengers Shield BROKEN
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to (Paladin) Avenger's Shield
    • Actions
      • -------- create dummy to slow first target --------
      • Set GEN_TEMP_POINT[1] = (Position of (Target unit of ability being cast))
      • Unit - Create 1 Dummy Caster for (Owner of (Casting unit)) at GEN_TEMP_POINT[1] facing Default building facing degrees
      • Unit - Hide (Last created unit)
      • Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
      • Unit - Add (Paladin) Avenger's Shield slow effect to (Last created unit)
      • Unit - Order (Last created unit) to Human Sorceress - Slow (Target unit of ability being cast)
      • -------- create a unit group of targets that can be hit by avengers shield --------
      • Set GEN_TEMP_GROUP[1] = (Units within 300.00 of GEN_TEMP_POINT[1] matching (((Matching unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True))
      • Custom script: call RemoveLocation(udg_GEN_TEMP_POINT[1])
      • -------- remove the original target so it doesn't get hit again --------
      • DISABLED FUNCTION: Unit Group - Remove (Target unit of ability being cast) from GEN_TEMP_GROUP[1]
      • -------- do a loop to find and hit 2 additional targets --------
      • For each (Integer A) from 1 to 2, do (Actions)
        • Loop - Actions
          • -------- check that there are units in the unit group so that dummys dont get created for nothing --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DISABLED FUNCTION: (Number of units in GEN_TEMP_GROUP[1]) Greater than 0
            • Then - Actions
              • Game - Display to (All players) the text: (String((Integer A)))
              • Game - Display to (All players) the text: (Number of units in potential targets group: + (String((Number of units in GEN_TEMP_GROUP[1]))))
              • -------- set a target as a random unit in the unit group --------
              • Set HPALADIN_av_shield_2nd_target[(Integer A)] = (Random unit from GEN_TEMP_GROUP[1])
              • -------- create dummy and cast --------
              • Set GEN_TEMP_POINT[2] = (Position of (Target unit of ability being cast))
              • Unit - Create 1 Dummy Caster for (Owner of (Casting unit)) at GEN_TEMP_POINT[2] facing Default building facing degrees
              • Unit - Hide (Last created unit)
              • Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
              • Unit - Add (Paladin) Avenger's Shield dummy to (Last created unit)
              • Unit - Order (Last created unit) to Neutral Alchemist - Acid Bomb HPALADIN_av_shield_2nd_target[(Integer A)]
              • Custom script: call RemoveLocation(udg_GEN_TEMP_POINT[2])
              • -------- remove the unit that has been hit so it doesnt get hit agian --------
              • Unit Group - Remove HPALADIN_av_shield_2nd_target[(Integer A)] from GEN_TEMP_GROUP[1]
            • Else - Actions
      • Custom script: call DestroyGroup(udg_GEN_TEMP_GROUP[1])
 
Because you didn't add the action?
  • Set GEN_TEMP_GROUP[1] = (Units within 300.00 of GEN_TEMP_POINT[1] matching (((Matching unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True) and ((Matching unit) Not Equal to (Target unit of ability being cast))
  • Set NewGroup = (Random 2 units from GEN_TEMP_GROUP[1])
  • Unit Group - Pick every unit in NewGroup and do (Actions)
    • Loop - Actions
      • //Actions here
  • Custom script: call DestroyGroup (udg_GEN_TEMP_GROUP[1])
  • Custom script: call DestroyGroup (udg_NewGroup)
In order to avoid counting the target unit, I included a Unit comparison in the GEN_TEMP_GROUP variable, as "(Matching unit) Not Equal to (Target unit of ability being cast)".
 
Level 5
Joined
May 20, 2008
Messages
138
That's not the problem, the problem is that no units are saved to GEN_TEMP_GROUP[1] at all.

if I put these actions after one another

  • Set GEN_TEMP_GROUP[1] = (Units within 300.00 of GEN_TEMP_POINT[1] matching (((Matching unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True))
  • Game - Display to (All players) the text: (Number of units in potential targets group: + (String((Number of units in GEN_TEMP_GROUP[1]))))
It still writes ingame that there are 0 untis in the unit group, even though there are lots of units close to the targetted unit.

EDIT: After some more testing I've found that it works if I disable these actions:

  • Set GEN_TEMP_POINT[1] = (Position of (Target unit of ability being cast))
  • DISABLED: Unit - Create 1 Dummy Caster for (Owner of (Casting unit)) at GEN_TEMP_POINT[1] facing Default building facing degrees
  • DISABLED: Unit - Hide (Last created unit)
  • DISABLED: Unit - Add a 5.00 second Generic expiration timer to (Last created unit)
  • DISABLED: Unit - Add (Paladin) Avenger's Shield slow effect to (Last created unit)
  • DISABLED: Unit - Order (Last created unit) to Human Sorceress - Slow (Target unit of ability being cast)
  • -------- create a unit group of targets that can be hit by avengers shield --------
  • Set GEN_TEMP_GROUP[1] = (Units within 300.00 of GEN_TEMP_POINT[1] matching (((Matching unit) belongs to an enemy of (Owner of (Casting unit))) Equal to True))
but why would the creation of the dummy interfere with setting the unit group variable later? it's not like there is a wait between the actions or anything. Goddamn weird.
 
Level 15
Joined
Oct 16, 2010
Messages
941
Try setting the casting unit to a variable right off the bat and then reffering to that variable from that point forward.

I've had problems before with using casting unit multiple times in a block. For some reason it seems to clear it sometimes.
 
Last edited:
Level 4
Joined
Oct 19, 2010
Messages
71
Yes. I remember reading somewhere before that there are certain types of data that are lost fairly quickly, so to prevent losing the data you have to assign them to a variable. Finding that post helped me fix an error in the map I'm working on. I'll try to find it again.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
The code seems fine; I'd first and foremost suggest you test without a filter and check whether the point is valid, although both of those look like they should work based on a quick glance. Also, if your ability targets a point and not a unit then that will be the culprit (if it can target both, like shockwave, you need to take that into account).

Edit: Don't let the two posters above me confuse you; saving certain event responses only matters if you use a wait or otherwise delay execution of the trigger.
 
Status
Not open for further replies.
Top