Since we are using TLevel.Load, the system to load creatures and items (together called 3D resources) is actually ready to use. A nice default handling of creatures and items suitable for 3D games is ready, in CastleCreatures and CastleItems units.
Creatures and items are defined by files named
in the game data. Their contents looks like this:
<?xml version="1.0"?> <resource name="MyCreatureName" type="WalkAttack" url="my_creature.castle-anim-frames"> <model> <idle animation_name="idle" /> <walk animation_name="walk" /> <attack animation_name="attack" /> <die animation_name="die" /> <hurt animation_name="hurt" /> </model> </resource>
url properties refer to actual 3D models
defining creature animations.
examples/fps_game/ data for a real example how such file looks
like. And see creating resources for a complete
resource.xml files, and how to create and export
The most important properties
about creatures and items specified in
name: this is a unique internal name of the resource (creature or item). It can be used as a placeholder name to place initial creatures/items on the level using 3D modeller (like Blender).
type: refers to ObjectPascal class handling the actual behavior of this resource. Engine already defines various basic creatures/items behavior, you can also extend our classes to create your own types.
To make the engine aware of such resources just add
call (from unit
CastleResources) to your program. This will cause all
information about the creatures and items automatically
You usually want to call
before loading the level, this way loading the level will be able
to automatically add initial creatures/items from placeholders.
It is best to list necessary creatures in
to have them prepared (list there both the initial creatures
and the creatures you will spawn by code during the game).
See creating levels for documentation of
The "type" of the creatures determines it's ObjectPascal class, in turn determining creature AI, and how many 3D models (or states) it has, and various other properties. Hostile creatures are automatically hostile to our Player.
Items are automatically pickable by player, player backpack is automatically managed.
Copyright Michalis Kamburelis and other Castle Game Engine developers.
Thank you to Paweł Wojciechowicz from Cat-astrophe Games for various graphics.
This documentation is also open-source and you can even redistribute it on open-source terms.