Skip to content

Commit

Permalink
improve TR3-like sidesteps (fixes #34)
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Feb 28, 2021
1 parent a3bd123 commit 97f658e
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 6 deletions.
46 changes: 40 additions & 6 deletions src/game/lara.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,22 @@ void LaraAsWalk(ITEM_INFO* item, COLL_INFO* coll)
return;
}

#ifdef T1M_FEAT_INPUT
if (!T1MConfig.enable_tr3_sidesteps
|| (CHK_ANY(Input, IN_SLOW) && CHK_ANY(Input, IN_FORWARD))) {
if (Input & IN_LEFT) {
Lara.turn_rate -= LARA_TURN_RATE;
if (Lara.turn_rate < -LARA_SLOW_TURN) {
Lara.turn_rate = -LARA_SLOW_TURN;
}
} else if (Input & IN_RIGHT) {
Lara.turn_rate += LARA_TURN_RATE;
if (Lara.turn_rate > LARA_SLOW_TURN) {
Lara.turn_rate = LARA_SLOW_TURN;
}
}
}
#else
if (Input & IN_LEFT) {
Lara.turn_rate -= LARA_TURN_RATE;
if (Lara.turn_rate < -LARA_SLOW_TURN) {
Expand All @@ -160,6 +176,7 @@ void LaraAsWalk(ITEM_INFO* item, COLL_INFO* coll)
Lara.turn_rate = LARA_SLOW_TURN;
}
}
#endif

if (Input & IN_FORWARD) {
if (Input & IN_SLOW) {
Expand Down Expand Up @@ -263,27 +280,27 @@ void LaraAsStop(ITEM_INFO* item, COLL_INFO* coll)
item->goal_anim_state = AS_STEPRIGHT;
}

if (Input & IN_LEFT) {
#ifdef T1M_FEAT_INPUT
if (Input & IN_LEFT) {
if (T1MConfig.enable_tr3_sidesteps && (Input & IN_SLOW)) {
item->goal_anim_state = AS_STEPLEFT;
} else {
item->goal_anim_state = AS_TURN_L;
}
#else
item->goal_anim_state = AS_TURN_L;
#endif
} else if (Input & IN_RIGHT) {
#ifdef T1M_FEAT_INPUT
if (T1MConfig.enable_tr3_sidesteps && (Input & IN_SLOW)) {
item->goal_anim_state = AS_STEPRIGHT;
} else {
item->goal_anim_state = AS_TURN_R;
}
}
#else
if (Input & IN_LEFT) {
item->goal_anim_state = AS_TURN_L;
} else if (Input & IN_RIGHT) {
item->goal_anim_state = AS_TURN_R;
#endif
}
#endif

if (Input & IN_JUMP) {
item->goal_anim_state = AS_COMPRESS;
Expand Down Expand Up @@ -526,6 +543,22 @@ void LaraAsBack(ITEM_INFO* item, COLL_INFO* coll)
item->goal_anim_state = AS_STOP;
}

#ifdef T1M_FEAT_INPUT
if (!T1MConfig.enable_tr3_sidesteps
|| (CHK_ANY(Input, IN_SLOW) && CHK_ANY(Input, IN_BACK))) {
if (Input & IN_LEFT) {
Lara.turn_rate -= LARA_TURN_RATE;
if (Lara.turn_rate < -LARA_SLOW_TURN) {
Lara.turn_rate = -LARA_SLOW_TURN;
}
} else if (Input & IN_RIGHT) {
Lara.turn_rate += LARA_TURN_RATE;
if (Lara.turn_rate > LARA_SLOW_TURN) {
Lara.turn_rate = LARA_SLOW_TURN;
}
}
}
#else
if (Input & IN_LEFT) {
Lara.turn_rate -= LARA_TURN_RATE;
if (Lara.turn_rate < -LARA_SLOW_TURN) {
Expand All @@ -537,6 +570,7 @@ void LaraAsBack(ITEM_INFO* item, COLL_INFO* coll)
Lara.turn_rate = LARA_SLOW_TURN;
}
}
#endif
}

void LaraAsFastTurn(ITEM_INFO* item, COLL_INFO* coll)
Expand Down
58 changes: 58 additions & 0 deletions src/game/larasurf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "game/lara.h"
#include "game/misc.h"
#include "game/vars.h"
#include "config.h"
#include "util.h"

void LaraSurface(ITEM_INFO* item, COLL_INFO* coll)
Expand Down Expand Up @@ -79,11 +80,22 @@ void LaraAsSurfSwim(ITEM_INFO* item, COLL_INFO* coll)
}

