objects/bear: create Golden Mask bear alias

This allows for the big spider in the Golden Mask to be used as an
alias for the bear.
This commit is contained in:
lahm86 2025-03-23 14:03:43 +00:00
parent 0aaa6a6779
commit 5bc307b14f
12 changed files with 82 additions and 55 deletions

View file

@ -7,6 +7,7 @@ CFG_BOOL(g_Config, gameplay.fix_pickup_drift_glitch, false)
CFG_BOOL(g_Config, gameplay.fix_floor_data_issues, true)
CFG_BOOL(g_Config, gameplay.fix_flare_throw_priority, true)
CFG_BOOL(g_Config, gameplay.fix_walk_run_jump, true)
CFG_BOOL(g_Config, gameplay.fix_bear_ai, true)
CFG_BOOL(g_Config, gameplay.enable_cheats, false)
CFG_BOOL(g_Config, gameplay.enable_console, true)
CFG_BOOL(g_Config, gameplay.enable_fmv, true)

View file

@ -1,3 +1,5 @@
#include "game/objects/creatures/bear.h"
#include "config.h"
#include "game/creature.h"
#include "game/lara/common.h"
@ -21,7 +23,11 @@
#define BEAR_RUN_TURN (5 * DEG_1) // = 910
#define BEAR_WALK_TURN (2 * DEG_1) // = 364
#define BEAR_EAT_RANGE SQUARE(WALL_L * 3 / 4) // = 589824
#if TR_VERSION == 1
#define BEAR_HITPOINTS 20
#else
#define BEAR_HITPOINTS 30
#endif
#define BEAR_RADIUS (WALL_L / 3) // = 341
#define BEAR_SMARTNESS 0x4000
// clang-format on
@ -47,30 +53,8 @@ static BITE m_BearHeadBite = { 0, 96, 335, 14 };
static BITE m_BearHeadBite = { .pos = { 0, 96, 335 }, .mesh_num = 14 };
#endif
static void M_Setup(OBJECT *obj);
static void M_Control(int16_t item_num);
static void M_Setup(OBJECT *const obj)
{
if (!obj->loaded) {
return;
}
obj->initialise_func = Creature_Initialise;
obj->control_func = M_Control;
obj->collision_func = Creature_Collision;
obj->shadow_size = UNIT_SHADOW / 2;
obj->hit_points = BEAR_HITPOINTS;
obj->radius = BEAR_RADIUS;
obj->smartness = BEAR_SMARTNESS;
obj->intelligent = 1;
obj->save_position = 1;
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
Object_GetBone(obj, 13)->rot_y = true;
}
static void M_Control(const int16_t item_num)
{
if (!Creature_Activate(item_num)) {
@ -79,12 +63,7 @@ static void M_Control(const int16_t item_num)
ITEM *const item = Item_Get(item_num);
OBJECT *const obj = Object_Get(item->object_id);
#if TR_VERSION == 1
const bool fix_bear_ai = g_Config.gameplay.fix_bear_ai;
#else
const bool fix_bear_ai = false;
#endif
obj->pivot_length = fix_bear_ai ? 0 : 500;
obj->pivot_length = g_Config.gameplay.fix_bear_ai ? 0 : 500;
CREATURE *const bear = (CREATURE *)item->data;
int16_t head = 0;
@ -198,7 +177,8 @@ static void M_Control(const int16_t item_num)
} else if (
info.bite
&& info.distance
< (fix_bear_ai ? BEAR_FIX_PAT_RANGE : BEAR_PAT_RANGE)) {
< (g_Config.gameplay.fix_bear_ai ? BEAR_FIX_PAT_RANGE
: BEAR_PAT_RANGE)) {
item->goal_anim_state = BEAR_STATE_ATTACK_2;
} else {
item->goal_anim_state = BEAR_STATE_WALK;
@ -248,6 +228,25 @@ static void M_Control(const int16_t item_num)
Creature_Animate(item_num, angle, 0);
}
#if TR_VERSION == 1
REGISTER_OBJECT(O_BEAR, M_Setup)
#endif
void Bear_Setup(OBJECT *const obj)
{
if (!obj->loaded) {
return;
}
obj->initialise_func = Creature_Initialise;
obj->control_func = M_Control;
obj->collision_func = Creature_Collision;
obj->shadow_size = UNIT_SHADOW / 2;
obj->hit_points = BEAR_HITPOINTS;
obj->radius = BEAR_RADIUS;
obj->smartness = BEAR_SMARTNESS;
obj->intelligent = 1;
obj->save_position = 1;
obj->save_hitpoints = 1;
obj->save_anim = 1;
obj->save_flags = 1;
Object_GetBone(obj, 13)->rot_y = true;
}
REGISTER_OBJECT(O_BEAR, Bear_Setup)

View file

@ -75,6 +75,7 @@ typedef struct {
bool fix_floor_data_issues;
bool fix_flare_throw_priority;
bool fix_walk_run_jump;
bool fix_bear_ai;
bool enable_cheats;
bool enable_console;
bool enable_fmv;

View file

@ -0,0 +1,5 @@
#pragma once
#include "../types.h"
void Bear_Setup(OBJECT *obj);

View file

@ -272,6 +272,7 @@ OBJ_ID_DEFINE(O_EARTHQUAKE, 264)
// that manually calls the setup routine overriding whatever information was in
// the slot.
OBJ_ID_DEFINE(O_MONK_3, O_MONK_1)
OBJ_ID_DEFINE(O_BEAR, O_BIG_SPIDER)
// Force the O_NUMBER_OF to be valid
OBJ_ID_DEFINE(O_LAST, 264)

View file

@ -1,3 +1,5 @@
#include "game/objects/creatures/big_spider.h"
#include "game/creature.h"
#include "game/lara/control.h"
#include "game/objects/common.h"
@ -33,29 +35,8 @@ static const BITE m_SpiderBite = {
.mesh_num = 1,
};
static void M_Setup(OBJECT *obj);
static void M_Control(int16_t item_num);
static void M_Setup(OBJECT *const obj)
{
if (!obj->loaded) {
return;
}
obj->control_func = M_Control;
obj->collision_func = Creature_Collision;
obj->hit_points = BIG_SPIDER_HITPOINTS;
obj->radius = BIG_SPIDER_RADIUS;
obj->shadow_size = UNIT_SHADOW / 2;
obj->intelligent = 1;
obj->save_position = 1;
obj->save_hitpoints = 1;
obj->save_flags = 1;
obj->save_anim = 1;
}
static void M_Control(const int16_t item_num)
{
if (!Creature_Activate(item_num)) {
@ -132,4 +113,24 @@ static void M_Control(const int16_t item_num)
Creature_Animate(item_num, angle, tilt);
}
REGISTER_OBJECT(O_BIG_SPIDER, M_Setup)
void BigSpider_Setup(OBJECT *const obj)
{
if (!obj->loaded) {
return;
}
obj->control_func = M_Control;
obj->collision_func = Creature_Collision;
obj->hit_points = BIG_SPIDER_HITPOINTS;
obj->radius = BIG_SPIDER_RADIUS;
obj->shadow_size = UNIT_SHADOW / 2;
obj->intelligent = 1;
obj->save_position = 1;
obj->save_hitpoints = 1;
obj->save_flags = 1;
obj->save_anim = 1;
}
REGISTER_OBJECT(O_BIG_SPIDER, BigSpider_Setup)

View file

@ -0,0 +1,5 @@
#pragma once
#include <libtrx/game/objects/types.h>
void BigSpider_Setup(OBJECT *obj);

View file

@ -25,6 +25,7 @@ const GAME_OBJECT_ID g_EnemyObjects[] = {
O_JELLY,
O_SPIDER,
O_BIG_SPIDER,
O_BEAR,
O_CROW,
O_TIGER,
O_BARTOLI,

View file

@ -136,7 +136,7 @@
},
"fix_bear_ai": {
"Title": "Fix bear AI",
"Description": "Fixes bear pat attack so it does not miss Lara."
"Description": "Fixes the bear pat attack so it does not miss Lara."
},
"fix_descending_glitch": {
"Title": "Fix breakable floor falls",

View file

@ -117,6 +117,10 @@
"enable_exit_fade_effects": {
"Title": "Exit fade effects",
"Description": "Enables the fade effects when exiting the game to desktop."
},
"fix_bear_ai": {
"Title": "Fix bear AI",
"Description": "Fixes the bear pat attack in The Golden Mask so it does not miss Lara."
}
}
}

View file

@ -124,6 +124,10 @@
"enable_exit_fade_effects": {
"Title": "Effetti di dissolvenza in uscita",
"Description": "Abilita gli effetti di dissolvenza quando si esce dal gioco."
},
"fix_bear_ai": {
"Title": "Correggi IA degli orsi",
"Description": "Risolve un problema per cui gli attacchi con le zampe d'orso non colpivano Lara quando indossava la Maschera d'oro."
}
}
}

View file

@ -42,6 +42,11 @@
"ID": "gameplay_fixes",
"Image": "Graphics/graphic2.jpg",
"Properties": [
{
"Field": "fix_bear_ai",
"DataType": "Bool",
"DefaultValue": true
},
{
"Field": "fix_m16_accuracy",
"DataType": "Bool",