Refactor health.cpp

This commit is contained in:
Sezz 2021-11-10 16:11:36 +11:00
parent be1ee111bf
commit a3b1403433
11 changed files with 182 additions and 186 deletions

View file

@ -415,8 +415,8 @@ void LaraControl(ITEM_INFO* item, COLL_INFO* coll)
Lara.gunStatus = LG_NO_ARMS; Lara.gunStatus = LG_NO_ARMS;
} }
if (item->currentAnimState != LS_SPRINT && DashTimer < 120) if (item->currentAnimState != LS_SPRINT && Lara.sprintTimer < LARA_SPRINT_MAX)
DashTimer++; Lara.sprintTimer++;
Lara.isDucked = false; Lara.isDucked = false;
@ -516,7 +516,7 @@ void LaraControl(ITEM_INFO* item, COLL_INFO* coll)
if (heightFromWater > SWIM_DEPTH) if (heightFromWater > SWIM_DEPTH)
{ {
Lara.waterStatus = LW_SURFACE; Lara.waterStatus = LW_SURFACE;
item->pos.yPos += 1 - heightFromWater; item->pos.yPos += 1 - heightFromWater; // BUG: Crawl exit flip results in Lara teleporting above the surface because of this. @Sezz 2021.11.10
item->animNumber = LA_ONWATER_IDLE; item->animNumber = LA_ONWATER_IDLE;
item->frameNumber = GF(LA_ONWATER_IDLE, 0); item->frameNumber = GF(LA_ONWATER_IDLE, 0);
@ -725,13 +725,13 @@ void LaraControl(ITEM_INFO* item, COLL_INFO* coll)
} }
} }
} }
else if (Lara.air < 1800 && item->hitPoints >= 0) else if (Lara.air < LARA_AIR_MAX && item->hitPoints >= 0)
{ {
if (Lara.Vehicle == NO_ITEM) // only for the upv !! if (Lara.Vehicle == NO_ITEM) // only for the upv !!
{ {
Lara.air += 10; Lara.air += 10;
if (Lara.air > 1800) if (Lara.air > LARA_AIR_MAX)
Lara.air = 1800; Lara.air = LARA_AIR_MAX;
} }
} }
@ -765,8 +765,8 @@ void LaraControl(ITEM_INFO* item, COLL_INFO* coll)
if (item->hitPoints >= 0) if (item->hitPoints >= 0)
{ {
Lara.air += 10; Lara.air += 10;
if (Lara.air > 1800) if (Lara.air > LARA_AIR_MAX)
Lara.air = 1800; Lara.air = LARA_AIR_MAX;
} }
LaraSurface(item, coll); LaraSurface(item, coll);
@ -804,8 +804,11 @@ void LaraAboveWater(ITEM_INFO* item, COLL_INFO* coll)
coll->Setup.Radius = LARA_RAD; coll->Setup.Radius = LARA_RAD;
coll->Setup.Height = LARA_HEIGHT; coll->Setup.Height = LARA_HEIGHT;
if ((TrInput & IN_LOOK) && Lara.ExtraAnim == NO_ITEM && Lara.look) if (TrInput & IN_LOOK && Lara.look &&
Lara.ExtraAnim == NO_ITEM)
{
LookLeftRight(); LookLeftRight();
}
else else
ResetLook(); ResetLook();
@ -939,62 +942,50 @@ void LaraUnderWater(ITEM_INFO* item, COLL_INFO* coll)
if (LaraDrawType == LARA_TYPE::DIVESUIT) if (LaraDrawType == LARA_TYPE::DIVESUIT)
{ {
if (Lara.turnRate < -ANGLE(0.5)) if (Lara.turnRate < -ANGLE(0.5f))
{ Lara.turnRate += ANGLE(0.5f);
Lara.turnRate += ANGLE(0.5); else if (Lara.turnRate > ANGLE(0.5f))
} Lara.turnRate -= ANGLE(0.5f);
else if (Lara.turnRate > ANGLE(0.5))
{
Lara.turnRate -= ANGLE(0.5);
}
else else
{
Lara.turnRate = 0; Lara.turnRate = 0;
}
}
else if (Lara.turnRate < -ANGLE(2))
{
Lara.turnRate += ANGLE(2);
}
else if (Lara.turnRate > ANGLE(2))
{
Lara.turnRate -= ANGLE(2);
} }
else if (Lara.turnRate < -ANGLE(2.0f))
Lara.turnRate += ANGLE(2.0f);
else if (Lara.turnRate > ANGLE(2.0f))
Lara.turnRate -= ANGLE(2.0f);
else else
{
Lara.turnRate = 0; Lara.turnRate = 0;
}
item->pos.yRot += Lara.turnRate; item->pos.yRot += Lara.turnRate;
if (LaraDrawType == LARA_TYPE::DIVESUIT) if (LaraDrawType == LARA_TYPE::DIVESUIT)
UpdateSubsuitAngles(); UpdateSubsuitAngles();
if (item->pos.zRot < -ANGLE(2)) if (item->pos.zRot < -ANGLE(2.0f))
item->pos.zRot += ANGLE(2); item->pos.zRot += ANGLE(2.0f);
else if (item->pos.zRot > ANGLE(2)) else if (item->pos.zRot > ANGLE(2.0f))
item->pos.zRot -= ANGLE(2); item->pos.zRot -= ANGLE(2.0f);
else else
item->pos.zRot = 0; item->pos.zRot = 0;
if (item->pos.xRot < -ANGLE(85)) if (item->pos.xRot < -ANGLE(85.0f))
item->pos.xRot = -ANGLE(85); item->pos.xRot = -ANGLE(85.0f);
else if (item->pos.xRot > ANGLE(85)) else if (item->pos.xRot > ANGLE(85.0f))
item->pos.xRot = ANGLE(85); item->pos.xRot = ANGLE(85.0f);
if (LaraDrawType == LARA_TYPE::DIVESUIT) if (LaraDrawType == LARA_TYPE::DIVESUIT)
{ {
if (item->pos.zRot > ANGLE(44)) if (item->pos.zRot > ANGLE(44.0f))
item->pos.zRot = ANGLE(44); item->pos.zRot = ANGLE(44.0f);
else if (item->pos.zRot < -ANGLE(44)) else if (item->pos.zRot < -ANGLE(44.0f))
item->pos.zRot = -ANGLE(44); item->pos.zRot = -ANGLE(44.0f);
} }
else else
{ {
if (item->pos.zRot > ANGLE(22)) if (item->pos.zRot > ANGLE(22.0f))
item->pos.zRot = ANGLE(22); item->pos.zRot = ANGLE(22.0f);
else if (item->pos.zRot < -ANGLE(22)) else if (item->pos.zRot < -ANGLE(22.0f))
item->pos.zRot = -ANGLE(22); item->pos.zRot = -ANGLE(22.0f);
} }
if (Lara.currentActive && Lara.waterStatus != LW_FLYCHEAT) if (Lara.currentActive && Lara.waterStatus != LW_FLYCHEAT)
@ -1022,7 +1013,7 @@ void LaraUnderWater(ITEM_INFO* item, COLL_INFO* coll)
void LaraSurface(ITEM_INFO* item, COLL_INFO* coll) void LaraSurface(ITEM_INFO* item, COLL_INFO* coll)
{ {
Camera.targetElevation = -ANGLE(22); Camera.targetElevation = -ANGLE(22.0f);
coll->Setup.BadHeightDown = 32512; coll->Setup.BadHeightDown = 32512;
coll->Setup.BadHeightUp = -128; coll->Setup.BadHeightUp = -128;
@ -1051,12 +1042,12 @@ void LaraSurface(ITEM_INFO* item, COLL_INFO* coll)
lara_control_routines[item->currentAnimState](item, coll); lara_control_routines[item->currentAnimState](item, coll);
if (item->pos.zRot >= -ANGLE(2) && item->pos.zRot <= ANGLE(2)) if (item->pos.zRot >= -ANGLE(2) && item->pos.zRot <= ANGLE(2.0f))
item->pos.zRot = 0; item->pos.zRot = 0;
else if (item->pos.zRot < 0) else if (item->pos.zRot < 0)
item->pos.zRot += ANGLE(2); item->pos.zRot += ANGLE(2.0f);
else else
item->pos.zRot -= ANGLE(2); item->pos.zRot -= ANGLE(2.0f);
if (Lara.currentActive && Lara.waterStatus != LW_FLYCHEAT) if (Lara.currentActive && Lara.waterStatus != LW_FLYCHEAT)
LaraWaterCurrent(coll); LaraWaterCurrent(coll);

View file

@ -30,6 +30,10 @@ constexpr auto LARA_RAD_DEATH = 400;
constexpr auto LARA_FREEFALL_SPEED = 131; constexpr auto LARA_FREEFALL_SPEED = 131;
constexpr auto LARA_VELOCITY = 12; constexpr auto LARA_VELOCITY = 12;
constexpr auto LARA_HEALTH_MAX = 1000.0f;
constexpr auto LARA_AIR_MAX = 1800.0f;
constexpr auto LARA_SPRINT_MAX = 120.0f;
extern LaraInfo Lara; extern LaraInfo Lara;
extern ITEM_INFO* LaraItem; extern ITEM_INFO* LaraItem;
extern COLL_INFO LaraCollision; extern COLL_INFO LaraCollision;

View file

@ -203,7 +203,7 @@ void lara_as_run(ITEM_INFO* item, COLL_INFO* coll)
return; return;
} }
if (TrInput & IN_SPRINT && DashTimer) if (TrInput & IN_SPRINT && Lara.sprintTimer)
{ {
item->goalAnimState = LS_SPRINT; item->goalAnimState = LS_SPRINT;
return; return;
@ -1873,13 +1873,13 @@ void lara_as_dash(ITEM_INFO* item, COLL_INFO* coll)
{ {
/*state 73*/ /*state 73*/
/*collision: lara_col_dash*/ /*collision: lara_col_dash*/
if (item->hitPoints <= 0 || !DashTimer || !(TrInput & IN_SPRINT) || Lara.waterStatus == LW_WADE) if (item->hitPoints <= 0 || !Lara.sprintTimer || !(TrInput & IN_SPRINT) || Lara.waterStatus == LW_WADE)
{ {
item->goalAnimState = LS_RUN_FORWARD; item->goalAnimState = LS_RUN_FORWARD;
return; return;
} }
DashTimer--; Lara.sprintTimer--;
if (TrInput & IN_DUCK if (TrInput & IN_DUCK
&& (Lara.gunStatus == LG_NO_ARMS && (Lara.gunStatus == LG_NO_ARMS

View file

@ -35,7 +35,7 @@ void InitialiseLara(int restore)
Lara.look = true; Lara.look = true;
Lara.itemNumber = itemNumber; Lara.itemNumber = itemNumber;
Lara.hitDirection = -1; Lara.hitDirection = -1;
Lara.air = 1800; Lara.air = LARA_AIR_MAX;
Lara.weaponItem = NO_ITEM; Lara.weaponItem = NO_ITEM;
PoisonFlag = 0; PoisonFlag = 0;
Lara.poisoned = 0; Lara.poisoned = 0;
@ -59,7 +59,7 @@ void InitialiseLara(int restore)
Lara.location = -1; Lara.location = -1;
Lara.highestLocation = -1; Lara.highestLocation = -1;
Lara.ropePtr = -1; Lara.ropePtr = -1;
LaraItem->hitPoints = 1000; LaraItem->hitPoints = LARA_HEALTH_MAX;
Lara.gunStatus = LG_NO_ARMS; Lara.gunStatus = LG_NO_ARMS;
memset(&Lara.NewAnims, 0, sizeof(AnimsNew)); //make sure script changes these AFTER Lara is initialized? memset(&Lara.NewAnims, 0, sizeof(AnimsNew)); //make sure script changes these AFTER Lara is initialized?
@ -99,7 +99,7 @@ void InitialiseLara(int restore)
InitialiseLaraAnims(LaraItem); InitialiseLaraAnims(LaraItem);
Lara.BeetleLife = 3; Lara.BeetleLife = 3;
DashTimer = 120; Lara.sprintTimer = LARA_SPRINT_MAX;
} }
void LaraInitialiseMeshes() void LaraInitialiseMeshes()

View file

@ -997,6 +997,7 @@ struct LaraTightrope
short tightropeItem; // maybe give Tightrope Item a property for difficulty? short tightropeItem; // maybe give Tightrope Item a property for difficulty?
}; };
#endif #endif
struct LaraInfo struct LaraInfo
{ {
short itemNumber; short itemNumber;
@ -1010,6 +1011,7 @@ struct LaraInfo
short poseCount; short poseCount;
short hitFrame; short hitFrame;
short hitDirection; short hitDirection;
int sprintTimer;
short air; short air;
short diveCount; short diveCount;
short deathCount; short deathCount;

View file

@ -22,81 +22,6 @@ struct SUBSUIT_INFO
SUBSUIT_INFO Subsuit; SUBSUIT_INFO Subsuit;
byte SubHitCount = 0; byte SubHitCount = 0;
void LaraWaterCurrent(COLL_INFO* coll)
{
if (Lara.currentActive)
{
SINK_INFO* sink = &g_Level.Sinks[Lara.currentActive - 1];
short angle = mGetAngle(sink->x, sink->z, LaraItem->pos.xPos, LaraItem->pos.zPos);
Lara.currentXvel += (sink->strength * 1024 * phd_sin(angle - ANGLE(90.0f)) - Lara.currentXvel) / 16;
Lara.currentZvel += (sink->strength * 1024 * phd_cos(angle - ANGLE(90.0f)) - Lara.currentZvel) / 16;
LaraItem->pos.yPos += (sink->y - LaraItem->pos.yPos) >> 4;
}
else
{
int shift = 0;
if (abs(Lara.currentXvel) <= 16)
shift = (abs(Lara.currentXvel) > 8) + 2;
else
shift = 4;
Lara.currentXvel -= Lara.currentXvel >> shift;
if (abs(Lara.currentXvel) < 4)
Lara.currentXvel = 0;
if (abs(Lara.currentZvel) <= 16)
shift = (abs(Lara.currentZvel) > 8) + 2;
else
shift = 4;
Lara.currentZvel -= Lara.currentZvel >> shift;
if (abs(Lara.currentZvel) < 4)
Lara.currentZvel = 0;
if (!Lara.currentXvel && !Lara.currentZvel)
return;
}
LaraItem->pos.xPos += Lara.currentXvel >> 8;
LaraItem->pos.zPos += Lara.currentZvel >> 8;
Lara.currentActive = 0;
coll->Setup.ForwardAngle = phd_atan(LaraItem->pos.zPos - coll->Setup.OldPosition.z, LaraItem->pos.xPos - coll->Setup.OldPosition.x);
coll->Setup.Height = LARA_HEIGHT_CRAWL;
GetCollisionInfo(coll, LaraItem, PHD_VECTOR(0, 200, 0));
if (coll->CollisionType == CT_FRONT)
{
if (LaraItem->pos.xRot > ANGLE(35.0f))
LaraItem->pos.xRot += ANGLE(1.0f);
else if (LaraItem->pos.xRot < -ANGLE(35.0f))
LaraItem->pos.xRot -= ANGLE(1.0f);
else
LaraItem->fallspeed = 0;
}
else if (coll->CollisionType == CT_TOP)
LaraItem->pos.xRot -= ANGLE(1.0f);
else if (coll->CollisionType == CT_TOP_FRONT)
LaraItem->fallspeed = 0;
else if (coll->CollisionType == CT_LEFT)
LaraItem->pos.yRot += ANGLE(5.0f);
else if (coll->CollisionType == CT_RIGHT)
LaraItem->pos.yRot -= ANGLE(5.0f);
if (coll->Middle.Floor < 0 && coll->Middle.Floor != NO_HEIGHT)
LaraItem->pos.yPos += coll->Middle.Floor;
ShiftItem(LaraItem, coll);
coll->Setup.OldPosition.x = LaraItem->pos.xPos;
coll->Setup.OldPosition.y = LaraItem->pos.yPos;
coll->Setup.OldPosition.z = LaraItem->pos.zPos;
}
void lara_col_waterroll(ITEM_INFO* item, COLL_INFO* coll) void lara_col_waterroll(ITEM_INFO* item, COLL_INFO* coll)
{ {
LaraSwimCollision(item, coll); LaraSwimCollision(item, coll);
@ -400,3 +325,78 @@ void SwimTurn(ITEM_INFO* item)
item->pos.zRot += LARA_LEAN_RATE * 2; item->pos.zRot += LARA_LEAN_RATE * 2;
} }
} }
void LaraWaterCurrent(COLL_INFO* coll)
{
if (Lara.currentActive)
{
SINK_INFO* sink = &g_Level.Sinks[Lara.currentActive - 1];
short angle = mGetAngle(sink->x, sink->z, LaraItem->pos.xPos, LaraItem->pos.zPos);
Lara.currentXvel += (sink->strength * 1024 * phd_sin(angle - ANGLE(90.0f)) - Lara.currentXvel) / 16;
Lara.currentZvel += (sink->strength * 1024 * phd_cos(angle - ANGLE(90.0f)) - Lara.currentZvel) / 16;
LaraItem->pos.yPos += (sink->y - LaraItem->pos.yPos) >> 4;
}
else
{
int shift = 0;
if (abs(Lara.currentXvel) <= 16)
shift = (abs(Lara.currentXvel) > 8) + 2;
else
shift = 4;
Lara.currentXvel -= Lara.currentXvel >> shift;
if (abs(Lara.currentXvel) < 4)
Lara.currentXvel = 0;
if (abs(Lara.currentZvel) <= 16)
shift = (abs(Lara.currentZvel) > 8) + 2;
else
shift = 4;
Lara.currentZvel -= Lara.currentZvel >> shift;
if (abs(Lara.currentZvel) < 4)
Lara.currentZvel = 0;
if (!Lara.currentXvel && !Lara.currentZvel)
return;
}
LaraItem->pos.xPos += Lara.currentXvel >> 8;
LaraItem->pos.zPos += Lara.currentZvel >> 8;
Lara.currentActive = 0;
coll->Setup.ForwardAngle = phd_atan(LaraItem->pos.zPos - coll->Setup.OldPosition.z, LaraItem->pos.xPos - coll->Setup.OldPosition.x);
coll->Setup.Height = LARA_HEIGHT_CRAWL;
GetCollisionInfo(coll, LaraItem, PHD_VECTOR(0, 200, 0));
if (coll->CollisionType == CT_FRONT)
{
if (LaraItem->pos.xRot > ANGLE(35.0f))
LaraItem->pos.xRot += ANGLE(1.0f);
else if (LaraItem->pos.xRot < -ANGLE(35.0f))
LaraItem->pos.xRot -= ANGLE(1.0f);
else
LaraItem->fallspeed = 0;
}
else if (coll->CollisionType == CT_TOP)
LaraItem->pos.xRot -= ANGLE(1.0f);
else if (coll->CollisionType == CT_TOP_FRONT)
LaraItem->fallspeed = 0;
else if (coll->CollisionType == CT_LEFT)
LaraItem->pos.yRot += ANGLE(5.0f);
else if (coll->CollisionType == CT_RIGHT)
LaraItem->pos.yRot -= ANGLE(5.0f);
if (coll->Middle.Floor < 0 && coll->Middle.Floor != NO_HEIGHT)
LaraItem->pos.yPos += coll->Middle.Floor;
ShiftItem(LaraItem, coll);
coll->Setup.OldPosition.x = LaraItem->pos.xPos;
coll->Setup.OldPosition.y = LaraItem->pos.yPos;
coll->Setup.OldPosition.z = LaraItem->pos.zPos;
}

View file

@ -1,7 +1,6 @@
#pragma once #pragma once
#include "collide.h" #include "collide.h"
void LaraWaterCurrent(COLL_INFO* coll);
void lara_col_waterroll(ITEM_INFO* item, COLL_INFO* coll); void lara_col_waterroll(ITEM_INFO* item, COLL_INFO* coll);
void lara_col_uwdeath(ITEM_INFO* item, COLL_INFO* coll); void lara_col_uwdeath(ITEM_INFO* item, COLL_INFO* coll);
void lara_col_dive(ITEM_INFO* item, COLL_INFO* coll); void lara_col_dive(ITEM_INFO* item, COLL_INFO* coll);
@ -17,3 +16,4 @@ void lara_as_swim(ITEM_INFO* item, COLL_INFO* coll);
void UpdateSubsuitAngles(); void UpdateSubsuitAngles();
void SwimTurnSubsuit(ITEM_INFO* item); void SwimTurnSubsuit(ITEM_INFO* item);
void SwimTurn(ITEM_INFO* item); void SwimTurn(ITEM_INFO* item);
void LaraWaterCurrent(COLL_INFO* coll);

View file

@ -16,14 +16,13 @@ short PickupY;
short CurrentPickup; short CurrentPickup;
DISPLAY_PICKUP Pickups[MAX_COLLECTED_PICKUPS]; DISPLAY_PICKUP Pickups[MAX_COLLECTED_PICKUPS];
short PickupVel; short PickupVel;
int OldHitPoints = 1000; int OldHitPoints = LARA_HEALTH_MAX;
int HealthBarTimer = 40; int HealthBarTimer = 40;
float HealthBar = OldHitPoints; float HealthBar = OldHitPoints;
float MutateAmount = 0; float MutateAmount = 0;
int FlashState = 0; int FlashState = 0;
int FlashCount = 0; int FlashCount = 0;
int PoisonFlag = 0; int PoisonFlag = 0;
int DashTimer = 0;
extern RendererHUDBar* g_HealthBar; extern RendererHUDBar* g_HealthBar;
extern RendererHUDBar* g_DashBar; extern RendererHUDBar* g_DashBar;
extern RendererHUDBar* g_AirBar; extern RendererHUDBar* g_AirBar;
@ -39,6 +38,7 @@ void DrawHealthBarOverlay(int value)
color2 = 0xA0A000; color2 = 0xA0A000;
else else
color2 = 0xA00000; color2 = 0xA00000;
g_Renderer.drawBar(value, ::g_HealthBar, ID_HEALTH_BAR_TEXTURE, GlobalCounter, Lara.poisoned); g_Renderer.drawBar(value, ::g_HealthBar, ID_HEALTH_BAR_TEXTURE, GlobalCounter, Lara.poisoned);
} }
} }
@ -46,19 +46,17 @@ void DrawHealthBarOverlay(int value)
void DrawHealthBar(float value) void DrawHealthBar(float value)
{ {
if (CurrentLevel) if (CurrentLevel)
{
g_Renderer.drawBar(value, ::g_HealthBar, ID_HEALTH_BAR_TEXTURE, GlobalCounter, Lara.poisoned); g_Renderer.drawBar(value, ::g_HealthBar, ID_HEALTH_BAR_TEXTURE, GlobalCounter, Lara.poisoned);
}
} }
void UpdateHealthBar(int flash) void UpdateHealthBar(ITEM_INFO* item, int flash)
{ {
int hitPoints = LaraItem->hitPoints; auto hitPoints = item->hitPoints;
if (hitPoints < 0) if (hitPoints < 0)
hitPoints = 0; hitPoints = 0;
else if (hitPoints > 1000) else if (hitPoints > LARA_HEALTH_MAX)
hitPoints = 1000; hitPoints = LARA_HEALTH_MAX;
// OPT: smoothly transition health bar display. // OPT: smoothly transition health bar display.
if (EnableSmoothHealthBar) if (EnableSmoothHealthBar)
@ -72,8 +70,8 @@ void UpdateHealthBar(int flash)
if (HealthBar - MutateAmount < 0) if (HealthBar - MutateAmount < 0)
MutateAmount = HealthBar; MutateAmount = HealthBar;
else if (HealthBar - MutateAmount > 1000) else if (HealthBar - MutateAmount > LARA_HEALTH_MAX)
MutateAmount = HealthBar - 1000; MutateAmount = HealthBar - LARA_HEALTH_MAX;
HealthBar -= MutateAmount / 3; HealthBar -= MutateAmount / 3;
MutateAmount -= MutateAmount / 3; MutateAmount -= MutateAmount / 3;
@ -100,36 +98,32 @@ void UpdateHealthBar(int flash)
HealthBarTimer = 0; HealthBarTimer = 0;
// Flash when at 1/4 capacity AND HP bar is not transitioning. // Flash when at 1/4 capacity AND HP bar is not transitioning.
if (HealthBar <= 1000 / 4) if (HealthBar <= LARA_HEALTH_MAX / 4)
{ {
if (!BinocularRange) if (!BinocularRange)
{ {
if (flash) if (flash)
DrawHealthBar(HealthBar / 1000.0f); DrawHealthBar(HealthBar / LARA_HEALTH_MAX);
else else
DrawHealthBar(0); DrawHealthBar(0);
} }
else else
{ {
if (flash) if (flash)
DrawHealthBarOverlay(HealthBar / 1000.0f); DrawHealthBarOverlay(HealthBar / LARA_HEALTH_MAX);
else else
DrawHealthBarOverlay(0); DrawHealthBarOverlay(0);
} }
} }
else if ((HealthBarTimer > 0) else if (HealthBarTimer > 0 ||
|| (HealthBar <= 0) HealthBar <= 0 ||
|| (Lara.gunStatus == LG_READY && Lara.gunType != WEAPON_TORCH) Lara.gunStatus == LG_READY && Lara.gunType != WEAPON_TORCH ||
|| (Lara.poisoned >= 256)) Lara.poisoned >= 256)
{ {
if (!BinocularRange) if (!BinocularRange)
{ DrawHealthBar(HealthBar / LARA_HEALTH_MAX);
DrawHealthBar(HealthBar / 1000.0f);
}
else else
{ DrawHealthBarOverlay(HealthBar / LARA_HEALTH_MAX);
DrawHealthBarOverlay(HealthBar / 1000.0f);
}
} }
if (PoisonFlag) if (PoisonFlag)
@ -139,47 +133,49 @@ void UpdateHealthBar(int flash)
void DrawAirBar(float value) void DrawAirBar(float value)
{ {
if (CurrentLevel) if (CurrentLevel)
{
g_Renderer.drawBar(value, ::g_AirBar,ID_AIR_BAR_TEXTURE,0,0); g_Renderer.drawBar(value, ::g_AirBar,ID_AIR_BAR_TEXTURE,0,0);
}
} }
void UpdateAirBar(int flash) void UpdateAirBar(ITEM_INFO* item, int flash)
{ {
if (Lara.air == 1800 || LaraItem->hitPoints <= 0) if (Lara.air == LARA_AIR_MAX || item->hitPoints <= 0)
return; return;
if ((Lara.Vehicle == NO_ITEM) if (Lara.Vehicle == NO_ITEM ||
|| (g_Level.Items[Lara.Vehicle].objectNumber != ID_UPV)) g_Level.Items[Lara.Vehicle].objectNumber != ID_UPV)
{ {
if ((Lara.waterStatus != LW_UNDERWATER) if (Lara.waterStatus != LW_UNDERWATER &&
&& (Lara.waterStatus != LW_SURFACE) Lara.waterStatus != LW_SURFACE &&
&& (!(TestLaraSwamp(LaraItem) && (Lara.waterSurfaceDist < -775)))) !(TestLaraSwamp(item) && Lara.waterSurfaceDist < -(STOP_SIZE + STEP_SIZE - 1)))
return; return;
} }
int air = Lara.air; int air = Lara.air;
if (air < 0) if (air < 0)
air = 0; air = 0;
else if (air > 1800) else if (air > LARA_AIR_MAX)
air = 1800; air = LARA_AIR_MAX;
if (air <= 450) if (air <= (LARA_AIR_MAX / 4))
{ {
if (flash) if (flash)
DrawAirBar(air / 1800.0f); DrawAirBar(air / LARA_AIR_MAX);
else else
DrawAirBar(0); DrawAirBar(0);
} }
else else
DrawAirBar(air / 1800.0f); DrawAirBar(air / LARA_AIR_MAX);
} }
void DrawDashBar(int value) void DrawSprintBar(float value)
{ {
if (CurrentLevel) if (CurrentLevel)
{ g_Renderer.drawBar(value, ::g_DashBar, ID_DASH_BAR_TEXTURE, 0, 0);
g_Renderer.drawBar(value, ::g_DashBar,ID_DASH_BAR_TEXTURE,0,0); }
}
void UpdateSprintBar()
{
if (Lara.sprintTimer < LARA_SPRINT_MAX)
DrawSprintBar(Lara.sprintTimer / LARA_SPRINT_MAX);
} }
void DrawAllPickups() void DrawAllPickups()
@ -223,6 +219,7 @@ void DrawAllPickups()
if (i == MAX_COLLECTED_PICKUPS) if (i == MAX_COLLECTED_PICKUPS)
{ {
CurrentPickup = 0; CurrentPickup = 0;
return; return;
} }
} }
@ -237,11 +234,11 @@ void AddDisplayPickup(GAME_OBJECT_ID objectNumber)
for (int i = 0; i < MAX_COLLECTED_PICKUPS; i++) for (int i = 0; i < MAX_COLLECTED_PICKUPS; i++)
{ {
if (pickup->life < 0) if (pickup->life < 0)
{ {
pickup->life = 45; pickup->life = 45;
pickup->objectNumber = objectNumber; pickup->objectNumber = objectNumber;
break; break;
} }
@ -272,5 +269,6 @@ int FlashIt()
FlashState ^= 1; FlashState ^= 1;
FlashCount = 5; FlashCount = 5;
} }
return FlashState; return FlashState;
} }

