Page MenuHomePhabricator

Working with Zones
Updated 1,360 Days AgoPublic

If you want to spawn zones on the fly, you can use SPAWN_ZONE for most zones.
Here are descriptions of some of the zone types available:

  • win - first player to enter wins the round
  • death - any players that enter get killed, gaining the number of points specified by SCORE_DEATHZONE
  • deathTeam - similar as above, but players part of the same team as the zone won't be killed.
  • fortress - also called a base zone. Controlled by BASE_ and FORTRESS_ commands.
  • flag - as seen in capture the flag. Uses fortress/base zones and controlled by FLAG_ commands
  • ball - Players can push this away from them, and can be scored in a team's fortress/base zone.
  • ballTeam - Similar as above, but acts as a death zone to anyone not on the same team as the ball.
  • koh - "King of the hill" zone. Only one player inside collects gains KOH_SCORE points every KOH_SCORE_TIME seconds. If there are more or less than one players inside, nobody gets points.
  • acceleration - Continuously increases any players' speeds by the amount specified at spawn.
  • speed - Maintains players' speeds inside at the value specified at spawn.
  • rubber - Increases players' rubber by the amount specified at spawn. Also influenced by RUBBERZONE_RATE.
  • sumo - Creates fortress zones for all teams in the same area. It's not magic; they'll still behave the same as spawning base/fortress zones yourself.
  • zombie - A death zone that chases players. Controlled by ZOMBIE_ZONE_ settings and will update which direction it needs to go at the polling interval of SHOT_SEEK_UPDATE_TIME seconds.
  • zombieOwner - Same as above, but owned by another player. Player gains SCORE_ZOMBIE_ZONE_REVENGE points.
  • teleport - Teleports players that enter to another location you choose. Has been known in the past to be troublesome.

The zones all have similar syntax but with minor changes per zone type. You can be reminded at any time of a list of zone types and the exact syntax required by running SPAWN_ZONE.

As a brief overview though, all of the zones require a few basic arguments in order to actually work. For example, if you want to spawn a death zone at the center of the grid with a radius of 10:

SPAWN_ZONE death 250 250 10

Many zones will add additional zone-specific arguments at the beginning. For example, if you want a fortress zone owned by team blue, you can do something like SPAWN_ZONE fortress team_blue 150 350 15. Or how about a zone to speed people up? SPAWN_ZONE acceleration 40 350 150 15. However, confusingly, rubber zones and teleport zones require their arguments after the moving directions xdir and ydir: SPAWN_ZONE rubber 350 350 15 0 0 10

Oh, and before I forget, you can easily get rid of all zones on the grid by running the confusingly named DESTROY_ALL. Despite the name, it ONLY destroys zones. (KILL_ALL is similar but for players, NOT zones)

Basic zone controls

If you want to control zones externally later, you can give zones a name for easy reference. We'll name this one Bob:

SPAWN_ZONE n Bob death 250 250 5

Now, let's say Bob's been naughty. You can teleport Bob to the corner:


Or maybe you want to be a bit less forceful about it. Bob can move over to the corner himself:


(see the full route explanations later)
Should Bob grow up? Let's set a growth rate of 10 ourselves:


But wait, that means Bob will eventually consume the entire grid! We don't want that! Instead, set a target radius with the same rate:


You can even make the change immediate if you set the rate to -1.

There are a few SET_ZONE_ commands not covered here, such as SET_ZONE_COLOR which takes colors out of 1 unlike SPAWN_ZONE which takes them out of 15 in +ap.

(please note that some of the commands here may not exist or fully function as described here if you use an older revision.)

Moving zones & routing

Now, let's look at the some of the other values. <xdir> <ydir> <interactive> all relate to how the zone behaves while moving. Use xdir and ydir to specify the velocity of the zone. "Interactive" just means it can bounce off walls. The direction and speed can be controlled later via SET_ZONE_DIR and SET_ZONE_SPEED

Of course, that just means the zone will be moving aimlessly around the grid. We can do better than that. We can feed a zone an array of points to follow. The most widespread way would be to just feed a list of points when spawning the zone like so:

SPAWN_ZONE death L 150 150 150 350 350 350 350 150 150 150 Z 10 0 10 10

Something to be aware of here is that if the first and last routing points are the same (here it's 150,150 and 150,150) it will only go around once. If you want it to keep going in a square, you can make the last set of points slightly different:

SPAWN_ZONE death L 150 150 150 350 350 350 350 150 149 150 Z 10 0 10 10

This will move indefinitely until the zone is destroyed.

But what if we don't want to spawn a new zone every time we want to change its route? Historically, the only way was using SET_ZONE_POSITION, which was poorly named and uses relative coordinates. However, since then some *_ZONE_ROUTE specific commands have been added.

Don't forget to set a name for easy access:

SPAWN_ZONE n myZone death 250 250 15

Now you can pass the same parameters to SET_ZONE_ROUTE and even set a rate as the last parameter:

SET_ZONE_ROUTE myZone 150 150 150 350 350 350 350 150 149 150 20

Of course, future calls to SET_ZONE_ROUTE will overwrite the current route. If you simply want to add to the route, you can call ADD_ZONE_ROUTE to add another coordinate to the route without interrupting it's movement.

ADD_ZONE_ROUTE myZone 250 250

Now it will also go to the center. If you want it to instead stop at the center, however, just pass the same coordinate twice in a row:

ADD_ZONE_ROUTE myZone 250 250 250 250

Back to where we started.

Zone IDs

When zones are spawned, they are provided with an object ID which can be used later instead of names. Unfortunately though, there is currently no in-game way to grab said ID. If you want its ID, you're going to have to either experiment and find it yourself, or watch the ladderlog. You can enable LADDERLOG_WRITE_ZONE_GRIDPOS to have the server write the list of zones to the ladderlog continuously every ZONE_GRIDPOS_INTERVAL seconds.

Collapsing/destroying zones

Collapsing zones means they shrink until they disappear, while destroying them means they disappear instantly.
How to do it? This is simple enough. For any zones without a name, you can simply run COLLAPSE_ZONE or DESTROY_ZONE. Adding a name to COLLAPSE_ or DESTROY_ZONE will only collapse zones with that name. COLLAPSE_ZONE_ID and DESTROY_ZONE_ID are also available here.

Last Author
Last Edited
Jul 30 2020, 3:29 AM

Event Timeline

Armanelgtron edited the content of this document. (Show Details)Jul 30 2020, 3:29 AM