Fix errors in movement LOS tests; fix run jump queuing on steps; cleanup

This commit is contained in:
Sezz 2022-02-06 13:31:10 +11:00
parent 09bb109915
commit 435cbfff52
3 changed files with 66 additions and 29 deletions

View file

@ -215,7 +215,7 @@ void SetLaraRunJumpQueue(ITEM_INFO* item, COLL_INFO* coll)
(probe.Position.Floor - y) >= CLICK(0.5f)) && // OR there is a drop below far ahead.
probe.Position.Floor != NO_HEIGHT)
{
info->runJumpQueued = (item->targetState == LS_RUN_FORWARD);
info->runJumpQueued = IsRunJumpQueueableState((LARA_STATE)item->targetState);
}
else
info->runJumpQueued = false;
@ -348,11 +348,11 @@ void HandleLaraMovementParameters(ITEM_INFO* item, COLL_INFO* coll)
LaraInfo*& info = item->data;
// Reset running jump timer.
if (!IsRunJumpCountState((LARA_STATE)item->activeState))
if (!IsRunJumpCountableState((LARA_STATE)item->activeState))
info->runJumpCount = 0;
// Reset running jump action queue.
if (item->activeState != LS_RUN_FORWARD)
if (!IsRunJumpQueueableState((LARA_STATE)item->activeState))
info->runJumpQueued = false;
// Reset projected height value used by step function.

View file

@ -1216,7 +1216,19 @@ bool IsJumpState(LARA_STATE state)
return false;
}
bool IsRunJumpCountState(LARA_STATE state)
bool IsRunJumpQueueableState(LARA_STATE state)
{
if (state == LS_RUN_FORWARD ||
state == LS_STEP_UP ||
state == LS_STEP_DOWN)
{
return true;
}
return false;
}
bool IsRunJumpCountableState(LARA_STATE state)
{
if (state == LS_RUN_FORWARD ||
state == LS_WALK_FORWARD ||
@ -1344,20 +1356,32 @@ bool TestLaraMoveTolerance(ITEM_INFO* item, COLL_INFO* coll, MoveTestSetup testS
bool isSlopeUp = testSetup.CheckSlopeUp ? (probe.Position.FloorSlope && probe.Position.Floor < y) : false;
bool isDeath = testSetup.CheckDeath ? probe.Block->Flags.Death : false;
// Conduct "ray" test at upper floor bound.
auto start = GAME_VECTOR(
item->pos.xPos,
auto start1 = GAME_VECTOR(item->pos.xPos,
y + testSetup.UpperFloorBound - 1,
item->pos.zPos,
item->roomNumber);
auto end = GAME_VECTOR(
probe.Coordinates.x,
probe.Coordinates.y - 1,
auto end1 = GAME_VECTOR(probe.Coordinates.x,
y + testSetup.UpperFloorBound - 1,
probe.Coordinates.z,
item->roomNumber);
if (!LOS(&start, &end))
auto start2 = GAME_VECTOR(item->pos.xPos,
y - coll->Setup.Height + 1,
item->pos.zPos,
item->roomNumber);
auto end2 = GAME_VECTOR(probe.Coordinates.x,
probe.Coordinates.y + 1,
probe.Coordinates.z,
item->roomNumber);
// Conduct "ray" test at upper floor bound.
if (!LOS(&start1, &end1))
return false;
// Conduct "ray" test at lowest ceiling bound.
if (!LOS(&start2, &end2))
return false;
// Assess move feasibility to location ahead.
@ -1525,20 +1549,32 @@ bool TestLaraCrawlMoveTolerance(ITEM_INFO* item, COLL_INFO* coll, MoveTestSetup
bool isSlopeUp = testSetup.CheckSlopeUp ? (probe.Position.FloorSlope && probe.Position.Floor < y) : false;
bool isDeath = testSetup.CheckDeath ? probe.Block->Flags.Death : false;
// Conduct "ray" test at upper floor bound.
auto start = GAME_VECTOR(
item->pos.xPos,
auto start1 = GAME_VECTOR(item->pos.xPos,
y + testSetup.UpperFloorBound - 1,
item->pos.zPos,
item->roomNumber);
auto end = GAME_VECTOR(
probe.Coordinates.x,
probe.Coordinates.y - 1,
auto end1 = GAME_VECTOR(probe.Coordinates.x,
y + testSetup.UpperFloorBound - 1,
probe.Coordinates.z,
item->roomNumber);
if (!LOS(&start, &end))
auto start2 = GAME_VECTOR(item->pos.xPos,
y - LARA_HEIGHT_CRAWL + 1,
item->pos.zPos,
item->roomNumber);
auto end2 = GAME_VECTOR(probe.Coordinates.x,
probe.Coordinates.y + 1,
probe.Coordinates.z,
item->roomNumber);
// Conduct "ray" test at upper floor bound.
if (!LOS(&start1, &end1))
return false;
// Conduct "ray" test at lowest ceiling bound.
if (!LOS(&start2, &end2))
return false;
// Assess move feasibility to location ahead.

View file

@ -50,7 +50,8 @@ void GetTighRopeFallOff(int Regularity);
bool IsStandingWeapon(LARA_WEAPON_TYPE gunType);
bool IsJumpState(LARA_STATE state);
bool IsRunJumpCountState(LARA_STATE state);
bool IsRunJumpQueueableState(LARA_STATE state);
bool IsRunJumpCountableState(LARA_STATE state);
bool IsVaultState(LARA_STATE state);
bool TestLaraSplat(ITEM_INFO* item, int dist, int height, int side = 0);