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"
|
2019-11-14 20:15:29 +01:00
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
short PickupX;
|
|
|
|
short PickupY;
|
|
|
|
short CurrentPickup;
|
2019-11-14 20:15:29 +01:00
|
|
|
DISPLAY_PICKUP Pickups[NUM_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;
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2020-01-04 13:26:22 +01:00
|
|
|
extern LaraExtraInfo g_LaraExtra;
|
|
|
|
|
|
|
|
void DrawHealthBarOverlay(int value)
|
|
|
|
{
|
|
|
|
if (CurrentLevel)
|
|
|
|
{
|
|
|
|
int color2 = 0;
|
|
|
|
if (Lara.poisoned || Lara.gassed)
|
|
|
|
color2 = 0xA0A000;
|
|
|
|
else
|
|
|
|
color2 = 0xA00000;
|
|
|
|
g_Renderer->DrawBar(245, 32, 150, 12, value, 0xA00000, color2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawHealthBar(int value)
|
|
|
|
{
|
|
|
|
if (CurrentLevel)
|
|
|
|
{
|
|
|
|
int color2;
|
|
|
|
if (Lara.poisoned || Lara.gassed)
|
|
|
|
color2 = 0xA0A000;
|
|
|
|
else
|
|
|
|
color2 = 0xA00000;
|
|
|
|
g_Renderer->DrawBar(20, 32, 150, 12, value, 0xA00000, color2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
DrawHealthBar(hitPoints / 10);
|
|
|
|
else
|
|
|
|
DrawHealthBar(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (flash)
|
|
|
|
DrawHealthBarOverlay(hitPoints / 10);
|
|
|
|
else
|
|
|
|
DrawHealthBarOverlay(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((HealtBarTimer > 0)
|
|
|
|
|| (hitPoints <= 0)
|
|
|
|
|| (Lara.gunStatus == LG_READY && Lara.gunType != WEAPON_TORCH)
|
|
|
|
|| (Lara.poisoned >= 256))
|
|
|
|
{
|
|
|
|
if (!BinocularRange && !SniperOverlay)
|
|
|
|
{
|
|
|
|
DrawHealthBar(hitPoints / 10);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawHealthBarOverlay(hitPoints / 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PoisonFlag)
|
|
|
|
PoisonFlag--;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawAirBar(int value)
|
2018-08-19 09:46:58 +02:00
|
|
|
{
|
2020-01-04 13:26:22 +01:00
|
|
|
if (CurrentLevel)
|
|
|
|
{
|
|
|
|
g_Renderer->DrawBar(20, 10, 150, 12, value, 0x0000A0, 0x0050A0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateAirBar(int flash)
|
|
|
|
{
|
|
|
|
if (Lara.air == 1800 || LaraItem->hitPoints <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((g_LaraExtra.Vehicle == NO_ITEM)
|
|
|
|
|| (Items[g_LaraExtra.Vehicle].objectNumber != ID_UPV))
|
|
|
|
{
|
|
|
|
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)
|
|
|
|
DrawAirBar((air * 100) / 1800);
|
|
|
|
else
|
|
|
|
DrawAirBar(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DrawAirBar((air * 100) / 1800);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
g_Renderer->DrawBar(630, 32, 150, 12, value, 0xA0A000, 0x00A000);
|
|
|
|
}
|
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;
|
|
|
|
int i = 0;
|
2019-11-14 20:15:29 +01:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (Pickups[pickupIndex].life > 0)
|
|
|
|
break;
|
|
|
|
pickupIndex = (pickupIndex + 1) & 7;
|
|
|
|
i++;
|
|
|
|
} while (i < 8);
|
|
|
|
|
|
|
|
CurrentPickup = pickupIndex;
|
|
|
|
if (i != 8)
|
|
|
|
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
|
|
|
{
|
2019-11-27 15:12:35 +01:00
|
|
|
for (int i = 0; i < 8; 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
|
|
|
{
|
2019-11-27 15:12:35 +01:00
|
|
|
for (int i = 0; i < 8; 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;
|
|
|
|
}
|
|
|
|
|
2018-08-19 09:46:58 +02:00
|
|
|
void Inject_Healt()
|
|
|
|
{
|
2020-01-04 13:26:22 +01:00
|
|
|
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|