From af14243414b1df7b5faaace2f727c95948ff7eb6 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Tue, 16 Apr 2024 17:59:10 +0200 Subject: [PATCH] port Creature_Underwater --- docs/progress.svg | 16 ++++++++-------- docs/progress.txt | 2 +- src/game/creature.c | 16 ++++++++++++++++ src/game/creature.h | 1 + src/global/funcs.h | 1 - src/inject_exec.c | 1 + 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/docs/progress.svg b/docs/progress.svg index 66a3ace..5d2ca37 100644 --- a/docs/progress.svg +++ b/docs/progress.svg @@ -69,10 +69,10 @@ Tomb2.exe progress according to the physical function order: -35.47% (432) · 62.07% (756) · 0.41% (5) · 2.05% (25) +35.55% (433) · 61.99% (755) · 0.41% (5) · 2.05% (25) - - + + @@ -195,7 +195,7 @@ void __cdecl Creature_Head(ITEM_INFO *item, int16_t required); void __cdecl Creature_Neck(ITEM_INFO *item, int16_t required); void __cdecl Creature_Float(int16_t item_num); -void __cdecl Creature_Underwater(ITEM_INFO *item, int32_t depth); +void __cdecl Creature_Underwater(ITEM_INFO *item, int32_t depth); int16_t __cdecl Creature_Effect(ITEM_INFO *item, BITE_INFO *bite, int16_t (*spawn)(int32_t x, int32_t y, int32_t z, int16_t speed, int16_t y_rot, int16_t room_num)); int32_t __cdecl Creature_Vault(int16_t item_num, int16_t angle, int32_t vault, int32_t shift); void __cdecl Creature_Kill(ITEM_INFO *item, int32_t kill_anim, int32_t kill_state, int32_t lara_kill_state); @@ -1299,10 +1299,10 @@ Tomb2.exe progress according to the function sizes: -32.25% · 67.42% · 0% · 0.32% +32.27% · 67.40% · 0% · 0.32% - - + + @@ -2095,7 +2095,7 @@ void __cdecl Music_Shutdown(void); bool __cdecl TIME_Init(void); LPCTSTR __cdecl GuidBinaryToString(GUID *guid); -void __cdecl Creature_Underwater(ITEM_INFO *item, int32_t depth); +void __cdecl Creature_Underwater(ITEM_INFO *item, int32_t depth); const FLOOR_INFO *__cdecl Camera_GoodPosition(int32_t x, int32_t y, int32_t z, int16_t room_num); void __cdecl InitialiseCult3(int16_t item_num); void __cdecl set_arm_info(LARA_ARM *arm, int32_t frame); diff --git a/docs/progress.txt b/docs/progress.txt index 70e63b4..54e9e04 100644 --- a/docs/progress.txt +++ b/docs/progress.txt @@ -1808,7 +1808,7 @@ typedef struct { 0040FF10 00000049 + void __cdecl Creature_Head(ITEM_INFO *item, int16_t required); 0040FF60 0000004E + void __cdecl Creature_Neck(ITEM_INFO *item, int16_t required); 0040FFB0 000000A8 + void __cdecl Creature_Float(int16_t item_num); -00410060 00000050 - void __cdecl Creature_Underwater(ITEM_INFO *item, int32_t depth); +00410060 00000050 + void __cdecl Creature_Underwater(ITEM_INFO *item, int32_t depth); 004100B0 0000005C - int16_t __cdecl Creature_Effect(ITEM_INFO *item, BITE_INFO *bite, int16_t (*spawn)(int32_t x, int32_t y, int32_t z, int16_t speed, int16_t y_rot, int16_t room_num)); 00410110 00000131 - int32_t __cdecl Creature_Vault(int16_t item_num, int16_t angle, int32_t vault, int32_t shift); 00410250 0000016F - void __cdecl Creature_Kill(ITEM_INFO *item, int32_t kill_anim, int32_t kill_state, int32_t lara_kill_state); diff --git a/src/game/creature.c b/src/game/creature.c index ede3b0c..66c9366 100644 --- a/src/game/creature.c +++ b/src/game/creature.c @@ -677,3 +677,19 @@ void __cdecl Creature_Float(const int16_t item_num) Item_NewRoom(item_num, room_num); } } + +void __cdecl Creature_Underwater(ITEM_INFO *const item, const int32_t depth) +{ + const int32_t wh = Room_GetWaterHeight( + item->pos.x, item->pos.y, item->pos.z, item->room_num); + if (item->pos.y >= wh + depth) { + return; + } + + item->pos.y = wh + depth; + if (item->rot.x > 2 * PHD_DEGREE) { + item->rot.x -= 2 * PHD_DEGREE; + } else { + CLAMPG(item->rot.x, 0); + } +} diff --git a/src/game/creature.h b/src/game/creature.h index 546cf02..52e8e55 100644 --- a/src/game/creature.h +++ b/src/game/creature.h @@ -17,3 +17,4 @@ void __cdecl Creature_Tilt(ITEM_INFO *item, int16_t angle); void __cdecl Creature_Head(ITEM_INFO *item, int16_t required); void __cdecl Creature_Neck(ITEM_INFO *item, int16_t required); void __cdecl Creature_Float(int16_t item_num); +void __cdecl Creature_Underwater(ITEM_INFO *item, int32_t depth); diff --git a/src/global/funcs.h b/src/global/funcs.h index 7919bc2..12bf8ab 100644 --- a/src/global/funcs.h +++ b/src/global/funcs.h @@ -18,7 +18,6 @@ #define Boat_Animation ((void __cdecl (*)(ITEM_INFO *boat, int32_t collide))0x0040D950) #define Boat_Control ((void __cdecl (*)(int16_t item_num))0x0040DAC0) #define Gondola_Control ((void __cdecl (*)(int16_t item_num))0x0040E0F0) -#define Creature_Underwater ((void __cdecl (*)(ITEM_INFO *item, int32_t depth))0x00410060) #define Creature_Effect ((int16_t __cdecl (*)(ITEM_INFO *item, BITE_INFO *bite, int16_t (*spawn)(int32_t x, int32_t y, int32_t z, int16_t speed, int16_t y_rot, int16_t room_num)))0x004100B0) #define Creature_Vault ((int32_t __cdecl (*)(int16_t item_num, int16_t angle, int32_t vault, int32_t shift))0x00410110) #define Creature_Kill ((void __cdecl (*)(ITEM_INFO *item, int32_t kill_anim, int32_t kill_state, int32_t lara_kill_state))0x00410250) diff --git a/src/inject_exec.c b/src/inject_exec.c index df9ac4a..1692b06 100644 --- a/src/inject_exec.c +++ b/src/inject_exec.c @@ -527,6 +527,7 @@ static void Inject_Creature(void) INJECT(1, 0x0040FF10, Creature_Head); INJECT(1, 0x0040FF60, Creature_Neck); INJECT(1, 0x0040FFB0, Creature_Float); + INJECT(1, 0x00410060, Creature_Underwater); } static void Inject_Box(void)