Skip to content

Commit

Permalink
lara: enable rolling underwater (#994)
Browse files Browse the repository at this point in the history
Adds the underwater rolling animations from TR2 to Lara's enhanced
animation injection set and adds the optional state change handling
to Lara's state routines.
Modifies the command to rotate 180 deg by applying to the X rotation
as well as Y.
Resolves #993.
  • Loading branch information
lahm86 committed Sep 21, 2023
1 parent ab11de3 commit 5e43b6d
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [Unreleased](https://github.com/rr-/Tomb1Main/compare/stable...develop) - ××××-××-××
- added Linux builds and toolchain
- added an option to allow Lara to roll while underwater, similar to TR2+ (#993)

## [2.16](https://github.com/rr-/Tomb1Main/compare/2.15.3...2.16) - 2023-09-20
- added a new rendering mode called "framebuffer" that lets the game to run at lower resolutions (#114)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ Not all options are turned on by default. Refer to `Tomb1Main_ConfigTool.exe` fo
- added ability to cancel ledge-swinging animation like in TR2+
- added ability to jump at any point while running like in TR2+
- added ability to automatically walk to items when nearby
- added ability to roll while underwater like in TR2+
- added a pause screen
- added a choice whether to play NG or NG+ without having to play the entire game
- added Japanese mode (guns deal twice the damage, inspired by JP release of TR3); available for both NG and NG+
Expand Down
Binary file modified bin/data/lara_animations.bin
Binary file not shown.
2 changes: 2 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ bool Config_ReadFromJSON(const char *cfg_data)
READ_BOOL(restore_ps1_enemies, false);
READ_BOOL(enable_game_modes, true);
READ_BOOL(enable_save_crystals, false);
READ_BOOL(enable_uw_roll, true);

CLAMP(g_Config.start_lara_hitpoints, 1, LARA_HITPOINTS);
CLAMP(g_Config.fov_value, 30, 255);
Expand Down Expand Up @@ -439,6 +440,7 @@ bool Config_Write(void)
WRITE_BOOL(restore_ps1_enemies);
WRITE_BOOL(enable_game_modes);
WRITE_BOOL(enable_save_crystals);
WRITE_BOOL(enable_uw_roll);

WRITE_INTEGER(rendering.render_mode);
WRITE_BOOL(rendering.enable_fullscreen);
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ typedef struct {
bool restore_ps1_enemies;
bool enable_game_modes;
bool enable_save_crystals;
bool enable_uw_roll;

struct {
int32_t layout;
Expand Down
1 change: 1 addition & 0 deletions src/game/effect_routines/turn_180.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
void FX_Turn180(ITEM_INFO *item)
{
item->pos.y_rot += PHD_180;
item->pos.x_rot *= -1;
}
7 changes: 6 additions & 1 deletion src/game/lara/lara_col.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void (*g_LaraCollisionRoutines[])(ITEM_INFO *item, COLL_INFO *coll) = {
Lara_Col_SurfLeft, Lara_Col_SurfRight, Lara_Col_UseMidas,
Lara_Col_DieMidas, Lara_Col_SwanDive, Lara_Col_FastDive,
Lara_Col_Gymnast, Lara_Col_WaterOut, Lara_Col_Controlled,
Lara_Col_Twist,
Lara_Col_Twist, Lara_Col_UWRoll,
};

static void Lara_Col_Default(ITEM_INFO *item, COLL_INFO *coll);
Expand Down Expand Up @@ -682,6 +682,11 @@ void Lara_Col_Twist(ITEM_INFO *item, COLL_INFO *coll)
Lara_Col_Default(item, coll);
}

void Lara_Col_UWRoll(ITEM_INFO *item, COLL_INFO *coll)
{
Lara_SwimCollision(item, coll);
}

void Lara_Col_SwitchOn(ITEM_INFO *item, COLL_INFO *coll)
{
Lara_Col_Default(item, coll);
Expand Down
1 change: 1 addition & 0 deletions src/game/lara/lara_col.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ void Lara_Col_FastDive(ITEM_INFO *item, COLL_INFO *coll);
void Lara_Col_Gymnast(ITEM_INFO *item, COLL_INFO *coll);
void Lara_Col_WaterOut(ITEM_INFO *item, COLL_INFO *coll);
void Lara_Col_Twist(ITEM_INFO *item, COLL_INFO *coll);
void Lara_Col_UWRoll(ITEM_INFO *item, COLL_INFO *coll);
23 changes: 22 additions & 1 deletion src/game/lara/lara_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void (*g_LaraStateRoutines[])(ITEM_INFO *item, COLL_INFO *coll) = {
Lara_State_SurfLeft, Lara_State_SurfRight, Lara_State_UseMidas,
Lara_State_DieMidas, Lara_State_SwanDive, Lara_State_FastDive,
Lara_State_Gymnast, Lara_State_WaterOut, Lara_State_Controlled,
Lara_State_Twist,
Lara_State_Twist, Lara_State_UWRoll,
};

static bool m_JumpPermitted = true;
Expand Down Expand Up @@ -793,6 +793,12 @@ void Lara_State_Twist(ITEM_INFO *item, COLL_INFO *coll)
{
}

void Lara_State_UWRoll(ITEM_INFO *item, COLL_INFO *coll)
{
item->fall_speed = 0;
item->goal_anim_state = LS_TREAD;
}

void Lara_State_Null(ITEM_INFO *item, COLL_INFO *coll)
{
coll->enable_spaz = 0;
Expand Down Expand Up @@ -1007,6 +1013,11 @@ void Lara_State_Swim(ITEM_INFO *item, COLL_INFO *coll)

coll->enable_spaz = 0;

if (g_Config.enable_uw_roll && g_Input.roll) {
item->goal_anim_state = LS_UW_ROLL;
return;
}

if (g_Input.forward) {
item->pos.x_rot -= 2 * PHD_DEGREE;
}
Expand Down Expand Up @@ -1044,6 +1055,11 @@ void Lara_State_Glide(ITEM_INFO *item, COLL_INFO *coll)

coll->enable_spaz = 0;

if (g_Config.enable_uw_roll && g_Input.roll) {
item->goal_anim_state = LS_UW_ROLL;
return;
}

if (g_Input.forward) {
item->pos.x_rot -= 2 * PHD_DEGREE;
} else if (g_Input.back) {
Expand Down Expand Up @@ -1085,6 +1101,11 @@ void Lara_State_Tread(ITEM_INFO *item, COLL_INFO *coll)

coll->enable_spaz = 0;

if (g_Config.enable_uw_roll && g_Input.roll) {
item->goal_anim_state = LS_UW_ROLL;
return;
}

if (g_Input.forward) {
item->pos.x_rot -= 2 * PHD_DEGREE;
} else if (g_Input.back) {
Expand Down
1 change: 1 addition & 0 deletions src/game/lara/lara_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ void Lara_State_FastDive(ITEM_INFO *item, COLL_INFO *coll);
void Lara_State_Gymnast(ITEM_INFO *item, COLL_INFO *coll);
void Lara_State_WaterOut(ITEM_INFO *item, COLL_INFO *coll);
void Lara_State_Twist(ITEM_INFO *item, COLL_INFO *coll);
void Lara_State_UWRoll(ITEM_INFO *item, COLL_INFO *coll);
1 change: 1 addition & 0 deletions src/global/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ typedef enum LARA_STATE {
LS_WATER_OUT = 55,
LS_CONTROLLED = 56,
LS_TWIST = 57,
LS_UW_ROLL = 58,
} LARA_STATE;

typedef enum LARA_GUN_STATE {
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 @@ -103,6 +103,10 @@
"Title": "Responsive jumping",
"Description": "Allows Lara to jump at any point while running, similar to TR2+."
},
"enable_uw_roll": {
"Title": "Underwater roll",
"Description": "Allows Lara to roll while underwater, similar to TR2+."
},
"enable_numeric_keys": {
"Title": "Numeric key quick item use",
"Description": "Enables quick weapon draws and medipack usage.\n- 1: Draw pistols\n- 2: Draw shotgun\n- 3: Draw magnums\n- 4: Draw Uzis\n- 8: Use small medipack\n- 9: Use large medipack"
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 @@ -103,6 +103,10 @@
"Title": "Saut réactif",
"Description": "Permet à Lara de sauter à tout moment pendant la course, similaire à TR2+."
},
"enable_uw_roll": {
"Title": "Retourné sous-marin",
"Description": "Permet à Lara de faire un demi tour immédiat, sous l'eau, similaire a TR2+."
},
"enable_numeric_keys": {
"Title": "Touches rapide numériques",
"Description": "Active les touches rapides numériques en haut du clavier, en raccourci d'équipement d'armes ou d'utilisation de soins.\n- 1: Pistolets\n- 2: Fusil à pompe\n- 3: Magnums\n- 4: Uzis\n- 8: Utiliser une petite trousse de soin\n- 9: Utiliser une grande trousse de soin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
"DataType": "Bool",
"DefaultValue": false
},
{
"Field": "enable_uw_roll",
"DataType": "Bool",
"DefaultValue": true
},
{
"Field": "enable_numeric_keys",
"DataType": "Bool",
Expand Down

0 comments on commit 5e43b6d

Please sign in to comment.