Home - Forums - Documentation - Gallery - Bugs

Crystal Core uses the CEL entity system for objects. There are a few rules for an object (entity) to observe so it can be used in the Crystal Core system as something that can be picked up, used, and so on. Note that the behaviour for a weapon can be written in Python or XML.

Contents

Pickable objects

First to have an object that can be picked up (be it ammo, a weapon, or just any other object) it needs to have the characteristics property class with the weight property set. If the player can carry the object (i.e. weight is ok) then it will be picked up and put in the players inventory (if it is a normal object) or handled appropriately in case it is ammo or a weapon.

Weapons

A weapon is a pickable object (so must follow the rules above). In addition it needs to have the weapon class and it must have the cc_weaponslot property which is a number between 1 and 5 indicating for which slot the weapon is suitable. It must also have the cc_ammo property which is a number indicating the amount of shots left in the weapon. If a weapon is picked up by the player it is not put in the inventory but instead it goes to one of the five weapon slots. If another weapon was already at that slot that weapon will be dropped on the ground if it is a different kind of weapon or else it will be merged (ammo of the weapon being picked up will be added to the weapon in hand).

Ammo

Ammo is a pickable object. In addition it needs to have the ammo class and it must also have the cc_weaponslot property and the cc_ammo property. If you don't have a weapon in the specified slot then the ammo cannot be picked up (stays on the ground). Otherwise the amount of ammo is immediately added to the weapon.

Usable objects

An object that can be used needs to implement the cc_use message. There are two possibilities. Either the object has to be used from inside your inventory or else it is an object that can be used when on the ground. If the object is pickable it can only be used from inside your inventory. In that case it can have the following four return values:

  • -1: object cannot be used (yet) and it stays in inventory.
  • 0: object is used and stays in inventory.
  • 1: object is used, it is removed from inventory and destroyed.
  • 2: object is used, it is removed from inventory but not destroyed.

Objects that are not pickable can only be used in place. In that case cc_use can have the following return values:

  • -1: object cannot be used (yet) but in principle it is an object that could be used in certain situations.
  • 0: object is used and stays on ground.
  • 1: object is used, removed from the ground, and destroyed.
  • 2: object is used, removed from the ground but not destroyed.

Placing Entities

Entities (and other things like creatures) are never placed directly in maps. Instead we use empties (blender name) or nodes (CS name) with well-chosen names (like 'medkit_spawnpoint_reddoor') so that we can assign these to entities at runtime.

| Article | Discussion | View source | History |