Overview
Characters are billboard entities with inventory, health, AI behavior, and animation states. They serve as the base for both players and NPCs.Function Reference
character_new()
Creates and initializes a new character entity.Pointer to the game instance
Pointer to the window instance
Character identifier for loading configuration and assets from the map
Pointer to the newly created character, or
NULL on allocation failureStructure Definition
s_character
The character structure extendst_billboard with combat, inventory, and AI properties.
Base billboard entity data (see Billboards)
360-degree sprite array for item usage animation
360-degree sprite array for death animation
360-degree sprite array for hit reaction animation
360-degree sprite array for walking animation
Default idle sprite (reference to billboard.sprites)
Timestamp of last damage received
Timestamp of last item use
Timestamp of last automatic item use
Audio played when character takes damage
Audio played when character dies
Currently targeted entity for AI/interaction
Reference to the character that last damaged this character
Direction to the target entity
Timestamp of last inventory scroll action
Debug flag for cheat mode
Array of inventory items (size: 9)
Drop entity spawned when items are dropped
Whether character drops items on death
Field of view for rendering (defaults to PLAYER_FOV if not set)
Number of rays for raycasting
Currently selected inventory slot (0-8)
Identifier of the last used item
Current ammunition count
Character’s score value (awarded to killer on death)
Timestamp of death
Flag tracking previous death state
Current death state
Constants
Duration in milliseconds that hit animation plays
Default maximum health if not specified in map configuration
Number of inventory slots
Minimum delay in seconds between inventory scrolls
Inventory System
Characters have a 9-slot inventory system configured via map types:{identifier}_{slot}_INVENTORY where slot is 0-8.
Map Type Configuration
Maximum health points (default: 100)
Starting ammunition
Score awarded to killer on death
Field of view in degrees
"TRUE" to drop inventory on death, "FALSE" otherwisePath to walking sprite assets (360-degree)
Path to death sprite assets (360-degree)
Path to hit sprite assets (360-degree) or hit sound
Drop entity identifier spawned on death
Animation System
Characters automatically switch between animation states:- Death - When
health <= 0anddead == true - Hit - Within
CHARACTER_HIT_DELAYms after taking damage - Using - While using an item
- Walking - While controller movement is active
- Idle - Default state
Combat System
When a character is shot:- Updates
last_hittimestamp - Sets
last_hit_by_characterto the shooter - Plays hit sound or death sound
- Awards
scoreto shooter on death - Sets
dead = truewhen health reaches 0 - Triggers death animation
Helper Functions
Example
See Also
- Player - Player-specific character extension
- Items - Inventory system
- Billboards - Base billboard entity