From 6913863f98215b6d16edf9179da94e55e32862d3 Mon Sep 17 00:00:00 2001 From: walkawayy <81546780+walkawayy@users.noreply.github.com> Date: Fri, 25 Feb 2022 17:45:24 -0500 Subject: [PATCH] WIP: improve bear AI --- src/config.c | 2 ++ src/config.h | 1 + src/game/objects/creatures/bear.c | 16 ++++++++++++++-- .../Tomb1Main_ConfigTool/Resources/Lang/en.json | 4 ++++ .../Tomb1Main_ConfigTool/Resources/Lang/es.json | 4 ++++ .../Tomb1Main_ConfigTool/Resources/Lang/fr.json | 4 ++++ .../Resources/specification.json | 5 +++++ 7 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/config.c b/src/config.c index 9fe27da57..f137b08c8 100644 --- a/src/config.c +++ b/src/config.c @@ -193,6 +193,7 @@ bool Config_ReadFromJSON(const char *cfg_data) READ_BOOL(fix_qwop_glitch, false); READ_BOOL(fix_alligator_ai, true); READ_BOOL(change_pierre_spawn, true); + READ_BOOL(fix_bear_ai, true); READ_INTEGER(fov_value, 65); READ_INTEGER(resolution_width, -1); READ_INTEGER(resolution_height, -1); @@ -377,6 +378,7 @@ bool Config_Write(void) WRITE_BOOL(fix_qwop_glitch); WRITE_BOOL(fix_alligator_ai); WRITE_BOOL(change_pierre_spawn); + WRITE_BOOL(fix_bear_ai); WRITE_INTEGER(fov_value); WRITE_INTEGER(resolution_width); WRITE_INTEGER(resolution_height); diff --git a/src/config.h b/src/config.h index 7a507083c..3b9f2a04a 100644 --- a/src/config.h +++ b/src/config.h @@ -83,6 +83,7 @@ typedef struct { bool fix_qwop_glitch; bool fix_alligator_ai; bool change_pierre_spawn; + bool fix_bear_ai; int32_t fov_value; bool fov_vertical; bool enable_demo; diff --git a/src/game/objects/creatures/bear.c b/src/game/objects/creatures/bear.c index aecf35e6f..bd4032de5 100644 --- a/src/game/objects/creatures/bear.c +++ b/src/game/objects/creatures/bear.c @@ -1,6 +1,9 @@ #include "game/objects/creatures/bear.h" +#include "config.h" #include "game/creature.h" +#include "game/box.h" +#include "game/collide.h" #include "game/effects/blood.h" #include "game/items.h" #include "game/lara.h" @@ -24,6 +27,7 @@ #define BEAR_REAR_RANGE SQUARE(WALL_L * 2) // = 4194304 #define BEAR_ATTACK_RANGE SQUARE(WALL_L) // = 1048576 #define BEAR_PAT_RANGE SQUARE(600) // = 360000 +#define BEAR_FIX_PAT_RANGE SQUARE(300) // = 90000 #define BEAR_RUN_TURN (5 * PHD_DEGREE) // = 910 #define BEAR_WALK_TURN (2 * PHD_DEGREE) // = 364 #define BEAR_EAT_RANGE SQUARE(WALL_L * 3 / 4) // = 589824 @@ -56,7 +60,11 @@ void Bear_Setup(OBJECT_INFO *obj) obj->collision = Creature_Collision; obj->shadow_size = UNIT_SHADOW / 2; obj->hit_points = BEAR_HITPOINTS; - obj->pivot_length = 500; + if (g_Config.fix_bear_ai) { + obj->pivot_length = 0; + } else { + obj->pivot_length = 500; + } obj->radius = BEAR_RADIUS; obj->smartness = BEAR_SMARTNESS; obj->intelligent = 1; @@ -187,7 +195,11 @@ void Bear_Control(int16_t item_num) item->goal_anim_state = item->required_anim_state; } else if (bear->mood == MOOD_BORED || bear->mood == MOOD_ESCAPE) { item->goal_anim_state = BEAR_STOP; - } else if (info.bite && info.distance < BEAR_PAT_RANGE) { + } else if ( + info.bite + && info.distance + < (g_Config.fix_bear_ai ? BEAR_FIX_PAT_RANGE + : BEAR_PAT_RANGE)) { item->goal_anim_state = BEAR_ATTACK2; } else { item->goal_anim_state = BEAR_WALK; diff --git a/tools/config/Tomb1Main_ConfigTool/Resources/Lang/en.json b/tools/config/Tomb1Main_ConfigTool/Resources/Lang/en.json index 10431cd58..44e1a2a95 100644 --- a/tools/config/Tomb1Main_ConfigTool/Resources/Lang/en.json +++ b/tools/config/Tomb1Main_ConfigTool/Resources/Lang/en.json @@ -119,6 +119,10 @@ "Title": "Fix alligator AI", "Description": "Fixes alligators dealing no damage if Lara remains still in the water." }, + "fix_bear_ai": { + "Title": "Fix bear AI", + "Description": "Fixes bears somehow." + }, "fix_descending_glitch": { "Title": "Fix breakable floor falls", "Description": "Fixes sidestepping and walking backwards on breakable tiles causing Lara to immediately descend to the tile underneath." diff --git a/tools/config/Tomb1Main_ConfigTool/Resources/Lang/es.json b/tools/config/Tomb1Main_ConfigTool/Resources/Lang/es.json index 7b3d8a4e8..f426f26cb 100644 --- a/tools/config/Tomb1Main_ConfigTool/Resources/Lang/es.json +++ b/tools/config/Tomb1Main_ConfigTool/Resources/Lang/es.json @@ -255,6 +255,10 @@ "Description": "Soluciona que los cocodrilos que no inflijan daño si Lara permanece inmóvil en el agua.", "Title": "Arreglar IA de cocodrilo" }, + "fix_bear_ai": { + "Title": "Fix bear AI", + "Description": "Fixes bears somehow." + }, "fix_bridge_collision": { "Description": "Soluciona que Lara no pueda agarrar partes de algunos puentes y paredes invisibles en el borde.", "Title": "Arreglar la colisión de puentes" diff --git a/tools/config/Tomb1Main_ConfigTool/Resources/Lang/fr.json b/tools/config/Tomb1Main_ConfigTool/Resources/Lang/fr.json index 07e41ecf9..8d874cb82 100644 --- a/tools/config/Tomb1Main_ConfigTool/Resources/Lang/fr.json +++ b/tools/config/Tomb1Main_ConfigTool/Resources/Lang/fr.json @@ -119,6 +119,10 @@ "Title": "Correction de l'intelligence artficielle des aligators", "Description": "Corrige les alligators n'infligeant aucun dégât si Lara reste toujours dans l'eau." }, + "fix_bear_ai": { + "Title": "Fix bear AI", + "Description": "Fixes bears somehow." + }, "fix_descending_glitch": { "Title": "Correction des chutes de plaques de sol cassantes", "Description": "Corrige le contournement et la marche arrière sur les tuiles cassables, ce qui fait que Lara descend immédiatement vers la tuile en dessous." diff --git a/tools/config/Tomb1Main_ConfigTool/Resources/specification.json b/tools/config/Tomb1Main_ConfigTool/Resources/specification.json index acb136fb4..31b3d12d6 100644 --- a/tools/config/Tomb1Main_ConfigTool/Resources/specification.json +++ b/tools/config/Tomb1Main_ConfigTool/Resources/specification.json @@ -100,6 +100,11 @@ "DataType": "Bool", "DefaultValue": true }, + { + "Field": "fix_bear_ai", + "DataType": "Bool", + "DefaultValue": true + }, { "Field": "fix_descending_glitch", "DataType": "Bool",