View file

@ -1,4 +1,6 @@
#pragma once #pragma once
#include "items.h"
#define MAX_COLLECTED_PICKUPS 32 #define MAX_COLLECTED_PICKUPS 32
enum GAME_OBJECT_ID : short; enum GAME_OBJECT_ID : short;
@ -11,10 +13,11 @@ struct DISPLAY_PICKUP
void DrawHealthBarOverlay(int value); void DrawHealthBarOverlay(int value);
void DrawHealthBar(float value); void DrawHealthBar(float value);
void UpdateHealthBar(int flash); void UpdateHealthBar(ITEM_INFO* item, int flash);
void DrawAirBar(float value); void DrawAirBar(float value);
void UpdateAirBar(int flash); void UpdateAirBar(ITEM_INFO* item, int flash);
void DrawDashBar(int value); void DrawSprintBar(float value);
void UpdateSprintBar();
void AddDisplayPickup(GAME_OBJECT_ID objectNumber); void AddDisplayPickup(GAME_OBJECT_ID objectNumber);
void DrawAllPickups(); void DrawAllPickups();
void InitialisePickupDisplay(); void InitialisePickupDisplay();
@ -31,6 +34,5 @@ extern float HealthBar;
extern float MutateAmount; extern float MutateAmount;
extern int FlashState; extern int FlashState;
extern int PoisonFlag; extern int PoisonFlag;
extern int DashTimer;
extern bool EnableSmoothHealthBar; extern bool EnableSmoothHealthBar;

