From d0b542b106212d54794b2d33a2193aee41f3e37e Mon Sep 17 00:00:00 2001 From: Woops Date: Wed, 20 May 2020 22:07:27 -0500 Subject: [PATCH] water crawlspaces and crawl handling --- TR5Main/Game/lara.cpp | 16 ++++++++-- TR5Main/Game/larasurf.cpp | 66 +++++++++++++++++++++++++++++++++++++-- TR5Main/Global/enums.h | 3 ++ 3 files changed, 80 insertions(+), 5 deletions(-) diff --git a/TR5Main/Game/lara.cpp b/TR5Main/Game/lara.cpp index 09d1a3d5b..fbda91a93 100644 --- a/TR5Main/Game/lara.cpp +++ b/TR5Main/Game/lara.cpp @@ -5124,6 +5124,12 @@ void lara_as_all4s(ITEM_INFO* item, COLL_INFO* coll)//14970, 14A78 (F) Lara.gunStatus = LG_HANDS_BUSY; Camera.targetElevation = -ANGLE(23); + + if (Rooms[LaraItem->roomNumber].flags & ENV_FLAG_WATER) + { + item->goalAnimState = STATE_LARA_CROUCH_IDLE; + item->requiredAnimState = STATE_LARA_STOP; + } } void lara_col_duck(ITEM_INFO* item, COLL_INFO* coll)//147C4, 148CC (F) @@ -5201,7 +5207,9 @@ void lara_as_duck(ITEM_INFO* item, COLL_INFO* coll)//14688, 14738 (F) && (TrInput & IN_DUCK || Lara.keepDucked) && Lara.gunStatus == LG_NO_ARMS && Lara.waterStatus != LW_WADE - && !(Rooms[roomNum].flags & ENV_FLAG_WATER)) + || Lara.waterSurfaceDist == 256 + && !(Lara.waterSurfaceDist > 256) + /*&& !(Rooms[roomNum].flags & ENV_FLAG_WATER)*/) { if ((item->animNumber == ANIMATION_LARA_CROUCH_IDLE @@ -5223,7 +5231,9 @@ void lara_as_duck(ITEM_INFO* item, COLL_INFO* coll)//14688, 14738 (F) && (TrInput & IN_DUCK || Lara.keepDucked) && Lara.gunStatus == LG_NO_ARMS && Lara.waterStatus != LW_WADE - && !(Rooms[roomNum].flags & ENV_FLAG_WATER)) //is this necessary? + || Lara.waterSurfaceDist == 256 + && !(Lara.waterSurfaceDist > 256)) + //&& !(Rooms[roomNum].flags & ENV_FLAG_WATER)) //is this necessary?- update: nope, it's not { lara_as_crouch_roll(item, coll); } @@ -5235,7 +5245,7 @@ void lara_as_crouch_roll(ITEM_INFO* item, COLL_INFO* coll) /*stop Lara from doing it in these conditions to avoid trouble*/ if (LaraFloorFront(item, item->pos.yRot, 1024) >= 384 || //4 clicks away from holes in the floor - TestWall(item, 1024, 0, -128)) //4 clicks away from walls + TestWall(item, 1024, 0, -256)) //4 clicks away from walls { return; } diff --git a/TR5Main/Game/larasurf.cpp b/TR5Main/Game/larasurf.cpp index 6faa6b570..3824e3954 100644 --- a/TR5Main/Game/larasurf.cpp +++ b/TR5Main/Game/larasurf.cpp @@ -344,6 +344,7 @@ int LaraTestWaterClimbOut(ITEM_INFO* item, COLL_INFO* coll)//4D22C, 4D690 return 0; int frontFloor = coll->frontFloor + 700; + int frontCeiling = coll->frontCeiling + 700; if (frontFloor <= -512 || frontFloor > 316) return 0; @@ -401,6 +402,53 @@ int LaraTestWaterClimbOut(ITEM_INFO* item, COLL_INFO* coll)//4D22C, 4D690 item->pos.zPos = (item->pos.zPos & 0xFFFFFC00) + 1124; } + + if (frontFloor <= -256) + { + if (LaraCeilingFront(item, item->pos.yRot, 256, 512) >= -512) + { + item->animNumber = ANIMATION_LARA_CLIMB_OUT_OF_WATER_TO_2CLICK; + item->frameNumber = Anims[item->animNumber].frameBase; + item->goalAnimState = ANIMATION_LARA_CROUCH_IDLE; + } + else + { + item->animNumber = ANIMATION_LARA_CLIMB_OUT_OF_WATER; + item->frameNumber = Anims[item->animNumber].frameBase; + item->goalAnimState = STATE_LARA_STOP; + } + } + else if (128 > frontFloor >= 0) + { + if (LaraCeilingFront(item, item->pos.yRot, 256, 512) >= -512) + { + item->animNumber = ANIMATION_LARA_ONWATER_TO_LAND_LOW_TO_2CLICK; + item->frameNumber = Anims[item->animNumber].frameBase; + item->goalAnimState = ANIMATION_LARA_CROUCH_IDLE; + } + else + { + item->animNumber = ANIMATION_LARA_ONWATER_TO_LAND_LOW; + item->frameNumber = Anims[item->animNumber].frameBase; + item->goalAnimState = STATE_LARA_STOP; + } + } + + if (frontFloor > 128) + { + if (LaraCeilingFront(item, item->pos.yRot, 256, 512) >= -512) + { + item->animNumber = ANIMATION_LARA_WATER_TO_SUBMERGED_CRAWL; + item->frameNumber = Anims[item->animNumber].frameBase; + item->goalAnimState = ANIMATION_LARA_CROUCH_IDLE; + } + else + item->animNumber = ANIMATION_LARA_ONWATER_TO_WADE; + item->frameNumber = Anims[item->animNumber].frameBase; +// item->goalAnimState = STATE_LARA_STOP; + } + +/* if (frontFloor >= -128) { if (frontFloor >= 128) @@ -410,18 +458,32 @@ int LaraTestWaterClimbOut(ITEM_INFO* item, COLL_INFO* coll)//4D22C, 4D690 } else { + if (LaraFloorFront(item, item->pos.yRot, 256) == -256 && + LaraCeilingFront(item, item->pos.yRot, 256, 256) != NO_HEIGHT && + LaraCeilingFront(item, item->pos.yRot, 256, 256) <= -512) + { + item->animNumber = ANIMATION_LARA_ONWATER_TO_LAND_LOW_TO_2CLICK; + item->frameNumber = Anims[item->animNumber].frameBase; + } item->animNumber = ANIMATION_LARA_ONWATER_TO_LAND_LOW; item->frameNumber = Anims[item->animNumber].frameBase; } } else { + if (LaraFloorFront(item, item->pos.yRot, 256) == -256 && + LaraCeilingFront(item, item->pos.yRot, 256, 256) != NO_HEIGHT && + LaraCeilingFront(item, item->pos.yRot, 256, 256) <= -512) + { + item->animNumber = ANIMATION_LARA_CLIMB_OUT_OF_WATER_TO_2CLICK; + item->frameNumber = Anims[item->animNumber].frameBase; + } item->animNumber = ANIMATION_LARA_CLIMB_OUT_OF_WATER; item->frameNumber = Anims[item->animNumber].frameBase; - } + }*/ item->currentAnimState = STATE_LARA_ONWATER_EXIT; - item->goalAnimState = STATE_LARA_STOP; +// item->goalAnimState = STATE_LARA_STOP; item->pos.yRot = rot; Lara.gunStatus = LG_HANDS_BUSY; item->pos.zRot = 0; diff --git a/TR5Main/Global/enums.h b/TR5Main/Global/enums.h index 7288be186..ed3887877 100644 --- a/TR5Main/Global/enums.h +++ b/TR5Main/Global/enums.h @@ -858,6 +858,9 @@ enum LARA_ANIM ANIMATION_LARA_1CLICK_CRAWL_EXIT = 477, // 1 click crawlspace exit ANIMATION_LARA_2CLICK_CRAWL_EXIT = 478, // 2 click crawlspace exit ANIMATION_LARA_1CLICK_CRAWL_TO_CRAWL = 479, // maneuver up 1 click in crawlspace + ANIMATION_LARA_CLIMB_OUT_OF_WATER_TO_2CLICK = 480, // climb out of water to 2click crawlspace + ANIMATION_LARA_ONWATER_TO_LAND_LOW_TO_2CLICK = 481, // climb out of onwater to 2click crawlspace + ANIMATION_LARA_WATER_TO_SUBMERGED_CRAWL = 482, // wade out of water to submerged crawlspace NUM_LARA_ANIMS };