Spawn Group Controllers
Spawn Group Controllers can be used to automatically repopulate Spawn Points with different Spawn Groups once the previous group has been cleared out. Also works on whole sets of Spawn Groups.
Functionality Description
A Spawn Group Controller can be assigned multiple sets of Spawn Groups from which it'll chose exactly one to populate a set of Spawn Points. The Spawn Points will check upon initialisation if the linked Spawn Group is child of a Spawn Group Controller and register themselves to this controller if present. Each time a Mob is spawned or removed, the Spawn Point will notify the controller of the event. Once the Spawn Group Controller detects that all Spawns have been removed, it will cycle the currently active Spawn Group Set and reassign this one to all linked Spawn Points. There are options to block respawning until all Mobs have been removed in a Spawn Group Set and to control how the cycling will be done.
STEP ONE: Create some Spawn Groups
First visit the tutorial on Creating NPCs and Monsters if you don't know how to create Spawns and Spawn Groups and continue here once you understood this.
Now create some Spawns and Spawn Infos. They can be completely arbitrary, but let's assume you created two Spawns per realm. If only Spawn Infos linking to Spawns of a single realm are added to a Spawn Group, the controller will flag the Spawn Group with this realm. As soon as a single Spawn Info linked to a Spawn with a different realm is added, the Spawn Groups realm will be set to undefined. When creating a whole Spawn Group Set, the set will be processed the same way: it only needs one Spawn Group to have assigned a different realm than all others to break the cycle. The following code illustrates how you could create one Spawn Group per realm that will be flagged accordingly:
LightContested1 = DBSpawnGroup(zone="zoneone",groupName="LightContested1") # Add a Spawn Info linking to a Spawn which has the realm set to RPG_REALM_LIGHT LightContested1.addSpawnInfo(sInfoLight1) # Add a Spawn Info linking to a Spawn which has the realm set to RPG_REALM_LIGHT LightContested1.addSpawnInfo(sInfoLight2) DarkContested1 = DBSpawnGroup(zone="zoneone",groupName="DarkContested1") # Add a Spawn Info linking to a Spawn which has the realm set to RPG_REALM_DARKNESS DarkContested1.addSpawnInfo(sInfoDark1) # Add a Spawn Info linking to a Spawn which has the realm set to RPG_REALM_DARKNESS DarkContested1.addSpawnInfo(sInfoDark2) MonsterContested1 = DBSpawnGroup(zone="zoneone",groupName="MonsterContested1") # Add a Spawn Info linking to a Spawn which has the realm set to RPG_REALM_MONSTER MonsterContested1.addSpawnInfo(sInfoMonster1) # Add a Spawn Info linking to a Spawn which has the realm set to RPG_REALM_MONSTER MonsterContested1.addSpawnInfo(sInfoMonster2)
STEP TWO: Create a Spawn Group Controller
Create a Spawn Group Controller with the following code:
controller = DBSpawnGroupController(name="ContestedTerritory1") controller.respawnCycle = RPG_SPAWNCONTROLLER_CYCLE_LASTKILLERREALM controller.respawnFlags = (RPG_SPAWNCONTROLLER_RESPAWN_WIPE | RPG_SPAWNCONTROLLER_RESPAWN_IMMEDIATE)
The name given on creation isn't really of importance for the moment, but giving a descriptive name to each object is good style.
With the attribute respawnCycle it is possible to control how the Spawn Group Controller will change Spawn Group Sets once all Mobs of the previous set have been removed. Here's a list of possible values:
- RPG_SPAWNCONTROLLER_CYCLE_RANDOM: Choose the next Spawn Group Set completely at random from the assigned sets.
- RPG_SPAWNCONTROLLER_CYCLE_OTHER: Choose the next Spawn Group Set randomly from the assigned sets but don't choose the previous set again.
- RPG_SPAWNCONTROLLER_CYCLE_REALM: Choose a random Spawn Group Set of the assigned sets with a different realm than the previous one.
- RPG_SPAWNCONTROLLER_CYCLE_LASTKILLERREALM: Attempt to choose a Spawn Group Set with the same realm as the killer of the last Spawn under control. If no such set is found, try to cycle like RPG_SPAWNCONTROLLER_CYCLE_REALM.
- RPG_SPAWNCONTROLLER_CYCLE_KILLERREALM: Attempt to choose a Spawn Group Set with the same realm as had the most killers of the previously controlled sets mobs. If this is not possible, cycle like RPG_SPAWNCONTROLLER_CYCLE_REALM.
Note: The initial Spawn Group Set will always be chosen randomly. Also killers that have the same realm as the current Spawn Group Set have their realm ignored. This means a different realm will be chosen for next cycle in those cases.
Currently there exist three respawn flags: RPG_SPAWNCONTROLLER_RESPAWN_NORMAL, RPG_SPAWNCONTROLLER_RESPAWN_WIPE and RPG_SPAWNCONTROLLER_RESPAWN_IMMEDIATE. If RPG_SPAWNCONTROLLER_RESPAWN_WIPE is set, the controller will block any automatically timed respawns until next cycle. RPG_SPAWNCONTROLLER_RESPAWN_IMMEDIATE forces all Spawn Points to respawn new mobs as soon as a new cycle starts. Otherwise, Spawn Points will wait until current timers have run out.
Now it's time to add the previously created Spawn Groups to our Spawn Group Controller:
controller.addSpawnGroup(LightContested1,"Light has taken over!\\n") controller.addSpawnGroup(DarkContested1,"Darkness has taken over!\\n") controller.addSpawnGroup(MonsterContested1,"Monsters are roaming about!\\n")
The first argument is the Spawn Group object, the second a message string that will be sent to all players in the same zone if the Spawn Group Controller cycles to this group. If wished, a third argument can be given to set a sound file which will be played on cycling to all players in the zone as well. The message and sound are optional, they just add more atmosphere.
... and we're done.
Advanced
To better control which Spawn to spawn at which Spawn Point, it is possible to define sets of Spawn Groups. Each Spawn Group added to such a set bears a Group Index. Upon cycling, Spawn Points will always be assigned Spawn Groups with the same Group Index. It isn't necessary to define a Spawn Group for each Group Index for each cycle. In such cases the Spawn Points linked to the Group Index missing an entry will just not spawn any Mobs in that cycle. A set of Spawn Groups could look like this:
spawnGroupSetLight1 = SpawnGroupSet() spawnGroupSetLight1.addSpawnGroup(LightContested1,0) spawnGroupSetLight1.addSpawnGroup(LightContested2,1) spawnGroupSetDark1 = SpawnGroupSet() spawnGroupSetDark1.addSpawnGroup(DarkContested1,0) spawnGroupSetDark1.addSpawnGroup(DarkContested2,1)
The first argument is the Spawn Group to add, the second the Group Index. When cycling Spawn Group Sets, Spawn Points using either LightContested1 or DarkContested1 will cycle to LightContested1 or DarkContested1 and Spawn Points using either LightContested2 or DarkContested2 will cycle to LightContested2 or DarkContested2.
Add Spawn Group Sets to a Spawn Group Controller with the following code:
controller.addSpawnGroupSet(spawnGroupSetLight1,"Light has taken over!\\n") controller.addSpawnGroupSet(spawnGroupSetDark1,"Darkness has taken over!\\n")
The first argument is the previously created Spawn Group Set, the second is again the string that will be sent to the clients in the same zone once the Spawn Group Controller cycles to this set and the third (not used here) would be a path to a sound file which would be played to all players in the zone. It is possible to mix Spawn Groups and Spawn Group Sets in the same controller. Single Spawn Groups all get assigned the Group Index -1 and a unique set id.
Return to Tutorials

