diff --git a/src/tr2/decomp/flares.c b/src/tr2/decomp/flares.c index d5ac53699..c1b4b4f40 100644 --- a/src/tr2/decomp/flares.c +++ b/src/tr2/decomp/flares.c @@ -280,8 +280,8 @@ void Flare_Undraw(void) if (Item_TestAnimEqual(g_LaraItem, LA_FLARE_THROW)) { g_Lara.flare_control_left = 0; - if (frame_num_2 - >= g_Anims[LA_FLARE_THROW].frame_base + LF_FL_THROW_FT - 1) { + if (Item_TestFrameRange( + g_LaraItem, LF_FL_THROW_FT - 1, LF_FL_THROW_END)) { g_Lara.gun_type = g_Lara.last_gun_type; g_Lara.request_gun_type = g_Lara.last_gun_type; g_Lara.gun_status = LGS_ARMLESS; diff --git a/src/tr2/decomp/flares.h b/src/tr2/decomp/flares.h index edd7f2b00..23b360321 100644 --- a/src/tr2/decomp/flares.h +++ b/src/tr2/decomp/flares.h @@ -5,6 +5,7 @@ typedef enum { LF_FL_HOLD_FT = 1, LF_FL_THROW_FT = 32, + LF_FL_THROW_END = 35, LF_FL_DRAW_FT = 39, LF_FL_IGNITE_FT = 23, LF_FL_2_HOLD_FT = 15, diff --git a/src/tr2/decomp/skidoo.c b/src/tr2/decomp/skidoo.c index c1a1c86ef..f1c9b6031 100644 --- a/src/tr2/decomp/skidoo.c +++ b/src/tr2/decomp/skidoo.c @@ -46,6 +46,9 @@ #define SKIDOO_MOMENTUM_TURN (PHD_DEGREE * 3) // = 546 #define SKIDOO_MAX_MOMENTUM_TURN (PHD_DEGREE * 150) // = 27300 +#define LF_SKIDOO_EXIT_END 59 +#define LF_SKIDOO_LET_GO_END 17 + typedef enum { SKIDOO_GET_ON_NONE = 0, SKIDOO_GET_ON_LEFT = 1, @@ -704,7 +707,7 @@ int32_t Skidoo_CheckGetOff(void) if ((g_LaraItem->current_anim_state == LARA_STATE_SKIDOO_GET_OFF_R || g_LaraItem->current_anim_state == LARA_STATE_SKIDOO_GET_OFF_L) - && g_LaraItem->frame_num == g_Anims[g_LaraItem->anim_num].frame_end) { + && Item_TestFrameEqual(g_LaraItem, LF_SKIDOO_EXIT_END)) { if (g_LaraItem->current_anim_state == LARA_STATE_SKIDOO_GET_OFF_L) { g_LaraItem->rot.y += PHD_90; } else { @@ -726,8 +729,7 @@ int32_t Skidoo_CheckGetOff(void) if (g_LaraItem->current_anim_state == LARA_STATE_SKIDOO_LET_GO && (skidoo->pos.y == skidoo->floor - || g_LaraItem->frame_num - == g_Anims[g_LaraItem->anim_num].frame_end)) { + || Item_TestFrameEqual(g_LaraItem, LF_SKIDOO_LET_GO_END))) { Item_SwitchToAnim(g_LaraItem, LA_FREEFALL, 0); g_LaraItem->current_anim_state = LARA_STATE_SKIDOO_GET_OFF_R; if (skidoo->pos.y == skidoo->floor) { diff --git a/src/tr2/game/gun/gun_rifle.c b/src/tr2/game/gun/gun_rifle.c index e70706158..bc0a77f88 100644 --- a/src/tr2/game/gun/gun_rifle.c +++ b/src/tr2/game/gun/gun_rifle.c @@ -15,6 +15,10 @@ #include #include +#define GUN_RIFLE_EQUIP_ANIM 1 +#define GUN_RIFLE_DRAW_FRAME 10 +#define GUN_RIFLE_UNDRAW_FRAME 21 + static bool m_M16Firing = false; static bool m_HarpoonFired = false; @@ -242,7 +246,7 @@ void Gun_Rifle_Draw(const LARA_GUN_TYPE weapon_type) if (weapon_type == LGT_GRENADE) { Item_SwitchToObjAnim(item, 0, 0, O_LARA_GRENADE); } else { - Item_SwitchToAnim(item, GUN_RIFLE_EQUIP_FRAME, 0); + Item_SwitchToAnim(item, GUN_RIFLE_EQUIP_ANIM, 0); } item->goal_anim_state = LA_G_DRAW; item->current_anim_state = LA_G_DRAW; @@ -256,7 +260,7 @@ void Gun_Rifle_Draw(const LARA_GUN_TYPE weapon_type) if (item->current_anim_state == LA_G_AIM || item->current_anim_state == LA_G_UAIM) { Gun_Rifle_Ready(weapon_type); - } else if (item->frame_num - g_Anims[item->anim_num].frame_base == 10) { + } else if (Item_TestFrameEqual(item, GUN_RIFLE_DRAW_FRAME)) { Gun_Rifle_DrawMeshes(weapon_type); } else if (g_Lara.water_status == LWS_UNDERWATER) { item->goal_anim_state = LA_G_UAIM; @@ -293,7 +297,7 @@ void Gun_Rifle_Undraw(const LARA_GUN_TYPE weapon_type) g_Lara.right_arm.lock = 0; } else if ( item->current_anim_state == LA_G_UNDRAW - && item->frame_num - g_Anims[item->anim_num].frame_base == 21) { + && Item_TestFrameEqual(item, GUN_RIFLE_UNDRAW_FRAME)) { Gun_Rifle_UndrawMeshes(weapon_type); } @@ -344,7 +348,7 @@ void Gun_Rifle_Animate(const LARA_GUN_TYPE weapon_type) break; case LA_G_RECOIL: - if (item->frame_num - g_Anims[item->anim_num].frame_base == 0) { + if (Item_TestFrameEqual(item, 0)) { item->goal_anim_state = LA_G_UNAIM; if (g_Lara.water_status != LWS_UNDERWATER && !running && !m_HarpoonFired) { @@ -396,7 +400,7 @@ void Gun_Rifle_Animate(const LARA_GUN_TYPE weapon_type) break; case LA_G_URECOIL: - if (item->frame_num - g_Anims[item->anim_num].frame_base == 0) { + if (Item_TestFrameEqual(item, 0)) { item->goal_anim_state = LA_G_UUNAIM; if ((g_Lara.water_status == LWS_UNDERWATER || running) && !m_HarpoonFired) { diff --git a/src/tr2/game/lara/col.c b/src/tr2/game/lara/col.c index 50b054849..853c9632e 100644 --- a/src/tr2/game/lara/col.c +++ b/src/tr2/game/lara/col.c @@ -14,6 +14,39 @@ #include #include +#define LF_WALK_STEP_L_START 0 +#define LF_WALK_STEP_L_NEAR_END 5 +#define LF_WALK_STEP_L_END 6 +#define LF_WALK_STEP_R_START 7 +#define LF_WALK_STEP_R_MID 22 +#define LF_WALK_STEP_R_NEAR_END 23 +#define LF_WALK_STEP_R_END 25 +#define LF_WALK_STEP_L_2_START 26 +#define LF_WALK_STEP_L_2_END 35 + +#define LF_RUN_L_START 0 +#define LF_RUN_L_HEEL_GROUND 3 +#define LF_RUN_L_END 9 +#define LF_RUN_R_START 10 +#define LF_RUN_R_FOOT_GROUND 14 +#define LF_RUN_R_END 21 + +#define LF_BACK_R_START 964 +#define LF_BACK_R_END 993 + +#define LF_WADE_L_START 0 +#define LF_WADE_L_END 9 +#define LF_WADE_R_START 10 +#define LF_WADE_R_END 21 + +#define LF_WADE_STEP_L_START 3 +#define LF_WADE_STEP_L_END 14 + +#define LF_HANG 21 +#define LF_CLIMB_L_SHIFT_START 28 +#define LF_CLIMB_L_SHIFT_END 29 +#define LF_CLIMB_R_SHIFT 57 + void Lara_CollideStop(ITEM *const item, const COLL_INFO *const coll) { switch (coll->old_anim_state) { @@ -223,12 +256,17 @@ void Lara_Col_Walk(ITEM *item, COLL_INFO *coll) } if (Lara_DeflectEdge(item, coll)) { - if (item->frame_num >= 29 && item->frame_num <= 47) { - Item_SwitchToAnim(item, LA_WALK_STOP_LEFT, 0); - } else if ( - (item->frame_num >= 22 && item->frame_num <= 28) - || (item->frame_num >= 48 && item->frame_num <= 57)) { + if (Item_TestAnimEqual(item, LA_WALK_FORWARD) + && Item_TestFrameRange( + item, LF_WALK_STEP_R_START, LF_WALK_STEP_R_END)) { Item_SwitchToAnim(item, LA_WALK_STOP_RIGHT, 0); + } else if ( + Item_TestAnimEqual(item, LA_WALK_FORWARD) + && (Item_TestFrameRange( + item, LF_WALK_STEP_L_START, LF_WALK_STEP_L_END) + || Item_TestFrameRange( + item, LF_WALK_STEP_L_2_START, LF_WALK_STEP_L_2_END))) { + Item_SwitchToAnim(item, LA_WALK_STOP_LEFT, 0); } else { Lara_CollideStop(item, coll); } @@ -239,7 +277,9 @@ void Lara_Col_Walk(ITEM *item, COLL_INFO *coll) } if (coll->side_mid.floor > STEP_L / 2) { - if (item->frame_num >= 28 && item->frame_num <= 45) { + if (Item_TestAnimEqual(item, LA_WALK_FORWARD) + && Item_TestFrameRange( + item, LF_WALK_STEP_L_END, LF_WALK_STEP_R_NEAR_END)) { Item_SwitchToAnim(item, LA_WALK_DOWN_LEFT, 0); } else { Item_SwitchToAnim(item, LA_WALK_DOWN_RIGHT, 0); @@ -248,7 +288,9 @@ void Lara_Col_Walk(ITEM *item, COLL_INFO *coll) if (coll->side_mid.floor >= -STEPUP_HEIGHT && coll->side_mid.floor < -STEP_L / 2) { - if (item->frame_num >= 27 && item->frame_num <= 44) { + if (Item_TestAnimEqual(item, LA_WALK_FORWARD) + && Item_TestFrameRange( + item, LF_WALK_STEP_L_NEAR_END, LF_WALK_STEP_R_MID)) { Item_SwitchToAnim(item, LA_WALK_UP_STEP_LEFT, 0); } else { Item_SwitchToAnim(item, LA_WALK_UP_STEP_RIGHT, 0); @@ -282,14 +324,14 @@ void Lara_Col_Run(ITEM *item, COLL_INFO *coll) if (Lara_DeflectEdge(item, coll)) { item->rot.z = 0; - if (!Item_TestAnimEqual(item, LA_RUN_START) + if (Item_TestAnimEqual(item, LA_RUN) && Lara_TestWall(item, STEP_L, 0, -STEP_L * 5 / 2)) { item->current_anim_state = LS_SPLAT; - if (item->frame_num >= 0 && item->frame_num <= 9) { + if (Item_TestFrameRange(item, LF_RUN_L_START, LF_RUN_L_END)) { Item_SwitchToAnim(item, LA_WALL_SMASH_LEFT, 0); return; } - if (item->frame_num >= 10 && item->frame_num <= 21) { + if (Item_TestFrameRange(item, LF_RUN_R_START, LF_RUN_R_END)) { Item_SwitchToAnim(item, LA_WALL_SMASH_RIGHT, 0); return; } @@ -308,7 +350,8 @@ void Lara_Col_Run(ITEM *item, COLL_INFO *coll) || coll->side_front.floor >= -STEP_L / 2)) { coll->side_mid.floor = 0; } else { - if (item->frame_num >= 3 && item->frame_num <= 14) { + if (Item_TestFrameRange( + item, LF_RUN_L_HEEL_GROUND, LF_RUN_R_FOOT_GROUND)) { Item_SwitchToAnim(item, LA_RUN_UP_STEP_LEFT, 0); } else { Item_SwitchToAnim(item, LA_RUN_UP_STEP_RIGHT, 0); @@ -501,7 +544,7 @@ void Lara_Col_Hang(ITEM *item, COLL_INFO *coll) || coll->hit_static) { if (g_Lara.climb_status && Item_TestAnimEqual(item, LA_REACH_TO_HANG) - && item->frame_num == g_Anims[item->anim_num].frame_base + 21 + && Item_TestFrameEqual(item, LF_HANG) && coll->side_mid.ceiling <= -256) { item->goal_anim_state = LS_HANG; item->current_anim_state = LS_HANG; @@ -515,7 +558,7 @@ void Lara_Col_Hang(ITEM *item, COLL_INFO *coll) } else if ( g_Input.back && g_Lara.climb_status && Item_TestAnimEqual(item, LA_REACH_TO_HANG) - && item->frame_num == g_Anims[item->anim_num].frame_base + 21) { + && Item_TestFrameEqual(item, LF_HANG)) { item->goal_anim_state = LS_HANG; item->current_anim_state = LS_HANG; Item_SwitchToAnim(item, LA_LADDER_DOWN_HANGING, 0); @@ -629,7 +672,7 @@ void Lara_Col_Back(ITEM *item, COLL_INFO *coll) if (coll->side_mid.floor > STEP_L / 2 && coll->side_mid.floor < STEPUP_HEIGHT) { - if (item->frame_num >= 964 && item->frame_num <= 993) { + if (Item_TestFrameRange(item, LF_BACK_R_START, LF_BACK_R_END)) { Item_SwitchToAnim(item, LA_WALK_DOWN_BACK_RIGHT, 0); } else { Item_SwitchToAnim(item, LA_WALK_DOWN_BACK_LEFT, 0); @@ -903,13 +946,15 @@ void Lara_Col_Wade(ITEM *item, COLL_INFO *coll) if (Lara_DeflectEdge(item, coll)) { item->rot.z = 0; if (coll->side_front.type != COLL_NONE - && coll->side_front.floor < -STEP_L * 5 / 2) { + && coll->side_front.floor < -STEP_L * 5 / 2 + && coll->old_anim_state == LS_WADE + && Item_TestAnimEqual(item, LA_WADE)) { item->current_anim_state = LS_SPLAT; - if (item->frame_num >= 0 && item->frame_num <= 9) { + if (Item_TestFrameRange(item, LF_WADE_L_START, LF_WADE_L_END)) { Item_SwitchToAnim(item, LA_WALL_SMASH_LEFT, 0); return; } - if (item->frame_num >= 10 && item->frame_num <= 21) { + if (Item_TestFrameRange(item, LF_WADE_R_START, LF_WADE_R_END)) { Item_SwitchToAnim(item, LA_WALL_SMASH_RIGHT, 0); return; } @@ -923,7 +968,8 @@ void Lara_Col_Wade(ITEM *item, COLL_INFO *coll) if (coll->side_mid.floor >= -STEPUP_HEIGHT && coll->side_mid.floor < -STEP_L / 2) { - if (item->frame_num >= 3 && item->frame_num <= 14) { + if (Item_TestFrameRange( + item, LF_WADE_STEP_L_START, LF_WADE_STEP_L_END)) { Item_SwitchToAnim(item, LA_RUN_UP_STEP_LEFT, 0); } else { Item_SwitchToAnim(item, LA_RUN_UP_STEP_RIGHT, 0); @@ -1108,12 +1154,12 @@ void Lara_Col_Climbing(ITEM *item, COLL_INFO *coll) } int32_t yshift; - int32_t frame_rel = item->frame_num - g_Anims[item->anim_num].frame_base; - if (frame_rel == 0) { + if (Item_TestFrameEqual(item, 0)) { yshift = 0; - } else if (frame_rel == 28 || frame_rel == 29) { + } else if (Item_TestFrameRange( + item, LF_CLIMB_L_SHIFT_START, LF_CLIMB_L_SHIFT_END)) { yshift = -STEP_L; - } else if (frame_rel == 57) { + } else if (Item_TestFrameEqual(item, LF_CLIMB_R_SHIFT)) { yshift = -STEP_L * 2; } else { return; @@ -1165,12 +1211,12 @@ void Lara_Col_ClimbDown(ITEM *item, COLL_INFO *coll) } int32_t yshift; - int32_t frame_rel = item->frame_num - g_Anims[item->anim_num].frame_base; - if (frame_rel == 0) { + if (Item_TestFrameEqual(item, 0)) { yshift = 0; - } else if (frame_rel >= 28 && frame_rel <= 29) { + } else if (Item_TestFrameRange( + item, LF_CLIMB_L_SHIFT_START, LF_CLIMB_L_SHIFT_END)) { yshift = STEP_L; - } else if (frame_rel == 57) { + } else if (Item_TestFrameEqual(item, LF_CLIMB_R_SHIFT)) { yshift = STEP_L * 2; } else { return; diff --git a/src/tr2/game/lara/misc.c b/src/tr2/game/lara/misc.c index 7c5726745..9fd2daa95 100644 --- a/src/tr2/game/lara/misc.c +++ b/src/tr2/game/lara/misc.c @@ -431,7 +431,7 @@ void Lara_HangTest(ITEM *item, COLL_INFO *coll) } if (Item_TestAnimEqual(item, LA_REACH_TO_HANG) - && item->frame_num == g_Anims[item->anim_num].frame_base + 21 + && Item_TestFrameEqual(item, LF_HANG) && Lara_TestClimbStance(item, coll)) { item->goal_anim_state = LS_CLIMB_STANCE; } diff --git a/src/tr2/game/lara/state.c b/src/tr2/game/lara/state.c index e211c48fc..7c17bb9e3 100644 --- a/src/tr2/game/lara/state.c +++ b/src/tr2/game/lara/state.c @@ -16,6 +16,22 @@ #include #define LF_ROLL 2 +#define LF_JUMP_READY 4 +#define LF_FLARE_PICKUP_END 89 +#define LF_UW_FLARE_PICKUP_END 35 +#define LF_SHARK_DEATH_END 56 +#define LF_SHARK_DEATH_TIMER_DELAY 25 +#define LF_TREX_DEATH_TIMER_DELAY 45 +#define LF_YETI_DEATH_TIMER_DELAY 70 +#define LF_DRAGON_DAGGER_PULLED 1 +#define LF_DRAGON_DAGGER_STORED 180 +#define LF_DRAGON_DAGGER_ANIM_END 239 +#define LF_START_HOUSE_BEGIN 1 +#define LF_START_HOUSE_DAGGER_STORED 401 +#define LF_START_HOUSE_END 427 +#define LF_SHOWER_START 1 +#define LF_SHOWER_SHOTGUN_PICKUP 316 +#define LF_SHOWER_END 349 static bool m_JumpPermitted = true; @@ -101,7 +117,9 @@ void Lara_State_Run(ITEM *item, COLL_INFO *coll) if (Item_TestAnimEqual(item, LA_RUN_START)) { m_JumpPermitted = false; - } else if (!Item_TestAnimEqual(item, LA_RUN) || item->frame_num == 4) { + } else if ( + !Item_TestAnimEqual(item, LA_RUN) + || Item_TestFrameEqual(item, LF_JUMP_READY)) { m_JumpPermitted = true; } @@ -588,7 +606,10 @@ void Lara_State_Pickup(ITEM *item, COLL_INFO *coll) void Lara_State_PickupFlare(ITEM *item, COLL_INFO *coll) { Lara_State_Pickup(item, coll); - if (item->frame_num == g_Anims[item->anim_num].frame_end - 1) { + const int16_t frame_num = Item_TestAnimEqual(item, LA_FLARE_PICKUP) + ? LF_FLARE_PICKUP_END + : LF_UW_FLARE_PICKUP_END; + if (Item_TestFrameEqual(item, frame_num)) { g_Lara.gun_status = LGS_ARMLESS; } } @@ -711,7 +732,7 @@ void Lara_State_Extra_YetiKill(ITEM *item, COLL_INFO *coll) g_Camera.target_angle = CAM_YETI_KILL_ANGLE; g_Camera.target_distance = CAM_YETI_KILL_DISTANCE; g_Lara.hit_direction = -1; - if (item->frame_num < g_Anims[item->anim_num].frame_end - 30) { + if (Item_TestFrameRange(item, 0, LF_YETI_DEATH_TIMER_DELAY)) { g_Lara.death_timer = 1; } } @@ -722,15 +743,15 @@ void Lara_State_Extra_SharkKill(ITEM *item, COLL_INFO *coll) g_Camera.target_distance = CAM_SHARK_KILL_DISTANCE; g_Lara.hit_direction = -1; - if (item->frame_num == g_Anims[item->anim_num].frame_end) { - int32_t water_height = Room_GetWaterHeight( + if (Item_TestFrameEqual(item, LF_SHARK_DEATH_END)) { + const int32_t water_height = Room_GetWaterHeight( item->pos.x, item->pos.y, item->pos.z, item->room_num); if (water_height != NO_HEIGHT && water_height < item->pos.y - 100) { item->pos.y -= 5; } } - if (item->frame_num < g_Anims[item->anim_num].frame_end - 30) { + if (Item_TestFrameRange(item, 0, LF_SHARK_DEATH_TIMER_DELAY)) { g_Lara.death_timer = 1; } } @@ -754,24 +775,20 @@ void Lara_State_Extra_DinoKill(ITEM *item, COLL_INFO *coll) g_Camera.target_angle = CAM_TREX_KILL_ANGLE; g_Camera.target_elevation = CAM_TREX_KILL_ELEVATION; g_Lara.hit_direction = -1; - if (item->frame_num < g_Anims[item->anim_num].frame_end - 30) { + if (Item_TestFrameRange(item, 0, LF_TREX_DEATH_TIMER_DELAY)) { g_Lara.death_timer = 1; } } void Lara_State_Extra_PullDagger(ITEM *item, COLL_INFO *coll) { - int32_t frame_num_rel = - item->frame_num - g_Anims[item->anim_num].frame_base; - if (frame_num_rel == 1) { + if (Item_TestFrameEqual(item, LF_DRAGON_DAGGER_PULLED)) { Music_PlaySynced(MX_DAGGER_PULL); - } else if (frame_num_rel == 180) { + } else if (Item_TestFrameEqual(item, LF_DRAGON_DAGGER_STORED)) { g_Lara.mesh_ptrs[LM_HAND_R] = g_Meshes[g_Objects[O_LARA].mesh_idx + LM_HAND_R]; Inv_AddItem(O_PUZZLE_ITEM_2); - } - - if (item->frame_num == g_Anims[item->anim_num].frame_end) { + } else if (Item_TestFrameEqual(item, LF_DRAGON_DAGGER_ANIM_END)) { item->rot.y += PHD_90; const ITEM *const dragon_bones = Item_Find(O_DRAGON_BONES_2); @@ -788,19 +805,17 @@ void Lara_State_Extra_StartAnim(ITEM *item, COLL_INFO *coll) void Lara_State_Extra_StartHouse(ITEM *item, COLL_INFO *coll) { - int32_t frame_num_rel = - item->frame_num - g_Anims[item->anim_num].frame_base; - if (frame_num_rel == 1) { + if (Item_TestFrameEqual(item, LF_START_HOUSE_BEGIN)) { Music_PlaySynced(MX_REVEAL_2); g_Lara.mesh_ptrs[LM_HAND_R] = g_Meshes[g_Objects[O_LARA_EXTRA].mesh_idx + LM_HAND_R]; g_Lara.mesh_ptrs[LM_HIPS] = g_Meshes[g_Objects[O_LARA_EXTRA].mesh_idx]; - } else if (frame_num_rel == 401) { + } else if (Item_TestFrameEqual(item, LF_START_HOUSE_DAGGER_STORED)) { g_Lara.mesh_ptrs[LM_HAND_R] = g_Meshes[g_Objects[O_LARA].mesh_idx + LM_HAND_R]; g_Lara.mesh_ptrs[LM_HIPS] = g_Meshes[g_Objects[O_LARA].mesh_idx]; Inv_AddItem(O_PUZZLE_ITEM_1); - } else if (item->frame_num == g_Anims[item->anim_num].frame_end) { + } else if (Item_TestFrameEqual(item, LF_START_HOUSE_END)) { g_Camera.type = CAM_CHASE; Viewport_AlterFOV(-1); } @@ -810,9 +825,7 @@ void Lara_State_Extra_FinalAnim(ITEM *item, COLL_INFO *coll) { item->hit_points = 1000; - int32_t frame_num_rel = - item->frame_num - g_Anims[item->anim_num].frame_base; - if (frame_num_rel == 1) { + if (Item_TestFrameEqual(item, LF_SHOWER_START)) { g_Lara.back_gun = 0; g_Lara.mesh_ptrs[LM_HAND_R] = g_Meshes[g_Objects[O_LARA].mesh_idx + LM_HAND_R]; @@ -821,10 +834,10 @@ void Lara_State_Extra_FinalAnim(ITEM *item, COLL_INFO *coll) g_Lara.mesh_ptrs[LM_HIPS] = g_Meshes[g_Objects[O_LARA_EXTRA].mesh_idx + LM_HIPS]; Music_PlaySynced(MX_CUTSCENE_BATH); - } else if (frame_num_rel == 316) { + } else if (Item_TestFrameEqual(item, LF_SHOWER_SHOTGUN_PICKUP)) { g_Lara.mesh_ptrs[LM_HAND_R] = g_Meshes[g_Objects[O_LARA_SHOTGUN].mesh_idx + LM_HAND_R]; - } else if (item->frame_num == g_Anims[item->anim_num].frame_end - 1) { + } else if (Item_TestFrameEqual(item, LF_SHOWER_END)) { g_LevelComplete = true; } } diff --git a/src/tr2/game/objects/creatures/bird_guardian.c b/src/tr2/game/objects/creatures/bird_guardian.c index 018a4f472..73d25bef4 100644 --- a/src/tr2/game/objects/creatures/bird_guardian.c +++ b/src/tr2/game/objects/creatures/bird_guardian.c @@ -19,6 +19,7 @@ #define BIRD_GUARDIAN_ATTACK_1_RANGE SQUARE(WALL_L) // = 1048576 #define BIRD_GUARDIAN_ATTACK_2_RANGE SQUARE(WALL_L * 2) // = 4194304 #define BIRD_GUARDIAN_PUNCH_DAMAGE 200 +#define BIRD_GUARDIAN_DEATH_FRAME 158 // clang-format on typedef enum { @@ -192,7 +193,7 @@ void BirdGuardian_Control(const int16_t item_num) item->current_anim_state = BIRD_GUARDIAN_STATE_DEATH; } - if (item->frame_num == g_Anims[item->anim_num].frame_end) { + if (Item_TestFrameEqual(item, BIRD_GUARDIAN_DEATH_FRAME)) { g_LevelComplete = true; } } diff --git a/src/tr2/game/objects/creatures/dragon.c b/src/tr2/game/objects/creatures/dragon.c index abbf5e0c3..8896d97d4 100644 --- a/src/tr2/game/objects/creatures/dragon.c +++ b/src/tr2/game/objects/creatures/dragon.c @@ -199,8 +199,7 @@ void Dragon_Collision( if (g_Input.action && item->object_id == O_DRAGON_BACK && (Item_TestAnimEqual(item, DRAGON_ANIM_DEAD) || (Item_TestAnimEqual(item, DRAGON_ANIM_RESURRECT) - && item->frame_num - g_Anims[item->anim_num].frame_base - <= DRAGON_ALMOST_LIVE)) + && Item_TestFrameRange(item, 0, DRAGON_ALMOST_LIVE))) && !lara_item->gravity && shift <= DRAGON_MID && shift > DRAGON_CLOSE - 350 && side_shift > -350 && side_shift < 350 && angle > PHD_90 - 30 * PHD_DEGREE diff --git a/src/tr2/game/objects/general/detonator.c b/src/tr2/game/objects/general/detonator.c index 6f1d6cf63..19782541a 100644 --- a/src/tr2/game/objects/general/detonator.c +++ b/src/tr2/game/objects/general/detonator.c @@ -11,6 +11,10 @@ #include "game/sound.h" #include "global/vars.h" +#define EXPLOSION_START_FRAME 76 +#define EXPLOSION_END_FRAME 99 +#define EXPLOSION_ACTION_FRAME 80 + static XYZ_32 m_DetonatorPosition = { .x = 0, .y = 0, .z = 0 }; static int16_t m_GongBounds[12] = { @@ -73,13 +77,11 @@ void Detonator_Control(const int16_t item_num) ITEM *const item = Item_Get(item_num); Item_Animate(item); - const int32_t frame_num = - item->frame_num - g_Anims[item->anim_num].frame_base; - if (frame_num > 75 && frame_num < 100) { + if (Item_TestFrameRange(item, EXPLOSION_START_FRAME, EXPLOSION_END_FRAME)) { Output_AddDynamicLight(item->pos.x, item->pos.y, item->pos.z, 13, 11); } - if (frame_num == 80) { + if (Item_TestFrameEqual(item, EXPLOSION_ACTION_FRAME)) { g_Camera.bounce = -150; Sound_Effect(SFX_EXPLOSION_1, NULL, SPM_ALWAYS); } diff --git a/src/tr2/game/objects/general/gong_bonger.c b/src/tr2/game/objects/general/gong_bonger.c index d15c6eea6..f8d0cb9b8 100644 --- a/src/tr2/game/objects/general/gong_bonger.c +++ b/src/tr2/game/objects/general/gong_bonger.c @@ -5,6 +5,9 @@ #include "game/room.h" #include "global/vars.h" +#define GONG_BONGER_STRIKE_FRAME 41 +#define GONG_BONGER_END_FRAME 79 + static void M_ActivateHeavyTriggers(int16_t item_num); static void M_ActivateHeavyTriggers(const int16_t item_num) @@ -27,12 +30,12 @@ void GongBonger_Control(const int16_t item_num) ITEM *const item = Item_Get(item_num); Item_Animate(item); - if (item->frame_num - g_Anims[item->anim_num].frame_base == 41) { + if (Item_TestFrameEqual(item, GONG_BONGER_STRIKE_FRAME)) { Music_Play(MX_REVEAL_1, MPM_ALWAYS); g_Camera.bounce -= 50; } - if (item->frame_num == g_Anims[item->anim_num].frame_end) { + if (Item_TestFrameEqual(item, GONG_BONGER_END_FRAME)) { M_ActivateHeavyTriggers(item_num); } } diff --git a/src/tr2/game/objects/general/movable_block.c b/src/tr2/game/objects/general/movable_block.c index a692a13b5..eab4ccbda 100644 --- a/src/tr2/game/objects/general/movable_block.c +++ b/src/tr2/game/objects/general/movable_block.c @@ -301,9 +301,8 @@ void MovableBlock_Collision( } } } else if ( - lara_item->current_anim_state == LS_PP_READY - && lara_item->frame_num - == g_Anims[LA_PUSHABLE_GRAB].frame_base + LF_PPREADY) { + Item_TestAnimEqual(lara_item, LA_PUSHABLE_GRAB) + && Item_TestFrameEqual(lara_item, LF_PPREADY)) { if (!Item_TestPosition(m_MovableBlockBounds, item, lara_item)) { return; } diff --git a/src/tr2/game/objects/general/pickup.c b/src/tr2/game/objects/general/pickup.c index 8b795c047..837469ea4 100644 --- a/src/tr2/game/objects/general/pickup.c +++ b/src/tr2/game/objects/general/pickup.c @@ -91,16 +91,14 @@ static void M_DoAboveWater(const int16_t item_num, ITEM *const lara_item) } if (lara_item->current_anim_state == LS_PICKUP) { - if (lara_item->frame_num - == g_Anims[LA_PICKUP].frame_base + LF_PICKUP_ERASE) { + if (Item_TestFrameEqual(lara_item, LF_PICKUP_ERASE)) { M_DoPickup(item_num); } goto cleanup; } if (lara_item->current_anim_state == LS_FLARE_PICKUP) { - if (lara_item->frame_num - == g_Anims[LA_FLARE_PICKUP].frame_base + LF_PICKUP_FLARE + if (Item_TestFrameEqual(lara_item, LF_PICKUP_FLARE) && item->object_id == O_FLARE_ITEM && g_Lara.gun_type != LGT_FLARE) { M_DoFlarePickup(item_num); @@ -149,17 +147,14 @@ static void M_DoUnderwater(const int16_t item_num, ITEM *const lara_item) } if (lara_item->current_anim_state == LS_PICKUP) { - if (lara_item->frame_num - == g_Anims[LA_UNDERWATER_PICKUP].frame_base + LF_PICKUP_UW) { + if (Item_TestFrameEqual(lara_item, LF_PICKUP_UW)) { M_DoPickup(item_num); } goto cleanup; } if (lara_item->current_anim_state == LS_FLARE_PICKUP) { - if (lara_item->frame_num - == g_Anims[LA_UNDERWATER_FLARE_PICKUP].frame_base - + LF_PICKUP_FLARE_UW + if (Item_TestFrameEqual(lara_item, LF_PICKUP_FLARE_UW) && item->object_id == O_FLARE_ITEM && g_Lara.gun_type != LGT_FLARE) { M_DoFlarePickup(item_num); diff --git a/src/tr2/game/objects/general/puzzle_hole.c b/src/tr2/game/objects/general/puzzle_hole.c index 12d40fb59..f3717973d 100644 --- a/src/tr2/game/objects/general/puzzle_hole.c +++ b/src/tr2/game/objects/general/puzzle_hole.c @@ -90,8 +90,7 @@ void PuzzleHole_Collision( if (lara_item->current_anim_state != LS_STOP) { if (lara_item->current_anim_state != LS_USE_PUZZLE || !Item_TestPosition(m_PuzzleHoleBounds, item, lara_item) - || lara_item->frame_num - != g_Anims[LA_USE_PUZZLE].frame_base + LF_USE_PUZZLE) { + || !Item_TestFrameEqual(lara_item, LF_USE_PUZZLE)) { return; } diff --git a/src/tr2/game/objects/traps/dart_emitter.c b/src/tr2/game/objects/traps/dart_emitter.c index 888461997..e9e47bc1b 100644 --- a/src/tr2/game/objects/traps/dart_emitter.c +++ b/src/tr2/game/objects/traps/dart_emitter.c @@ -68,7 +68,7 @@ void DartEmitter_Control(const int16_t item_num) } if (item->current_anim_state == DART_EMITTER_STATE_FIRE - && item->frame_num == g_Anims[item->anim_num].frame_base) { + && Item_TestFrameEqual(item, 0)) { M_CreateDart(item); } diff --git a/src/tr2/game/objects/vehicles/boat.c b/src/tr2/game/objects/vehicles/boat.c index c683a876a..8b6fb371b 100644 --- a/src/tr2/game/objects/vehicles/boat.c +++ b/src/tr2/game/objects/vehicles/boat.c @@ -27,6 +27,8 @@ #define BOAT_GET_ON_J_ANIM 6 #define BOAT_GET_ON_START 1 +#define LF_BOAT_EXIT_END 24 + #define BOAT_RADIUS 500 #define BOAT_SIDE 300 #define BOAT_FRONT 750 @@ -779,7 +781,7 @@ void Boat_Control(const int16_t item_num) if ((lara->current_anim_state == BOAT_STATE_JUMP_R || lara->current_anim_state == BOAT_STATE_JUMP_L) - && lara->frame_num == g_Anims[lara->anim_num].frame_end) { + && Item_TestFrameEqual(lara, LF_BOAT_EXIT_END)) { if (lara->current_anim_state == BOAT_STATE_JUMP_L) { lara->rot.y -= PHD_90; } else {