Skip to content

Commit

Permalink
tr2: port Pickup_Trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Oct 14, 2024
1 parent 391463a commit bec26d1
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 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 @@ -3602,7 +3602,7 @@ typedef enum {
0x00438D40 0x0039 + void __cdecl Switch_Control(int16_t item_num);
0x00438D80 0x00BD + int32_t __cdecl Switch_Trigger(int16_t item_num, int16_t timer);
0x00438E40 0x003D + int32_t __cdecl Keyhole_Trigger(int16_t item_num);
0x00438E80 0x0033 -R int32_t __cdecl PickupTrigger(int16_t item_num);
0x00438E80 0x0033 + int32_t __cdecl Pickup_Trigger(int16_t item_num);
0x00438EC0 0x0023 -R void __cdecl SecretControl(int16_t item_num);

# game/rat.c
Expand Down
11 changes: 11 additions & 0 deletions src/tr2/game/objects/general/pickup.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,14 @@ void __cdecl Pickup_Collision(
M_DoUnderwater(item_num, lara_item);
}
}

int32_t Pickup_Trigger(int16_t item_num)
{
ITEM *const item = Item_Get(item_num);
if (item->status != IS_INVISIBLE) {
return false;
}

item->status = IS_DEACTIVATED;
return true;
}
2 changes: 2 additions & 0 deletions src/tr2/game/objects/general/pickup.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@

void __cdecl Pickup_Collision(
int16_t item_num, ITEM *lara_item, COLL_INFO *coll);

int32_t Pickup_Trigger(int16_t item_num);
3 changes: 2 additions & 1 deletion src/tr2/game/room.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "game/math.h"
#include "game/music.h"
#include "game/objects/general/keyhole.h"
#include "game/objects/general/pickup.h"
#include "game/objects/general/switch.h"
#include "game/shell.h"
#include "global/const.h"
Expand Down Expand Up @@ -434,7 +435,7 @@ void __cdecl Room_TestTriggers(const int16_t *fd, bool heavy)

case TT_PICKUP: {
const int16_t value = TRIGGER_VALUE(*fd++);
if (!PickupTrigger(value)) {
if (!Pickup_Trigger(value)) {
return;
}
break;
Expand Down
1 change: 0 additions & 1 deletion src/tr2/global/funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@
#define Bandit2Control ((void __cdecl (*)(int16_t item_num))0x004378B0)
#define WinstonControl ((void __cdecl (*)(int16_t item_num))0x00437CF0)
#define DetonatorCollision ((void __cdecl (*)(int16_t item_num, ITEM *lara_item, COLL_INFO *coll))0x00438600)
#define PickupTrigger ((int32_t __cdecl (*)(int16_t item_num))0x00438E80)
#define SecretControl ((void __cdecl (*)(int16_t item_num))0x00438EC0)
#define MouseControl ((void __cdecl (*)(int16_t item_num))0x00438EF0)
#define InitialiseStartInfo ((void __cdecl (*)(void))0x004390E0)
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 @@ -974,6 +974,7 @@ static void M_Objects(const bool enable)
INJECT(enable, 0x00438D40, Switch_Control);
INJECT(enable, 0x00438D80, Switch_Trigger);
INJECT(enable, 0x00438E40, Keyhole_Trigger);
INJECT(enable, 0x00438E80, Pickup_Trigger);
INJECT(enable, 0x00442B30, FlameEmitter_Control);
INJECT(enable, 0x00442BC0, Flame_Control);
INJECT(enable, 0x00442E70, EmberEmitter_Control);
Expand Down

0 comments on commit bec26d1

Please sign in to comment.