317 lines
10 KiB
Python
317 lines
10 KiB
Python
"""
|
|
Prototypes
|
|
|
|
A prototype is a simple way to create individualized instances of a
|
|
given typeclass. It is dictionary with specific key names.
|
|
|
|
For example, you might have a Sword typeclass that implements everything a
|
|
Sword would need to do. The only difference between different individual Swords
|
|
would be their key, description and some Attributes. The Prototype system
|
|
allows to create a range of such Swords with only minor variations. Prototypes
|
|
can also inherit and combine together to form entire hierarchies (such as
|
|
giving all Sabres and all Broadswords some common properties). Note that bigger
|
|
variations, such as custom commands or functionality belong in a hierarchy of
|
|
typeclasses instead.
|
|
|
|
A prototype can either be a dictionary placed into a global variable in a
|
|
python module (a 'module-prototype') or stored in the database as a dict on a
|
|
special Script (a db-prototype). The former can be created just by adding dicts
|
|
to modules Evennia looks at for prototypes, the latter is easiest created
|
|
in-game via the `olc` command/menu.
|
|
|
|
Prototypes are read and used to create new objects with the `spawn` command
|
|
or directly via `evennia.spawn` or the full path `evennia.prototypes.spawner.spawn`.
|
|
|
|
A prototype dictionary have the following keywords:
|
|
|
|
Possible keywords are:
|
|
- `prototype_key` - the name of the prototype. This is required for db-prototypes,
|
|
for module-prototypes, the global variable name of the dict is used instead
|
|
- `prototype_parent` - string pointing to parent prototype if any. Prototype inherits
|
|
in a similar way as classes, with children overriding values in their partents.
|
|
- `key` - string, the main object identifier.
|
|
- `typeclass` - string, if not set, will use `settings.BASE_OBJECT_TYPECLASS`.
|
|
- `location` - this should be a valid object or #dbref.
|
|
- `home` - valid object or #dbref.
|
|
- `destination` - only valid for exits (object or #dbref).
|
|
- `permissions` - string or list of permission strings.
|
|
- `locks` - a lock-string to use for the spawned object.
|
|
- `aliases` - string or list of strings.
|
|
- `attrs` - Attributes, expressed as a list of tuples on the form `(attrname, value)`,
|
|
`(attrname, value, category)`, or `(attrname, value, category, locks)`. If using one
|
|
of the shorter forms, defaults are used for the rest.
|
|
- `tags` - Tags, as a list of tuples `(tag,)`, `(tag, category)` or `(tag, category, data)`.
|
|
- Any other keywords are interpreted as Attributes with no category or lock.
|
|
These will internally be added to `attrs` (eqivalent to `(attrname, value)`.
|
|
|
|
See the `spawn` command and `evennia.prototypes.spawner.spawn` for more info.
|
|
|
|
"""
|
|
|
|
# TEMPLATES
|
|
|
|
ROOM = {
|
|
"prototype_key": "room",
|
|
"prototype_tags": ["room"],
|
|
"key": "empty room",
|
|
"desc": "An empty room.",
|
|
"map_icon": "|w□|n",
|
|
"typeclass": "typeclasses.rooms.IndoorRoom"
|
|
}
|
|
|
|
EXIT = {
|
|
"prototype_key": "exit",
|
|
"prototype_tags": ["room", "exit"],
|
|
"key": "corridor",
|
|
"desc": "An empty corridor.",
|
|
"typeclass": "typeclasses.exits.BaseDoor"
|
|
}
|
|
|
|
ITEM = {
|
|
"prototype_key": "item",
|
|
"prototype_tags": ["item"],
|
|
"key": "item",
|
|
"desc": "An unremarkable item made of dreams.",
|
|
"typeclass": "typeclasses.objects.Item"
|
|
}
|
|
|
|
ITEM_EQUIPPABLE = {
|
|
"prototype_key": "item_equippable",
|
|
"prototype_tags": ["item", "equippable"],
|
|
"key": "equippable item",
|
|
"desc": "An unremarkable equippable item made of dreams.",
|
|
"typeclass": "typeclasses.objects.EquippableItem",
|
|
"slot": 'head'
|
|
}
|
|
|
|
FEATURE = {
|
|
"prototype_key": "feature",
|
|
"prototype_tags": ["feature"],
|
|
"key": "feature",
|
|
"desc": "Something slightly remarkable.",
|
|
"feature_desc": "A slightly remarkable |wfeature|n.",
|
|
"typeclass": "typeclasses.objects.Feature"
|
|
}
|
|
|
|
FEATURE_CONTAINER = {
|
|
"prototype_key": "feature_container",
|
|
"prototype_tags": ["feature", "container"],
|
|
"key": "generic container",
|
|
"desc": "A generic container.",
|
|
"feature_desc": "A dreadful |wgeneric container|n lies on the floor.",
|
|
"typeclass": "typeclasses.objects.ContainerFeature"
|
|
}
|
|
|
|
# FEATURES
|
|
|
|
F_ARMORED_SKELETON = {
|
|
"prototype_parent": "FEATURE",
|
|
"prototype_tags": ["feature"],
|
|
"prototype_key": "f_armored_skeleton",
|
|
"key": "skeleton of a soldier in armor",
|
|
"aliases": ["skeleton"],
|
|
"desc": "The skeleton of a soldier, still locked in their armor now "
|
|
"rusty. They lie leaning against the barricade where he died, their bony hand "
|
|
"clutched to the handle of a broken spear.",
|
|
"feature_desc": "A |wskeleton|n in a broken armor is collapsed on the floor behind the table.",
|
|
"locks": "search:all()"
|
|
}
|
|
|
|
F_RUBBLE_01 = {
|
|
"prototype_parent": "FEATURE",
|
|
"prototype_tags": ["feature"],
|
|
"prototype_key": "f_rubble_01",
|
|
"key": "pile of stones",
|
|
"aliases": ["pile"],
|
|
"desc": "A large root system pierced the ceiling of this room, shattering one"
|
|
" of the load-bearing boards. Some of the covering stones now lie damaged on the ground,"
|
|
"filling the floor with debris.",
|
|
"feature_desc": "A |wpile of stones|n and a collapsed beam from the ceiling make it difficult to cross this area.",
|
|
"locks": "search:all()"
|
|
}
|
|
|
|
FEATURE_SKELETON = {
|
|
"prototype_parent": "FEATURE",
|
|
"prototype_tags": ["feature"],
|
|
"prototype_key": "feature_skeleton",
|
|
"key": "rugged skeleton",
|
|
"aliases": ["skeleton"],
|
|
"desc": "An old humanoid skeleton, eroded by the passage of time.",
|
|
"feature_desc": "A rugged humanoid |wskeleton|n lies on the floor, theirs bony hand still clutching a broken "
|
|
"spear. What remains of theirs armor and clothing is too battered to let you recognize their "
|
|
"origins.",
|
|
"locks": "search:all()"
|
|
}
|
|
|
|
SUMMONING_CIRCLE = {
|
|
"prototype_parent": "feature",
|
|
"prototype_tags": ["feature"],
|
|
"prototype_key": "summoning_circle",
|
|
"key": "circle of summoning",
|
|
"aliases": ["circle", "summoning circle"],
|
|
"desc": "A circular pattern of mystical runes drawn with blood.",
|
|
"feature_desc": "An arcane |wcircle of summoning|n is draw with blood on the floor.",
|
|
}
|
|
|
|
# ITEMS
|
|
|
|
STONE = {
|
|
"prototype_parent": "ITEM",
|
|
"prototype_tags": ["item"],
|
|
"prototype_key": "stone",
|
|
"key": "stone",
|
|
"aliases": ["granite stone"],
|
|
"desc": "An unremarkable stone made of granite."
|
|
}
|
|
|
|
BIG_STONE = {
|
|
"prototype_parent": "ITEM",
|
|
"prototype_tags": ["item"],
|
|
"prototype_key": "big stone",
|
|
"key": "big stone",
|
|
"aliases": ["big granite stone"],
|
|
"desc": "An unremarkable stone made of granite. It seems very heavy.",
|
|
"get_err_msg": "You are not strong enough to lift this stone.",
|
|
"locks": "get:attr_gt(strength, 50)",
|
|
}
|
|
|
|
BROKEN_CROWN = {
|
|
"prototype_parent": "ITEM_EQUIPPABLE",
|
|
"prototype_tags": ["item", "equippable"],
|
|
"prototype_key": "broken_crown",
|
|
"key": "broken crown",
|
|
"desc": "An old iron crown, dented and covered in rust.",
|
|
"slot": 'head'
|
|
}
|
|
|
|
MULTICOLORED_ROBE = {
|
|
"prototype_parent": "ITEM_EQUIPPABLE",
|
|
"prototype_tags": ["item", "equippable"],
|
|
"prototype_key": "multicolored robe",
|
|
"key": "multicolored robe",
|
|
"desc": "A long robe, made of many different colored cloth patches.",
|
|
"slot": 'torso'
|
|
}
|
|
|
|
PLAIN_TROUSERS = {
|
|
"prototype_parent": "ITEM_EQUIPPABLE",
|
|
"prototype_tags": ["item", "equippable"],
|
|
"prototype_key": "plain trousers",
|
|
"key": "plain trousers",
|
|
"desc": "Simple but robust cloth trousers.",
|
|
"slot": 'legs'
|
|
}
|
|
|
|
LEATHER_BOOTS = {
|
|
"prototype_parent": "ITEM_EQUIPPABLE",
|
|
"prototype_tags": ["item", "equippable"],
|
|
"prototype_key": "leather boots",
|
|
"key": "leather boots",
|
|
"desc": "A worn pair of leather boots.",
|
|
"slot": 'foot'
|
|
}
|
|
|
|
LANTERN = {
|
|
"prototype_parent": "ITEM",
|
|
"prototype_tags": ["item"],
|
|
"prototype_key": "lantern",
|
|
"key": "old lantern",
|
|
"aliases": ["lantern"],
|
|
"desc": "An old lantern, still filled with oil.",
|
|
"attrs": [("is_lit", True, None, None)],
|
|
"tags": [("emit_light", "effect", None)],
|
|
"locks": "light:all()",
|
|
}
|
|
|
|
TORCH = {
|
|
"prototype_parent": "ITEM",
|
|
"prototype_tags": ["item"],
|
|
"prototype_key": "torch",
|
|
"key": "torch",
|
|
"aliases": ["torch"],
|
|
"desc": "A crude torch made from a splinter of wood.",
|
|
"attrs": [("is_lit", False, None, None)],
|
|
"locks": "light:all()",
|
|
}
|
|
|
|
BLADE_TOOL = {
|
|
"prototype_parent": "ITEM_EQUIPPABLE",
|
|
"prototype_tags": ["item", "equippable", "material"],
|
|
"prototype_key": "blade tool",
|
|
"key": "steel blade",
|
|
"aliases": ["blade"],
|
|
"desc": "A steel blade, with an oak handle wrapped in cloth.",
|
|
"tags": [("blade", "crafting_tool", None)],
|
|
"slot": 'foot'
|
|
}
|
|
|
|
WOOD_MATERIAL = {
|
|
"prototype_parent": "ITEM",
|
|
"prototype_tags": ["item", "material"],
|
|
"prototype_key": "wood_material",
|
|
"key": "piece of wood",
|
|
"aliases": ["wood"],
|
|
"desc": "An unremarkable piece of wood.",
|
|
"tags": [("wood", "crafting_material", None)],
|
|
}
|
|
|
|
CLOTH_MATERIAL = {
|
|
"prototype_parent": "ITEM",
|
|
"prototype_tags": ["item", "material"],
|
|
"prototype_key": "cloth_material",
|
|
"key": "old rags",
|
|
"aliases": ["rags"],
|
|
"desc": "A torn piece of dirty cloth.",
|
|
"tags": [("cloth", "crafting_material", None)],
|
|
}
|
|
|
|
BLOOD_MATERIAL = {
|
|
"prototype_parent": "ITEM",
|
|
"prototype_tags": ["item", "material"],
|
|
"prototype_key": "blood_material",
|
|
"key": "vial of blood",
|
|
"aliases": ["blood, vial"],
|
|
"desc": "A vial of blood. Fresh.",
|
|
"tags": [("blood", "crafting_material", None)],
|
|
}
|
|
|
|
## example of module-based prototypes using
|
|
## the variable name as `prototype_key` and
|
|
## simple Attributes
|
|
|
|
# from random import randint
|
|
#
|
|
# GOBLIN = {
|
|
# "key": "goblin grunt",
|
|
# "health": lambda: randint(20,30),
|
|
# "resists": ["cold", "poison"],
|
|
# "attacks": ["fists"],
|
|
# "weaknesses": ["fire", "light"],
|
|
# "tags": = [("greenskin", "monster"), ("humanoid", "monster")]
|
|
# }
|
|
#
|
|
# GOBLIN_WIZARD = {
|
|
# "prototype_parent": "GOBLIN",
|
|
# "key": "goblin wizard",
|
|
# "spells": ["fire ball", "lighting bolt"]
|
|
# }
|
|
#
|
|
# GOBLIN_ARCHER = {
|
|
# "prototype_parent": "GOBLIN",
|
|
# "key": "goblin archer",
|
|
# "attacks": ["short bow"]
|
|
# }
|
|
#
|
|
# This is an example of a prototype without a prototype
|
|
# (nor key) of its own, so it should normally only be
|
|
# used as a mix-in, as in the example of the goblin
|
|
# archwizard below.
|
|
# ARCHWIZARD_MIXIN = {
|
|
# "attacks": ["archwizard staff"],
|
|
# "spells": ["greater fire ball", "greater lighting"]
|
|
# }
|
|
#
|
|
# GOBLIN_ARCHWIZARD = {
|
|
# "key": "goblin archwizard",
|
|
# "prototype_parent" : ("GOBLIN_WIZARD", "ARCHWIZARD_MIXIN")
|
|
# }
|