mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 20:58:07 +03:00
creature: move creature declarations to TRX
This moves common creature function declarations, types, enums and consts to TRX, along with TR2's Creature_Activate approach, although currently only used in TR2. A follow-up task will be to update each TR1 creature control similarly.
This commit is contained in:
parent
58e8def9e5
commit
b6bb8459e8
15 changed files with 110 additions and 116 deletions
16
src/libtrx/game/creature/common.c
Normal file
16
src/libtrx/game/creature/common.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include "game/creature.h"
|
||||
|
||||
bool Creature_Activate(const int16_t item_num)
|
||||
{
|
||||
ITEM *const item = Item_Get(item_num);
|
||||
if (item->status != IS_INVISIBLE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!LOT_EnableBaddieAI(item_num, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
item->status = IS_ACTIVE;
|
||||
return true;
|
||||
}
|
|
@ -1,34 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "items.h"
|
||||
#include "math.h"
|
||||
#include "pathing.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum {
|
||||
MOOD_BORED = 0,
|
||||
MOOD_ATTACK = 1,
|
||||
MOOD_ESCAPE = 2,
|
||||
MOOD_STALK = 3,
|
||||
} MOOD_TYPE;
|
||||
|
||||
typedef struct {
|
||||
int16_t head_rotation;
|
||||
int16_t neck_rotation;
|
||||
int16_t maximum_turn;
|
||||
int16_t flags;
|
||||
int16_t item_num;
|
||||
MOOD_TYPE mood;
|
||||
LOT_INFO lot;
|
||||
XYZ_32 target;
|
||||
#if TR_VERSION == 2
|
||||
ITEM *enemy;
|
||||
#endif
|
||||
} CREATURE;
|
||||
|
||||
#define CREATURE_STALK_DIST (3 * WALL_L) // = 3072
|
||||
#define CREATURE_ESCAPE_DIST (5 * WALL_L) // = 5120
|
||||
#define CREATURE_TARGET_DIST (4 * WALL_L) // = 4096
|
||||
|
||||
bool Creature_IsHostile(const ITEM *item);
|
||||
#include "./creature/common.h"
|
||||
#include "./creature/const.h"
|
||||
#include "./creature/enum.h"
|
||||
#include "./creature/types.h"
|
||||
|
|
22
src/libtrx/include/libtrx/game/creature/common.h
Normal file
22
src/libtrx/include/libtrx/game/creature/common.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include "../collision.h"
|
||||
#include "./types.h"
|
||||
|
||||
bool Creature_Activate(int16_t item_num);
|
||||
bool Creature_IsHostile(const ITEM *item);
|
||||
|
||||
extern void Creature_Initialise(int16_t item_num);
|
||||
extern void Creature_Collision(
|
||||
int16_t item_num, ITEM *lara_item, COLL_INFO *coll);
|
||||
extern void Creature_AIInfo(ITEM *item, AI_INFO *info);
|
||||
extern void Creature_Mood(const ITEM *item, const AI_INFO *info, bool violent);
|
||||
extern int16_t Creature_Turn(ITEM *item, int16_t maximum_turn);
|
||||
extern void Creature_Tilt(ITEM *item, int16_t angle);
|
||||
extern void Creature_Head(ITEM *item, int16_t required);
|
||||
extern bool Creature_Animate(int16_t item_num, int16_t angle, int16_t tilt);
|
||||
extern int16_t Creature_Effect(
|
||||
const ITEM *item, const BITE *bite,
|
||||
int16_t (*spawn)(
|
||||
int32_t x, int32_t y, int32_t z, int16_t speed, int16_t y_rot,
|
||||
int16_t room_num));
|
8
src/libtrx/include/libtrx/game/creature/const.h
Normal file
8
src/libtrx/include/libtrx/game/creature/const.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#define FRONT_ARC DEG_90
|
||||
#define UNIT_SHADOW 256
|
||||
|
||||
#define CREATURE_STALK_DIST (3 * WALL_L) // = 3072
|
||||
#define CREATURE_ESCAPE_DIST (5 * WALL_L) // = 5120
|
||||
#define CREATURE_TARGET_DIST (4 * WALL_L) // = 4096
|
8
src/libtrx/include/libtrx/game/creature/enum.h
Normal file
8
src/libtrx/include/libtrx/game/creature/enum.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
typedef enum {
|
||||
MOOD_BORED = 0,
|
||||
MOOD_ATTACK = 1,
|
||||
MOOD_ESCAPE = 2,
|
||||
MOOD_STALK = 3,
|
||||
} MOOD_TYPE;
|
45
src/libtrx/include/libtrx/game/creature/types.h
Normal file
45
src/libtrx/include/libtrx/game/creature/types.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
#pragma once
|
||||
|
||||
#include "../items.h"
|
||||
#include "../pathing.h"
|
||||
#include "./enum.h"
|
||||
|
||||
typedef struct {
|
||||
int16_t head_rotation;
|
||||
int16_t neck_rotation;
|
||||
int16_t maximum_turn;
|
||||
int16_t flags;
|
||||
int16_t item_num;
|
||||
MOOD_TYPE mood;
|
||||
LOT_INFO lot;
|
||||
XYZ_32 target;
|
||||
#if TR_VERSION == 2
|
||||
ITEM *enemy;
|
||||
#endif
|
||||
} CREATURE;
|
||||
|
||||
typedef struct {
|
||||
int16_t zone_num;
|
||||
// TODO: merge
|
||||
union {
|
||||
int16_t enemy_zone;
|
||||
int16_t enemy_zone_num;
|
||||
};
|
||||
int32_t distance;
|
||||
int32_t ahead;
|
||||
int32_t bite;
|
||||
int16_t angle;
|
||||
int16_t enemy_facing;
|
||||
} AI_INFO;
|
||||
|
||||
typedef struct {
|
||||
// TODO: merge
|
||||
#if TR_VERSION == 1
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t z;
|
||||
#else
|
||||
XYZ_32 pos;
|
||||
#endif
|
||||
int32_t mesh_num;
|
||||
} BITE;
|
|
@ -120,6 +120,7 @@ sources = [
|
|||
'game/console/common.c',
|
||||
'game/console/history.c',
|
||||
'game/console/registry.c',
|
||||
'game/creature/common.c',
|
||||
'game/demo/common.c',
|
||||
'game/fader.c',
|
||||
'game/game.c',
|
||||
|
|
|
@ -82,7 +82,8 @@ void Creature_AIInfo(ITEM *item, AI_INFO *info)
|
|||
&& (g_LaraItem->pos.y < item->pos.y + STEP_L);
|
||||
}
|
||||
|
||||
void Creature_Mood(ITEM *item, AI_INFO *info, bool violent)
|
||||
void Creature_Mood(
|
||||
const ITEM *const item, const AI_INFO *const info, const bool violent)
|
||||
{
|
||||
CREATURE *creature = item->data;
|
||||
if (!creature) {
|
||||
|
@ -317,7 +318,7 @@ void Creature_Head(ITEM *item, int16_t required)
|
|||
}
|
||||
|
||||
int16_t Creature_Effect(
|
||||
ITEM *item, BITE *bite,
|
||||
const ITEM *const item, const BITE *const bite,
|
||||
int16_t (*spawn)(
|
||||
int32_t x, int32_t y, int32_t z, int16_t speed, int16_t yrot,
|
||||
int16_t room_num))
|
||||
|
|
|
@ -22,20 +22,7 @@ typedef struct {
|
|||
} water;
|
||||
} HYBRID_INFO;
|
||||
|
||||
void Creature_Initialise(int16_t item_num);
|
||||
void Creature_AIInfo(ITEM *item, AI_INFO *info);
|
||||
void Creature_Mood(ITEM *item, AI_INFO *info, bool violent);
|
||||
int16_t Creature_Turn(ITEM *item, int16_t maximum_turn);
|
||||
void Creature_Tilt(ITEM *item, int16_t angle);
|
||||
void Creature_Head(ITEM *item, int16_t required);
|
||||
int16_t Creature_Effect(
|
||||
ITEM *item, BITE *bite,
|
||||
int16_t (*spawn)(
|
||||
int32_t x, int32_t y, int32_t z, int16_t speed, int16_t yrot,
|
||||
int16_t room_num));
|
||||
bool Creature_CheckBaddieOverlap(int16_t item_num);
|
||||
void Creature_Collision(int16_t item_num, ITEM *lara_item, COLL_INFO *coll);
|
||||
bool Creature_Animate(int16_t item_num, int16_t angle, int16_t tilt);
|
||||
bool Creature_CanTargetEnemy(ITEM *item, AI_INFO *info);
|
||||
bool Creature_ShootAtLara(
|
||||
ITEM *item, int32_t distance, BITE *gun, int16_t extra_rotation,
|
||||
|
|
|
@ -66,7 +66,6 @@
|
|||
#define MIN_HEAD_TILT_SURF (-40 * DEG_1) // = -7280
|
||||
#define DIVE_WAIT 10
|
||||
#define STEPUP_HEIGHT ((STEP_L * 3) / 2) // = 384
|
||||
#define FRONT_ARC DEG_90
|
||||
#define MAX_HEAD_CHANGE (DEG_1 * 5) // = 910
|
||||
#define MAX_TILT (DEG_1 * 3) // = 546
|
||||
#define CAM_A_HANG 0
|
||||
|
@ -79,7 +78,6 @@
|
|||
#define COMBAT_DISTANCE (WALL_L * 5 / 2) // = 2560
|
||||
#define MAX_ELEVATION (85 * DEG_1) // = 15470
|
||||
#define DEFAULT_RADIUS 10
|
||||
#define UNIT_SHADOW 256
|
||||
#define NO_BAD_POS (-NO_HEIGHT)
|
||||
#define NO_BAD_NEG NO_HEIGHT
|
||||
#define BAD_JUMP_CEILING ((STEP_L * 3) / 4) // = 192
|
||||
|
|
|
@ -223,23 +223,6 @@ typedef struct {
|
|||
int16_t sample_num;
|
||||
} WEAPON_INFO;
|
||||
|
||||
typedef struct {
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
int32_t z;
|
||||
int32_t mesh_num;
|
||||
} BITE;
|
||||
|
||||
typedef struct {
|
||||
int16_t zone_num;
|
||||
int16_t enemy_zone;
|
||||
int32_t distance;
|
||||
int32_t ahead;
|
||||
int32_t bite;
|
||||
int16_t angle;
|
||||
int16_t enemy_facing;
|
||||
} AI_INFO;
|
||||
|
||||
typedef struct {
|
||||
bool is_blocked;
|
||||
char *content_text;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include <libtrx/game/math.h>
|
||||
#include <libtrx/utils.h>
|
||||
|
||||
#define FRONT_ARC DEG_90
|
||||
#define ESCAPE_CHANCE 2048
|
||||
#define RECOVER_CHANCE 256
|
||||
#define MAX_X_ROT (20 * DEG_1) // = 3640
|
||||
|
@ -43,21 +42,6 @@ void Creature_Initialise(const int16_t item_num)
|
|||
item->data = 0;
|
||||
}
|
||||
|
||||
int32_t Creature_Activate(const int16_t item_num)
|
||||
{
|
||||
ITEM *const item = Item_Get(item_num);
|
||||
if (item->status != IS_INVISIBLE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!LOT_EnableBaddieAI(item_num, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
item->status = IS_ACTIVE;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Creature_AIInfo(ITEM *const item, AI_INFO *const info)
|
||||
{
|
||||
CREATURE *const creature = (CREATURE *)item->data;
|
||||
|
@ -130,7 +114,8 @@ void Creature_AIInfo(ITEM *const item, AI_INFO *const info)
|
|||
&& ABS(enemy->pos.y - item->pos.y) <= STEP_L;
|
||||
}
|
||||
|
||||
void Creature_Mood(const ITEM *item, const AI_INFO *info, int32_t violent)
|
||||
void Creature_Mood(
|
||||
const ITEM *const item, const AI_INFO *const info, const bool violent)
|
||||
{
|
||||
CREATURE *const creature = item->data;
|
||||
if (creature == nullptr) {
|
||||
|
@ -372,7 +357,7 @@ void Creature_Die(const int16_t item_num, const bool explode)
|
|||
}
|
||||
}
|
||||
|
||||
int32_t Creature_Animate(
|
||||
bool Creature_Animate(
|
||||
const int16_t item_num, const int16_t angle, const int16_t tilt)
|
||||
{
|
||||
ITEM *const item = Item_Get(item_num);
|
||||
|
|
|
@ -4,32 +4,17 @@
|
|||
|
||||
#include <libtrx/game/creature.h>
|
||||
|
||||
void Creature_Initialise(int16_t item_num);
|
||||
int32_t Creature_Activate(int16_t item_num);
|
||||
void Creature_AIInfo(ITEM *item, AI_INFO *info);
|
||||
void Creature_Mood(const ITEM *item, const AI_INFO *info, int32_t violent);
|
||||
int32_t Creature_CheckBaddieOverlap(int16_t item_num);
|
||||
void Creature_Die(int16_t item_num, bool explode);
|
||||
int32_t Creature_Animate(int16_t item_num, int16_t angle, int16_t tilt);
|
||||
int16_t Creature_Turn(ITEM *item, int16_t max_turn);
|
||||
void Creature_Tilt(ITEM *item, int16_t angle);
|
||||
void Creature_Head(ITEM *item, int16_t required);
|
||||
void Creature_Neck(ITEM *item, int16_t required);
|
||||
void Creature_Float(int16_t item_num);
|
||||
void Creature_Underwater(ITEM *item, int32_t depth);
|
||||
int16_t Creature_Effect(
|
||||
const ITEM *item, const BITE *bite,
|
||||
int16_t (*spawn)(
|
||||
int32_t x, int32_t y, int32_t z, int16_t speed, int16_t y_rot,
|
||||
int16_t room_num));
|
||||
int32_t Creature_Vault(
|
||||
int16_t item_num, int16_t angle, int32_t vault, int32_t shift);
|
||||
void Creature_Kill(
|
||||
ITEM *item, int32_t kill_anim, int32_t kill_state, int32_t lara_kill_state);
|
||||
void Creature_GetBaddieTarget(int16_t item_num, int32_t goody);
|
||||
void Creature_Collision(int16_t item_num, ITEM *lara_item, COLL_INFO *coll);
|
||||
int32_t Creature_CanTargetEnemy(const ITEM *item, const AI_INFO *info);
|
||||
bool Creature_IsHostile(const ITEM *item);
|
||||
bool Creature_IsAlly(const ITEM *item);
|
||||
int32_t Creature_ShootAtLara(
|
||||
ITEM *item, const AI_INFO *info, const BITE *gun, int16_t extra_rotation,
|
||||
|
|
|
@ -193,5 +193,3 @@
|
|||
|
||||
#define LOW_LIGHT 5120
|
||||
#define HIGH_LIGHT 4096
|
||||
|
||||
#define UNIT_SHADOW 256
|
||||
|
|
|
@ -154,16 +154,6 @@ typedef struct {
|
|||
int16_t sample_num;
|
||||
} WEAPON_INFO;
|
||||
|
||||
typedef struct {
|
||||
int16_t zone_num;
|
||||
int16_t enemy_zone_num;
|
||||
int32_t distance;
|
||||
int32_t ahead;
|
||||
int32_t bite;
|
||||
int16_t angle;
|
||||
int16_t enemy_facing;
|
||||
} AI_INFO;
|
||||
|
||||
typedef enum {
|
||||
GFE_PICTURE = 0,
|
||||
GFE_LIST_START = 1,
|
||||
|
@ -190,11 +180,6 @@ typedef enum {
|
|||
GFE_REMOVE_AMMO = 22,
|
||||
} GF_EVENTS;
|
||||
|
||||
typedef struct {
|
||||
XYZ_32 pos;
|
||||
int32_t mesh_num;
|
||||
} BITE;
|
||||
|
||||
typedef struct {
|
||||
SECTOR *sector;
|
||||
SECTOR old_sector;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue