• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Spawn spiders when egg is destroyed trigger not working

Status
Not open for further replies.
Level 3
Joined
Aug 24, 2014
Messages
22
So I have this trigger. It spawns a spider whenever an egg (a destructible) is destroyed.
  • Spider Egg Hatch
    • Events
      • Destructible - A destructible within Spider Cave 1 <gen> dies
      • Destructible - A destructible within Spider Cave 2 <gen> dies
    • Conditions
      • (Destructible-type of (Dying destructible)) Equal to Egg Sack
    • Actions
      • Game - Display to (All players) the text: !!!
      • Set temp_loc = (Position of (Dying destructible))
      • Unit - Create 1 Spiderling for Neutral Hostile at temp_loc facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_temp_loc)
However, it doesn't always work. Some eggs in certain area do spawn spiders, while other do not (still inside the region).

I have tried:

  • Changing event to "A destructible within <playable map area> dies": Now no egg spawns spiders.
  • Making sure all eggs are the same type of destructible: They are.

Can anyone spot what's wrong with my trigger? Thank you.



EDIT: I found out why. The event "a destructible within region dies" only cares about up to 64 destructible within the region, so if there are more then nothing will happen when those die. So the solution is to just make more smaller regions.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,016
If you do what IcemanBo suggest, but aware that working with the "Pick every destructible in <REGION> and do (actions)" action often hits the operations limit and will crash the thread before completing (and nothing after it in the same trigger will run). This happens when there are many trees or other destructibles in the chosen <REGION>, so it's best to have a specially-defined region to look in instead of using something like Playable Map Area. I would keep the two regions you have and do:
  • Events
    • Time - Elapsed game-time is 0.50 seconds //map init event can crash too, so I suggest avoiding it
  • Conditions
  • Actions
    • Destructible - Pick every destructible in Spider Cave 1 <gen> and do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Then actions) else do (Else actions)
          • If - Conditions
            • (Destructible-type of (Picked destructible)) equal to Egg Sack
          • Then - Actions
            • Trigger - Add to Spider Egg Hatch <gen> the event (Destructible - (Picked destructible) dies)
            • -------- This means the Spider Egg Hatch trigger no longer needs any events or conditions in the trigger editor --------
          • Else - Actions
    • Destructible - Pick every destructible in Spider Cave 2 <gen> and do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Then actions) else do (Else actions)
          • If - Conditions
            • (Destructible-type of (Picked destructible)) equal to Egg Sack
          • Then - Actions
            • Trigger - Add to Spider Egg Hatch <gen> the event (Destructible - (Picked destructible) dies)
          • Else - Actions
 
Level 12
Joined
Jan 10, 2023
Messages
191
You are correct about the 64 destructible maximum when picking a destructible within a region, but if you give what Iceman said a shot you won't have to make a bunch of regions for this and it may save you some trouble down the road if you don't determine your regions based on the eggs population.

If you run one trigger that initializes the 'Spider Egg Hatch' trigger I think you will have a better system.

This concept worked for me with 30,000 barrels being picked in one scoop on a 256x256 map.
  • Pick All Eggs
    • Events
      • Time - Elapsed game time is 0.50 seconds
    • Conditions
    • Actions
      • Destructible - Pick every destructible in (Entire map) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Egg Sack
            • Then - Actions
              • Trigger - Add to (This trigger) the event (Destructible - (Picked destructible) dies)
            • Else - Actions
              • Do nothing
The Events of your trigger will be filled with all of the eggsacks in the map when 'Pick All Eggs' runs.
You no longer need the condition because the only destructibles that will run this trigger are each of the specific eggs that have been picked.
  • Spider Egg Hatch
    • Events
    • Conditions
    • Actions
      • Game - Display to (All players) the text: !!!
      • Set VariableSet temp_loc = (Position of (Dying destructible))
      • Unit - Create 1 Spiderling for Neutral Hostile at temp_loc facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_temp_loc)

If you decide you want to make more eggs, just do this:
  • Create New Egg
    • Events
      • Number of Egg Sacks - Number of Egg Sacks is too few
    • Conditions
      • ((Egg Sack) is In demand) Equal to True
    • Actions
      • Destructible - Create a Egg Sack at (Center of (Playable map area)) facing Default building facing with scale 1.00 and variation 0
      • Trigger - Add to Spider Egg Hatch <gen> the event (Destructible - (Last created destructible) dies)

Basically the same as Pyrogasm's example except I'm confirming that you should hit the destructibles limit before you hit the OP Limit with this one.

In a system I am currently working on I needed to detect when specific destructibles died and I stumbled on this thread and Iceman's suggestion work perfectly for me.

I decided to 'stress-test' it and loaded a 256x256 map with 30,000 destructibles and picked every destructible in the entire map in one go and added them all to the event of a trigger like he said and wc3 handled it well, granted that was the ONLY thing that I tested at this time so I had nothing else going on.
 
Status
Not open for further replies.
Top