Overview
The item system provides a flexible framework for weapons, collectibles, and usable items. Items can be carried in character inventories, dropped as world entities, and configured with custom behaviors.Function Reference
item_new()
Creates a generic item.Pointer to the game instance
Pointer to the window instance
Item identifier for configuration lookup
Pointer to the newly created item, or
NULL on allocation failureweapon_new()
Creates a weapon item with damage and range properties.Pointer to the game instance
Pointer to the window instance
Weapon identifier for configuration lookup
Pointer to the newly created weapon, or
NULL on allocation failurecollectible_new()
Creates a collectible item that modifies character stats.Pointer to the game instance
Pointer to the window instance
Collectible identifier for configuration lookup
Pointer to the newly created collectible, or
NULL on allocation failureStructure Definitions
s_item
Base item structure with common properties and behavior hooks.Called every frame to update item state
Cleanup function called before freeing item
Called when item is used by a character
Called when item is dropped into the world
Unique character identifying this item type
Display name of the item
Item description text
True if item is a weapon
True if item is a collectible
Whether item can currently be used
Character currently using this item
Previous frame’s usage state
True if item is currently being used
If true, item is consumed after one use
Minimum delay between uses in milliseconds
Sound played when item cannot be used
Timestamp of last “can’t use” sound play
Timestamp of last use
Sound played when item is used
Sound played when item is picked up
Icon sprite displayed during use
Original icon sprite reference
Current icon sprite (for HUD)
Full-screen sprite during use
Current screen sprite
Original screen sprite reference
s_weapon
Weapon item with combat properties.Base item structure
Damage dealt per hit
Maximum effective range
Ammunition consumed per use
s_collectible
Collectible item that modifies character stats.Base item structure
Health points added when collected
Score points added when collected
Ammunition added when collected
Map Type Configuration
Item Configuration
Display name of the item
Item description text
Delay between uses in seconds
"TRUE" for consumable items, "FALSE" for reusablePath to inventory icon sprite
Path to first-person screen sprite
Path to icon sprite during use
Path to screen sprite during use
Path to use sound effect
Path to pickup sound effect
Path to sound when item cannot be used
Weapon Configuration
Damage dealt per shot
Maximum effective range
Ammunition consumed per use
Collectible Configuration
Health points restored (absolute value used)
Ammunition added (absolute value used)
Score points added (absolute value used)
Helper Functions
Example
See Also
- Characters - Inventory management
- Billboards - Drop entities