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

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..
 
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:
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