Minor refactoring, cleanup

This commit is contained in:
Sezz 2022-02-04 22:18:55 +11:00
parent fc0d7611b4
commit 64a57cad92
8 changed files with 74 additions and 68 deletions

View file

@ -36,8 +36,8 @@ void lara_as_crouch_idle(ITEM_INFO* item, COLL_INFO* coll)
LaraInfo*& info = item->data;
coll->Setup.EnableSpasm = false;
coll->Setup.EnableObjectPush = true;
coll->Setup.EnableSpasm = false;
Camera.targetElevation = -ANGLE(24.0f);
// TODO: Dispatch pickups from within states.
@ -144,8 +144,8 @@ void lara_as_crouch_roll(ITEM_INFO* item, COLL_INFO* coll)
LaraInfo*& info = item->data;
info->look = false;
coll->Setup.EnableSpasm = false;
coll->Setup.EnableObjectPush = true;
coll->Setup.EnableSpasm = false;
Camera.targetElevation = -ANGLE(24.0f);
if (TrInput & IN_LEFT)
@ -348,8 +348,8 @@ void lara_as_crawl_idle(ITEM_INFO* item, COLL_INFO* coll)
LaraInfo*& info = item->data;
info->gunStatus = LG_HANDS_BUSY;
coll->Setup.EnableSpasm = false;
coll->Setup.EnableObjectPush = true;
coll->Setup.EnableSpasm = false;
Camera.targetElevation = -ANGLE(24.0f);
// TODO: Dispatch pickups from within states.
@ -487,8 +487,8 @@ void lara_as_crawl_forward(ITEM_INFO* item, COLL_INFO* coll)
LaraInfo*& info = item->data;
info->gunStatus = LG_HANDS_BUSY;
coll->Setup.EnableSpasm = false;
coll->Setup.EnableObjectPush = true;
coll->Setup.EnableSpasm = false;
Camera.targetElevation = -ANGLE(24.0f);
if (item->hitPoints <= 0)
@ -592,8 +592,8 @@ void lara_as_crawl_back(ITEM_INFO* item, COLL_INFO* coll)
info->look = false;
info->gunStatus = LG_HANDS_BUSY;
coll->Setup.EnableSpasm = false;
coll->Setup.EnableObjectPush = true;
coll->Setup.EnableSpasm = false;
Camera.targetElevation = -ANGLE(24.0f);
if (item->hitPoints <= 0)
@ -688,8 +688,8 @@ void lara_as_crawl_turn_left(ITEM_INFO* item, COLL_INFO* coll)
LaraInfo*& info = item->data;
info->gunStatus = LG_HANDS_BUSY;
coll->Setup.EnableSpasm = false;
coll->Setup.EnableObjectPush = true;
coll->Setup.EnableSpasm = false;
Camera.targetElevation = -ANGLE(24.0f);
if (item->hitPoints <= 0)
@ -748,8 +748,8 @@ void lara_as_crawl_turn_right(ITEM_INFO* item, COLL_INFO* coll)
LaraInfo*& info = item->data;
info->gunStatus = LG_HANDS_BUSY;
coll->Setup.EnableSpasm = false;
coll->Setup.EnableObjectPush = true;
coll->Setup.EnableSpasm = false;
Camera.targetElevation = -ANGLE(24.0f);
if (item->hitPoints <= 0)
@ -805,8 +805,8 @@ void lara_col_crawl_to_hang(ITEM_INFO* item, COLL_INFO* coll)
{
LaraInfo*& info = item->data;
coll->Setup.EnableObjectPush = true;
coll->Setup.EnableSpasm = false;
coll->Setup.EnableObjectPush = false;
Camera.targetAngle = 0;
Camera.targetElevation = -ANGLE(45.0f);

View file

@ -246,8 +246,6 @@ void SetLaraFallBackState(ITEM_INFO* item)
void SetLaraMonkeyFallState(ITEM_INFO* item)
{
LaraInfo*& info = item->data;
// Hack.
if (item->activeState == LS_MONKEY_TURN_180)
return;
@ -340,14 +338,9 @@ void HandleLaraMovementParameters(ITEM_INFO* item, COLL_INFO* coll)
LaraInfo*& info = item->data;
// Reset running jump timer.
if (item->activeState != LS_RUN_FORWARD &&
item->activeState != LS_WALK_FORWARD &&
item->activeState != LS_JUMP_FORWARD &&
item->activeState != LS_SPRINT &&
item->activeState != LS_SPRINT_DIVE)
{
if (!IsRunJumpCountState((LARA_STATE)item->activeState))
info->runJumpCount = 0;
}
// Reset running jump action queue.
if (item->activeState != LS_RUN_FORWARD)

View file

@ -1369,6 +1369,20 @@ bool IsJumpState(LARA_STATE state)
return false;
}
bool IsRunJumpCountState(LARA_STATE state)
{
if (state == LS_RUN_FORWARD ||
state == LS_WALK_FORWARD ||
state == LS_JUMP_FORWARD ||
state == LS_SPRINT ||
state == LS_SPRINT_DIVE)
{
return true;
}
return false;
}
bool TestLaraSplat(ITEM_INFO* item, int dist, int height, int side)
{
auto start = GAME_VECTOR(

View file

@ -51,6 +51,7 @@ void GetTighRopeFallOff(int Regularity);
bool IsStandingWeapon(LARA_WEAPON_TYPE gunType);
bool IsJumpState(LARA_STATE state);
bool IsRunJumpCountState(LARA_STATE state);
bool TestLaraSplat(ITEM_INFO* item, int dist, int height, int side = 0);
bool TestLaraPose(ITEM_INFO* item, COLL_INFO* coll);

View file

@ -121,21 +121,17 @@ void AnimateItem(ITEM_INFO* item)
SoundEffect(cmd[1] & 0x3FFF, &item->pos, 2);
}
else if (g_Level.Rooms[item->roomNumber].flags & ENV_FLAG_WATER)
{
if (!flags || flags == (int)SOUND_PLAYCONDITION::Water && (g_Level.Rooms[Camera.pos.roomNumber].flags & ENV_FLAG_WATER || Objects[item->objectNumber].intelligent))
else if (TestEnvironment(ENV_FLAG_WATER, item))
{
if (!flags || flags == (int)SOUND_PLAYCONDITION::Water && (TestEnvironment(ENV_FLAG_WATER, Camera.pos.roomNumber) || Objects[item->objectNumber].intelligent))
SoundEffect(cmd[1] & 0x3FFF, &item->pos, 2);
}
}
else if (!flags || flags == (int)SOUND_PLAYCONDITION::Land && !(g_Level.Rooms[Camera.pos.roomNumber].flags & ENV_FLAG_WATER))
{
else if (!flags || flags == (int)SOUND_PLAYCONDITION::Land && !TestEnvironment(ENV_FLAG_WATER, Camera.pos.roomNumber))
SoundEffect(cmd[1] & 0x3FFF, &item->pos, 2);
}
}
else
{
if (g_Level.Rooms[item->roomNumber].flags & ENV_FLAG_WATER)
if (TestEnvironment(ENV_FLAG_WATER, item))
SoundEffect(cmd[1] & 0x3FFF, &item->pos, 1);
else
SoundEffect(cmd[1] & 0x3FFF, &item->pos, 0);

View file

@ -224,7 +224,7 @@ void MoveCamera(GAME_VECTOR* ideal, int speed)
}
int y = Camera.pos.y;
if (g_Level.Rooms[Camera.pos.roomNumber].flags & ENV_FLAG_SWAMP)
if (TestEnvironment(ENV_FLAG_SWAMP, Camera.pos.roomNumber))
y = g_Level.Rooms[Camera.pos.roomNumber].y - STEP_SIZE;
auto probe = GetCollisionResult(Camera.pos.x, y, Camera.pos.z, Camera.pos.roomNumber);
@ -334,7 +334,7 @@ void ChaseCamera(ITEM_INFO* item)
auto probe = GetCollisionResult(Camera.target.x, Camera.target.y + STEP_SIZE, Camera.target.z, Camera.target.roomNumber);
if (g_Level.Rooms[probe.RoomNumber].flags & ENV_FLAG_SWAMP)
if (TestEnvironment(ENV_FLAG_SWAMP, probe.RoomNumber))
Camera.target.y = g_Level.Rooms[probe.RoomNumber].y - STEP_SIZE;
int y = Camera.target.y;
@ -470,7 +470,7 @@ void CombatCamera(ITEM_INFO* item)
}
auto probe = GetCollisionResult(Camera.target.x, Camera.target.y + STEP_SIZE, Camera.target.z, Camera.target.roomNumber);
if (g_Level.Rooms[probe.RoomNumber].flags & ENV_FLAG_SWAMP)
if (TestEnvironment(ENV_FLAG_SWAMP, probe.RoomNumber))
Camera.target.y = g_Level.Rooms[probe.RoomNumber].y - STEP_SIZE;
probe = GetCollisionResult(Camera.target.x, Camera.target.y, Camera.target.z, Camera.target.roomNumber);
@ -823,7 +823,7 @@ void LookCamera(ITEM_INFO* item)
GetLaraJointPosition(&pos, LM_HEAD);
probe = GetCollisionResult(pos.x, pos.y + STEP_SIZE, pos.z, item->roomNumber);
if (g_Level.Rooms[probe.RoomNumber].flags & ENV_FLAG_SWAMP)
if (TestEnvironment(ENV_FLAG_SWAMP, probe.RoomNumber))
{
pos.y = g_Level.Rooms[probe.RoomNumber].y - STEP_SIZE;
probe = GetCollisionResult(pos.x, pos.y, pos.z, probe.RoomNumber);
@ -864,7 +864,7 @@ void LookCamera(ITEM_INFO* item)
{
roomNum = probe.RoomNumber;
probe = GetCollisionResult(x, y + STEP_SIZE, z, probe.RoomNumber);
if (g_Level.Rooms[probe.RoomNumber].flags & ENV_FLAG_SWAMP)
if (TestEnvironment(ENV_FLAG_SWAMP, probe.RoomNumber))
{
y = g_Level.Rooms[probe.RoomNumber].y - STEP_SIZE;
break;
@ -999,7 +999,7 @@ void LookCamera(ITEM_INFO* item)
y = Camera.pos.y;
probe = GetCollisionResult(Camera.pos.x, y, Camera.pos.z, Camera.pos.roomNumber);
if ((g_Level.Rooms[probe.RoomNumber].flags & ENV_FLAG_SWAMP))
if (TestEnvironment(ENV_FLAG_SWAMP, probe.RoomNumber))
Camera.pos.y = g_Level.Rooms[probe.RoomNumber].y - STEP_SIZE;
else if (y < probe.Position.Ceiling ||
y > probe.Position.Floor ||
@ -1017,7 +1017,7 @@ void LookCamera(ITEM_INFO* item)
probe.Position.Ceiling >= probe.Position.Floor ||
probe.Position.Floor == NO_HEIGHT ||
probe.Position.Ceiling == NO_HEIGHT ||
g_Level.Rooms[probe.RoomNumber].flags & ENV_FLAG_SWAMP)
TestEnvironment(ENV_FLAG_SWAMP, probe.RoomNumber))
{
Camera.pos.x = pos.x;
Camera.pos.y = pos.y;
@ -1416,8 +1416,7 @@ void CalculateCamera()
}
// Camera is in a water room, play water sound effect.
if (g_Level.Rooms[Camera.pos.roomNumber].flags & ENV_FLAG_WATER)
if (TestEnvironment(ENV_FLAG_WATER, Camera.pos.roomNumber))
{
SoundEffect(SFX_TR4_UNDERWATER, NULL, SFX_ALWAYS);
if (Camera.underwater == false)
@ -1530,7 +1529,7 @@ void CalculateCamera()
if (Camera.type != CAMERA_TYPE::CHASE_CAMERA &&
Camera.flags != CF_CHASE_OBJECT &&
(Camera.number != -1 &&(SniperCamActive = g_Level.Cameras[Camera.number].flags & 3, g_Level.Cameras[Camera.number].flags & 2)))
(Camera.number != -1 && (SniperCamActive = g_Level.Cameras[Camera.number].flags & 3, g_Level.Cameras[Camera.number].flags & 2)))
{
PHD_VECTOR pos = { 0, 0, 0 };
GetLaraJointPosition(&pos, LM_TORSO);

View file

@ -4,6 +4,7 @@
#include "Game/animation.h"
#include "Game/camera.h"
#include "Game/collision/sphere.h"
#include "Game/collision/collide_room.h"
#include "Game/control/control.h"
#include "Game/control/lot.h"
#include "Game/effects/tomb4fx.h"
@ -706,7 +707,8 @@ int CreatureAnimation(short itemNumber, short angle, short tilt)
else
{
floor = GetFloor(item->pos.xPos, y + STEP_SIZE, item->pos.zPos, &roomNumber);
if (g_Level.Rooms[roomNumber].flags & (ENV_FLAG_WATER | ENV_FLAG_SWAMP))
if (TestEnvironment(ENV_FLAG_WATER, roomNumber) ||
TestEnvironment(ENV_FLAG_SWAMP, roomNumber))
{
dy = -LOT->fly;
}

View file

@ -2,6 +2,7 @@
#include "Game/effects/effects.h"
#include "Game/animation.h"
#include "Game/collision/collide_room.h"
#include "Game/effects/lara_fx.h"
#include "Game/effects/drip.h"
#include "Game/effects/bubble.h"
@ -1221,7 +1222,7 @@ void WadeSplash(ITEM_INFO* item, int wh, int wd)
GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
ROOM_INFO* room = &g_Level.Rooms[roomNumber];
if (!(room->flags & ENV_FLAG_WATER))
if (!TestEnvironment(ENV_FLAG_WATER, room))
return;
short roomNumber2 = item->roomNumber;
@ -1229,7 +1230,7 @@ void WadeSplash(ITEM_INFO* item, int wh, int wd)
ROOM_INFO* room2 = &g_Level.Rooms[roomNumber2];
if (room2->flags & ENV_FLAG_WATER)
if (TestEnvironment(ENV_FLAG_WATER, room2))
return;
ANIM_FRAME* frame = GetBestFrame(item);
@ -1270,15 +1271,15 @@ void Splash(ITEM_INFO* item)
GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
ROOM_INFO* room = &g_Level.Rooms[roomNumber];
if (room->flags & ENV_FLAG_WATER)
if (TestEnvironment(ENV_FLAG_WATER, room))
{
int wh = GetWaterHeight(item->pos.xPos, item->pos.yPos, item->pos.zPos, roomNumber);
SplashSetup.y = wh - 1;
int waterHeight = GetWaterHeight(item->pos.xPos, item->pos.yPos, item->pos.zPos, roomNumber);
SplashSetup.y = waterHeight - 1;
SplashSetup.x = item->pos.xPos;
SplashSetup.z = item->pos.zPos;
SplashSetup.splashPower = item->fallspeed;
SplashSetup.innerRadius = 64;
SetupSplash(&SplashSetup,roomNumber);
SetupSplash(&SplashSetup, roomNumber);
}
}