This commit is contained in:
Sezz 2022-02-03 12:21:28 +11:00
parent beb134505a
commit ec2c4e63df
10 changed files with 59 additions and 61 deletions

View file

@ -487,7 +487,7 @@ void LaraControl(ITEM_INFO* item, COLL_INFO* coll)
UpdateItemRoom(item, 0);
StopSoundEffect(SFX_TR4_LARA_FALL);
if (item->activeState == LS_SWAN_DIVE_START)
if (item->activeState == LS_SWAN_DIVE)
{
info->gunStatus = LG_HANDS_FREE;
item->pos.xRot = -ANGLE(45.0f);
@ -495,7 +495,7 @@ void LaraControl(ITEM_INFO* item, COLL_INFO* coll)
AnimateLara(item);
item->fallspeed *= 2;
}
else if (item->activeState == LS_SWAN_DIVE_END)
else if (item->activeState == LS_FREEFALL_DIVE)
{
info->gunStatus = LG_HANDS_FREE;
item->pos.xRot = -ANGLE(85.0f);
@ -532,8 +532,8 @@ void LaraControl(ITEM_INFO* item, COLL_INFO* coll)
item->targetState = LS_IDLE;
else if (isSwamp)
{
if (item->activeState == LS_SWAN_DIVE_START ||
item->activeState == LS_SWAN_DIVE_END)
if (item->activeState == LS_SWAN_DIVE ||
item->activeState == LS_FREEFALL_DIVE)
{
item->pos.yPos = waterHeight + (WALL_SIZE - 24);
}

View file

@ -54,9 +54,8 @@ constexpr auto LARA_VELOCITY = 12;
constexpr auto LARA_FREEFALL_SPEED = 131;
constexpr auto LARA_FREEFALL_SCREAM_SPEED = 154;
constexpr auto LARA_FREEFALL_DIVE_DEATH_SPEED = 154;
constexpr auto LARA_TERMINAL_VELOCITY = 0; // TODO
constexpr auto LARA_RUN_JUMP_TIME = 22; // Frames to count before running jump is possible.
constexpr auto LARA_RUN_JUMP_TIME = 22; // Frames to count before a running jump is possible.
constexpr auto LARA_POSE_TIME = 30 * 30; // 30 frames * 30 = 30 seconds to AFK pose.
constexpr auto LARA_HEALTH_MAX = 1000.0f;

View file

@ -634,8 +634,6 @@ void lara_col_idle(ITEM_INFO* item, COLL_INFO* coll)
ShiftItem(item, coll);
// TODO: Vaulting from this state.
if (TestLaraStep(item, coll))
{
DoLaraStep(item, coll);

View file

@ -58,7 +58,7 @@ void DoLaraStep(ITEM_INFO* item, COLL_INFO* coll)
}
// 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.
// TODO: This approach may cause undesirable artefacts where an object pushes Lara rapidly up/down a slope or a platform rapidly ascends/descends.
constexpr int rate = 50;
int threshold = std::max(abs(item->speed) / 3 * 2, STEP_SIZE / 16);
int sign = std::copysign(1, coll->Middle.Floor);

View file

@ -21,11 +21,11 @@
// Control & Collision Functions
// -----------------------------
// TODO: Unused? Naming is also completely mismatched; enum calls it LS_GRAB_TO_FALL.
// TODO: Unused? Naming is also completely mismatched.
// State: LS_GRAB_TO_FALL
// Collision: lara_void_func()
void lara_col_land(ITEM_INFO* item, COLL_INFO* coll)
{
/*state 14*/
/*state code: lara_void_func*/
lara_col_idle(item, coll);
}
@ -98,7 +98,7 @@ void lara_as_jump_forward(ITEM_INFO* item, COLL_INFO* coll)
if (TrInput & IN_WALK &&
info->gunStatus == LG_HANDS_FREE)
{
item->targetState = LS_SWAN_DIVE_START;
item->targetState = LS_SWAN_DIVE;
return;
}
@ -296,20 +296,21 @@ void lara_as_jump_prepare(ITEM_INFO* item, COLL_INFO* coll)
return;
}
if (TrInput & IN_LEFT &&
TrInput & (IN_FORWARD | IN_BACK))
if (TrInput & (IN_FORWARD | IN_BACK))
{
if (TrInput & IN_LEFT)
{
info->turnRate -= LARA_TURN_RATE;
if (info->turnRate < -LARA_SLOW_TURN_MAX)
info->turnRate = -LARA_SLOW_TURN_MAX;
}
else if (TrInput & IN_RIGHT &&
TrInput & (IN_FORWARD | IN_BACK))
else if (TrInput & IN_RIGHT)
{
info->turnRate += LARA_TURN_RATE;
if (info->turnRate > LARA_SLOW_TURN_MAX)
info->turnRate = LARA_SLOW_TURN_MAX;
}
}
// JUMP key repressed without directional key; cancel directional jump lock.
if (DbInput & IN_JUMP && !(TrInput & IN_DIRECTION))
@ -754,10 +755,10 @@ void lara_as_fall_back(ITEM_INFO* item, COLL_INFO* coll)
// Collision: lara_col_fall_back()
void lara_col_fall_back(ITEM_INFO* item, COLL_INFO* coll)
{
LaraJumpCollision(item, coll, item->pos.yRot + ANGLE(180.0f));
lara_col_jump_back(item, coll);
}
// State: LS_SWAN_DIVE_START (52)
// State: LS_SWAN_DIVE (52)
// Collision: lara_col_swan_dive()
void lara_as_swan_dive(ITEM_INFO* item, COLL_INFO* coll)
{
@ -785,17 +786,16 @@ void lara_as_swan_dive(ITEM_INFO* item, COLL_INFO* coll)
DoLaraLean(item, coll, LARA_LEAN_MAX, LARA_LEAN_RATE / 2);
}
if (item->fallspeed >= LARA_FREEFALL_SPEED &&
item->targetState != LS_FREEFALL_DIVE) // Hack?
if (item->fallspeed >= LARA_FREEFALL_SPEED)
{
item->targetState = LS_SWAN_DIVE_END;
item->targetState = LS_FREEFALL_DIVE;
return;
}
item->targetState = LS_SWAN_DIVE_START;
item->targetState = LS_SWAN_DIVE;
}
// State: LS_SWAN_DIVE_START (52)
// State: LS_SWAN_DIVE (52)
// Control: lara_as_swan_dive()
void lara_col_swan_dive(ITEM_INFO* item, COLL_INFO* coll)
{
@ -850,9 +850,9 @@ void lara_as_freefall_dive(ITEM_INFO* item, COLL_INFO* coll)
if (TestLaraLand(item, coll))
{
// TODO: Apply fall damage?
DoLaraFallDamage(item); // Should never occur before fall speed reaches death speed, but here for extendability.
if (item->fallspeed >= LARA_FREEFALL_DIVE_DEATH_SPEED)
if (item->hitPoints <= 0 || item->fallspeed >= LARA_FREEFALL_DIVE_DEATH_SPEED)
item->targetState = LS_DEATH;
else
item->targetState = LS_IDLE;
@ -874,5 +874,5 @@ void lara_as_freefall_dive(ITEM_INFO* item, COLL_INFO* coll)
// Control: lara_as_freefall_dive()
void lara_col_freefall_dive(ITEM_INFO* item, COLL_INFO* coll)
{
LaraJumpCollision(item, coll, item->pos.yRot);
lara_col_jump_forward(item, coll);
}

View file

@ -27,7 +27,7 @@ void lara_as_slide_forward(ITEM_INFO* item, COLL_INFO* coll)
if (item->hitPoints <= 0)
{
item->targetState = LS_DEATH; //
item->targetState = LS_DEATH; // TODO
return;
}
@ -124,7 +124,7 @@ void lara_as_slide_back(ITEM_INFO* item, COLL_INFO* coll)
if (item->hitPoints <= 0)
{
item->targetState = LS_DEATH; //
item->targetState = LS_DEATH; // TODO
return;
}

View file

@ -59,7 +59,7 @@ enum LARA_STATE
LS_SLIDE_BACK = 32,
LS_ONWATER_STOP = 33,
LS_ONWATER_FORWARD = 34,
LS_FREEFALL_DIVE = 35,
LS_ONWATER_DIVE = 35,
LS_PUSHABLE_PUSH = 36,
LS_PUSHABLE_PULL = 37,
LS_PUSHABLE_GRAB = 38,
@ -76,8 +76,8 @@ enum LARA_STATE
LS_ONWATER_RIGHT = 49,
LS_USE_MIDAS = 50,
LS_MIDAS_DEATH = 51,
LS_SWAN_DIVE_START = 52,
LS_SWAN_DIVE_END = 53,
LS_SWAN_DIVE = 52,
LS_FREEFALL_DIVE = 53,
LS_HANDSTAND = 54,
LS_ONWATER_EXIT = 55,

View file

@ -1096,10 +1096,10 @@ bool TestLaraMonkeyFall(ITEM_INFO* item, COLL_INFO* coll)
bool TestLaraLand(ITEM_INFO* item, COLL_INFO* coll)
{
int heightToFloor = GetCollisionResult(item).Position.Floor - item->pos.yPos;
int heightFromFloor = GetCollisionResult(item).Position.Floor - item->pos.yPos;
if (item->airborne && item->fallspeed >= 0 &&
(heightToFloor <= std::min<int>(item->fallspeed, STEPUP_HEIGHT) ||
(heightFromFloor <= std::min<int>(item->fallspeed, STEPUP_HEIGHT) ||
TestEnvironment(ENV_FLAG_SWAMP, item)))
{
return true;
@ -1357,11 +1357,11 @@ bool IsJumpState(LARA_STATE state)
state == LS_JUMP_LEFT ||
state == LS_JUMP_RIGHT ||
state == LS_JUMP_UP ||
state == LS_REACH ||
state == LS_FREEFALL ||
state == LS_FALL_BACK ||
state == LS_SWAN_DIVE_START ||
state == LS_FREEFALL_DIVE)
state == LS_REACH ||
state == LS_SWAN_DIVE ||
state == LS_FREEFALL_DIVE ||
state == LS_FREEFALL)
{
return true;
}

View file

@ -3,6 +3,7 @@
#include <filesystem>
#include "Game/camera.h"
#include "Game/collision/collide_room.h"
#include "Game/Lara/lara.h"
#include "Game/room.h"
#include "Specific/setup.h"
@ -133,7 +134,7 @@ bool LoadSample(char *pointer, int compSize, int uncompSize, int index)
return true;
}
long SoundEffect(int effectID, PHD_3DPOS* position, int env_flags, float pitchMultiplier, float gainMultiplier)
long SoundEffect(int effectID, PHD_3DPOS* position, int envFlags, float pitchMultiplier, float gainMultiplier)
{
if (effectID >= g_Level.SoundMap.size())
return 0;
@ -141,10 +142,10 @@ long SoundEffect(int effectID, PHD_3DPOS* position, int env_flags, float pitchMu
if (BASS_GetDevice() == -1)
return 0;
if (!(env_flags & SFX_ALWAYS))
if (!(envFlags & SFX_ALWAYS))
{
// Don't play effect if effect's environment isn't the same as camera position's environment
if ((env_flags & ENV_FLAG_WATER) != (g_Level.Rooms[Camera.pos.roomNumber].flags & ENV_FLAG_WATER))
if (envFlags & ENV_FLAG_WATER != TestEnvironment(ENV_FLAG_WATER, Camera.pos.roomNumber))
return 0;
}

View file

@ -109,7 +109,7 @@ struct SoundTrackInfo
extern std::map<std::string, int> SoundTrackMap;
extern std::vector<SoundTrackInfo> SoundTracks;
long SoundEffect(int effectID, PHD_3DPOS* position, int env_flags, float pitchMultiplier = 1.0f, float gainMultiplier = 1.0f);
long SoundEffect(int effectID, PHD_3DPOS* position, int envFlags, float pitchMultiplier = 1.0f, float gainMultiplier = 1.0f);
void StopSoundEffect(short effectID);
bool LoadSample(char *buffer, int compSize, int uncompSize, int currentIndex);
void FreeSamples();