Crossfire Server, Trunk
|
Archetypes define the standard properties of predefined objects: monsters, weapons, armours, walls, spells, etc. Most objects in a map are equivalent to their archetype definition, but it is of course possible to define special properties for specific needs.
Archetypes are not manipulated at runtime (with the exception of temporary archetypes, see below), and are loaded into memory during the server startup.
Archetypes are defined in the arch
git module. The definition is split in many .arc
files, usually one per predefined item.
Archetype manipulation functions are defined in the arch.cpp file, and the structure is archetype.
It is possible to add objects in an archetype's inventory. All objects created from this archetype will have a copy of those objects, and additional objects if defined.
To add an object in an archetype, just add a arch archetype_name
in the file, followed by custom values for the objects, finished by an end
tag. This is equivalent to the format used for saving objects on maps.
Temporary archetypes are special archetypes used for custom monsters. When the map loading code detects a customized monster, it will create a temporary archetype that will contain the initial values of the monster.
This temporary archetype is required for the custom values to survive a call to fix_object(), call that will happen when the monster picks/drops items, is cursed, etc.
Temporary archetypes will be automatically destroyed when the last object they are linked to is object_free()'d.