#ifndef TILE_H #define TILE_H #include "inventory.h" #define TILE_NULL 0 #define PASS 0 #define NO_PASS 1 #define NULL_CHAR '\0' #define PLAYER 1 #define FLOOR 2 #define WALL 3 #define DOOR 4 #define ITEM 5 #define EQUIP 6 #define NPC 7 #define STATE_CLOSED 0 #define STATE_OPEN 1 #define STATE_BROKEN 2 #define STATE_MISSING 3 // TODO: move this elsewhere, perhaps to a stats.c file - it is for items, players, and npcs, so perhaps separate would be best. struct Stats { char strength; char constitution; char dexterity; char intelligence; char wisdom; char charisma; }; /*** Tile struct Tile is the overarching struct for all objects on the map, be they walls, items, monsters, or even the players. ***/ struct Tile { unsigned int tid; short id; // the tile's id, 0-9,999=walls;10,000-19,999=ground;20,000-29,999=items;30,000-39,999=monsters short x; // x coords on the map short y; // y coords on the map struct Tile *next; // pointer to next Tile in the chain struct Tile *prev; // pointer to previous Tile in the chain void *data; // pointer to the Tile's actual data, preferably a struct }; struct Tile null_tile; // FIXME: temporary solution to next and prev pointers struct BasicTile { char name[16]; }; struct DoorTile { char name[16]; int state; }; extern struct DoorTile doors[]; struct PlayerTile { char name[16]; int vision; char stats[31]; char slots[63]; char used_slots[63]; // struct Slots slots; // struct Slots used_slots; struct Inventory inventory; struct Inventory equipment; struct Controller *controller; }; extern struct PlayerTile players[]; struct NpcTile { char name[16]; int vision; int behavior; // for BEHAVE_AGGRESSIVE, etc. char stats[31]; char slots[63]; char used_slots[63]; // struct Slots slots; // struct Slots used_slots; struct Inventory inventory; struct Inventory equipment; struct Tile *target; }; extern struct NpcTile npcs[]; struct ItemTile { char name[16]; int type; // 0 = generic item }; extern struct ItemTile items[]; struct EquipTile { char name[16]; int type; // TODO: remove? char required_slots[63]; // required slots to equip char damage_mod[63]; // damage given by wearing item char armour_mod[63]; // armour given by wearing item char stat_mod[63]; // stats given by wearing item char slot_mod[63]; // slots given by wearing item }; extern struct EquipTile equips[]; /* interface used for creating new Tile */ struct Tile *newTile(unsigned int tid, short id, short x, short y); void freeTile(struct Tile* tile); /* */ void removeFromChain(struct Tile* tile); struct Tile *getLastTile(struct Tile* tile); /*** activateTile (target_tile, activator_tile) This function, when called on a TRIGGER tile, attempts to do various operations on the target_tile depending on the TriggerTile's type among other conditions. A basic example is the DOOR subtype, which simple toggles from STATE_OPEN to STATE_CLOSED and vice versa when activated. ***/ int activateTile(struct Tile *target_tile, struct Tile *activator_tile); #endif