Enemy spawns
Placing spawn points with the toolgun: enemies, levels, hives and respawning.
The Enemy Spawns tool (Q menu > Tools > RPG X) places the points enemies spawn at on the
current map. It's an ordinary toolgun tool, so owners (the sandbox permission) can use it. Every change goes into the database immediately; there's no save button and no
file to copy to the server.
| On the toolgun | Does |
|---|---|
| Left click | Place a spawn point where you aim. Aiming at an existing point's marker updates that point with the menu's settings instead. |
| Right click | Copy the aimed-at point's settings into the menu. |
| Reload | Delete the aimed-at point. |
The tool's menu:
- Enemies: every NPC in the spawn menu (including addon NPCs), searchable; tick the ones that can spawn at a point. Your picks are remembered between sessions.
- Placement: Automatic (floor or ceiling, from the surface you click), Floor (enemies spawn above it) or Ceiling (enemies spawn below it).
- Hostile to players (on by default): even NPCs that normally like players (rebels, citizens) attack them. Off: the enemies like players, even ones that normally attack them (zombies, Combine), and stay friendly when shot.
- Invincible (off by default): nothing can damage its enemies, at all. The engine is told they take no damage (bullets, explosions, fire, physics, barnacles, falling...), and any damage that still reaches them is blocked. Their health bar reads "Invincible".
- Static (off by default): its enemies never leave their post. They can't walk, jump, climb, fly, swim or crawl, so they turn, aim and fight from the spot they spawned on, like a turret, and hunting (see below) still tells them where the shooter is without sending them there. Melee enemies only hit what comes within reach. NPCs only: a NextBot moves by its own code.
- Hive (a name, empty by default): points with the same hive name aggro together. Attack one
of their enemies and the rest of that hive comes too, but nobody else. Without a hive, each
enemy is on its own. (GMod's NPC list normally puts whole types in one squad, so hurting one
antlion alerts every antlion on the map; spawn point enemies don't use those squads.)
A hive is also in range as a whole: while a player is near any of its points, all of them
count as near (each still waits its own respawn time). So its enemies can't be pulled away from
the rest, or sniped from outside the range, without the hive spawning and staying.
One-shot kills count too: when a hostile hive's enemy is shot (by a player, their vehicle or
their grenade), every other hostile one in the hive learns who did it and where, even if the
shot killed it outright (the engine's squads only pass it on from one that survives to notice).
rpgx_hive_alert_on_kill 0lets a clean kill go unnoticed; hits it survives still alert. They come for you, not the noise: a hostile enemy that's shot (hive or not) and every one its hive alerts hunt the shooter, even out of their sight (sniped from beyond their view distance). Forrpgx_enemy_hunt_timeseconds (30) they're told where the shooter is every half second, and while they can't see them they run there, instead of investigating the shot and the body. Each hit starts it over; it ends early if the shooter dies or goes notarget. - Minimum / maximum level (1-1000; swapped if the wrong way round) and respawn time (1-3600 s).
While the tool is out, every point on the map shows the enemy that would spawn there as a frozen, 80% see-through statue facing you, with its #number over it, standing on floor points and hanging below ceiling points. A point with several enemies shows each in turn, every 2 seconds. Aim at a statue (it turns gold) and the clicks above act on it.
Looking at a statue, or at a live enemy from a point, shows that point's settings in a panel on the left of the screen (under the tool's own info box): its enemies, levels, respawn time, placement, hostile, invincible, static, hive and role (shop / quest giver and its quests), and for a live enemy which one it is, its level and its health. Only while the tool is out. Numbers stay with their point for good (deleting #2 doesn't renumber #3).
To know what an NPC looks like and how big it is, the server spawns one of each type for an instant
the first time it's needed (most stock NPCs only get their model from the engine when they spawn),
measures it and removes it. That's done once per NPC type ever: the results are kept in
garrysmod/data/rpgx/npc_shapes.json and measured again only when the NPC list entry changes (an
addon update). New types are measured in the background, one every 0.2 s, instead of all at once
(a point with 14 new types used to freeze the server for a moment); meanwhile the point shows a
placeholder and doesn't spawn. Anything without a model shows as the editor's player-start figure.
Spawning #
- A point is active while a player is within
rpgx_enemy_activation_range. It keeps one enemy alive, picked at random from its list (only ones that fit: barnacles and other ceiling-only NPCs on ceiling points, floor turrets on floor points). - When the enemy dies (or is removed some other way), the next one comes after the point's respawn time. The countdown runs in real time, whether anyone is near or not (even while the server sleeps with nobody on it): someone who comes back after it ran out gets an enemy straight away.
- When nobody has been near for
rpgx_enemy_idle_despawnseconds, the enemy is removed; it comes back as soon as someone is near again, without waiting. - Enemies spawn the way the spawn menu does it (their weapon, model, key values), a little above floor points and dropped to the floor, or hanging just below ceiling points. If someone is standing right on the spot, it waits until they move.
- Each enemy gets a random level from the point's range. Level 1 is the NPC as normal; every
level above adds
rpgx_enemy_health_per_levelhealth andrpgx_enemy_damage_per_leveldamage (+10% each by default, so level 5 = +40%). - Enemies from spawn points ignore each other, whatever they are and whichever side they take on players (a friendly rebel won't shoot a hostile zombie). NPCs from the spawn menu aren't affected by this.
- Changing a point in the tool replaces its current enemy with one using the new settings; deleting a point removes its enemy.
Holding the toolgun (any tool) counts as not being there: points don't spawn or stay active
for you, and no NPC on the map targets you. Any NPC already after you forgets you. Put it away
and you're back. (If you had notarget on yourself, putting the toolgun away leaves it on.)
Every enemy from a point has a health bar floating over its head, facing you, with its name
and level (and « Shop » / « Quest giver » over it for those), when you can see it within 1500 units.
What each enemy is (its point, level, health, role, invincible) reaches players in its own message,
rpgx_enemy_info, not in the NPC's networked vars: those sometimes never arrived, or arrived
stale, on NPCs that reuse an old one's entity index (bars missing, a shop that wouldn't open, the
wrong "Invincible"). They're still set, for addons. On the client, GAMEMODE:EnemyInfo( ent ).