This module implements a simple mobile object with a very rudimentary AI as well as an aggressive enemy object based on that mobile class.

class evennia.contrib.tutorials.tutorial_world.mob.CmdMobOnOff(**kwargs)[source]

Bases: evennia.commands.command.Command

Activates/deactivates Mob


mobon <mob> moboff <mob>

This turns the mob from active (alive) mode to inactive (dead) mode. It is used during building to activate the mob once it’s prepared.

key = 'mobon'
aliases = ['moboff']
locks = 'cmd:superuser()'

Uses the mob’s set_alive/set_dead methods to turn on/off the mob.”

help_category = 'general'
lock_storage = 'cmd:superuser()'
search_index_entry = {'aliases': 'moboff', 'category': 'general', 'key': 'mobon', 'no_prefix': ' moboff', 'tags': '', 'text': "\n Activates/deactivates Mob\n\n Usage:\n mobon <mob>\n moboff <mob>\n\n This turns the mob from active (alive) mode\n to inactive (dead) mode. It is used during\n building to activate the mob once it's\n prepared.\n "}
class evennia.contrib.tutorials.tutorial_world.mob.MobCmdSet(cmdsetobj=None, key=None)[source]

Bases: evennia.commands.cmdset.CmdSet

Holds the admin command controlling the mob


Hook method - this should be overloaded in the inheriting class, and should take care of populating the cmdset by use of self.add().

path = 'evennia.contrib.tutorials.tutorial_world.mob.MobCmdSet'
class evennia.contrib.tutorials.tutorial_world.mob.Mob(*args, **kwargs)[source]

Bases: evennia.contrib.tutorials.tutorial_world.objects.TutorialObject

This is a state-machine AI mobile. It has several states which are controlled from setting various Attributes. All default to True:

patrolling: if set, the mob will move randomly

from room to room, but preferring to not return the way it came. If unset, the mob will remain stationary (idling) until attacked.

aggressive: if set, will attack Characters in

the same room using whatever Weapon it carries (see tutorial_world.objects.TutorialWeapon). if unset, the mob will never engage in combat no matter what.

hunting: if set, the mob will pursue enemies trying

to flee from it, so it can enter combat. If unset, it will return to patrolling/idling if fled from.

immortal: If set, the mob cannot take any damage. irregular_echoes: list of strings the mob generates at irregular intervals. desc_alive: the physical description while alive desc_dead: the physical descripion while dead send_defeated_to: unique key/alias for location to send defeated enemies to defeat_msg: message to echo to defeated opponent defeat_msg_room: message to echo to room. Accepts %s as the name of the defeated. hit_msg: message to echo when this mob is hit. Accepts %s for the mob’s key. weapon_ineffective_msg: message to echo for useless attacks death_msg: message to echo to room when this mob dies. patrolling_pace: how many seconds per tick, when patrolling aggressive_pace: -”- attacking hunting_pace: -”- hunting death_pace: -”- returning to life when dead

field ‘home’ - the home location should set to someplace inside

the patrolling area. The mob will use this if it should happen to roam into a room with no exits.


When initialized from cache (after a server reboot), set up the AI state.


Called the first time the object is created. We set up the base properties and flags here.

set_alive(*args, **kwargs)[source]

Set the mob to “alive” mode. This effectively resurrects it from the dead state.


Set the mob to “dead” mode. This turns it off and makes sure it can take no more damage. It also starts a ticker for when it will return.


Starts just standing around. This will kill the ticker and do nothing more.


Start the patrolling state by registering us with the ticker-handler at a leasurely pace.


Start the hunting state


Start the attacking state

do_patrol(*args, **kwargs)[source]

Called repeatedly during patrolling mode. In this mode, the mob scans its surroundings and randomly chooses a viable exit. One should lock exits with the traverse:has_account() lock in order to block the mob from moving outside its area while allowing account-controlled characters to move normally.

do_hunting(*args, **kwargs)[source]

Called regularly when in hunting mode. In hunting mode the mob scans adjacent rooms for enemies and moves towards them to attack if possible.

do_attack(*args, **kwargs)[source]

Called regularly when in attacking mode. In attacking mode the mob will bring its weapons to bear on any targets in the room.

at_hit(weapon, attacker, damage)[source]

Someone landed a hit on us. Check our status and start attacking if not already doing so.


This is triggered whenever a new character enters the room. This is called by the TutorialRoom the mob stands in and allows it to be aware of changes immediately without needing to poll for them all the time. For example, the mob can react right away, also when patrolling on a very slow ticker.

exception DoesNotExist

Bases: evennia.contrib.tutorials.tutorial_world.objects.TutorialObject.DoesNotExist

exception MultipleObjectsReturned

Bases: evennia.contrib.tutorials.tutorial_world.objects.TutorialObject.MultipleObjectsReturned

path = 'evennia.contrib.tutorials.tutorial_world.mob.Mob'
typename = 'Mob'