2018-08-19 09:46:58 +02:00
|
|
|
#include "healt.h"
|
|
|
|
#include "draw.h"
|
2019-11-14 20:15:29 +01:00
|
|
|
#include "pickup.h"
|
2020-01-04 13:26:22 +01:00
|
|
|
#include "lara.h"
|
2020-04-14 07:13:31 +02:00
|
|
|
#include "camera.h"
|
2020-04-22 14:12:10 +02:00
|
|
|
#include "../Specific/level.h"
|
2020-04-24 19:15:05 +02:00
|
|
|
#include "control.h"
|
2019-11-14 20:15:29 +01:00
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
short PickupX;
|
|
|
|
short PickupY;
|
|
|
|
short CurrentPickup;
|
2020-01-13 07:38:46 +01:00
|
|
|
DISPLAY_PICKUP Pickups[MAX_COLLECTED_PICKUPS];
|
2019-11-27 15:12:35 +01:00
|
|
|
short PickupVel;
|
2020-01-04 13:26:22 +01:00
|
|
|
int OldHitPoints = 1000;
|
|
|
|
int HealtBarTimer = 40;
|
|
|
|
int FlashState = 0;
|
|
|
|
int FlashCount = 0;
|
|
|
|
int PoisonFlag = 0;
|
|
|
|
int DashTimer = 0;
|
2020-01-12 17:28:04 +01:00
|
|
|
extern RendererHUDBar* g_HealthBar;
|
2020-01-12 23:10:38 +01:00
|
|
|
extern RendererHUDBar* g_DashBar;
|
|
|
|
extern RendererHUDBar* g_AirBar;
|
2020-01-04 13:26:22 +01:00
|
|
|
|
|
|
|
void DrawHealthBarOverlay(int value)
|
|
|
|
{
|
|
|
|
if (CurrentLevel)
|
|
|
|
{
|
|
|
|
int color2 = 0;
|
|
|
|
if (Lara.poisoned || Lara.gassed)
|
|
|
|
color2 = 0xA0A000;
|
|
|
|
else
|
|
|
|
color2 = 0xA00000;
|
2020-01-12 17:28:04 +01:00
|
|
|
g_Renderer->DrawBar(value, g_HealthBar);
|
2020-01-04 13:26:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-13 00:02:32 +01:00
|
|
|
void DrawHealthBar(float value)
|
2020-01-04 13:26:22 +01:00
|
|
|
{
|
|
|
|
if (CurrentLevel)
|
|
|
|
{
|
2020-01-12 17:28:04 +01:00
|
|
|
//int color2;
|
|
|
|
//if (Lara.poisoned || Lara.gassed)
|
|
|
|
// color2 = 0xA0A000;
|
|
|
|
//else
|
|
|
|
// color2 = 0xA00000;
|
|
|
|
g_Renderer->DrawBar(value,g_HealthBar);
|
2020-01-04 13:26:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateHealtBar(int flash)
|
|
|
|
{
|
|
|
|
int hitPoints = LaraItem->hitPoints;
|
|
|
|
|
|
|
|
if (hitPoints < 0)
|
|
|
|
hitPoints = 0;
|
|
|
|
else if (hitPoints > 1000)
|
|
|
|
hitPoints = 1000;
|
|
|
|
|
|
|
|
if (OldHitPoints != hitPoints)
|
|
|
|
{
|
|
|
|
OldHitPoints = hitPoints;
|
|
|
|
HealtBarTimer = 40;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HealtBarTimer < 0)
|
|
|
|
HealtBarTimer = 0;
|
|
|
|
|
|
|
|
if (hitPoints <= 1000 / 4)
|
|
|
|
{
|
|
|
|
if (!BinocularRange)
|
|
|
|
{
|
|
|
|
if (flash)
|
2020-01-13 19:51:08 +01:00
|
|
|
DrawHealthBar(hitPoints / 1000.0f);
|
2020-01-04 13:26:22 +01:00
|
|
|
else
|
|
|
|
DrawHealthBar(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (flash)
|
2020-01-13 19:51:08 +01:00
|
|
|
DrawHealthBarOverlay(hitPoints / 1000.0f);
|
2020-01-04 13:26:22 +01:00
|
|
|
else
|
|
|
|
DrawHealthBarOverlay(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((HealtBarTimer > 0)
|
|
|
|
|| (hitPoints <= 0)
|
|
|
|
|| (Lara.gunStatus == LG_READY && Lara.gunType != WEAPON_TORCH)
|
|
|
|
|| (Lara.poisoned >= 256))
|
|
|
|
{
|
|
|
|
if (!BinocularRange && !SniperOverlay)
|
|
|
|
{
|
2020-01-13 00:02:32 +01:00
|
|
|
DrawHealthBar(hitPoints / 1000.0f);
|
2020-01-04 13:26:22 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-13 00:02:32 +01:00
|
|
|
DrawHealthBarOverlay(hitPoints / 1000.0f);
|
2020-01-04 13:26:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PoisonFlag)
|
|
|
|
PoisonFlag--;
|
|
|
|
}
|
|
|
|
|
2020-01-13 00:02:32 +01:00
|
|
|
void DrawAirBar(float value)
|
2018-08-19 09:46:58 +02:00
|
|
|
{
|
2020-01-04 13:26:22 +01:00
|
|
|
if (CurrentLevel)
|
|
|
|
{
|
2020-01-12 23:10:38 +01:00
|
|
|
g_Renderer->DrawBar(value, g_AirBar);
|
2020-01-04 13:26:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateAirBar(int flash)
|
|
|
|
{
|
|
|
|
if (Lara.air == 1800 || LaraItem->hitPoints <= 0)
|
|
|
|
return;
|
|
|
|
|
2020-04-27 14:01:00 +02:00
|
|
|
if ((Lara.Vehicle == NO_ITEM)
|
|
|
|
|| (Items[Lara.Vehicle].objectNumber != ID_UPV))
|
2020-01-04 13:26:22 +01:00
|
|
|
{
|
|
|
|
if ((Lara.waterStatus != LW_UNDERWATER)
|
|
|
|
&& (Lara.waterStatus != LW_SURFACE)
|
|
|
|
&& (!((Rooms[LaraItem->roomNumber].flags & ENV_FLAG_SWAMP)
|
|
|
|
&& (Lara.waterSurfaceDist < -775))))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int air = Lara.air;
|
|
|
|
if (air < 0)
|
|
|
|
air = 0;
|
|
|
|
else if (air > 1800)
|
|
|
|
air = 1800;
|
|
|
|
if (air <= 450)
|
|
|
|
{
|
|
|
|
if (flash)
|
2020-01-12 17:28:04 +01:00
|
|
|
DrawAirBar(air/ 1800.0f);
|
2020-01-04 13:26:22 +01:00
|
|
|
else
|
|
|
|
DrawAirBar(0);
|
|
|
|
}
|
|
|
|
else
|
2020-01-12 17:28:04 +01:00
|
|
|
DrawAirBar(air / 1800.0f);
|
2020-01-04 13:26:22 +01:00
|
|
|
|
|
|
|
if (Lara.gassed)
|
|
|
|
{
|
|
|
|
if (Lara.dpoisoned < 2048)
|
|
|
|
Lara.dpoisoned += 2;
|
|
|
|
Lara.gassed = false;
|
|
|
|
}
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|
|
|
|
|
2020-01-04 13:26:22 +01:00
|
|
|
void DrawDashBar(int value)
|
2018-08-19 09:46:58 +02:00
|
|
|
{
|
2020-01-04 13:26:22 +01:00
|
|
|
if (CurrentLevel)
|
|
|
|
{
|
2020-01-12 23:10:38 +01:00
|
|
|
g_Renderer->DrawBar(value, g_DashBar);
|
2020-01-04 13:26:22 +01:00
|
|
|
}
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
int DrawAllPickups()
|
2019-11-14 20:15:29 +01:00
|
|
|
{
|
|
|
|
if (Pickups[CurrentPickup].life > 0)
|
|
|
|
{
|
|
|
|
if (PickupX > 0)
|
|
|
|
{
|
|
|
|
PickupX += -PickupX >> 5;
|
|
|
|
return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Pickups[CurrentPickup].life--;
|
|
|
|
return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (Pickups[CurrentPickup].life == 0)
|
|
|
|
{
|
|
|
|
if (PickupX < 128)
|
|
|
|
{
|
|
|
|
if (PickupVel < 16)
|
|
|
|
PickupVel++;
|
|
|
|
PickupX += PickupVel >> 2;
|
|
|
|
return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Pickups[CurrentPickup].life = -1;
|
|
|
|
PickupVel = 0;
|
|
|
|
return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
int pickupIndex = CurrentPickup;
|
2020-01-12 12:58:50 -03:00
|
|
|
int i;
|
2020-01-13 07:38:46 +01:00
|
|
|
for (i = 0; i < MAX_COLLECTED_PICKUPS; ++i)
|
2019-11-14 20:15:29 +01:00
|
|
|
{
|
|
|
|
if (Pickups[pickupIndex].life > 0)
|
|
|
|
break;
|
2020-01-13 07:38:46 +01:00
|
|
|
pickupIndex = pickupIndex + 1 & MAX_COLLECTED_PICKUPS - 1;
|
2020-01-12 12:58:50 -03:00
|
|
|
}
|
2019-11-14 20:15:29 +01:00
|
|
|
|
|
|
|
CurrentPickup = pickupIndex;
|
2020-01-13 07:38:46 +01:00
|
|
|
if (i != MAX_COLLECTED_PICKUPS)
|
2019-11-14 20:15:29 +01:00
|
|
|
return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber);
|
|
|
|
|
|
|
|
CurrentPickup = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void AddDisplayPickup(short objectNumber)
|
2019-11-14 20:15:29 +01:00
|
|
|
{
|
2020-01-13 07:38:46 +01:00
|
|
|
for (int i = 0; i < MAX_COLLECTED_PICKUPS; i++)
|
2019-11-14 20:15:29 +01:00
|
|
|
{
|
|
|
|
DISPLAY_PICKUP* pickup = &Pickups[i];
|
|
|
|
if (pickup->life < 0)
|
|
|
|
{
|
|
|
|
pickup->life = 45;
|
|
|
|
pickup->objectNumber = objectNumber;
|
|
|
|
PickedUpObject(objectNumber);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No free slot found, so just pickup the object ithout displaying it
|
|
|
|
PickedUpObject(objectNumber);
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void InitialisePickupDisplay()
|
2019-11-14 20:15:29 +01:00
|
|
|
{
|
2020-01-13 07:38:46 +01:00
|
|
|
for (int i = 0; i < MAX_COLLECTED_PICKUPS; i++)
|
2019-11-14 20:15:29 +01:00
|
|
|
{
|
|
|
|
DISPLAY_PICKUP* pickup = &Pickups[i];
|
|
|
|
pickup->life = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
PickupX = 128;
|
|
|
|
PickupY = 128;
|
|
|
|
PickupVel = 0;
|
|
|
|
CurrentPickup = 0;
|
|
|
|
}
|
|
|
|
|
2020-01-04 13:26:22 +01:00
|
|
|
int FlashIt()
|
|
|
|
{
|
|
|
|
if (FlashCount)
|
|
|
|
FlashCount--;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FlashState ^= 1;
|
|
|
|
FlashCount = 5;
|
|
|
|
}
|
|
|
|
return FlashState;
|
|
|
|
}
|