• 🏆 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!

[General] Trouble with creep spawning

Status
Not open for further replies.
Level 2
Joined
Dec 9, 2018
Messages
4
Hi everyone, I'm attempting to make my first hero arena and I'm stuck on trying to make neutral creeps respawn only when there are no other units in the region. I've attached an image of what I have so far, I don't really understand why my condition isn't working, it always resolves to false and no units spawn. Thanks for the help!
 

Attachments

  • imguEIKtujs.PNG
    imguEIKtujs.PNG
    19.9 KB · Views: 59
Level 13
Joined
Oct 12, 2016
Messages
769
The reason your thing don't work be since it counts ALL them units in that region: friendly, dead, or otherwise.
For the most efficient way to do this:

First
, I recommend creating a pre-made Unit Group in the variables. DO NOT remove this pre-made unit group.

Second, spawn the units you want at the location then add them to their pre-made unit group.
(make sure you remove your memory leaks for this, see: Things That Leak for a detailed tutorial and why it's important for coding)

Third, change the event from a periodic event to a generic unit event: "A unit dies."

Fourth, in the condition section, check if the Triggering Unit is in the pre-made unit group, and do an integer check for the number of units in that pre-made unit group = 0.

And finally, if the above conditions are met, spawn moar units. You can add a counter in the actions for increasing difficulty per wave, and a wait function if you feel like it.
 
Last edited:
Level 5
Joined
Mar 5, 2015
Messages
135
Have you tested that it turns out false all time? Because to me it seems that it turns true all the time. The reason being that the condition that you've made doesn't do exactly what you're thinking it does, and it's understandable why you're confused.

The condition checks if a specific region contains a specific unit. You are checking if the a specific region contains the "unit object" known as 'no unit',and this is where the confusion is at. The 'No unit' is an actual unit which doesn't exist (is null in JASS terms).
You're checking the region contains the unit object 'No Unit' which all regions do by definition. This makes the condition always to be true, and therefor it should always so spawn. (Ask if you need a better explanation of this).

Solution
To get the desired effect, instead you would use an integer comparison:

upload_2018-12-14_10-33-58.png



BUT you have to take into consideration what Wark writes:
it counts ALL them units in that region: friendly, dead, or otherwise.

Side note:
There things to consider, which optimizes your trigger (suggestions that Wark mentions), but I would suggest leave those aside until you fixed the problem you have first.
 
Status
Not open for further replies.
Top