View file

@ -555,7 +555,7 @@ static int MotorBikeCheckGetOff(void)
LaraItem->pos.zRot = 0; LaraItem->pos.zRot = 0;
Lara.Vehicle = NO_ITEM; Lara.Vehicle = NO_ITEM;
Lara.gunStatus = LG_NO_ARMS; Lara.gunStatus = LG_NO_ARMS;
DashTimer = 120; Lara.sprintTimer = 120;
return true; return true;
} }
@ -1200,14 +1200,14 @@ static int MotorbikeUserControl(ITEM_INFO* item, int height, int* pitch)
motorbike->revs = 0; motorbike->revs = 0;
} }
if ((TrInput & IN_TURBO) && (TrInput & IN_ACCELERATE) && DashTimer) if ((TrInput & IN_TURBO) && (TrInput & IN_ACCELERATE) && Lara.sprintTimer)
{ {
motorbike->flags |= FL_BOOST; motorbike->flags |= FL_BOOST;
DashTimer -= 2; Lara.sprintTimer -= 2;
if (DashTimer > MOTORBIKE_ACCEL)//hmm if (Lara.sprintTimer > MOTORBIKE_ACCEL)//hmm
{ {
motorbike->flags &= ~FL_BOOST; motorbike->flags &= ~FL_BOOST;
DashTimer = 0; Lara.sprintTimer = 0;
} }
} }
else else

View file

@ -2265,10 +2265,9 @@ namespace TEN::Renderer
// Bars // Bars
int flash = FlashIt(); int flash = FlashIt();
if (DashTimer < 120) UpdateSprintBar();
drawBar(DashTimer / 120.0f, g_DashBar,ID_DASH_BAR_TEXTURE,0,0); UpdateHealthBar(LaraItem, flash);
UpdateHealthBar(flash); UpdateAirBar(LaraItem, flash);
UpdateAirBar(flash);
DrawAllPickups(); DrawAllPickups();
drawOverlays(view); // Draw binoculars or lasersight drawOverlays(view); // Draw binoculars or lasersight