Skip to content

Commit

Permalink
WIP: improve bear AI
Browse files Browse the repository at this point in the history
  • Loading branch information
walkawayy committed Jul 30, 2023
1 parent df62ced commit a253997
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 12 additions & 2 deletions src/game/objects/creatures/bear.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "game/objects/creatures/bear.h"

#include "config.h"
#include "game/creature.h"
#include "game/effects/blood.h"
#include "game/items.h"
Expand All @@ -24,6 +25,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
Expand Down Expand Up @@ -56,7 +58,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;
Expand Down Expand Up @@ -187,7 +193,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;
Expand Down
4 changes: 4 additions & 0 deletions tools/config/Tomb1Main_ConfigTool/Resources/Lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
4 changes: 4 additions & 0 deletions tools/config/Tomb1Main_ConfigTool/Resources/Lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions tools/config/Tomb1Main_ConfigTool/Resources/Lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@
"DataType": "Bool",
"DefaultValue": true
},
{
"Field": "fix_bear_ai",
"DataType": "Bool",
"DefaultValue": true
},
{
"Field": "fix_descending_glitch",
"DataType": "Bool",
Expand Down

0 comments on commit a253997

Please sign in to comment.