Skip to content

Commit

Permalink
tr2: port Diver_Harpoon
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Oct 26, 2024
1 parent a30da40 commit 88c0d4f
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 10 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 @@ -3093,7 +3093,7 @@ typedef enum {
0x00416BF0 0x002D + void __cdecl Demo_GetInput(void);

# game/diver.c
0x00416C20 0x007A - int16_t __cdecl Diver_Harpoon(int32_t x, int32_t y, int32_t z, int16_t speed, PHD_ANGLE y_rot, int16_t room_num);
0x00416C20 0x007A + int16_t __cdecl Diver_Harpoon(int32_t x, int32_t y, int32_t z, int16_t speed, PHD_ANGLE y_rot, int16_t room_num);
0x00416CA0 0x0106 - int32_t __cdecl Diver_GetWaterSurface(int32_t x, int32_t y, int32_t z, int16_t room_num);
0x00416DB0 0x0389 + void __cdecl Diver_Control(int16_t item_num);

Expand Down
26 changes: 26 additions & 0 deletions src/tr2/game/objects/creatures/diver.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "game/objects/creatures/diver.h"

#include "game/creature.h"
#include "game/effects.h"
#include "game/los.h"
#include "global/const.h"
#include "global/funcs.h"
Expand All @@ -11,6 +12,7 @@
#define DIVER_DIE_ANIM 16
#define DIVER_HITPOINTS 20
#define DIVER_RADIUS (WALL_L / 3) // = 341
#define DIVER_HARPOON_SPEED 150

static BITE m_DiverBite = { .pos = { .x = 17, .y = 164, .z = 44, }, .mesh_num = 18 };

Expand Down Expand Up @@ -220,3 +222,27 @@ void __cdecl Diver_Control(int16_t item_num)
break;
}
}

int16_t __cdecl Diver_Harpoon(
const int32_t x, const int32_t y, const int32_t z, const int16_t speed,
const int16_t y_rot, const int16_t room_num)
{
const int16_t fx_num = Effect_Create(room_num);
if (fx_num != NO_ITEM) {
FX *const fx = &g_Effects[fx_num];
fx->pos.x = x;
fx->pos.y = y;
fx->pos.z = z;
fx->room_num = room_num;
fx->rot.x = 0;
fx->rot.y = y_rot;
fx->rot.z = 0;
fx->speed = DIVER_HARPOON_SPEED;
fx->fall_speed = 0;
fx->frame_num = 0;
fx->object_id = O_MISSILE_HARPOON;
fx->shade = 3584;
ShootAtLara(fx);
}
return fx_num;
}
4 changes: 4 additions & 0 deletions src/tr2/game/objects/creatures/diver.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
void Diver_Setup(void);

void __cdecl Diver_Control(int16_t item_num);

int16_t __cdecl Diver_Harpoon(
int32_t x, int32_t y, int32_t z, int16_t speed, int16_t y_rot,
int16_t room_num);
1 change: 0 additions & 1 deletion src/tr2/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

// clang-format off
#define Output_InsertInventoryBackground ((void __cdecl (*)(const int16_t *obj_ptr))0x00401D50)
#define Diver_Harpoon ((int16_t __cdecl (*)(int32_t x, int32_t y, int32_t z, int16_t speed, PHD_ANGLE y_rot, int16_t room_num))0x00416C20)
#define Diver_GetWaterSurface ((int32_t __cdecl (*)(int32_t x, int32_t y, int32_t z, int16_t room_num))0x00416CA0)
#define Dog_Control ((void __cdecl (*)(int16_t item_num))0x00417160)
#define Tiger_Control ((void __cdecl (*)(int16_t item_num))0x00417510)
Expand Down
1 change: 1 addition & 0 deletions src/tr2/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ static void M_Objects(const bool enable)
INJECT(enable, 0x004138E0, Object_Collision);
INJECT(enable, 0x00413940, Door_Collision);
INJECT(enable, 0x004139C0, Object_Collision_Trap);
INJECT(enable, 0x00416C20, Diver_Harpoon);
INJECT(enable, 0x00416DB0, Diver_Control);
INJECT(enable, 0x004177B0, Twinkle_Control);
INJECT(enable, 0x00417AC0, Dragon_Collision);
Expand Down

0 comments on commit 88c0d4f

Please sign in to comment.