Question for my understanding: How can the trigger "remember" a removed unit?

Level 15
Joined
Jun 9, 2008
Messages
308
Hi, so here is one specific question, but the answer to this might change how I look at triggers.

In the trigger below (simplified for convenience), the game detects the "Unit type of summoned unit", no problem. The trigger works.

  • Variety summon Rodents
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Summoning unit)) Equal to Varmint Nest (Rodents)
          • (Unit-type of (Summoning unit)) Equal to Varmint Nest (Gophers)
    • Actions
      • Game - Display to (All players) the text: Rats!
      • Set Standpoint = (Position of (Summoning unit))
      • Set Gewerbegebiet = (Region centered at Standpoint with size (700.00, 700.00))
      • -------- Rodents and Gophers --------
      • Set Fleeceposition = (Random point in Gewerbegebiet)
      • Unit - Remove (Summoned unit) from the game
      • Unit - Create 1 (Unit-type of (Summoned unit)) for (Owner of (Summoned unit)) at Fleeceposition facing Standpoint
      • Custom script: call RemoveLocation(udg_Fleeceposition)
      • Set Louis = (Last created unit)
      • Custom script: call RemoveLocation(udg_Standpoint)
      • Custom script: call RemoveRect(udg_Gewerbegebiet)
But how can that be, since I removed the summoned unit from the game before the action that requires "Unit type of summoned unit"?

And follow-up question: If that IS problematic, after all, could it be a cause of the glicthes I am experiencing in my map?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I suppose it hasn't been garbage collected yet. There's still a handle id that points to all sorts of data related to that unit, such as it's Unit-type.

Anyway, you may want to Kill the unit before Removing it to fire any Death events and other important things that should happen. Obviously that depends on your usage of the "A unit Dies" Event.

Also, if you're referring to your map's animation glitches, I don't see any correlation. That issue almost sounds like a personal problem, have others confirmed that they experience it as well?
 
Last edited:
Level 15
Joined
Jun 9, 2008
Messages
308
I suppose it hasn't been garbage collected yet. There's a still a handle id that points to all sorts of data related to that unit, such as it's Unit-type.

Anyway, you may want to Kill the unit before Removing it to fire any Death events and other important things that should happen. Obviously that depends on your usage of the "A unit Dies" Event.

Also, if you're referring to your map's animation glitches, I don't see any correlation. That issue almost sounds like a personal problem, have others confirmed that they experience it as well?
Thanks! Especially the part with killing the unit first, apreciate it.

And no, I haven't let anyone else test the map yet.

I believe I have now a version more stable than others (I just let it run for 1h40min with no issue), but the testing is so tricky since the glitches seem to happen so randomly, sometimes after 10 seconds sometimes never.
I am starting to suspect that it might have something to do with "unit summoned" type events as triggers like that seem to lead more often to less playable versions of my map, but I dunno. Maybe I'll just share the WIP map at some point, see how it performs for other people.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Thanks! Especially the part with killing the unit first, apreciate it.

And no, I haven't let anyone else test the map yet.

I believe I have now a version more stable than others (I just let it run for 1h40min with no issue), but the testing is so tricky since the glitches seem to happen so randomly, sometimes after 10 seconds sometimes never.
I am starting to suspect that it might have something to do with "unit summoned" type events as triggers like that seem to lead more often to less playable versions of my map, but I dunno. Maybe I'll just share the WIP map at some point, see how it performs for other people.
I wouldn't worry about the animation glitch for now. Until you're ready to playtest the map with others then it's likely not worth the time. In the meantime, focus on understanding edge cases (like the Death event situation I mentioned) and getting back to making content. A "bad" trigger is generally only going to cause issues like memory leaks (which are usually insignificant) and outcomes like a variable referencing the wrong object thus breaking the expected results. Worst case you create a crash due to an infinite loop or you desync players by improperly using GetLocalPlayer() or a "desyncy" function.
 
Last edited:
Top