diff --git a/docs/tr2/progress.svg b/docs/tr2/progress.svg index a72e16d7c..1222dac54 100644 --- a/docs/tr2/progress.svg +++ b/docs/tr2/progress.svg @@ -69,10 +69,10 @@ Tomb2.exe progress according to the physical function order: -73.31% (912) · 24.28% (302) · 0% (0) · 2.41% (30) +73.39% (913) · 24.20% (301) · 0% (0) · 2.41% (30) - - + + @@ -835,7 +835,7 @@ uint32_t __cdecl Text_GetScaleV(uint32_t value); void __cdecl Mine_Control(int16_t mine_num); void __cdecl SpikeWall_Control(int16_t item_num); -void __cdecl CeilingSpikes_Control(int16_t item_num); +void __cdecl SpikeCeiling_Control(int16_t item_num); void __cdecl Hook_Control(int16_t item_num); void __cdecl Propeller_Control(int16_t item_num); void __cdecl SpinningBlade_Control(int16_t item_num); @@ -1324,10 +1324,10 @@ Tomb2.exe progress according to the function sizes: -77.83% · 21.85% · 0% · 0.33% +77.91% · 21.77% · 0% · 0.33% - - + + @@ -1662,7 +1662,7 @@ void __cdecl SkidooArmed_Push(const ITEM *item, ITEM *lara_item, int32_t radius); void __cdecl Jelly_Control(int16_t item_num); void __cdecl S_DrawScreenBox(int32_t sx, int32_t sy, int32_t z, int32_t width, int32_t height, BYTE color_idx, const GOURAUD_OUTLINE *gour, uint16_t flags); -void __cdecl CeilingSpikes_Control(int16_t item_num); +void __cdecl SpikeCeiling_Control(int16_t item_num); void __cdecl Bartoli_Initialise(int16_t item_num); int32_t __cdecl S_SaveGame(const void *save_data, uint32_t save_size, int32_t slot_num); int32_t __cdecl GameStats(int32_t level_num); diff --git a/docs/tr2/progress.txt b/docs/tr2/progress.txt index e4618fc32..d1b5acca0 100644 --- a/docs/tr2/progress.txt +++ b/docs/tr2/progress.txt @@ -3742,7 +3742,7 @@ typedef enum { # game/traps.c 0x00440F10 0x01F4 + void __cdecl Mine_Control(int16_t mine_num); 0x00441110 0x0138 + void __cdecl SpikeWall_Control(int16_t item_num); -0x00441250 0x0115 - void __cdecl CeilingSpikes_Control(int16_t item_num); +0x00441250 0x0115 + void __cdecl SpikeCeiling_Control(int16_t item_num); 0x00441370 0x0086 - void __cdecl Hook_Control(int16_t item_num); 0x00441400 0x0190 - void __cdecl Propeller_Control(int16_t item_num); 0x00441590 0x017B - void __cdecl SpinningBlade_Control(int16_t item_num); diff --git a/src/tr2/game/objects/traps/spike_ceiling.c b/src/tr2/game/objects/traps/spike_ceiling.c new file mode 100644 index 000000000..e16667ca7 --- /dev/null +++ b/src/tr2/game/objects/traps/spike_ceiling.c @@ -0,0 +1,58 @@ +#include "game/objects/traps/spike_ceiling.h" + +#include "game/items.h" +#include "game/lara/control.h" +#include "game/room.h" +#include "game/sound.h" +#include "global/funcs.h" +#include "global/vars.h" + +#define SPIKE_CEILING_DAMAGE 20 +#define SPIKE_CEILING_SPEED 1 + +static void M_Move(int16_t item_num); +static void M_HitLara(ITEM *item); + +static void M_Move(const int16_t item_num) +{ + ITEM *const item = Item_Get(item_num); + const int32_t y = item->pos.y + 5; + int16_t room_num = item->room_num; + const SECTOR *const sector = + Room_GetSector(item->pos.x, y, item->pos.z, &room_num); + if (Room_GetHeight(sector, item->pos.x, y, item->pos.z) < y + WALL_L) { + item->status = IS_DEACTIVATED; + } else { + item->pos.y = y; + if (room_num != item->room_num) { + Item_NewRoom(item_num, room_num); + } + } + Sound_Effect(SFX_DOOR_SLIDE, &item->pos, SPM_NORMAL); +} + +static void M_HitLara(ITEM *const item) +{ + Lara_TakeDamage(SPIKE_CEILING_DAMAGE, true); + + DoLotsOfBlood( + g_LaraItem->pos.x, item->pos.y + LARA_HEIGHT, g_LaraItem->pos.z, + SPIKE_CEILING_SPEED, item->rot.y, g_LaraItem->room_num, 3); + item->touch_bits = 0; + + Sound_Effect(SFX_LARA_FLESH_WOUND, &item->pos, SPM_NORMAL); +} + +void __cdecl SpikeCeiling_Control(const int16_t item_num) +{ + ITEM *const item = Item_Get(item_num); + + const bool is_trigger_active = Item_IsTriggerActive(item); + if (is_trigger_active && item->status != IS_DEACTIVATED) { + M_Move(item_num); + } + + if (item->touch_bits) { + M_HitLara(item); + } +} diff --git a/src/tr2/game/objects/traps/spike_ceiling.h b/src/tr2/game/objects/traps/spike_ceiling.h new file mode 100644 index 000000000..a63f0912a --- /dev/null +++ b/src/tr2/game/objects/traps/spike_ceiling.h @@ -0,0 +1,5 @@ +#pragma once + +#include "global/types.h" + +void __cdecl SpikeCeiling_Control(int16_t item_num); diff --git a/src/tr2/global/funcs.h b/src/tr2/global/funcs.h index 5f8b5d5ab..508d889a1 100644 --- a/src/tr2/global/funcs.h +++ b/src/tr2/global/funcs.h @@ -134,7 +134,6 @@ #define Spider_Leap ((void __cdecl (*)(int16_t item_num, int16_t angle))0x0043FFC0) #define Spider_Control ((void __cdecl (*)(int16_t item_num))0x00440070) #define BigSpider_Control ((void __cdecl (*)(int16_t item_num))0x00440290) -#define CeilingSpikes_Control ((void __cdecl (*)(int16_t item_num))0x00441250) #define Hook_Control ((void __cdecl (*)(int16_t item_num))0x00441370) #define Propeller_Control ((void __cdecl (*)(int16_t item_num))0x00441400) #define SpinningBlade_Control ((void __cdecl (*)(int16_t item_num))0x00441590) diff --git a/src/tr2/inject_exec.c b/src/tr2/inject_exec.c index 1b48413e1..bdeab0c9d 100644 --- a/src/tr2/inject_exec.c +++ b/src/tr2/inject_exec.c @@ -77,6 +77,7 @@ #include "game/objects/traps/flame_emitter.h" #include "game/objects/traps/mine.h" #include "game/objects/traps/rolling_ball.h" +#include "game/objects/traps/spike_ceiling.h" #include "game/objects/traps/spike_wall.h" #include "game/objects/vehicles/boat.h" #include "game/objects/vehicles/skidoo_armed.h" @@ -1097,6 +1098,8 @@ static void M_Objects(const bool enable) INJECT(enable, 0x0043F2F0, SkidooArmed_Collision); INJECT(enable, 0x00440F10, Mine_Control); INJECT(enable, 0x00441110, SpikeWall_Control); + INJECT(enable, 0x00441250, SpikeCeiling_Control); + INJECT(enable, 0x00441250, SpikeCeiling_Control); INJECT(enable, 0x00441B30, RollingBall_Initialise); INJECT(enable, 0x00441B70, RollingBall_Control); INJECT(enable, 0x00441EC0, RollingBall_Collision); diff --git a/src/tr2/meson.build b/src/tr2/meson.build index 861c11529..4aa3d687b 100644 --- a/src/tr2/meson.build +++ b/src/tr2/meson.build @@ -212,6 +212,7 @@ dll_sources = [ 'game/objects/traps/flame_emitter.c', 'game/objects/traps/mine.c', 'game/objects/traps/rolling_ball.c', + 'game/objects/traps/spike_ceiling.c', 'game/objects/traps/spike_wall.c', 'game/objects/vars.c', 'game/objects/vehicles/boat.c',