Mob Server
From Multiverse
| MARS |
| Mob Server |
| Object Manager |
| Combat Server |
|
Abilities and Combat Plugin • Combat Statistics • Extending the MARS Combat System • Group System • Trainer Plug-in • Professions • Experience System |
| Tutorials |
| Other Examples |
|
Triggering an Action with a Mouseclick • Scheduled Execution • Working with Sound • Creating a Teleporter |
Contents |
Overview
The mob server controls mobs (mobile objects) and quests. Mobs can take on many behaviors and play many roles in your world. Mobs can be opponents to fight, people to talk to. They can give quests or provide a store front. In the Multiverse server, the mobs are represented by objects in the MobManagerPlugin (also called the "mob server").
The MobManagerPlugin contains an object for each mob in the world. The mobs can have behaviors to automate their actions such as combat, roam, and patrol. Mobs can be created directly or indirectly through a spawn generator. Spawn generators run in the mob server and create mobs automatically, typically replacing defeated mobs.
Scripts
By default, with the standard server start scripts, the mob server process runs the mob server plug-in, multiverse.server.plugins.MobManagerPlugin, and the quest plug-in, multiverse.mars.plugins.QuestPlugin.
In addition to scripts and files it reads for messaging configuration, it reads the following scripts:
-
multiverse/bin/mobserver_local.py -
multiverse/config/common/mobserver_init.py- Run before the mobserver manager plugin gets registered to define default Multiverse behaviors. If you want to add your own behaviors, usemv_home/config/world_name/mobserver_init.py. -
multiverse/config/sampleworld/mobserver_init.py- Defines and registers behaviors. -
multiverse/config/common/questplugin.py- Registers the quest plug-in. -
multiverse/config/common/mobserver.py- Defines and registers object factories. -
multiverse/config/sampleworld/mobserver.py- Defines and registers world-specific object factories. -
multiverse/config/common/extensions_mobserver.py(not provided by default).
MobManagerClient
MobManagerClient is the remote API to the mob server plug-in. It supports creating spawn generators.
Creating a spawn generator
Spawn generators can be created remotely using
MobManagerClient.createSpawnGenerator().
The following are required to create a spawn generator:
- A loaded instance
Spawn generators are non-persistent so can only be created in a loaded instance. - A registered template
The template defines the spawned object's initial properties. It's possible to use the empty BASE_TEMPLATE and define the object dynamically via override template. - A registered object factory
The object factory can add extra properties and behaviors to a spawned mob.
The template is registered with the ObjectManagerPlugin (usually in templates.py) and the object factory is registered with the MobManagerPlugin (usually in mobserver.py).
The spawn generator is described using a multiverse.server.objects.SpawnData object. This sets the spawn generator factory, location, radius, mob count, and other parameters. The SpawnData can be initialized in any process and passed to createSpawnGenerator().
Because spawn generators must be associated with a loaded instance, they're usually created in the instance init or load scripts. Here's an example of creating a spawn generator using object factory "ThreeBlindMiceFactory":
miceMarker = InstanceClient.getMarker(instanceOid, "micemarker")
miceMarker.getPoint().setY(0)
spawnData = SpawnData()
spawnData.setFactoryName("ThreeBlindMiceFactory")
spawnData.setInstanceOid(Long(instanceOid))
spawnData.setLoc(miceMarker.getPoint())
spawnData.setNumSpawns(3)
spawnData.setSpawnRadius(30000)
spawnData.setRespawnTime(60000)
MobManagerClient.createSpawnGenerator(spawnData)
The following articles contain more examples of defining and spawning mobs.
Creating a custom spawn generator
TODO: How to sub-class SpawnGenerator
