TombEngine/TR5Main/Game/items.h

120 lines
2.8 KiB
C
Raw Normal View History

2020-12-21 13:16:29 -03:00
#pragma once
#include <cstdint>
#include <string>
2021-08-28 13:27:58 +02:00
#include <vector>
2021-12-22 16:23:57 +03:00
#include "Game/animation.h"
2021-12-24 03:32:19 +03:00
#include "Game/itemdata/itemdata.h"
2021-12-22 16:23:57 +03:00
#include "Specific/newtypes.h"
2021-12-24 03:32:19 +03:00
#include "Specific/phd_global.h"
2021-09-19 23:41:26 +03:00
enum GAME_OBJECT_ID : short;
2020-12-21 13:16:29 -03:00
2021-10-08 16:45:45 +03:00
constexpr unsigned int NO_MESH_BITS = UINT_MAX;
enum AIObjectType
2020-12-21 13:16:29 -03:00
{
NO_AI = 0x0000,
GUARD = 0x0001,
AMBUSH = 0x0002,
PATROL1 = 0x0004,
MODIFY = 0x0008,
FOLLOW = 0x0010,
PATROL2 = 0x0020,
ALL_AIOBJ = (GUARD | AMBUSH | PATROL1 | MODIFY | FOLLOW | PATROL2)
};
enum ItemStatus
2020-12-21 13:16:29 -03:00
{
2021-05-13 10:11:22 +02:00
ITEM_NOT_ACTIVE = 0,
ITEM_ACTIVE = 1,
ITEM_DEACTIVATED = 2,
ITEM_INVISIBLE = 3
2020-12-21 13:16:29 -03:00
};
enum ItemFlags
2020-12-21 13:16:29 -03:00
{
IFLAG_CLEAR_BODY = (1 << 7), // 0x0080
IFLAG_INVISIBLE = (1 << 8), // 0x0100
IFLAG_REVERSE = (1 << 14), // 0x4000
IFLAG_KILLED = (1 << 15), // 0x8000
IFLAG_ACTIVATION_MASK = 0x3E00 // bits 9-13
};
struct ITEM_INFO
2021-09-19 23:41:26 +03:00
{
int floor;
uint32_t touchBits;
uint32_t meshBits;
GAME_OBJECT_ID objectNumber;
short currentAnimState;
short goalAnimState;
short requiredAnimState;
short animNumber;
short frameNumber;
2021-09-24 13:50:31 +03:00
std::vector<BONE_MUTATOR> mutator;
2021-09-19 23:41:26 +03:00
short roomNumber;
ROOM_VECTOR location;
short nextItem;
short nextActive;
short speed;
short fallspeed;
short hitPoints;
int boxNumber;
short timer;
uint16_t flags; // ItemFlags enum
short shade;
short triggerFlags;
2021-09-19 23:41:26 +03:00
short carriedItem;
short afterDeath;
short firedWeapon;
short itemFlags[8];
ITEM_DATA data;
PHD_3DPOS pos;
bool active;
short status; // ItemStatus enum
2022-01-21 23:23:10 +11:00
bool airborne;
2021-09-19 23:41:26 +03:00
bool hitStatus;
bool collidable;
bool lookedAt;
bool poisoned;
uint8_t aiBits; // AIObjectType enum
bool inDrawRoom;
bool friendly;
uint32_t swapMeshFlags;
short drawRoom;
short TOSSPAD;
PHD_3DPOS startPos;
short locationAI;
std::string luaName;
};
2020-12-21 13:16:29 -03:00
// used by fx->shade !
#define RGB555(r, g, b) ((r << 7) & 0x7C00 | (g << 2) & 0x3E0 | (b >> 3) & 0x1F)
#define WHITE555 RGB555(255, 255, 255)
#define GRAY555 RGB555(128, 128, 128)
#define BLACK555 RGB555( 0, 0, 0)
constexpr auto NO_ITEM = -1;
constexpr auto ALL_MESHBITS = -1;
constexpr auto NOT_TARGETABLE = -16384;
2021-09-19 23:41:26 +03:00
constexpr auto NUM_ITEMS = 1024;
2020-12-21 13:16:29 -03:00
void EffectNewRoom(short fxNumber, short roomNumber);
void ItemNewRoom(short itemNum, short roomNumber);
void AddActiveItem(short itemNumber);
void ClearItem(short itemNum);
short CreateItem();
void RemoveAllItemsInRoom(short roomNumber, short objectNumber);
void RemoveActiveItem(short itemNum);
void RemoveDrawnItem(short itemNum);
void InitialiseFXArray(int allocmem);
short CreateNewEffect(short roomNum);
void KillEffect(short fxNumber);
void InitialiseItem(short itemNum);
void InitialiseItemArray(int numItems);
void KillItem(short itemNum);
void UpdateItemRoom(ITEM_INFO* item, int height);
2021-09-15 14:24:03 +03:00
std::vector<int> FindAllItems(short objectNumber);
ITEM_INFO* FindItem(int object_number);
int FindItem(ITEM_INFO* item);