From 0d8330fa2005f2ebdef9b2a3b93f4f6d37f96c32 Mon Sep 17 00:00:00 2001 From: Troye Date: Thu, 27 Oct 2022 20:14:49 -0500 Subject: [PATCH 01/12] fix new lasers in zbuffer; disable new lasers for guards --- tomb3decomp/game/draw.cpp | 4 ++++ tomb3decomp/specific/draweffects.cpp | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tomb3decomp/game/draw.cpp b/tomb3decomp/game/draw.cpp index 9a8acb63..4207360f 100644 --- a/tomb3decomp/game/draw.cpp +++ b/tomb3decomp/game/draw.cpp @@ -2161,6 +2161,10 @@ void DrawAnimatingItem(ITEM_INFO* item) dest.z = pos.z; LOS(&src, &dest); + +#ifdef TROYESTUFF + dest.box_number = 0x1FFF; //bite me +#endif S_DrawLaserBeam(&src, &dest, 255, 2, 3); } } diff --git a/tomb3decomp/specific/draweffects.cpp b/tomb3decomp/specific/draweffects.cpp index 028a0032..ae0bd5b8 100644 --- a/tomb3decomp/specific/draweffects.cpp +++ b/tomb3decomp/specific/draweffects.cpp @@ -3607,8 +3607,11 @@ void S_DrawLaserBeam(GAME_VECTOR* src, GAME_VECTOR* dest, uchar cr, uchar cg, uc UpdateLaserShades(); #ifdef TROYESTUFF - if (tomb3.improved_lasers) - return DrawBetterLasers(src, dest, cr, cg, cb); + if (dest->box_number != 0x1FFF) //BITE. ME. + { + if (tomb3.improved_lasers) + return DrawBetterLasers(src, dest, cr, cg, cb); + } #endif dm = &App.DeviceInfoPtr->DDInfo[App.DXConfigPtr->nDD].D3DInfo[App.DXConfigPtr->nD3D].DisplayMode[App.DXConfigPtr->nVMode]; @@ -4789,7 +4792,7 @@ void DrawBetterLasers(GAME_VECTOR* src, GAME_VECTOR* dest, uchar cr, uchar cg, u v[2].ys -= s; v[3].ys -= s; - HWI_InsertGT4_Sorted(&v[0], &v[1], &v[2], &v[3], &tex, MID_SORT, 1); + HWI_InsertGT4_Poly(&v[0], &v[1], &v[2], &v[3], &tex, MID_SORT, 1); } phd_PopMatrix(); From 1a348778adfe09926f9a81f6e84323d3662f63e5 Mon Sep 17 00:00:00 2001 From: Troye Date: Thu, 27 Oct 2022 20:27:31 -0500 Subject: [PATCH 02/12] BoatCollision --- tomb3decomp/game/boat.cpp | 62 +++++++++++++++++++++++++++++++++ tomb3decomp/game/boat.h | 1 + tomb3decomp/global/progress.txt | 2 +- 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/tomb3decomp/game/boat.cpp b/tomb3decomp/game/boat.cpp index 62728d1e..cb1ad1fe 100644 --- a/tomb3decomp/game/boat.cpp +++ b/tomb3decomp/game/boat.cpp @@ -4,6 +4,10 @@ #include "../3dsystem/phd_math.h" #include "collide.h" #include "sphere.h" +#include "objects.h" +#include "items.h" +#include "control.h" +#include "../specific/specific.h" void InitialiseBoat(short item_number) { @@ -90,8 +94,66 @@ static long BoatCheckGeton(short item_number, COLL_INFO* coll) return pass; } +void BoatCollision(short item_number, ITEM_INFO* l, COLL_INFO* coll) +{ + ITEM_INFO* item; + long geton; + + if (l->hit_points < 0 || lara.skidoo != NO_ITEM) + return; + + geton = BoatCheckGeton(item_number, coll); + + if (!geton) + { + coll->enable_baddie_push = 1; + ObjectCollision(item_number, l, coll); + return; + } + + lara.skidoo = item_number; + + if (geton == 1) + l->anim_number = objects[VEHICLE_ANIM].anim_index + 8; + else if (geton == 2) + l->anim_number = objects[VEHICLE_ANIM].anim_index; + else if (geton == 3) + l->anim_number = objects[VEHICLE_ANIM].anim_index + 6; + else + l->anim_number = objects[VEHICLE_ANIM].anim_index + 1; + + lara.water_status = LARA_ABOVEWATER; + item = &items[item_number]; + l->pos.x_pos = item->pos.x_pos; + l->pos.y_pos = item->pos.y_pos - 5; + l->pos.z_pos = item->pos.z_pos; + l->pos.x_rot = 0; + l->pos.y_rot = item->pos.y_rot; + l->pos.z_rot = 0; + l->gravity_status = 0; + l->speed = 0; + l->fallspeed = 0; + l->frame_number = anims[l->anim_number].frame_base; + l->current_anim_state = 0; + l->goal_anim_state = 0; + + if (l->room_number != item->room_number) + ItemNewRoom(lara.item_number, item->room_number); + + AnimateItem(l); + + if (item->status != ITEM_ACTIVE) + { + AddActiveItem(item_number); + item->status = ITEM_ACTIVE; + } + + S_CDPlay(12, 0); +} + void inject_boat(bool replace) { INJECT(0x00411FE0, InitialiseBoat, replace); INJECT(0x00412040, BoatCheckGeton, replace); + INJECT(0x004121B0, BoatCollision, replace); } diff --git a/tomb3decomp/game/boat.h b/tomb3decomp/game/boat.h index 64da1211..7410be4f 100644 --- a/tomb3decomp/game/boat.h +++ b/tomb3decomp/game/boat.h @@ -2,5 +2,6 @@ #include "../global/vars.h" void InitialiseBoat(short item_number); +void BoatCollision(short item_number, ITEM_INFO* l, COLL_INFO* coll); void inject_boat(bool replace); diff --git a/tomb3decomp/global/progress.txt b/tomb3decomp/global/progress.txt index 2ee81d62..a8ed5970 100644 --- a/tomb3decomp/global/progress.txt +++ b/tomb3decomp/global/progress.txt @@ -170,7 +170,7 @@ tomb3decomp progress. 0x00411FE0 + InitialiseBoat 0x00412040 + BoatCheckGeton -0x004121B0 BoatCollision +0x004121B0 + BoatCollision 0x00412330 BoatUserControl 0x00412500 BoatAnimation 0x00412730 CanGetOff From 2906ee51fb0dfb59324c4a301d05233e66a424a6 Mon Sep 17 00:00:00 2001 From: Troye Date: Thu, 27 Oct 2022 23:22:40 -0500 Subject: [PATCH 03/12] DrawBoat --- tomb3decomp/game/boat.cpp | 14 ++++++++++++++ tomb3decomp/game/boat.h | 1 + tomb3decomp/global/progress.txt | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tomb3decomp/game/boat.cpp b/tomb3decomp/game/boat.cpp index cb1ad1fe..9f8904e7 100644 --- a/tomb3decomp/game/boat.cpp +++ b/tomb3decomp/game/boat.cpp @@ -8,6 +8,8 @@ #include "items.h" #include "control.h" #include "../specific/specific.h" +#include "draw.h" +#include "../specific/draweffects.h" void InitialiseBoat(short item_number) { @@ -151,9 +153,21 @@ void BoatCollision(short item_number, ITEM_INFO* l, COLL_INFO* coll) S_CDPlay(12, 0); } +void DrawBoat(ITEM_INFO* item) +{ + BOAT_INFO* boat; + + boat = (BOAT_INFO*)item->data; + item->data = &boat->prop_rot; + DrawAnimatingItem(item); + item->data = boat; + S_DrawWakeFX(item); +} + void inject_boat(bool replace) { INJECT(0x00411FE0, InitialiseBoat, replace); INJECT(0x00412040, BoatCheckGeton, replace); INJECT(0x004121B0, BoatCollision, replace); + INJECT(0x00413CF0, DrawBoat, replace); } diff --git a/tomb3decomp/game/boat.h b/tomb3decomp/game/boat.h index 7410be4f..4a454e12 100644 --- a/tomb3decomp/game/boat.h +++ b/tomb3decomp/game/boat.h @@ -3,5 +3,6 @@ void InitialiseBoat(short item_number); void BoatCollision(short item_number, ITEM_INFO* l, COLL_INFO* coll); +void DrawBoat(ITEM_INFO* item); void inject_boat(bool replace); diff --git a/tomb3decomp/global/progress.txt b/tomb3decomp/global/progress.txt index a8ed5970..183c8599 100644 --- a/tomb3decomp/global/progress.txt +++ b/tomb3decomp/global/progress.txt @@ -182,7 +182,7 @@ tomb3decomp progress. 0x00413900 DoShift 0x00413B80 GetCollisionAnim 0x00413C10 DoBoatShift -0x00413CF0 DrawBoat +0x00413CF0 + DrawBoat 0x00413D20 TriggerBoatMist 0x00413F00 BoatSplash From 7f658932c2eb700df70a8796ee48200aed4287c4 Mon Sep 17 00:00:00 2001 From: Troye Date: Thu, 27 Oct 2022 23:58:20 -0500 Subject: [PATCH 04/12] BoatUserControl --- tomb3decomp/game/boat.cpp | 89 +++++++++++++++++++++++++++++++++ tomb3decomp/global/progress.txt | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/tomb3decomp/game/boat.cpp b/tomb3decomp/game/boat.cpp index 9f8904e7..e52f67de 100644 --- a/tomb3decomp/game/boat.cpp +++ b/tomb3decomp/game/boat.cpp @@ -10,6 +10,7 @@ #include "../specific/specific.h" #include "draw.h" #include "../specific/draweffects.h" +#include "lara.h" void InitialiseBoat(short item_number) { @@ -164,10 +165,98 @@ void DrawBoat(ITEM_INFO* item) S_DrawWakeFX(item); } +static long BoatUserControl(ITEM_INFO* item) +{ + BOAT_INFO* boat; + long no_turn, max_speed; + + boat = (BOAT_INFO*)item->data; + no_turn = 1; + + if (item->pos.y_pos < boat->water - 128 || boat->water == NO_HEIGHT) + return 1; + + if ((input & IN_ROLL || input & IN_LOOK) && !item->speed) + { + if (!(input & (IN_RSTEP | IN_RIGHT | IN_LSTEP | IN_LEFT))) + item->speed = 0; + else if (!(input & IN_ROLL)) + item->speed = 20; + + if (input & IN_LOOK && !item->speed) + LookUpDown(); + } + else + { + if ((input & (IN_LSTEP | IN_LEFT)) && !(input & IN_JUMP) || (input & (IN_RSTEP | IN_RIGHT)) && input & IN_JUMP) + { + if (boat->boat_turn > 0) + boat->boat_turn -= 45; + else + { + boat->boat_turn -= 22; + + if (boat->boat_turn < -728) + boat->boat_turn = -728; + } + + no_turn = 0; + } + else if ((input & (IN_RSTEP | IN_RIGHT)) && !(input & IN_JUMP) || (input & (IN_LSTEP | IN_LEFT)) && input & IN_JUMP) + { + if (boat->boat_turn < 0) + boat->boat_turn += 45; + else + { + boat->boat_turn += 22; + + if (boat->boat_turn > 728) + boat->boat_turn = 728; + } + + no_turn = 0; + } + + if (input & IN_JUMP) + { + if (item->speed > 0) + item->speed -= 5; + else if (item->speed > -20) + item->speed -= 2; + } + else if (input & IN_ACTION) + { + if (input & IN_SPRINT) + max_speed = 185; + else if (input & IN_WALK) + max_speed = 36; + else + max_speed = 110; + + if (item->speed < max_speed) + item->speed = short(5 * item->speed / (2 * max_speed) + item->speed + 2); + else if (item->speed > max_speed + 1) + item->speed--; + } + else if (item->speed >= 0 && item->speed < 20 && (input & (IN_RSTEP | IN_RIGHT | IN_LSTEP | IN_LEFT))) + { + if (!item->speed && !(input & IN_ROLL)) + item->speed = 20; + } + else if (item->speed > 1) + item->speed--; + else + item->speed = 0; + } + + return no_turn; +} + void inject_boat(bool replace) { INJECT(0x00411FE0, InitialiseBoat, replace); INJECT(0x00412040, BoatCheckGeton, replace); INJECT(0x004121B0, BoatCollision, replace); INJECT(0x00413CF0, DrawBoat, replace); + INJECT(0x00412330, BoatUserControl, replace); } diff --git a/tomb3decomp/global/progress.txt b/tomb3decomp/global/progress.txt index 183c8599..c76f631f 100644 --- a/tomb3decomp/global/progress.txt +++ b/tomb3decomp/global/progress.txt @@ -171,7 +171,7 @@ tomb3decomp progress. 0x00411FE0 + InitialiseBoat 0x00412040 + BoatCheckGeton 0x004121B0 + BoatCollision -0x00412330 BoatUserControl +0x00412330 + BoatUserControl 0x00412500 BoatAnimation 0x00412730 CanGetOff 0x00412820 BoatControl From 582dec5b00c809206f05d3993f6c83b03c780967 Mon Sep 17 00:00:00 2001 From: Troye Date: Fri, 28 Oct 2022 00:09:24 -0500 Subject: [PATCH 05/12] CanGetOff (boat) --- tomb3decomp/game/boat.cpp | 30 ++++++++++++++++++++++++++++++ tomb3decomp/global/progress.txt | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tomb3decomp/game/boat.cpp b/tomb3decomp/game/boat.cpp index e52f67de..7f213c85 100644 --- a/tomb3decomp/game/boat.cpp +++ b/tomb3decomp/game/boat.cpp @@ -252,6 +252,35 @@ static long BoatUserControl(ITEM_INFO* item) return no_turn; } +static long CanGetOff(long lr) +{ + ITEM_INFO* item; + FLOOR_INFO* floor; + long x, y, z, h, c; + short angle, room_number; + + item = &items[lara.skidoo]; + + if (lr >= 0) + angle = item->pos.y_rot + 0x4000; + else + angle = item->pos.y_rot - 0x4000; + + x = item->pos.x_pos + ((WALL_SIZE * phd_sin(angle)) >> W2V_SHIFT); + y = item->pos.y_pos; + z = item->pos.z_pos + ((WALL_SIZE * phd_cos(angle)) >> W2V_SHIFT); + + room_number = item->room_number; + floor = GetFloor(x, y, z, &room_number); + h = GetHeight(floor, x, y, z); + c = GetCeiling(floor, x, y, z); + + if (h - item->pos.y_pos >= -512 && height_type != BIG_SLOPE && height_type != DIAGONAL && c - item->pos.y_pos <= -762 && h - c >= 762) + return 1; + + return 0; +} + void inject_boat(bool replace) { INJECT(0x00411FE0, InitialiseBoat, replace); @@ -259,4 +288,5 @@ void inject_boat(bool replace) INJECT(0x004121B0, BoatCollision, replace); INJECT(0x00413CF0, DrawBoat, replace); INJECT(0x00412330, BoatUserControl, replace); + INJECT(0x00412730, CanGetOff, replace); } diff --git a/tomb3decomp/global/progress.txt b/tomb3decomp/global/progress.txt index c76f631f..3ac2d84a 100644 --- a/tomb3decomp/global/progress.txt +++ b/tomb3decomp/global/progress.txt @@ -173,7 +173,7 @@ tomb3decomp progress. 0x004121B0 + BoatCollision 0x00412330 + BoatUserControl 0x00412500 BoatAnimation -0x00412730 CanGetOff +0x00412730 + CanGetOff 0x00412820 BoatControl 0x004130C0 DoWake 0x00413290 TestWaterHeight From 3e37f6f1708ce6fa4822cd2fc7b6d3c420feb174 Mon Sep 17 00:00:00 2001 From: Troye Date: Fri, 28 Oct 2022 00:35:06 -0500 Subject: [PATCH 06/12] BoatAnimation --- tomb3decomp/game/boat.cpp | 92 +++++++++++++++++++++++++++++++++ tomb3decomp/global/progress.txt | 2 +- 2 files changed, 93 insertions(+), 1 deletion(-) diff --git a/tomb3decomp/game/boat.cpp b/tomb3decomp/game/boat.cpp index 7f213c85..3fce6768 100644 --- a/tomb3decomp/game/boat.cpp +++ b/tomb3decomp/game/boat.cpp @@ -281,6 +281,97 @@ static long CanGetOff(long lr) return 0; } +static void BoatAnimation(ITEM_INFO* item, long collide) +{ + BOAT_INFO* boat; + + boat = (BOAT_INFO*)item->data; + + if (lara_item->hit_points <= 0) + { + if (lara_item->current_anim_state != 8) + { + lara_item->anim_number = objects[VEHICLE_ANIM].anim_index + 18; + lara_item->frame_number = anims[lara_item->anim_number].frame_base; + lara_item->current_anim_state = 8; + lara_item->goal_anim_state = 8; + } + } + else if (item->pos.y_pos < boat->water - 128 && item->fallspeed > 0) + { + if (lara_item->current_anim_state != 6) + { + lara_item->anim_number = objects[VEHICLE_ANIM].anim_index + 15; + lara_item->frame_number = anims[lara_item->anim_number].frame_base; + lara_item->current_anim_state = 6; + lara_item->goal_anim_state = 6; + } + } + else if (collide) + { + if (lara_item->current_anim_state != 5) + { + lara_item->anim_number = objects[VEHICLE_ANIM].anim_index + collide; + lara_item->frame_number = anims[lara_item->anim_number].frame_base; + lara_item->current_anim_state = 5; + lara_item->goal_anim_state = 5; + } + } + else + { + switch (lara_item->current_anim_state) + { + case 1: + + if (input & IN_ROLL && !item->speed) + { + if (input & (IN_RSTEP | IN_RIGHT) && CanGetOff(item->pos.y_rot + 0x4000)) + lara_item->goal_anim_state = 3; + else if (input & (IN_LSTEP | IN_LEFT) && CanGetOff(item->pos.y_rot - 0x4000)) + lara_item->goal_anim_state = 4; + } + + if (item->speed > 0) + lara_item->goal_anim_state = 2; + + break; + + case 2: + + if (item->speed <= 0) + lara_item->goal_anim_state = 1; + else if (input & (IN_RSTEP | IN_RIGHT)) + lara_item->goal_anim_state = 7; + else if (input & (IN_LSTEP | IN_LEFT)) + lara_item->goal_anim_state = 9; + + break; + + case 6: + lara_item->goal_anim_state = 2; + break; + + case 7: + + if (item->speed <= 0) + lara_item->goal_anim_state = 1; + else if (!(input & (IN_RSTEP | IN_RIGHT))) + lara_item->goal_anim_state = 2; + + break; + + case 9: + + if (item->speed <= 0) + lara_item->goal_anim_state = 1; + else if (!(input & (IN_LSTEP | IN_LEFT))) + lara_item->goal_anim_state = 2; + + break; + } + } +} + void inject_boat(bool replace) { INJECT(0x00411FE0, InitialiseBoat, replace); @@ -289,4 +380,5 @@ void inject_boat(bool replace) INJECT(0x00413CF0, DrawBoat, replace); INJECT(0x00412330, BoatUserControl, replace); INJECT(0x00412730, CanGetOff, replace); + INJECT(0x00412500, BoatAnimation, replace); } diff --git a/tomb3decomp/global/progress.txt b/tomb3decomp/global/progress.txt index 3ac2d84a..b0f6e19b 100644 --- a/tomb3decomp/global/progress.txt +++ b/tomb3decomp/global/progress.txt @@ -172,7 +172,7 @@ tomb3decomp progress. 0x00412040 + BoatCheckGeton 0x004121B0 + BoatCollision 0x00412330 + BoatUserControl -0x00412500 BoatAnimation +0x00412500 + BoatAnimation 0x00412730 + CanGetOff 0x00412820 BoatControl 0x004130C0 DoWake From c1e8b47031a67c2edea01c890459aad6d830244a Mon Sep 17 00:00:00 2001 From: Troye Date: Fri, 28 Oct 2022 03:05:22 -0500 Subject: [PATCH 07/12] TestWaterHeight --- tomb3decomp/game/boat.cpp | 31 ++++++++++++++++++++++++++++++- tomb3decomp/global/progress.txt | 2 +- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/tomb3decomp/game/boat.cpp b/tomb3decomp/game/boat.cpp index 3fce6768..1fe34685 100644 --- a/tomb3decomp/game/boat.cpp +++ b/tomb3decomp/game/boat.cpp @@ -311,7 +311,7 @@ static void BoatAnimation(ITEM_INFO* item, long collide) { if (lara_item->current_anim_state != 5) { - lara_item->anim_number = objects[VEHICLE_ANIM].anim_index + collide; + lara_item->anim_number = short(objects[VEHICLE_ANIM].anim_index + collide); lara_item->frame_number = anims[lara_item->anim_number].frame_base; lara_item->current_anim_state = 5; lara_item->goal_anim_state = 5; @@ -372,6 +372,34 @@ static void BoatAnimation(ITEM_INFO* item, long collide) } } +static long TestWaterHeight(ITEM_INFO* item, long z, long x, PHD_VECTOR* pos) +{ + FLOOR_INFO* floor; + long s, c, h; + short room_number; + + s = phd_sin(item->pos.y_rot); + c = phd_cos(item->pos.y_rot); + pos->x = item->pos.x_pos + ((x * c + z * s) >> W2V_SHIFT); + pos->y = item->pos.y_pos + ((x * phd_sin(item->pos.z_rot)) >> W2V_SHIFT) - ((z * phd_sin(item->pos.x_rot)) >> W2V_SHIFT); + pos->z = item->pos.z_pos + ((z * c - x * s) >> W2V_SHIFT); + + room_number = item->room_number; + GetFloor(pos->x, pos->y, pos->z, &room_number); + h = GetWaterHeight(pos->x, pos->y, pos->z, room_number); + + if (h == NO_HEIGHT) + { + floor = GetFloor(pos->x, pos->y, pos->z, &room_number); + h = GetHeight(floor, pos->x, pos->y, pos->z); + + if (h == NO_HEIGHT) + return h; + } + + return h - 5; +} + void inject_boat(bool replace) { INJECT(0x00411FE0, InitialiseBoat, replace); @@ -381,4 +409,5 @@ void inject_boat(bool replace) INJECT(0x00412330, BoatUserControl, replace); INJECT(0x00412730, CanGetOff, replace); INJECT(0x00412500, BoatAnimation, replace); + INJECT(0x00413290, TestWaterHeight, replace); } diff --git a/tomb3decomp/global/progress.txt b/tomb3decomp/global/progress.txt index b0f6e19b..0676473b 100644 --- a/tomb3decomp/global/progress.txt +++ b/tomb3decomp/global/progress.txt @@ -176,7 +176,7 @@ tomb3decomp progress. 0x00412730 + CanGetOff 0x00412820 BoatControl 0x004130C0 DoWake -0x00413290 TestWaterHeight +0x00413290 + TestWaterHeight 0x00413390 DoBoatDynamics 0x004133E0 BoatDynamics 0x00413900 DoShift From 809a841a15c2f151dfa52899829bd7a938fa427e Mon Sep 17 00:00:00 2001 From: Troye Date: Fri, 28 Oct 2022 04:36:15 -0500 Subject: [PATCH 08/12] DoShift --- tomb3decomp/game/boat.cpp | 106 ++++++++++++++++++++++++++++++++ tomb3decomp/global/progress.txt | 2 +- 2 files changed, 107 insertions(+), 1 deletion(-) diff --git a/tomb3decomp/game/boat.cpp b/tomb3decomp/game/boat.cpp index 1fe34685..bb0dfa95 100644 --- a/tomb3decomp/game/boat.cpp +++ b/tomb3decomp/game/boat.cpp @@ -400,6 +400,111 @@ static long TestWaterHeight(ITEM_INFO* item, long z, long x, PHD_VECTOR* pos) return h - 5; } +static long DoShift(ITEM_INFO* item, PHD_VECTOR* newPos, PHD_VECTOR* oldPos) +{ + FLOOR_INFO* floor; + long x, z, nX, nZ, oX, oZ, sX, sZ, h; + short room_number; + + nX = newPos->x >> WALL_SHIFT; + nZ = newPos->z >> WALL_SHIFT; + oX = oldPos->x >> WALL_SHIFT; + oZ = oldPos->z >> WALL_SHIFT; + sX = newPos->x & (WALL_SIZE - 1); + sZ = newPos->z & (WALL_SIZE - 1); + + if (nX == oX) + { + if (nZ == oZ) + { + item->pos.z_pos += (oldPos->z - newPos->z); + item->pos.x_pos += (oldPos->x - newPos->x); + return 0; + } + else if (nZ <= oZ) + { + item->pos.z_pos += WALL_SIZE - sZ; + return item->pos.x_pos - newPos->x; + } + else + { + item->pos.z_pos -= 1 + sZ; + return newPos->x - item->pos.x_pos; + } + } + + if (nZ == oZ) + { + if (nX <= oX) + { + item->pos.x_pos += WALL_SIZE - sX; + return newPos->z - item->pos.z_pos; + } + else + { + item->pos.x_pos -= 1 + sX; + return item->pos.z_pos - newPos->z; + } + } + + x = 0; + z = 0; + room_number = item->room_number; + floor = GetFloor(oldPos->x, newPos->y, newPos->z, &room_number); + h = GetHeight(floor, oldPos->x, newPos->y, newPos->z); + + if (h < oldPos->y - 256) + { + if (newPos->z > oldPos->z) + z = -1 - sZ; + else + z = WALL_SIZE - sZ; + } + + room_number = item->room_number; + floor = GetFloor(newPos->x, newPos->y, oldPos->z, &room_number); + h = GetHeight(floor, newPos->x, newPos->y, oldPos->z); + + if (h < oldPos->y - 256) + { + if (newPos->x > oldPos->x) + x = -1 - sX; + else + x = WALL_SIZE - sX; + } + + if (x && z) + { + item->pos.x_pos += x; + item->pos.z_pos += z; + return 0; + } + + if (z) + { + item->pos.z_pos += z; + + if (z > 0) + return item->pos.x_pos - newPos->x; + else + return newPos->x - item->pos.x_pos; + } + + if (x) + { + item->pos.x_pos += x; + + if (x > 0) + return newPos->z - item->pos.z_pos; + else + return item->pos.z_pos - newPos->z; + } + + item->pos.x_pos += oldPos->x - newPos->x; + item->pos.z_pos += oldPos->z - newPos->z; + return 0; +} + void inject_boat(bool replace) { INJECT(0x00411FE0, InitialiseBoat, replace); @@ -410,4 +515,5 @@ void inject_boat(bool replace) INJECT(0x00412730, CanGetOff, replace); INJECT(0x00412500, BoatAnimation, replace); INJECT(0x00413290, TestWaterHeight, replace); + INJECT(0x00413900, DoShift, replace); } diff --git a/tomb3decomp/global/progress.txt b/tomb3decomp/global/progress.txt index 0676473b..74525cdf 100644 --- a/tomb3decomp/global/progress.txt +++ b/tomb3decomp/global/progress.txt @@ -179,7 +179,7 @@ tomb3decomp progress. 0x00413290 + TestWaterHeight 0x00413390 DoBoatDynamics 0x004133E0 BoatDynamics -0x00413900 DoShift +0x00413900 + DoShift 0x00413B80 GetCollisionAnim 0x00413C10 DoBoatShift 0x00413CF0 + DrawBoat From c7b4776007069221ab3e830002e237df0cb955da Mon Sep 17 00:00:00 2001 From: Troye Date: Fri, 28 Oct 2022 04:48:57 -0500 Subject: [PATCH 09/12] GetCollisionAnim --- tomb3decomp/game/boat.cpp | 32 ++++++++++++++++++++++++++++++++ tomb3decomp/global/progress.txt | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/tomb3decomp/game/boat.cpp b/tomb3decomp/game/boat.cpp index bb0dfa95..b2e80c3d 100644 --- a/tomb3decomp/game/boat.cpp +++ b/tomb3decomp/game/boat.cpp @@ -505,6 +505,37 @@ static long DoShift(ITEM_INFO* item, PHD_VECTOR* newPos, PHD_VECTOR* oldPos) return 0; } +static long GetCollisionAnim(ITEM_INFO* item, PHD_VECTOR* pos) +{ + long s, c, fb, lr; + + pos->x = item->pos.x_pos - pos->x; + pos->z = item->pos.z_pos - pos->z; + + if (!pos->x && !pos->z) + return 0; + + s = phd_sin(item->pos.y_rot); + c = phd_cos(item->pos.y_rot); + fb = (s * pos->x + c * pos->z) >> W2V_SHIFT; + lr = (c * pos->x - s * pos->z) >> W2V_SHIFT; + + if (abs(fb) <= abs(lr)) + { + if (lr > 0) + return 11; + else + return 12; + } + else + { + if (fb > 0) + return 14; + else + return 13; + } +} + void inject_boat(bool replace) { INJECT(0x00411FE0, InitialiseBoat, replace); @@ -516,4 +547,5 @@ void inject_boat(bool replace) INJECT(0x00412500, BoatAnimation, replace); INJECT(0x00413290, TestWaterHeight, replace); INJECT(0x00413900, DoShift, replace); + INJECT(0x00413B80, GetCollisionAnim, replace); } diff --git a/tomb3decomp/global/progress.txt b/tomb3decomp/global/progress.txt index 74525cdf..d315f8a8 100644 --- a/tomb3decomp/global/progress.txt +++ b/tomb3decomp/global/progress.txt @@ -180,7 +180,7 @@ tomb3decomp progress. 0x00413390 DoBoatDynamics 0x004133E0 BoatDynamics 0x00413900 + DoShift -0x00413B80 GetCollisionAnim +0x00413B80 + GetCollisionAnim 0x00413C10 DoBoatShift 0x00413CF0 + DrawBoat 0x00413D20 TriggerBoatMist From 8f7322c9edd1b7a59f7af4d3d035e89243e5678f Mon Sep 17 00:00:00 2001 From: Troye Date: Fri, 28 Oct 2022 05:01:20 -0500 Subject: [PATCH 10/12] DoBoatShift --- tomb3decomp/game/boat.cpp | 30 ++++++++++++++++++++++++++++++ tomb3decomp/global/progress.txt | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tomb3decomp/game/boat.cpp b/tomb3decomp/game/boat.cpp index b2e80c3d..4cf5b7f6 100644 --- a/tomb3decomp/game/boat.cpp +++ b/tomb3decomp/game/boat.cpp @@ -536,6 +536,35 @@ static long GetCollisionAnim(ITEM_INFO* item, PHD_VECTOR* pos) } } +static void DoBoatShift(long item_number) +{ + ITEM_INFO* item; + ITEM_INFO* boat; + long item_num, x, z, dist; + + item = &items[item_number]; + + for (item_num = room[item->room_number].item_number; item_num != NO_ITEM; item_num = boat->next_item) + { + boat = &items[item_num]; + + if (boat->object_number == BOAT && item_num != item_number && lara.skidoo != item_num) + { + x = boat->pos.z_pos - item->pos.z_pos; + z = boat->pos.x_pos - item->pos.x_pos; + dist = SQUARE(x) + SQUARE(z); + + if (dist < 1000000) + { + item->pos.x_pos = boat->pos.x_pos - 1000000 * z / dist; + item->pos.z_pos = boat->pos.z_pos - 1000000 * x / dist; + } + + break; + } + } +} + void inject_boat(bool replace) { INJECT(0x00411FE0, InitialiseBoat, replace); @@ -548,4 +577,5 @@ void inject_boat(bool replace) INJECT(0x00413290, TestWaterHeight, replace); INJECT(0x00413900, DoShift, replace); INJECT(0x00413B80, GetCollisionAnim, replace); + INJECT(0x00413C10, DoBoatShift, replace); } diff --git a/tomb3decomp/global/progress.txt b/tomb3decomp/global/progress.txt index d315f8a8..fe318bce 100644 --- a/tomb3decomp/global/progress.txt +++ b/tomb3decomp/global/progress.txt @@ -181,7 +181,7 @@ tomb3decomp progress. 0x004133E0 BoatDynamics 0x00413900 + DoShift 0x00413B80 + GetCollisionAnim -0x00413C10 DoBoatShift +0x00413C10 + DoBoatShift 0x00413CF0 + DrawBoat 0x00413D20 TriggerBoatMist 0x00413F00 BoatSplash From 811198e155f2e5ffaff95bb5200a349a923619e6 Mon Sep 17 00:00:00 2001 From: Troye Date: Fri, 28 Oct 2022 05:27:48 -0500 Subject: [PATCH 11/12] DoBoatDynamics --- tomb3decomp/game/boat.cpp | 26 ++++++++++++++++++++++++++ tomb3decomp/global/progress.txt | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tomb3decomp/game/boat.cpp b/tomb3decomp/game/boat.cpp index 4cf5b7f6..5a9b4cd1 100644 --- a/tomb3decomp/game/boat.cpp +++ b/tomb3decomp/game/boat.cpp @@ -565,6 +565,31 @@ static void DoBoatShift(long item_number) } } +static long DoBoatDynamics(long height, long fallspeed, long* ypos) +{ + if (height <= *ypos) + { + fallspeed += (height - fallspeed - *ypos) >> 3; + + if (*ypos > height) + *ypos = height; + } + else + { + *ypos += fallspeed; + + if (*ypos <= height) + fallspeed += 6; + else + { + *ypos = height; + fallspeed = 0; + } + } + + return fallspeed; +} + void inject_boat(bool replace) { INJECT(0x00411FE0, InitialiseBoat, replace); @@ -578,4 +603,5 @@ void inject_boat(bool replace) INJECT(0x00413900, DoShift, replace); INJECT(0x00413B80, GetCollisionAnim, replace); INJECT(0x00413C10, DoBoatShift, replace); + INJECT(0x00413390, DoBoatDynamics, replace); } diff --git a/tomb3decomp/global/progress.txt b/tomb3decomp/global/progress.txt index fe318bce..821b3aee 100644 --- a/tomb3decomp/global/progress.txt +++ b/tomb3decomp/global/progress.txt @@ -177,7 +177,7 @@ tomb3decomp progress. 0x00412820 BoatControl 0x004130C0 DoWake 0x00413290 + TestWaterHeight -0x00413390 DoBoatDynamics +0x00413390 + DoBoatDynamics 0x004133E0 BoatDynamics 0x00413900 + DoShift 0x00413B80 + GetCollisionAnim From 24e098f07140a226e06b627438958c50766ebbdc Mon Sep 17 00:00:00 2001 From: Troye Date: Fri, 28 Oct 2022 23:57:55 -0500 Subject: [PATCH 12/12] things --- CHANGELOG.md | 8 ++++---- USING.md | 26 ++++++++++++++++++++++++-- tomb3decomp.rc | 8 ++++---- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a19c987..71bcfcb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # tomb3 changelog -## Unreleased +## [1.1.0](https://github.com/Trxyebeep/tomb3decomp/tree/V1.1.0) (Oct. 29 2022) ### Original bug fixes @@ -14,7 +14,7 @@ - Add crawl tilting. - Add an option for PSX yellow poison bar. - Make poison bar flash. -- Add an option for PSX water color. +- Add an option for (approximate, for now) PSX water color. - Add colsub for sparks, like smoke. - Improve bucket drawing, fixes PC bars disappearing in open spaces. Eg. beginning of Thames Wharf. - Improve pickup display code to show transparency correctly. @@ -22,8 +22,8 @@ ### tomb3 bug fixes -- Fix laser seams and color by refactoring its drawing function. -- Fix GetFullPath (fixes FMV playback). +- Fix laser seams and color. +- Fix GetFullPath (fixes some FMV playback issues). - Fix skybox drawing (fixes Lara's Home crash when using the no crystals patch). diff --git a/USING.md b/USING.md index 05980943..88fcf363 100644 --- a/USING.md +++ b/USING.md @@ -13,8 +13,22 @@ 4. Enjoy! #### CD version: -#TDB - +1. Install TR3 through the CD setup. +2. Copy these folders/files from your CD to the folder you installed TR3 in: +- audio +- cuts +- data +- fmv +- pix +- DEC130.dll +- EDEC.dll +- WINPLAY.dll +- WINSDEC.dll +- WINSTR.dll +3. Get the latest release package. +4. unzip the archive and copy over the contents to you TR3 folder, overwrite when prompted. +5. Run the game once to get the setup window at least once before running anything in the ExtraOptions folder. +6. Enjoy! ### *Updating/Non-first time installing:* 1. Get the latest release package. @@ -45,6 +59,8 @@ 1. PC: Original PC bars. 2. PSX: PSX bars. +#### Improved poison bar: Toggles a PSX-like poison bar instead of the original flat yellow bar. + #### Pickup Display: Toggles the pickup display on/off. #### Shadow: @@ -52,6 +68,8 @@ 2. PSX: PSX circle sprite shadow. ### Lara's moveset: +#### Crawl tilt: Toggles Lara aligning herself with the floor when crawling. + #### Duck roll: Toggles the duck roll on/off. When ducked, press the Sprint button. #### Flexible crawl: Provides less lag in her crawl moveset and restores the run-to-duck and the sprint-to-duck animations. @@ -66,3 +84,7 @@ #### Disable Gamma: Toggles the gamma option. Having this option on allows for accurate RGB output, which is otherwise impossible with Gamma on. #### DOZY: Toggles the flycheat on/off. in-game, press and hold the D O Z Y keys on your keyboard to fly. Walk button to get out of the cheat. + +#### PSX Crystal sfx: Toggles the "woosh" PSX sfx when collecting crystals (instead of the PC heal sfx). + +#### PSX Water Color: Toggles PSX water color. diff --git a/tomb3decomp.rc b/tomb3decomp.rc index 35840477..4b9b3419 100644 --- a/tomb3decomp.rc +++ b/tomb3decomp.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,0 - PRODUCTVERSION 1,0,0,0 + FILEVERSION 1,1,0,0 + PRODUCTVERSION 1,1,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -68,12 +68,12 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "Tomb Raider III Community Edition" - VALUE "FileVersion", "1.0.0.0" + VALUE "FileVersion", "1.1.0.0" VALUE "InternalName", "tomb3decomp.dll" VALUE "LegalCopyright", "Copyright (C) 2022" VALUE "OriginalFilename", "tomb3decomp.dll" VALUE "ProductName", "Tomb Raider III Community Edition" - VALUE "ProductVersion", "1.0.0.0" + VALUE "ProductVersion", "1.1.0.0" END END BLOCK "VarFileInfo"