creature: move Creature_Head to trx

This commit is contained in:
Marcin Kurczewski 2025-04-09 14:09:06 +02:00
parent a878739c40
commit 751e5c4cb5
5 changed files with 21 additions and 39 deletions

View file

@ -10,6 +10,12 @@
#define M_ESCAPE_CHANCE 2048 #define M_ESCAPE_CHANCE 2048
#define M_RECOVER_CHANCE 256 #define M_RECOVER_CHANCE 256
#define M_MAX_TILT (3 * DEG_1) // = 546 #define M_MAX_TILT (3 * DEG_1) // = 546
#define M_MAX_HEAD_CHANGE (5 * DEG_1) // = 910
#if TR_VERSION == 1
#define M_HEAD_ARC FRONT_ARC
#elif TR_VERSION >= 2
#define M_HEAD_ARC 0x3000 // = 12288
#endif
static ITEM *M_ChooseEnemy(const ITEM *item); static ITEM *M_ChooseEnemy(const ITEM *item);
static bool M_SwitchToWater( static bool M_SwitchToWater(
@ -427,3 +433,17 @@ void Creature_Tilt(ITEM *const item, int16_t angle)
CLAMP(angle, -M_MAX_TILT, M_MAX_TILT); CLAMP(angle, -M_MAX_TILT, M_MAX_TILT);
item->rot.z += angle; item->rot.z += angle;
} }
void Creature_Head(ITEM *const item, const int16_t required)
{
CREATURE *const creature = item->data;
if (creature == nullptr) {
return;
}
int16_t change = required - creature->head_rotation;
CLAMP(change, -M_MAX_HEAD_CHANGE, M_MAX_HEAD_CHANGE);
creature->head_rotation += change;
CLAMP(creature->head_rotation, -M_HEAD_ARC, M_HEAD_ARC);
}

View file

@ -12,11 +12,11 @@ void Creature_Mood(const ITEM *item, const AI_INFO *info, bool violent);
int16_t Creature_Turn(ITEM *item, int16_t max_turn); int16_t Creature_Turn(ITEM *item, int16_t max_turn);
void Creature_Tilt(ITEM *item, int16_t angle); void Creature_Tilt(ITEM *item, int16_t angle);
void Creature_Head(ITEM *item, int16_t required);
extern bool Creature_IsHostile(const ITEM *item); extern bool Creature_IsHostile(const ITEM *item);
extern void Creature_Collision( extern void Creature_Collision(
int16_t item_num, ITEM *lara_item, COLL_INFO *coll); int16_t item_num, ITEM *lara_item, COLL_INFO *coll);
extern void Creature_Head(ITEM *item, int16_t required);
extern bool Creature_Animate(int16_t item_num, int16_t angle, int16_t tilt); extern bool Creature_Animate(int16_t item_num, int16_t angle, int16_t tilt);
extern int16_t Creature_Effect( extern int16_t Creature_Effect(
const ITEM *item, const BITE *bite, const ITEM *item, const BITE *bite,

View file

@ -18,29 +18,6 @@
#include <libtrx/game/math.h> #include <libtrx/game/math.h>
#include <libtrx/log.h> #include <libtrx/log.h>
void Creature_Head(ITEM *item, int16_t required)
{
CREATURE *creature = item->data;
if (!creature) {
return;
}
int16_t change = required - creature->head_rotation;
if (change > MAX_HEAD_CHANGE) {
change = MAX_HEAD_CHANGE;
} else if (change < -MAX_HEAD_CHANGE) {
change = -MAX_HEAD_CHANGE;
}
creature->head_rotation += change;
if (creature->head_rotation > FRONT_ARC) {
creature->head_rotation = FRONT_ARC;
} else if (creature->head_rotation < -FRONT_ARC) {
creature->head_rotation = -FRONT_ARC;
}
}
int16_t Creature_Effect( int16_t Creature_Effect(
const ITEM *const item, const BITE *const bite, const ITEM *const item, const BITE *const bite,
int16_t (*spawn)( int16_t (*spawn)(

View file

@ -56,7 +56,6 @@
#define MIN_HEAD_TILT_SURF (-40 * DEG_1) // = -7280 #define MIN_HEAD_TILT_SURF (-40 * DEG_1) // = -7280
#define DIVE_WAIT 10 #define DIVE_WAIT 10
#define STEPUP_HEIGHT ((STEP_L * 3) / 2) // = 384 #define STEPUP_HEIGHT ((STEP_L * 3) / 2) // = 384
#define MAX_HEAD_CHANGE (DEG_1 * 5) // = 910
#define CAM_A_HANG 0 #define CAM_A_HANG 0
#define CAM_E_HANG (-60 * DEG_1) // = -10920 #define CAM_E_HANG (-60 * DEG_1) // = -10920
#define CAM_WADE_ELEVATION (-22 * DEG_1) // = -4004 #define CAM_WADE_ELEVATION (-22 * DEG_1) // = -4004

View file

@ -358,20 +358,6 @@ bool Creature_Animate(
return true; return true;
} }
void Creature_Head(ITEM *item, int16_t required)
{
CREATURE *const creature = item->data;
if (creature == nullptr) {
return;
}
int16_t change = required - creature->head_rotation;
CLAMP(change, -MAX_HEAD_CHANGE, MAX_HEAD_CHANGE);
creature->head_rotation += change;
CLAMP(creature->head_rotation, -HEAD_ARC, HEAD_ARC);
}
void Creature_Neck(ITEM *const item, const int16_t required) void Creature_Neck(ITEM *const item, const int16_t required)
{ {
CREATURE *const creature = item->data; CREATURE *const creature = item->data;