Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
types: pull ITEM_INFO and GAME_OBJECT_ID
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Sep 6, 2024
1 parent f9a6af1 commit 1a7ca86
Show file tree
Hide file tree
Showing 5 changed files with 603 additions and 0 deletions.
96 changes: 96 additions & 0 deletions include/libtrx/game/items.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#pragma once

#include "objects.h"

#include <stdbool.h>
#include <stdint.h>
#include "math.h"

#pragma pack(push, 1)

#if TR_VERSION == 1
typedef enum {
DS_CARRIED = 0,
DS_FALLING = 1,
DS_DROPPED = 2,
DS_COLLECTED = 3,
} DROP_STATUS;

typedef struct CARRIED_ITEM {
GAME_OBJECT_ID object_id;
int16_t spawn_num;
XYZ_32 pos;
XYZ_16 rot;
int16_t room_num;
int16_t fall_speed;
DROP_STATUS status;
struct CARRIED_ITEM *next_item;
} CARRIED_ITEM;
#endif

typedef struct {
int32_t floor;
uint32_t touch_bits;
uint32_t mesh_bits;
#if TR_VERSION == 1
GAME_OBJECT_ID object_id;
#elif TR_VERSION == 2
int16_t object_id;
#endif
int16_t current_anim_state;
int16_t goal_anim_state;
int16_t required_anim_state;
int16_t anim_num;
int16_t frame_num;
int16_t room_num;
int16_t next_item;
int16_t next_active;
int16_t speed;
int16_t fall_speed;
int16_t hit_points;
int16_t box_num;
int16_t timer;
uint16_t flags;

#if TR_VERSION == 1
int16_t shade;
void *data;
void *priv;
CARRIED_ITEM *carried_item;
#elif TR_VERSION == 2
int16_t shade1;
int16_t shade2;
int16_t carried_item;
void *data;
#endif

XYZ_32 pos;
XYZ_16 rot;

uint16_t active : 1; // 0x0001
uint16_t status : 2; // 0x0002…0x0004
uint16_t gravity : 1; // 0x0008
uint16_t hit_status : 1; // 0x0010
uint16_t collidable : 1; // 0x0020
uint16_t looked_at : 1; // 0x0040
#if TR_VERSION == 1
uint16_t pad : 9; // 0x0080…0x8000
#elif TR_VERSION == 2
uint16_t dynamic_light : 1; // 0x0080
uint16_t killed : 1; // 0x0100
uint16_t pad : 7; // 0x0200…0x8000
#endif

#if TR_VERSION == 1
struct {
struct {
XYZ_32 pos;
XYZ_16 rot;
} result, prev;
} interp;
#endif
} ITEM_INFO;

#pragma pack(pop)

void Item_TakeDamage(ITEM_INFO *item, int16_t damage, bool hit_status);
19 changes: 19 additions & 0 deletions include/libtrx/game/math.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include <stdint.h>

#pragma pack(push, 1)

typedef struct {
int32_t x;
int32_t y;
int32_t z;
} XYZ_32;

typedef struct {
int16_t x;
int16_t y;
int16_t z;
} XYZ_16;

#pragma pack(pop)
Loading

0 comments on commit 1a7ca86

Please sign in to comment.