Skip to content

Commit

Permalink
tr2: port SkidooArmed_Collision
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Oct 22, 2024
1 parent 1b453a7 commit 8463d1e
Show file tree
Hide file tree
Showing 6 changed files with 38 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 @@ -3677,7 +3677,7 @@ typedef enum {
0x0043ED40 0x007F + void __cdecl SkidooDriver_Initialise(int16_t item_num);
0x0043EDD0 0x03E2 + void __cdecl SkidooDriver_Control(int16_t rider_num);
0x0043F1D0 0x0119 + void __cdecl SkidooArmed_Push(const ITEM *item, ITEM *lara_item, int32_t radius);
0x0043F2F0 0x0081 - void __cdecl SkidooArmed_Collision(int16_t item_num, ITEM *lara_item, COLL_INFO *coll);
0x0043F2F0 0x0081 + void __cdecl SkidooArmed_Collision(int16_t item_num, ITEM *lara_item, COLL_INFO *coll);

# game/sound.c
0x0043F380 0x0031 * int32_t __cdecl Music_GetRealTrack(int32_t track);
Expand Down
25 changes: 25 additions & 0 deletions src/tr2/game/objects/vehicles/skidoo_armed.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "game/objects/vehicles/skidoo_armed.h"

#include "game/items.h"
#include "game/lara/control.h"
#include "game/lara/misc.h"
#include "game/math.h"
#include "game/objects/creatures/skidoo_driver.h"
#include "global/funcs.h"
Expand Down Expand Up @@ -70,3 +72,26 @@ void __cdecl SkidooArmed_Push(
lara_item->pos.x = item->pos.x + ((rz * sy + rx * cy) >> W2V_SHIFT);
lara_item->pos.z = item->pos.z + ((rz * cy - rx * sy) >> W2V_SHIFT);
}

void __cdecl SkidooArmed_Collision(
const int16_t item_num, ITEM *const lara_item, COLL_INFO *const coll)
{
ITEM *const item = Item_Get(item_num);
if (!Item_TestBoundsCollide(item, lara_item, coll->radius)) {
return;
}

if (!Collide_TestCollision(item, lara_item)) {
return;
}

if (coll->enable_baddie_push) {
Lara_Push(
item, lara_item, coll, item->speed > 0 ? coll->enable_spaz : false,
false);
}

if (g_Lara.skidoo == NO_ITEM && item->speed > 0) {
Lara_TakeDamage(100, true);
}
}
3 changes: 3 additions & 0 deletions src/tr2/game/objects/vehicles/skidoo_armed.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ void SkidooArmed_Setup(void);

void __cdecl SkidooArmed_Push(
const ITEM *item, ITEM *lara_item, int32_t radius);

void __cdecl SkidooArmed_Collision(
int16_t item_num, ITEM *lara_item, COLL_INFO *coll);
1 change: 0 additions & 1 deletion src/tr2/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@
#define DoShift ((int32_t __cdecl (*)(ITEM *skidoo, XYZ_32 *pos, XYZ_32 *old))0x0043D320)
#define DoDynamics ((int32_t __cdecl (*)(int32_t height, int32_t fall_speed, int32_t *y))0x0043D5A0)
#define GetCollisionAnim ((int32_t __cdecl (*)(ITEM *skidoo, XYZ_32 *moved))0x0043D600)
#define SkidooArmed_Collision ((void __cdecl (*)(int16_t item_num, ITEM *lara_item, COLL_INFO *coll))0x0043F2F0)
#define Music_GetRealTrack ((int32_t __cdecl (*)(int32_t track))0x0043F380)
#define Collide_TestCollision ((int32_t __cdecl (*)(ITEM *item, const ITEM *lara_item))0x0043F9B0)
#define Collide_GetSpheres ((int32_t __cdecl (*)(const ITEM *item, SPHERE *spheres, bool world_space))0x0043FAE0)
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 @@ -1032,6 +1032,7 @@ static void M_Objects(const bool enable)
INJECT(enable, 0x0043ED40, SkidooDriver_Initialise);
INJECT(enable, 0x0043EDD0, SkidooDriver_Control);
INJECT(enable, 0x0043F1D0, SkidooArmed_Push);
INJECT(enable, 0x0043F2F0, SkidooArmed_Collision);
INJECT(enable, 0x00442B30, FlameEmitter_Control);
INJECT(enable, 0x00442BC0, Flame_Control);
INJECT(enable, 0x00442E70, EmberEmitter_Control);
Expand Down

0 comments on commit 8463d1e

Please sign in to comment.