2021-09-27 18:18:03 +10:00
|
|
|
#include "framework.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Game/Lara/lara_helpers.h"
|
|
|
|
|
2021-12-22 16:23:57 +03:00
|
|
|
#include "Game/collision/collide_room.h"
|
|
|
|
#include "Game/control/control.h"
|
|
|
|
#include "Game/items.h"
|
|
|
|
#include "Game/Lara/lara.h"
|
|
|
|
#include "Game/Lara/lara_tests.h"
|
|
|
|
#include "Game/Lara/lara_collide.h"
|
|
|
|
#include "Scripting/GameFlowScript.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Specific/input.h"
|
|
|
|
#include "Specific/level.h"
|
|
|
|
#include "Specific/setup.h"
|
2021-10-09 14:39:06 +11:00
|
|
|
|
2021-10-18 20:15:53 +11:00
|
|
|
// -----------------------------
|
|
|
|
// HELPER FUNCTIONS
|
|
|
|
// For State Control & Collision
|
|
|
|
// -----------------------------
|
|
|
|
|
2021-12-23 18:41:37 +11:00
|
|
|
// TODO: Make lean rate proportional to the turn rate, allowing for nicer aesthetics with future analog stick input.
|
2022-01-15 22:48:35 +11:00
|
|
|
void DoLaraLean(ITEM_INFO* item, COLL_INFO* coll, short maxAngle, short rate)
|
2021-12-23 18:41:37 +11:00
|
|
|
{
|
|
|
|
if (!item->speed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int sign = copysign(1, maxAngle);
|
|
|
|
|
|
|
|
if (coll->CollisionType == CT_LEFT || coll->CollisionType == CT_RIGHT)
|
|
|
|
item->pos.zRot += std::min(rate, (short)(abs((maxAngle * 3) / 5 - item->pos.zRot) / 3)) * sign;
|
|
|
|
else
|
|
|
|
item->pos.zRot += std::min(rate, (short)(abs(maxAngle - item->pos.zRot) / 3)) * sign;
|
|
|
|
}
|
|
|
|
|
2021-10-09 14:39:06 +11:00
|
|
|
// TODO: Some states can't make the most of this function due to missing step up/down animations.
|
|
|
|
// Try implementing leg IK as a substitute to make step animations obsolete. @Sezz 2021.10.09
|
|
|
|
void DoLaraStep(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
2021-12-04 14:01:41 +11:00
|
|
|
if (!TestLaraSwamp(item))
|
2021-10-09 14:39:06 +11:00
|
|
|
{
|
2021-12-04 14:01:41 +11:00
|
|
|
if (TestLaraStepUp(item, coll))
|
2021-10-10 14:03:38 +11:00
|
|
|
{
|
2021-12-04 14:01:41 +11:00
|
|
|
item->goalAnimState = LS_STEP_UP;
|
|
|
|
if (GetChange(item, &g_Level.Anims[item->animNumber]))
|
|
|
|
{
|
|
|
|
item->pos.yPos += coll->Middle.Floor;
|
|
|
|
return;
|
|
|
|
}
|
2021-10-10 14:03:38 +11:00
|
|
|
}
|
2021-12-04 14:01:41 +11:00
|
|
|
else if (TestLaraStepDown(item, coll))
|
2021-10-10 14:03:38 +11:00
|
|
|
{
|
2021-12-04 14:01:41 +11:00
|
|
|
item->goalAnimState = LS_STEP_DOWN;
|
|
|
|
if (GetChange(item, &g_Level.Anims[item->animNumber]))
|
|
|
|
{
|
|
|
|
item->pos.yPos += coll->Middle.Floor;
|
|
|
|
return;
|
|
|
|
}
|
2021-10-10 14:03:38 +11:00
|
|
|
}
|
2021-10-09 14:39:06 +11:00
|
|
|
}
|
|
|
|
|
2021-11-25 21:08:51 +11:00
|
|
|
// Height difference is below threshold for step dispatch OR step animation doesn't exist; translate Lara to new floor height.
|
|
|
|
// TODO: This approach might cause underirable artefacts where an object pushes Lara rapidly up/down a slope or a platform rapidly ascends/descends.
|
2021-12-10 12:30:23 +11:00
|
|
|
constexpr int rate = 50;
|
2021-12-04 14:01:41 +11:00
|
|
|
int threshold = std::max(abs(item->speed) / 3 * 2, STEP_SIZE / 16);
|
2021-11-28 16:17:03 +11:00
|
|
|
int sign = std::copysign(1, coll->Middle.Floor);
|
2021-12-10 22:31:34 +11:00
|
|
|
|
|
|
|
if (TestLaraSwamp(item) && coll->Middle.Floor > 0)
|
|
|
|
item->pos.yPos += SWAMP_GRAVITY;
|
|
|
|
else if (abs(coll->Middle.Floor) > (STEPUP_HEIGHT / 2)) // Outer range.
|
|
|
|
item->pos.yPos += rate * sign;
|
|
|
|
else if (abs(coll->Middle.Floor) <= (STEPUP_HEIGHT / 2) && // Inner range.
|
|
|
|
abs(coll->Middle.Floor) >= threshold)
|
2021-10-09 14:39:06 +11:00
|
|
|
{
|
2021-12-10 22:31:34 +11:00
|
|
|
item->pos.yPos += std::max((int)abs(coll->Middle.Floor / 2.75), threshold) * sign;
|
2021-10-09 16:56:07 +11:00
|
|
|
}
|
2021-12-10 22:31:34 +11:00
|
|
|
else
|
|
|
|
item->pos.yPos += coll->Middle.Floor;
|
2021-10-09 14:39:06 +11:00
|
|
|
}
|
|
|
|
|
2022-01-16 13:56:39 +11:00
|
|
|
void DoLaraMonkeyStep(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
|
|
|
int y = item->pos.yPos - LARA_HEIGHT_MONKEY;
|
|
|
|
auto probe = GetCollisionResult(item);
|
|
|
|
|
|
|
|
constexpr int rate = 50;
|
|
|
|
int threshold = std::max(abs(item->speed) / 3 * 2, (int)CLICK(1.25f) / 16);
|
|
|
|
int sign = std::copysign(1, probe.Position.Ceiling - y);
|
|
|
|
|
|
|
|
if (abs(probe.Position.Ceiling - y) > (CLICK(1.25f) / 2)) // Outer range.
|
|
|
|
item->pos.yPos += rate * sign;
|
|
|
|
else if (abs(probe.Position.Ceiling - y) <= (CLICK(1.25f) / 2) && // Inner range.
|
|
|
|
abs(probe.Position.Ceiling - y) >= threshold)
|
|
|
|
{
|
|
|
|
item->pos.yPos += std::max((int)abs((probe.Position.Ceiling - y) / 2.75), threshold) * sign;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
item->pos.yPos = probe.Position.Ceiling + LARA_HEIGHT_MONKEY;
|
|
|
|
}
|
|
|
|
|
2021-10-16 20:50:16 +11:00
|
|
|
void DoLaraCrawlVault(ITEM_INFO* item, COLL_INFO* coll)
|
2021-09-29 18:35:21 +10:00
|
|
|
{
|
2021-12-02 23:45:19 +11:00
|
|
|
LaraInfo*& info = item->data;
|
|
|
|
|
2021-12-10 12:30:23 +11:00
|
|
|
ResetLaraFlex(item);
|
2021-12-02 23:45:19 +11:00
|
|
|
|
2021-11-12 23:34:55 +11:00
|
|
|
if (TestLaraCrawlExitDownStep(item, coll))
|
2021-09-29 18:35:21 +10:00
|
|
|
{
|
2021-12-01 19:38:28 +11:00
|
|
|
if (TrInput & IN_DUCK && TestLaraCrawlDownStep(item, coll))
|
2021-11-12 23:34:55 +11:00
|
|
|
item->goalAnimState = LS_STEP_DOWN;
|
2021-10-18 00:33:46 +11:00
|
|
|
else [[likely]]
|
2021-11-12 23:34:55 +11:00
|
|
|
item->goalAnimState = LS_CRAWL_EXIT_DOWN_STEP;
|
2021-10-16 20:50:16 +11:00
|
|
|
|
|
|
|
return;
|
2021-09-29 18:35:21 +10:00
|
|
|
}
|
|
|
|
|
2021-11-12 23:34:55 +11:00
|
|
|
if (TestLaraCrawlExitJump(item, coll))
|
2021-10-16 20:50:16 +11:00
|
|
|
{
|
2021-11-12 23:34:55 +11:00
|
|
|
if (TrInput & IN_WALK)
|
|
|
|
item->goalAnimState = LS_CRAWL_EXIT_FLIP;
|
2021-10-18 00:33:46 +11:00
|
|
|
else [[likely]]
|
2021-11-12 23:34:55 +11:00
|
|
|
item->goalAnimState = LS_CRAWL_EXIT_JUMP;
|
2021-10-16 20:50:16 +11:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TestLaraCrawlUpStep(item, coll))
|
|
|
|
{
|
|
|
|
item->goalAnimState = LS_STEP_UP;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TestLaraCrawlDownStep(item, coll))
|
|
|
|
{
|
|
|
|
item->goalAnimState = LS_STEP_DOWN;
|
|
|
|
return;
|
|
|
|
}
|
2021-09-29 18:35:21 +10:00
|
|
|
}
|
|
|
|
|
2022-01-03 17:57:57 +11:00
|
|
|
// TODO: Doesn't always work on bridges.
|
2021-10-18 15:22:38 +11:00
|
|
|
void DoLaraCrawlToHangSnap(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
2021-12-04 12:54:01 +11:00
|
|
|
coll->Setup.ForwardAngle = item->pos.yRot + ANGLE(180.0f);
|
2021-11-03 21:44:48 +11:00
|
|
|
GetCollisionInfo(coll, item);
|
|
|
|
SnapItemToLedge(item, coll);
|
2021-12-04 12:54:01 +11:00
|
|
|
MoveItem(item, item->pos.yRot, -LARA_RAD_CRAWL);
|
2021-11-19 22:48:47 +11:00
|
|
|
item->pos.yRot += ANGLE(180.0f);
|
2021-11-03 21:44:48 +11:00
|
|
|
LaraResetGravityStatus(item, coll);
|
2021-10-18 15:22:38 +11:00
|
|
|
}
|
|
|
|
|
2022-01-12 17:31:03 +11:00
|
|
|
void DoLaraMonkeySnap(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
2022-01-15 22:48:35 +11:00
|
|
|
int y = item->pos.yPos - LARA_HEIGHT_MONKEY;
|
2022-01-12 17:31:03 +11:00
|
|
|
auto probe = GetCollisionResult(item);
|
|
|
|
|
2022-01-16 01:28:49 +11:00
|
|
|
// TODO: Static detection.
|
|
|
|
//TestForObjectOnLedge(item, coll);
|
|
|
|
|
|
|
|
if (probe.BottomBlock->Flags.Monkeyswing && // Monkey swing sector set.
|
2022-01-15 22:48:35 +11:00
|
|
|
(probe.Position.Ceiling - y) <= CLICK(1) && // Lower bound.
|
|
|
|
(probe.Position.Ceiling - y) >= -CLICK(1) && // Upper bound.
|
2022-01-12 17:31:03 +11:00
|
|
|
probe.Position.Ceiling != NO_HEIGHT)
|
|
|
|
{
|
|
|
|
item->pos.yPos = probe.Position.Ceiling + LARA_HEIGHT_MONKEY;
|
|
|
|
}
|
2022-01-15 22:48:35 +11:00
|
|
|
else
|
|
|
|
SetLaraMonkeyFallState(item);
|
2022-01-12 17:31:03 +11:00
|
|
|
}
|
|
|
|
|
2021-11-27 20:35:16 +11:00
|
|
|
void DoLaraCrawlFlex(ITEM_INFO* item, COLL_INFO* coll, short maxAngle, short rate)
|
|
|
|
{
|
|
|
|
LaraInfo*& info = item->data;
|
|
|
|
|
2021-12-14 14:35:42 +11:00
|
|
|
if (!item->speed)
|
|
|
|
return;
|
|
|
|
|
2021-11-27 20:35:16 +11:00
|
|
|
int sign = copysign(1, maxAngle);
|
|
|
|
rate = copysign(rate, maxAngle);
|
|
|
|
|
|
|
|
info->torsoZrot += std::min(abs(rate), abs(maxAngle - info->torsoZrot) / 6) * sign;
|
|
|
|
|
|
|
|
if (!(TrInput & IN_LOOK) &&
|
|
|
|
item->currentAnimState != LS_CRAWL_BACK)
|
|
|
|
{
|
|
|
|
info->headZrot = info->torsoZrot / 2;
|
|
|
|
info->headYrot = info->headZrot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-27 21:29:21 +11:00
|
|
|
void DoLaraLand(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
2021-12-28 15:48:59 +11:00
|
|
|
item->speed = 0;
|
|
|
|
item->fallspeed = 0;
|
|
|
|
item->gravityStatus = false;
|
2022-01-04 01:39:02 +11:00
|
|
|
|
|
|
|
LaraSnapToHeight(item, coll);
|
|
|
|
AnimateLara(item);
|
2021-12-27 21:29:21 +11:00
|
|
|
}
|
|
|
|
|
2021-12-20 00:11:04 +11:00
|
|
|
void SetLaraJumpDirection(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
|
|
|
LaraInfo*& info = item->data;
|
|
|
|
|
|
|
|
if (TrInput & IN_FORWARD &&
|
2022-01-02 15:54:43 +11:00
|
|
|
TestLaraJumpForward(item, coll))
|
2021-12-20 00:11:04 +11:00
|
|
|
{
|
|
|
|
info->jumpDirection = LaraJumpDirection::Forward;
|
|
|
|
}
|
|
|
|
else if (TrInput & IN_BACK &&
|
2022-01-02 15:54:43 +11:00
|
|
|
TestLaraJumpBack(item, coll))
|
2021-12-20 00:11:04 +11:00
|
|
|
{
|
|
|
|
info->jumpDirection = LaraJumpDirection::Back;
|
|
|
|
}
|
|
|
|
else if (TrInput & IN_LEFT &&
|
2022-01-02 15:54:43 +11:00
|
|
|
TestLaraJumpLeft(item, coll))
|
2021-12-20 00:11:04 +11:00
|
|
|
{
|
|
|
|
info->jumpDirection = LaraJumpDirection::Left;
|
|
|
|
}
|
|
|
|
else if (TrInput & IN_RIGHT &&
|
2022-01-02 15:54:43 +11:00
|
|
|
TestLaraJumpRight(item, coll))
|
2021-12-20 00:11:04 +11:00
|
|
|
{
|
|
|
|
info->jumpDirection = LaraJumpDirection::Right;
|
|
|
|
}
|
2022-01-02 15:54:43 +11:00
|
|
|
else if (TestLaraJumpUp(item, coll)) [[likely]]
|
2021-12-20 00:11:04 +11:00
|
|
|
info->jumpDirection = LaraJumpDirection::Up;
|
|
|
|
else
|
|
|
|
info->jumpDirection = LaraJumpDirection::None;
|
|
|
|
}
|
|
|
|
|
2021-12-19 19:12:35 +11:00
|
|
|
void SetLaraJumpQueue(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
|
|
|
LaraInfo*& info = item->data;
|
|
|
|
|
|
|
|
int y = item->pos.yPos;
|
2022-01-03 17:01:07 +11:00
|
|
|
int dist = WALL_SIZE;// WALL_SIZE / LARA_RUN_JUMP_TIME * std::max(1, LARA_RUN_JUMP_TIME/* - info->runJumpCount*/); // TODO: Adaptive distance.
|
|
|
|
auto probe = GetCollisionResult(item, item->pos.yRot, dist, -coll->Setup.Height);
|
2021-12-19 19:12:35 +11:00
|
|
|
|
2022-01-12 19:04:29 +11:00
|
|
|
if ((TestLaraRunJumpForward(item, coll) || // Area ahead is permissive.
|
|
|
|
(probe.Position.Ceiling - y) < -(coll->Setup.Height + (LARA_HEADROOM * 0.7f)) || // Ceiling height is permissive...
|
|
|
|
(probe.Position.Floor - y) >= CLICK(0.5f)) && // OR there is a drop below
|
2022-01-04 16:25:12 +11:00
|
|
|
probe.Position.Floor != NO_HEIGHT)
|
2022-01-12 19:04:29 +11:00
|
|
|
{
|
|
|
|
info->runJumpQueued = (item->goalAnimState == LS_RUN_FORWARD);
|
|
|
|
}
|
2021-12-19 19:12:35 +11:00
|
|
|
else
|
2022-01-03 17:01:07 +11:00
|
|
|
info->runJumpQueued = false;
|
2021-12-19 19:12:35 +11:00
|
|
|
}
|
|
|
|
|
2021-12-10 12:30:23 +11:00
|
|
|
void SetLaraFallState(ITEM_INFO* item)
|
|
|
|
{
|
|
|
|
SetAnimation(item, LA_FALL_START);
|
|
|
|
item->fallspeed = 0;
|
|
|
|
item->gravityStatus = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetLaraFallBackState(ITEM_INFO* item)
|
|
|
|
{
|
|
|
|
SetAnimation(item, LA_FALL_BACK);
|
|
|
|
item->fallspeed = 0;
|
|
|
|
item->gravityStatus = true;
|
|
|
|
}
|
|
|
|
|
2022-01-12 17:31:03 +11:00
|
|
|
void SetLaraMonkeyFallState(ITEM_INFO* item)
|
|
|
|
{
|
2022-01-12 18:21:52 +11:00
|
|
|
LaraInfo*& info = item->data;
|
|
|
|
|
2022-01-12 17:31:03 +11:00
|
|
|
if (item->currentAnimState != LS_MONKEY_TURN_180)
|
|
|
|
{
|
|
|
|
SetAnimation(item, LS_JUMP_UP, 9);
|
2022-01-12 18:21:52 +11:00
|
|
|
info->gunStatus = LG_HANDS_FREE;
|
2022-01-12 17:31:03 +11:00
|
|
|
item->speed = 2;
|
|
|
|
item->fallspeed = 1;
|
|
|
|
item->gravityStatus = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-27 17:52:29 +11:00
|
|
|
short GetLaraSlideDirection(COLL_INFO* coll)
|
|
|
|
{
|
|
|
|
short dir = 0;
|
|
|
|
|
|
|
|
//if (g_GameFlow->Animations.SlideExtended)
|
|
|
|
//{
|
|
|
|
// // TODO: Get true slope direction.
|
|
|
|
//}
|
|
|
|
//else
|
|
|
|
{
|
|
|
|
if (coll->TiltX > 2)
|
|
|
|
dir = -ANGLE(90.0f);
|
|
|
|
else if (coll->TiltX < -2)
|
|
|
|
dir = ANGLE(90.0f);
|
|
|
|
|
|
|
|
if (coll->TiltZ > 2 && coll->TiltZ > abs(coll->TiltX))
|
|
|
|
dir = ANGLE(180.0f);
|
|
|
|
else if (coll->TiltZ < -2 && -coll->TiltZ > abs(coll->TiltX))
|
|
|
|
dir = ANGLE(0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
return dir;
|
|
|
|
}
|
|
|
|
|
2021-12-18 20:42:15 +11:00
|
|
|
void SetLaraSlideState(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
|
|
|
LaraInfo*& info = item->data;
|
|
|
|
|
|
|
|
auto dir = GetLaraSlideDirection(coll);
|
|
|
|
short delta = dir - item->pos.yRot;
|
|
|
|
static short oldAngle = 1;
|
|
|
|
|
|
|
|
ShiftItem(item, coll);
|
|
|
|
|
|
|
|
if (delta < -ANGLE(90.0f) || delta > ANGLE(90.0f))
|
|
|
|
{
|
|
|
|
if (item->currentAnimState == LS_SLIDE_BACK && oldAngle == dir)
|
|
|
|
return;
|
|
|
|
|
|
|
|
SetAnimation(item, LA_SLIDE_BACK_START);
|
|
|
|
item->pos.yRot = dir + ANGLE(180.0f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (item->currentAnimState == LS_SLIDE_FORWARD && oldAngle == dir)
|
|
|
|
return;
|
|
|
|
|
|
|
|
SetAnimation(item, LA_SLIDE_FORWARD);
|
|
|
|
item->pos.yRot = dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
info->moveAngle = dir;
|
|
|
|
oldAngle = dir;
|
|
|
|
}
|
|
|
|
|
2021-12-10 12:30:23 +11:00
|
|
|
void ResetLaraFlex(ITEM_INFO* item, float rate)
|
2021-11-27 23:15:26 +11:00
|
|
|
{
|
|
|
|
LaraInfo*& info = item->data;
|
|
|
|
|
|
|
|
// Reset head.
|
|
|
|
if (abs(info->headXrot) > ANGLE(0.1f))
|
|
|
|
info->headXrot += info->headXrot / -rate;
|
|
|
|
else
|
|
|
|
info->headXrot = 0;
|
|
|
|
|
|
|
|
if (abs(info->headYrot) > ANGLE(0.1f))
|
|
|
|
info->headYrot += info->headYrot / -rate;
|
|
|
|
else
|
|
|
|
info->headYrot = 0;
|
|
|
|
|
|
|
|
if (abs(info->headZrot) > ANGLE(0.1f))
|
|
|
|
info->headZrot += info->headZrot / -rate;
|
|
|
|
else
|
|
|
|
info->headZrot = 0;
|
|
|
|
|
|
|
|
// Reset torso.
|
|
|
|
if (abs(info->torsoXrot) > ANGLE(0.1f))
|
|
|
|
info->torsoXrot += info->torsoXrot / -rate;
|
|
|
|
else
|
|
|
|
info->torsoXrot = 0;
|
|
|
|
|
|
|
|
if (abs(info->torsoYrot) > ANGLE(0.1f))
|
|
|
|
info->torsoYrot += info->torsoYrot / -rate;
|
|
|
|
else
|
|
|
|
info->torsoYrot = 0;
|
|
|
|
|
|
|
|
if (abs(info->torsoZrot) > ANGLE(0.1f))
|
|
|
|
info->torsoZrot += info->torsoZrot / -rate;
|
|
|
|
else
|
|
|
|
info->torsoZrot = 0;
|
|
|
|
}
|
|
|
|
|
2021-12-10 12:30:23 +11:00
|
|
|
void HandleLaraMovementParameters(ITEM_INFO* item, COLL_INFO* coll)
|
2021-09-27 18:18:03 +10:00
|
|
|
{
|
2021-12-10 12:30:23 +11:00
|
|
|
LaraInfo*& info = item->data;
|
2021-09-27 18:18:03 +10:00
|
|
|
|
2021-12-10 12:30:23 +11:00
|
|
|
// Reset running jump timer.
|
|
|
|
if (item->currentAnimState != LS_RUN_FORWARD &&
|
|
|
|
item->currentAnimState != LS_WALK_FORWARD &&
|
|
|
|
item->currentAnimState != LS_JUMP_FORWARD &&
|
2021-12-12 21:11:27 +11:00
|
|
|
item->currentAnimState != LS_SPRINT &&
|
2021-12-10 12:30:23 +11:00
|
|
|
item->currentAnimState != LS_SPRINT_DIVE)
|
|
|
|
{
|
2022-01-03 17:01:07 +11:00
|
|
|
info->runJumpCount = 0;
|
2021-12-10 12:30:23 +11:00
|
|
|
}
|
|
|
|
|
2022-01-03 17:01:07 +11:00
|
|
|
// Reset running jump action queue.
|
2021-12-12 13:27:26 +11:00
|
|
|
if (item->currentAnimState != LS_RUN_FORWARD)
|
2022-01-03 17:01:07 +11:00
|
|
|
info->runJumpQueued = false;
|
2021-12-12 13:27:26 +11:00
|
|
|
|
2021-12-10 12:30:23 +11:00
|
|
|
// Increment/reset AFK pose timer.
|
|
|
|
if (info->poseCount < LARA_POSE_TIME &&
|
|
|
|
TestLaraPose(item, coll) &&
|
|
|
|
!(TrInput & (IN_WAKE | IN_LOOK)) &&
|
|
|
|
g_GameFlow->Animations.Pose)
|
|
|
|
{
|
|
|
|
info->poseCount++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
info->poseCount = 0;
|
|
|
|
|
|
|
|
// Reset lean.
|
|
|
|
if (!info->isMoving || (info->isMoving && !(TrInput & (IN_LEFT | IN_RIGHT))))
|
|
|
|
{
|
|
|
|
if (abs(item->pos.zRot) > ANGLE(0.1f))
|
|
|
|
item->pos.zRot += item->pos.zRot / -6;
|
|
|
|
else
|
|
|
|
item->pos.zRot = 0;
|
|
|
|
}
|
|
|
|
|
2021-12-22 16:00:13 +11:00
|
|
|
// Temp.
|
|
|
|
if (abs(item->pos.xRot) > ANGLE(0.1f))
|
|
|
|
item->pos.xRot += item->pos.xRot / -6;
|
|
|
|
else
|
|
|
|
item->pos.xRot = 0;
|
|
|
|
|
2021-12-10 12:30:23 +11:00
|
|
|
// Reset crawl flex.
|
|
|
|
if (!(TrInput & IN_LOOK) &&
|
2021-12-10 22:31:34 +11:00
|
|
|
coll->Setup.Height > LARA_HEIGHT - LARA_HEADROOM &&
|
2021-12-10 12:30:23 +11:00
|
|
|
(!item->speed || (item->speed && !(TrInput & (IN_LEFT | IN_RIGHT)))))
|
|
|
|
{
|
|
|
|
ResetLaraFlex(item, 12);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset turn rate.
|
|
|
|
int sign = copysign(1, info->turnRate);
|
|
|
|
if (abs(info->turnRate) > ANGLE(2.0f))
|
|
|
|
info->turnRate -= ANGLE(2.0f) * sign;
|
|
|
|
else if (abs(info->turnRate) > ANGLE(0.5f))
|
|
|
|
info->turnRate -= ANGLE(0.5f) * sign;
|
|
|
|
else
|
|
|
|
info->turnRate = 0;
|
|
|
|
item->pos.yRot += info->turnRate;
|
2021-10-14 19:58:29 +11:00
|
|
|
}
|