• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

Mob spawning problem and resource transport

Status
Not open for further replies.
Level 1
Joined
Sep 21, 2011
Messages
3
Im making a sort of zombie survival/defence kind of map and I've stumbled on to a problem:

I've got a couple of triggers to spawn zerglings in random points of a region every <ammount of time> untill they reach a limit of 10 zerglings in the region.

The problem is I have no idea how to stop them from spawning if there are any player controlled units in that region. Ive tried using the "unit leaves region" event(but i'd need something like "all player 1's units leave region") and played around with conditions but to no avail.

Any suggestions?


Also - not to make another thread:

I'd like to make a resource transport system - miners mine minerals(got this done), carry them to a truck(that can only carry a certain ammount of resources) and this truck then carries the resource to a drop-off(command center). So far I've only been able to turn a flatbed into a mobile resource drop-off so any help on that subject would be greatly apreciated..
 
Level 7
Joined
Aug 13, 2007
Messages
309
1. Spawning units in a region is a terrible way to spawn units. Just make a point and then use offset by point. Example from my map:
JASS:
UnitCreate(1, gv_waveUnit, 0, 15, PointWithOffset(gv_waveSpawnPoint, RandomFixed(-2.0, 2.0), RandomFixed(-2.0, 2.0)), RandomFixed(0.0, 360.0));

2. This is what you would use if you continue with things as you have done though:
JASS:
native bool RegionContainsPoint (region r, point p);

So you'd use it like

JASS:
if (RegionContainsPoint(your_region_variable, UnitGetPosition(lv_u)) {
    return true; // or whatever
}

You'd enum the units in the region with a unit loop btw to get the units in there and set them to a variable such as lv_u.

Here are the functions for a enuming units.
JASS:
// Unit group
native void UnitGroupLoopBegin (unitgroup g);
native void UnitGroupLoopStep ();
native bool UnitGroupLoopDone ();
native unit UnitGroupLoopCurrent ();
native void UnitGroupLoopEnd ();
 
Last edited:
  • Like
Reactions: Rui
Level 1
Joined
Sep 21, 2011
Messages
3
The thing is I have no scripting experience whatsoever so I'd prefer to just use triggers.

Im thankful for the suggestion but im afraid it's all black magic to me :<

EDIT: okay, so i just changed my concept a little and integrated a simple day/night system so the mobs only spawn at night. Good enough.

But i'd still love some tips on the second part of my 1st post.
 
Last edited:
Level 7
Joined
Aug 13, 2007
Messages
309
The thing is I have no scripting experience whatsoever so I'd prefer to just use triggers.

Im thankful for the suggestion but im afraid it's all black magic to me :<

EDIT: okay, so i just changed my concept a little and integrated a simple day/night system so the mobs only spawn at night. Good enough.

But i'd still love some tips on the second part of my 1st post.

Apparently I am indeed a wizard.
 
Status
Not open for further replies.
Top