User Tools

Site Tools


spawning

Spawning

How to spawn NPCs

This How-To will show you how to add spawn points for NPCs.

Adding Spawnpoints in game

You can add a spawnpoint in game simply by using the spawn-command[1].

The Usage of the spawn-command is: “spawn npc range mintime maxtime”. This will create a spawnpoint for a single NPC with the definition id “npc”, that will wander “range” tiles around the spawnpoint, and if killed or tamed will respawn in “mintime” to “maxtime” minutes.

If you have your staff_flag turned on, you will see the the spawnpoint as a spawngem, that will normally look like the figurine of the npc it will spawn. (At first it looks like a gem, after the first spawn it will change the look to the figurine). If you doubleclick the spawngem, it will display a gump, where you can change the settings for this spawnpoint.

Scripting/Defining spawns

The second way to create NPC-spawns is to define spawnregions. These are defined in a xml-definition-file. Spawnregions are more flexible than single spawnpoints. You can spawn multiple NPCs, spawn random npc and you can define the spawnarea more precisly.

The definition of a spawnregion looks like this:

<spawnregion id="bear_forest">
  <maxnpcamount>600</maxnpcamount>
  <delay min="120" max="300" />
  <npcspercycle>20</npcspercycle>
  <npc id="black_bear" frequency="2" />
  <npc id="brown_bear" frequency="5" />
  <rectangle from="4741,2830" to="4790,2865" map="1" />
  <rectangle from="4817,3241" to="4883,3295" map="1" exception="true" />
</spawnregion>

The first line tells the server, that you are defining a new spawnregion called bear_forest. You can use the name/id of the spawnregion to manipulate this spwanregion in game with the spawnregion-command[2]. With maxnpcamount in the second line you can define how much npc this spawnregion should contain. With delay you control how often the spawnregion will spawn NPCs. The attributes are given in minutes. npcspercycle controls how many NPCs are spawned every cycle. In this Example the spawnregion will spawn 20 NPCs every 2 to 3 hours, until it contains 600 NPCs.

The next lines define what NPCs the spawnregion should spawn. For every possible NPC just add a line like <npc id=“npc_id” />. The spawnregion will randomly choose from this list of NPCs, when it spawns a new npc. If you want some NPCs to appear more frequently than others you can add the frequency-attribute. The effect of this attribute is the same as if you add the npc-line for this npc x-times. In the example the chance of spawning a black bear is 2/7 and of spawning a brown_bear is 5/7.

The area of the spawnregion is defined like a normal region. It can consist of several rectangles and points. For example <rectangle from=“4741,2830” to=“4790,2865” map=“1” /> will add the rectangle defined by the upper, left point 4741,2830 and the lower, right point 4790,2865 on map 1 to the area of the spanregion. You can even remove parts of the spawnregion, by adding the attribute exception=“true” to the rectangle.

spawning.txt · Last modified: 2014/03/09 19:13 by thooge