123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- """
- 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.
- """
- ROOM_EMPTY = {
- "prototype_key": "room_empty",
- "key": "empty room",
- "desc": "An empty room.",
- "typeclass": "typeclasses.rooms.IndoorRoom"
- }
- EXIT_EMPTY = {
- "prototype_key": "exit_empty",
- "key": "corridor",
- "desc": "An empty corridor.",
- "typeclass": "typeclasses.exits.BaseDoor"
- }
- BROKEN_CROWN = {
- "prototype_key": "broken_crown",
- "key": "broken crown",
- "desc": "An old iron crown, dented and covered in rust.",
- "typeclass": "typeclasses.objects.EquippableItem",
- "slot": 'head'
- }
- MULTICOLORED_ROBE = {
- "prototype_key": "multicolored robe",
- "key": "multicolored robe",
- "desc": "A long robe, made of many different colored cloth patches.",
- "typeclass": "typeclasses.objects.EquippableItem",
- "slot": 'torso'
- }
- PLAIN_TROUSERS = {
- "prototype_key": "plain trousers",
- "key": "plain trousers",
- "desc": "Simple but robust cloth trousers.",
- "typeclass": "typeclasses.objects.EquippableItem",
- "slot": 'legs'
- }
- LEATHER_BOOTS = {
- "prototype_key": "leather boots",
- "key": "leather boots",
- "desc": "A worn pair of leather boots.",
- "typeclass": "typeclasses.objects.EquippableItem",
- "slot": 'foot'
- }
- FEATURE_CONTAINER = {
- "prototype_key": "feature_container",
- "key": "chest",
- "desc": "A chest.",
- "feature_desc": "A |wchest|n lies on the floor.",
- "typeclass": "typeclasses.objects.ContainerFeature"
- }
- FEATURE_SKELETON = {
- "prototype_key": "feature_skeleton",
- "key": "rugged 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 clothings is too battered to let you recognize their origins.",
- "typeclass": "typeclasses.objects.Feature"
- }
- STONE = {
- "prototype_key": "stone",
- "key": "stone",
- "desc": "An unremarkable stone made of granite.",
- "aliases": ["granite stone"],
- "typeclass": "typeclasses.objects.Item"
- }
- BIG_STONE = {
- "prototype_key": "big stone",
- "key": "big stone",
- "desc": "An unremarkable stone made of granite. It seems very heavy.",
- "aliases": ["big granite stone"],
- "get_err_msg": "You are not strong enough to lift this stone.",
- "locks": "get:attr_gt(strength, 50)",
- "typeclass": "typeclasses.objects.Item"
- }
- LANTERN = {
- "prototype_key": "lantern",
- "key": "old lantern",
- "desc": "An old lantern, still filled with oil.",
- "aliases": ["lantern"],
- "attrs": [("is_lit", True, None, None)],
- "tags": [("emit_light", "effect", None)],
- "locks": "light:all()",
- "typeclass": "typeclasses.objects.Item"
- }
- BLADE_TOOL = {
- "prototype_key": "blade tool",
- "key": "steel blade",
- "desc": "A steel blade, with an oak handle wrapped in cloth.",
- "aliases": ["blade"],
- "tags": [("blade", "crafting_tool", None)],
- "typeclass": "typeclasses.objects.EquippableItem",
- "slot": 'foot'
- }
- WOOD_MATERIAL = {
- "prototype_key": "wood_material",
- "key": "piece of wood",
- "desc": "An unremarkable piece of wood.",
- "aliases": ["wood"],
- "tags": [("wood", "crafting_material", None)],
- "typeclass": "typeclasses.objects.Item"
- }
- BLOOD_MATERIAL = {
- "prototype_key": "blood_material",
- "key": "vial of blood",
- "desc": "A vial of blood. Fresh.",
- "aliases": ["blood, vial"],
- "tags": [("blood", "crafting_material", None)],
- "typeclass": "typeclasses.objects.Item"
- }
- SUMMONING_CIRCLE = {
- "prototype_key": "summoning_circle",
- "key": "summoning circle",
- "aliases": ["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.",
- "typeclass": "typeclasses.objects.Feature"
- }
- ## 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")
- # }
|