Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
port Lara_SwimTurn
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Nov 13, 2023
1 parent 3e57407 commit 205206a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
16 changes: 8 additions & 8 deletions docs/progress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1862,7 +1862,7 @@ typedef enum LARA_MESH {

# game/laraswim.c
00431F50 00000223 + void __cdecl Lara_HandleUnderwater(struct ITEM_INFO *item, struct COLL_INFO *coll);
00432180 00000086 - void __cdecl Lara_SwimTurn(struct ITEM_INFO *item);
00432180 00000086 + void __cdecl Lara_SwimTurn(struct ITEM_INFO *item);
00432210 0000006B + void __cdecl Lara_State_Swim(struct ITEM_INFO *item, struct COLL_INFO *coll);
00432280 00000076 + void __cdecl Lara_State_Glide(struct ITEM_INFO *item, struct COLL_INFO *coll);
00432300 00000085 + void __cdecl Lara_State_Tread(struct ITEM_INFO *item, struct COLL_INFO *coll);
Expand Down
19 changes: 19 additions & 0 deletions src/game/lara/lara_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@
#include "global/vars.h"
#include "util.h"

void __cdecl Lara_SwimTurn(struct ITEM_INFO *const item)
{
if (g_Input & IN_FORWARD) {
item->pos.x_rot -= LARA_TURN_RATE_UW;
} else if (g_Input & IN_BACK) {
item->pos.x_rot += LARA_TURN_RATE_UW;
}

if (g_Input & IN_LEFT) {
g_Lara.turn_rate -= LARA_TURN_RATE;
CLAMPL(g_Lara.turn_rate, -LARA_MED_TURN);
item->pos.z_rot -= LARA_LEAN_RATE_SWIM;
} else if (g_Input & IN_RIGHT) {
g_Lara.turn_rate += LARA_TURN_RATE;
CLAMPG(g_Lara.turn_rate, LARA_MED_TURN);
item->pos.z_rot += LARA_LEAN_RATE_SWIM;
}
}

void __cdecl Lara_State_Walk(struct ITEM_INFO *item, struct COLL_INFO *coll)
{
if (item->hit_points <= 0) {
Expand Down
3 changes: 3 additions & 0 deletions src/game/lara/lara_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

#include "global/types.h"

// TODO: make static
void __cdecl Lara_SwimTurn(struct ITEM_INFO *const item);

void __cdecl Lara_State_Walk(struct ITEM_INFO *item, struct COLL_INFO *coll);
void __cdecl Lara_State_Run(struct ITEM_INFO *item, struct COLL_INFO *coll);
void __cdecl Lara_State_Stop(struct ITEM_INFO *item, struct COLL_INFO *coll);
Expand Down
2 changes: 2 additions & 0 deletions src/global/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#define FAST_FALL_SPEED 128
#define LARA_TURN_UNDO (2 * PHD_DEGREE) // = 364
#define LARA_TURN_RATE ((PHD_DEGREE / 4) + LARA_TURN_UNDO) // = 409
#define LARA_TURN_RATE_UW (2 * PHD_DEGREE) // = 364
#define LARA_MED_TURN ((PHD_DEGREE * 4) + LARA_TURN_UNDO) // = 1092
#define LARA_SLOW_TURN ((PHD_DEGREE * 2) + LARA_TURN_UNDO) // = 728
#define LARA_SURF_TURN (LARA_SLOW_TURN / 2) // = 364
Expand All @@ -57,6 +58,7 @@
#define LARA_LEAN_UNDO_SURF (LARA_LEAN_UNDO * 2) // = 364
#define LARA_LEAN_UNDO_UW LARA_LEAN_UNDO_SURF // = 364
#define LARA_LEAN_RATE 273
#define LARA_LEAN_RATE_SWIM (LARA_LEAN_RATE * 2) // = 546
#define LARA_LEAN_MAX ((10 * PHD_DEGREE) + LARA_LEAN_UNDO) // = 2002
#define LARA_LEAN_MAX_UW (LARA_LEAN_MAX * 2) // = 4004
#define LARA_JUMP_TURN ((PHD_DEGREE * 1) + LARA_TURN_UNDO) // = 546
Expand Down
1 change: 0 additions & 1 deletion src/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@
#define Lara_SurfaceCollision ((void __cdecl (*)(struct ITEM_INFO *item, struct COLL_INFO *coll))0x00431B40)
#define Lara_TestWaterStepOut ((int32_t __cdecl (*)(struct ITEM_INFO *item, struct COLL_INFO *coll))0x00431C40)
#define Lara_TestWaterClimbOut ((int32_t __cdecl (*)(struct ITEM_INFO *item, struct COLL_INFO *coll))0x00431D30)
#define Lara_SwimTurn ((void __cdecl (*)(struct ITEM_INFO *item))0x00432180)
#define Lara_GetWaterDepth ((int32_t __cdecl (*)(int32_t x, int32_t y, int32_t z, int16_t room_num))0x004324A0)
#define Lara_TestWaterDepth ((void __cdecl (*)(struct ITEM_INFO *item, struct COLL_INFO *coll))0x00432640)
#define Lara_SwimCollision ((void __cdecl (*)(struct ITEM_INFO *item, struct COLL_INFO *coll))0x00432710)
Expand Down

0 comments on commit 205206a

Please sign in to comment.