Lara.dive_count = 0;

#ifdef T1M_FEAT_INPUT
if (!T1MConfig.enable_tr3_sidesteps || !CHK_ANY(Input, IN_SLOW)) {
if (Input & IN_LEFT) {
item->pos.y_rot -= LARA_SLOW_TURN;
} else if (Input & IN_RIGHT) {
item->pos.y_rot += LARA_SLOW_TURN;
}
}
#else
if (Input & IN_LEFT) {
item->pos.y_rot -= LARA_SLOW_TURN;
} else if (Input & IN_RIGHT) {
item->pos.y_rot += LARA_SLOW_TURN;
}
#endif

if (!(Input & IN_FORWARD)) {
item->goal_anim_state = AS_SURFTREAD;
Expand All @@ -106,11 +118,22 @@ void LaraAsSurfBack(ITEM_INFO* item, COLL_INFO* coll)
}

Lara.dive_count = 0;

#ifdef T1M_FEAT_INPUT
if (!T1MConfig.enable_tr3_sidesteps || !CHK_ANY(Input, IN_SLOW)) {
if (Input & IN_LEFT) {
item->pos.y_rot -= LARA_SLOW_TURN / 2;
} else if (Input & IN_RIGHT) {
item->pos.y_rot += LARA_SLOW_TURN / 2;
}
}
#else
if (Input & IN_LEFT) {
item->pos.y_rot -= LARA_SLOW_TURN / 2;
} else if (Input & IN_RIGHT) {
item->pos.y_rot += LARA_SLOW_TURN / 2;
}
#endif

if (!(Input & IN_BACK)) {
item->goal_anim_state = AS_SURFTREAD;
Expand All @@ -130,6 +153,17 @@ void LaraAsSurfLeft(ITEM_INFO* item, COLL_INFO* coll)
}

Lara.dive_count = 0;

#ifdef T1M_FEAT_INPUT
if (T1MConfig.enable_tr3_sidesteps && CHK_ALL(Input, IN_SLOW | IN_LEFT)) {
item->fall_speed += 8;
if (item->fall_speed > SURF_MAXSPEED) {
item->fall_speed = SURF_MAXSPEED;
}
return;
}
#endif

if (Input & IN_LEFT) {
item->pos.y_rot -= LARA_SLOW_TURN / 2;
} else if (Input & IN_RIGHT) {
Expand All @@ -154,6 +188,17 @@ void LaraAsSurfRight(ITEM_INFO* item, COLL_INFO* coll)
}

Lara.dive_count = 0;

#ifdef T1M_FEAT_INPUT
if (T1MConfig.enable_tr3_sidesteps && CHK_ALL(Input, IN_SLOW | IN_RIGHT)) {
item->fall_speed += 8;
if (item->fall_speed > SURF_MAXSPEED) {
item->fall_speed = SURF_MAXSPEED;
}
return;
}
#endif

if (Input & IN_LEFT) {
item->pos.y_rot -= LARA_SLOW_TURN / 2;
} else if (Input & IN_RIGHT) {
Expand Down Expand Up @@ -216,11 +261,24 @@ void LaraAsSurfTread(ITEM_INFO* item, COLL_INFO* coll)
item->goal_anim_state = AS_SURFBACK;
}

#ifdef T1M_FEAT_INPUT
if (CHK_ANY(Input, IN_STEPL)
|| (T1MConfig.enable_tr3_sidesteps
&& CHK_ALL(Input, IN_SLOW | IN_LEFT))) {
item->goal_anim_state = AS_SURFLEFT;
} else if (
CHK_ANY(Input, IN_STEPR)
|| (T1MConfig.enable_tr3_sidesteps
&& CHK_ALL(Input, IN_SLOW | IN_RIGHT))) {
item->goal_anim_state = AS_SURFRIGHT;
}
#else
if (Input & IN_STEPL) {
item->goal_anim_state = AS_SURFLEFT;
} else if (Input & IN_STEPR) {
item->goal_anim_state = AS_SURFRIGHT;
}
#endif

if (Input & IN_JUMP) {
Lara.dive_count++;
Expand Down

0 comments on commit 97f658e

Please sign in to comment.