Skip to content

Commit

Permalink
tr2/objects/body-part: fix decomp status
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Nov 5, 2024
1 parent c9948af commit 0f01993
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 101 deletions.
16 changes: 8 additions & 8 deletions docs/tr2/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/tr2/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3555,7 +3555,7 @@ typedef enum {
0x00432FE0 0x02D0 -R void __cdecl Missile_Control(int16_t fx_num);
0x004332B0 0x00A7 -R void __cdecl ShootAtLara(FX *fx);
0x00433360 0x0386 +R int32_t __cdecl Effect_ExplodingDeath(int16_t item_num, int32_t mesh_bits, int16_t damage);
0x004336F0 0x0200 -R void __cdecl BodyPart_Control(int16_t fx_num);
0x004336F0 0x0200 +R void __cdecl BodyPart_Control(int16_t fx_num);

# game/moveblock.c
0x004338F0 0x002C + void __cdecl MovableBlock_Initialise(int16_t item_num);
Expand Down
82 changes: 82 additions & 0 deletions src/tr2/game/objects/effects/body_part.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#include "game/objects/effects/body_part.h"

#include "game/effects.h"
#include "game/lara/control.h"
#include "game/lara/misc.h"
#include "game/math.h"
#include "game/room.h"
#include "game/sound.h"
#include "global/funcs.h"
#include "global/types.h"
#include "global/vars.h"

void BodyPart_Setup(void)
{
Expand All @@ -9,3 +17,77 @@ void BodyPart_Setup(void)
obj->loaded = 1;
obj->mesh_count = 0;
}

void __cdecl BodyPart_Control(const int16_t fx_num)
{
FX *const fx = &g_Effects[fx_num];
fx->rot.x += 5 * PHD_DEGREE;
fx->rot.z += 10 * PHD_DEGREE;
fx->pos.x += (fx->speed * Math_Sin(fx->rot.y)) >> W2V_SHIFT;
fx->pos.z += (fx->speed * Math_Cos(fx->rot.y)) >> W2V_SHIFT;
fx->pos.y += fx->fall_speed;
fx->fall_speed += GRAVITY;

int16_t room_num = fx->room_num;
const SECTOR *const sector =
Room_GetSector(fx->pos.x, fx->pos.y, fx->pos.z, &room_num);

if (!(g_Rooms[fx->room_num].flags & RF_UNDERWATER)
&& (g_Rooms[room_num].flags & RF_UNDERWATER)) {
const int16_t fx_num = Effect_Create(fx->room_num);
if (fx_num != NO_ITEM) {
FX *const splash_fx = &g_Effects[fx_num];
splash_fx->pos.x = fx->pos.x;
splash_fx->pos.y = fx->pos.y;
splash_fx->pos.z = fx->pos.z;
splash_fx->rot.y = 0;
splash_fx->speed = 0;
splash_fx->frame_num = 0;
splash_fx->object_id = O_SPLASH;
}
}

const int32_t ceiling =
Room_GetCeiling(sector, fx->pos.x, fx->pos.y, fx->pos.z);
if (fx->pos.y < ceiling) {
fx->pos.y = ceiling;
fx->fall_speed = -fx->fall_speed;
}

const int32_t height =
Room_GetHeight(sector, fx->pos.x, fx->pos.y, fx->pos.z);
if (fx->pos.y >= height) {
if (fx->counter) {
fx->speed = 0;
fx->frame_num = 0;
fx->counter = 0;
fx->object_id = O_EXPLOSION;
fx->shade = HIGH_LIGHT;
Sound_Effect(SFX_EXPLOSION1, &fx->pos, SPM_NORMAL);
} else {
Effect_Kill(fx_num);
}
return;
}

if (Lara_IsNearItem(&fx->pos, 2 * fx->counter)) {
Lara_TakeDamage(fx->counter, true);

if (fx->counter == 0) {
fx->speed = 0;
fx->frame_num = 0;
fx->counter = 0;
fx->object_id = O_EXPLOSION;
fx->shade = HIGH_LIGHT;
Sound_Effect(SFX_EXPLOSION1, &fx->pos, SPM_NORMAL);
g_Lara.spaz_effect_count = 5;
g_Lara.spaz_effect = fx;
} else {
Effect_Kill(fx_num);
}
}

if (room_num != fx->room_num) {
Effect_NewRoom(fx_num, room_num);
}
}
2 changes: 2 additions & 0 deletions src/tr2/game/objects/effects/body_part.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
#include "global/types.h"

void BodyPart_Setup(void);

void __cdecl BodyPart_Control(int16_t fx_num);
84 changes: 0 additions & 84 deletions src/tr2/game/objects/general/body_part.c

This file was deleted.

5 changes: 0 additions & 5 deletions src/tr2/game/objects/general/body_part.h

This file was deleted.

1 change: 0 additions & 1 deletion src/tr2/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
#define Flare_Control ((void __cdecl (*)(int16_t item_num))0x00430070)
#define Missile_Control ((void __cdecl (*)(int16_t fx_num))0x00432FE0)
#define ShootAtLara ((void __cdecl (*)(FX *fx))0x004332B0)
#define BodyPart_Control ((void __cdecl (*)(int16_t fx_num))0x004336F0)
#define Object_DrawUnclippedItem ((void __cdecl (*)(const ITEM *item))0x004341A0)
#define Earthquake_Control ((void __cdecl (*)(int16_t item_num))0x00434210)
#define FinalCutscene_Control ((void __cdecl (*)(int16_t item_num))0x004342F0)
Expand Down
2 changes: 1 addition & 1 deletion src/tr2/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
#include "game/objects/creatures/diver.h"
#include "game/objects/creatures/dragon.h"
#include "game/objects/creatures/skidoo_driver.h"
#include "game/objects/effects/body_part.h"
#include "game/objects/effects/ember.h"
#include "game/objects/effects/flame.h"
#include "game/objects/effects/twinkle.h"
#include "game/objects/general/body_part.h"
#include "game/objects/general/bridge_common.h"
#include "game/objects/general/bridge_flat.h"
#include "game/objects/general/bridge_tilt_1.h"
Expand Down
1 change: 0 additions & 1 deletion src/tr2/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ dll_sources = [
'game/objects/general/bell.c',
'game/objects/general/big_bowl.c',
'game/objects/general/bird_tweeter.c',
'game/objects/general/body_part.c',
'game/objects/general/bridge_common.c',
'game/objects/general/bridge_flat.c',
'game/objects/general/bridge_tilt_1.c',
Expand Down

0 comments on commit 0f01993

Please sign in to comment.