dsekai
World engine for retrocomputers.
Loading...
Searching...
No Matches
Modules | Files | Data Structures | Macros | Functions
Items
Collaboration diagram for Items:

Modules

 Item Errors
 
 Item Types and Use
 Definitions and callbacks pertaining to ITEM use in-world.
 
 Item Flags
 Flags which affect an individual ITEM.
 

Files

file  item.h
 Definitions, functions, and macros pertaining to inventory objects.
 
file  itstruct.h
 Structs pertaining to inventory objects.
 

Data Structures

struct  ITEM
 An instance of an item in the world. More...
 

Macros

#define ITEM_INVENTORY_MAX   20
 Maximum number of items in a single MOBILE inventory.
 
#define DSEKAI_ITEMS_MAX   200
 Maximum number of items existing in the world at any time.
 
#define DSEKAI_ITEMS_ONSCREEN   (GRAPHICS_SPRITES_ONSCREEN / 3)
 
#define item_break_if_last(items, i)   if( ITEM_FLAG_NOT_LAST != (ITEM_FLAG_NOT_LAST & items[i].flags) ) { debug_printf( 1, "breaking early on item %d!", i ); break; }
 
#define ITEM_NAME_SZ   8
 The maximum characters in an ITEM::name.
 

Functions

int16_t item_exists_in_inventory (int16_t template_gid, MOBILE_GID owner_gid, struct DSEKAI_STATE *state) SECTION_ITEM
 Determine if/where item with the given ITEM::gid exists in the inventory of an dsekai_items_owners.
 
int16_t item_decr_or_delete (int16_t e_idx, struct DSEKAI_STATE *state) SECTION_ITEM
 
int16_t item_stack_or_add (int16_t template_gid, MOBILE_GID owner_gid, struct DSEKAI_STATE *state) SECTION_ITEM
 Create an item in DSEKAI_STATE::items_handle from a template in TILEMAP::item_defs or increment its count if possible.
 
int16_t item_give_mobile (int16_t e_idx, MOBILE_GID owner_gid, struct DSEKAI_STATE *state) SECTION_ITEM
 
int8_t item_drop (int16_t e_idx, struct DSEKAI_STATE *state) SECTION_ITEM
 Drop am item on the map floor where its owner is standing.
 
int16_t item_pickup_xy (uint8_t x, uint8_t y, MOBILE_GID owner_gid, struct DSEKAI_STATE *state) SECTION_ITEM
 Pick up an item at the given x, y tile coordinates on the given TILEMAP.
 

Detailed Description

Macro Definition Documentation

◆ DSEKAI_ITEMS_MAX

#define DSEKAI_ITEMS_MAX   200

Maximum number of items existing in the world at any time.

Note
This may be overridden by passing a -D argument to the compiler.
Attention
Changing this value may break compatibility with tilemaps or saves! Please use caution.

◆ ITEM_INVENTORY_MAX

#define ITEM_INVENTORY_MAX   20

Maximum number of items in a single MOBILE inventory.

Note
This may be overridden by passing a -D argument to the compiler.
Attention
Changing this value may break compatibility with tilemaps or saves! Please use caution.

Function Documentation

◆ item_drop()

int8_t item_drop ( int16_t  e_idx,
struct DSEKAI_STATE state 
)

Drop am item on the map floor where its owner is standing.

Parameters
e_idxIndex of the ITEM to drop in the current DSEKAI_STATE::items_handle.
tLocked MEMORY_PTR to the TILEMAP on which the item is being dropped.
stateLocked MEMORY_PTR to the current engine DSEKAI_STATE.
Returns
1 if give was successful, or error code otherwise.

◆ item_exists_in_inventory()

int16_t item_exists_in_inventory ( int16_t  template_gid,
MOBILE_GID  owner_gid,
struct DSEKAI_STATE state 
)

Determine if/where item with the given ITEM::gid exists in the inventory of an dsekai_items_owners.

Parameters
template_gidITEM::gid of the definition in TILEMAP::items.
owner_giddsekai_items_owners of the sought item.
stateLocked MEMORY_PTR to the current engine DSEKAI_STATE.
Returns
Index of the item in DSEKAI_STATE::items_handle if it exists or ITEM_ERROR_NOT_FOUND if not.

◆ item_give_mobile()

int16_t item_give_mobile ( int16_t  e_idx,
MOBILE_GID  owner_gid,
struct DSEKAI_STATE state 
)
Parameters
e_idxIndex of the ITEM to give in the current DSEKAI_STATE::items_handle.
owner_gidMOBILE_GID of the MOBILE to give the item to.
tLocked MEMORY_PTR to the TILEMAP containing template_gid in its TILEMAP::item_defs.
stateLocked MEMORY_PTR to the current engine DSEKAI_STATE.
Returns
New item index in DSEKAI_STATE::items_handle if give was successful, or error code otherwise.

◆ item_pickup_xy()

int16_t item_pickup_xy ( uint8_t  x,
uint8_t  y,
MOBILE_GID  owner_gid,
struct DSEKAI_STATE state 
)

Pick up an item at the given x, y tile coordinates on the given TILEMAP.

Parameters
owner_gidMOBILE_GID of the MOBILE to give the item to if found.
tLocked MEMORY_PTR to the TILEMAP from which the item is being picked up.
stateLocked MEMORY_PTR to the current engine DSEKAI_STATE.
Returns
Index of picked up item, or DSEKAI_ITEMS_MAX if no item was picked up.

◆ item_stack_or_add()

int16_t item_stack_or_add ( int16_t  template_gid,
MOBILE_GID  owner_gid,
struct DSEKAI_STATE state 
)

Create an item in DSEKAI_STATE::items_handle from a template in TILEMAP::item_defs or increment its count if possible.

If the item exists in the inventory of the owner it's being added to, this function will attempt to increment its count (stored in its Item Flags).

If the item does not exist, or its count in its owner's inventory has exceeded the maximum defined for its Item Types and Use in gc_items_max, then a new ITEM will be created in the inventory of that owner (unless that inventory has reached ITEM_INVENTORY_MAX).

Parameters
template_gidITEM::gid of the template in TILEMAP::item_defs to add.
owner_gidMOBILE_GID of the MOBILE to give the item to.
tLocked MEMORY_PTR to the TILEMAP containing template_gid in its TILEMAP::item_defs.
stateLocked MEMORY_PTR to the current engine DSEKAI_STATE.
Returns
Index of the new item or stack added to in DSEKAI_STATE::items_handle.