2020-08-15 15:16:08 -05:00
|
|
|
#include "framework.h"
|
|
|
|
#include "lara.h"
|
|
|
|
#include "lara_initialise.h"
|
2021-11-07 04:54:48 +03:00
|
|
|
#include "lara_tests.h"
|
2020-08-15 15:16:08 -05:00
|
|
|
#include "health.h"
|
2021-08-28 13:27:58 +02:00
|
|
|
#include "items.h"
|
|
|
|
#include "setup.h"
|
|
|
|
#include "level.h"
|
2021-09-16 03:56:04 +03:00
|
|
|
|
2020-08-15 15:16:08 -05:00
|
|
|
void InitialiseLara(int restore)
|
|
|
|
{
|
|
|
|
if (Lara.itemNumber == NO_ITEM)
|
|
|
|
return;
|
|
|
|
|
|
|
|
short itemNumber = Lara.itemNumber;
|
|
|
|
|
2021-09-16 03:56:04 +03:00
|
|
|
LaraItem->data = &Lara;
|
2020-08-15 15:16:08 -05:00
|
|
|
LaraItem->collidable = false;
|
2021-01-07 11:16:21 -03:00
|
|
|
LaraItem->location.roomNumber = LaraItem->roomNumber;
|
|
|
|
LaraItem->location.yNumber = LaraItem->pos.yPos;
|
2020-08-15 15:16:08 -05:00
|
|
|
|
|
|
|
if (restore)
|
|
|
|
{
|
|
|
|
LaraInfo backup;
|
|
|
|
memcpy(&backup, &Lara, sizeof(LaraInfo));
|
|
|
|
ZeroMemory(&Lara, sizeof(LaraInfo));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ZeroMemory(&Lara, sizeof(LaraInfo));
|
|
|
|
Lara.ExtraAnim = NO_ITEM;
|
|
|
|
Lara.Vehicle = NO_ITEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
Lara.look = true;
|
|
|
|
Lara.itemNumber = itemNumber;
|
|
|
|
Lara.hitDirection = -1;
|
2021-11-10 16:11:36 +11:00
|
|
|
Lara.air = LARA_AIR_MAX;
|
2020-08-15 15:16:08 -05:00
|
|
|
Lara.weaponItem = NO_ITEM;
|
|
|
|
PoisonFlag = 0;
|
|
|
|
Lara.poisoned = 0;
|
|
|
|
Lara.waterSurfaceDist = 100;
|
|
|
|
if (Lara.Weapons[static_cast<int>(LARA_WEAPON_TYPE::WEAPON_PISTOLS)].Present) {
|
|
|
|
Lara.holsterInfo.leftHolster = HOLSTER_SLOT::Pistols;
|
|
|
|
Lara.holsterInfo.rightHolster = HOLSTER_SLOT::Pistols;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Lara.holsterInfo.leftHolster = HOLSTER_SLOT::Empty;
|
|
|
|
Lara.holsterInfo.rightHolster = HOLSTER_SLOT::Empty;
|
|
|
|
}
|
|
|
|
if (Lara.Weapons[static_cast<int>(LARA_WEAPON_TYPE::WEAPON_SHOTGUN)].Present) {
|
|
|
|
Lara.holsterInfo.backHolster = HOLSTER_SLOT::Shotgun;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Lara.holsterInfo.backHolster = HOLSTER_SLOT::Empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Lara.location = -1;
|
|
|
|
Lara.highestLocation = -1;
|
|
|
|
Lara.ropePtr = -1;
|
2021-11-10 16:11:36 +11:00
|
|
|
LaraItem->hitPoints = LARA_HEALTH_MAX;
|
2020-08-15 15:16:08 -05:00
|
|
|
Lara.gunStatus = LG_NO_ARMS;
|
2021-07-08 14:15:14 -05:00
|
|
|
memset(&Lara.NewAnims, 0, sizeof(AnimsNew)); //make sure script changes these AFTER Lara is initialized?
|
2020-08-15 15:16:08 -05:00
|
|
|
|
|
|
|
LARA_WEAPON_TYPE gun = WEAPON_NONE;
|
|
|
|
|
|
|
|
if (Objects[ID_HK_ITEM].loaded)
|
|
|
|
gun = WEAPON_HK;
|
|
|
|
|
|
|
|
if (Objects[ID_PISTOLS_ITEM].loaded)
|
|
|
|
gun = WEAPON_PISTOLS;
|
|
|
|
|
|
|
|
Lara.lastGunType = Lara.gunType = Lara.requestGunType = gun;
|
|
|
|
|
|
|
|
LaraInitialiseMeshes();
|
|
|
|
|
|
|
|
if (gun == WEAPON_PISTOLS)
|
|
|
|
{
|
|
|
|
Lara.Weapons[WEAPON_PISTOLS].Present = true;
|
2021-01-26 10:03:59 +01:00
|
|
|
Lara.Weapons[WEAPON_PISTOLS].Ammo[WEAPON_AMMO1].setInfinite(true);
|
2020-08-15 15:16:08 -05:00
|
|
|
}
|
|
|
|
else if (gun == WEAPON_HK)
|
|
|
|
{
|
|
|
|
Lara.Weapons[WEAPON_HK].Present = true;
|
|
|
|
Lara.Weapons[WEAPON_HK].Ammo[WEAPON_AMMO1] = 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
Lara.Binoculars = true;
|
|
|
|
|
|
|
|
if (!restore)
|
|
|
|
{
|
|
|
|
if (Objects[ID_FLARE_INV_ITEM].loaded)
|
|
|
|
Lara.NumFlares = 3;
|
|
|
|
|
|
|
|
Lara.NumSmallMedipacks = 3;
|
|
|
|
Lara.NumLargeMedipacks = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
InitialiseLaraAnims(LaraItem);
|
2021-05-27 16:07:57 -05:00
|
|
|
Lara.BeetleLife = 3;
|
2021-11-10 16:11:36 +11:00
|
|
|
Lara.sprintTimer = LARA_SPRINT_MAX;
|
2020-08-15 15:16:08 -05:00
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void LaraInitialiseMeshes()
|
2020-08-15 15:16:08 -05:00
|
|
|
{
|
|
|
|
for (int i = 0; i < NUM_LARA_MESHES; i++)
|
|
|
|
{
|
|
|
|
//Meshes[i] = Meshes[MESHES(ID_LARA_SKIN, i)];
|
|
|
|
//LARA_MESHES(ID_LARA, MESHES(ID_LARA_SKIN, i));
|
|
|
|
Lara.meshPtrs[i] = Objects[ID_LARA_SKIN].meshIndex + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Hardcoded code */
|
|
|
|
|
|
|
|
if (Lara.gunType == WEAPON_HK)
|
|
|
|
{
|
|
|
|
Lara.holsterInfo.backHolster = HOLSTER_SLOT::HK;
|
|
|
|
}
|
|
|
|
else if (!Lara.Weapons[WEAPON_SHOTGUN].Present)
|
|
|
|
{
|
|
|
|
if (Lara.Weapons[WEAPON_HK].Present)
|
|
|
|
Lara.holsterInfo.backHolster = HOLSTER_SLOT::HK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-06 12:25:11 -05:00
|
|
|
Lara.holsterInfo.backHolster = HOLSTER_SLOT::Empty;
|
2020-08-15 15:16:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Lara.gunStatus = LG_NO_ARMS;
|
|
|
|
Lara.leftArm.frameNumber = 0;
|
|
|
|
Lara.rightArm.frameNumber = 0;
|
|
|
|
Lara.target = NULL;
|
|
|
|
Lara.rightArm.lock = false;
|
|
|
|
Lara.leftArm.lock = false;
|
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void InitialiseLaraAnims(ITEM_INFO* item)
|
2020-08-15 15:16:08 -05:00
|
|
|
{
|
2021-11-07 04:54:48 +03:00
|
|
|
if (TestLaraWater(item))
|
2020-08-15 15:16:08 -05:00
|
|
|
{
|
|
|
|
Lara.waterStatus = LW_UNDERWATER;
|
|
|
|
item->fallspeed = 0;
|
2021-11-16 17:25:17 +03:00
|
|
|
SetAnimation(item, LA_UNDERWATER_IDLE);
|
2020-08-15 15:16:08 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Lara.waterStatus = LW_ABOVE_WATER;
|
2021-11-16 17:25:17 +03:00
|
|
|
SetAnimation(item, LA_STAND_SOLID);
|
2020-08-15 15:16:08 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void InitialiseLaraLoad(short itemNum)
|
2020-08-15 15:16:08 -05:00
|
|
|
{
|
|
|
|
Lara.itemNumber = itemNum;
|
|
|
|
LaraItem = &g_Level.Items[itemNum];
|
|
|
|
}
|