TombEngine/TR5Main/Game/items.h

128 lines
2.9 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
// 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)
2021-10-08 16:45:45 +03:00
constexpr unsigned int NO_MESH_BITS = UINT_MAX;
constexpr auto NO_ITEM = -1;
constexpr auto ALL_MESHBITS = -1;
constexpr auto NOT_TARGETABLE = -16384;
constexpr auto NUM_ITEMS = 1024;
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 EntityAnimationData
{
int AnimNumber;
int FrameNumber;
int ActiveState;
int TargetState;
int RequiredState; // TODO: Phase out this weird feature.
bool Airborne;
int Velocity;
int VerticalVelocity;
int LateralVelocity;
std::vector<BONE_MUTATOR> Mutator;
};
struct ITEM_INFO
2021-09-19 23:41:26 +03:00
{
GAME_OBJECT_ID ObjectNumber;
std::string LuaName;
short NextItem;
short NextActive;
bool Active;
int Status; // ItemStatus enum.
short RoomNumber;
ROOM_VECTOR Location;
int BoxNumber;
int Timer;
int Floor;
short Shade;
int HitPoints;
bool HitStatus;
bool LookedAt;
bool Collidable;
bool InDrawRoom;
ITEM_DATA Data;
EntityAnimationData Animation;
PHD_3DPOS Position;
PHD_3DPOS StartPosition;
uint32_t TouchBits;
uint32_t MeshBits;
uint16_t Flags; // ItemFlags enum
short ItemFlags[8];
short TriggerFlags;
uint32_t SwapMeshFlags;
// TODO: Move to CreatureInfo?
uint8_t AIBits; // AIObjectType enum.
short AfterDeath;
short CarriedItem;
2021-09-19 23:41:26 +03:00
};
2020-12-21 13:16:29 -03:00
void EffectNewRoom(short fxNumber, short roomNumber);
2022-03-07 14:30:56 +11:00
void ItemNewRoom(short itemNumber, short roomNumber);
2020-12-21 13:16:29 -03:00
void AddActiveItem(short itemNumber);
2022-03-07 14:30:56 +11:00
void ClearItem(short itemNumber);
2020-12-21 13:16:29 -03:00
short CreateItem();
void RemoveAllItemsInRoom(short roomNumber, short objectNumber);
2022-03-07 14:30:56 +11:00
void RemoveActiveItem(short itemNumber);
void RemoveDrawnItem(short itemNumber);
void InitialiseFXArray(int allocateMemory);
short CreateNewEffect(short roomNumber);
2020-12-21 13:16:29 -03:00
void KillEffect(short fxNumber);
2022-03-07 14:30:56 +11:00
void InitialiseItem(short itemNumber);
void InitialiseItemArray(int totalItems);
void KillItem(short itemNumber);
void UpdateItemRoom(ITEM_INFO* item, int height, int xOffset = 0, int zOffset = 0);
2021-09-15 14:24:03 +03:00
std::vector<int> FindAllItems(short objectNumber);
2022-03-07 14:30:56 +11:00
ITEM_INFO* FindItem(int objectNumber);
int FindItem(ITEM_INFO* item);