2020-12-21 13:16:29 -03:00
|
|
|
#include "framework.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Game/control/control.h"
|
|
|
|
|
2021-09-15 17:40:00 +03:00
|
|
|
#include <process.h>
|
2021-12-22 16:23:57 +03:00
|
|
|
#include "Game/collision/collide_room.h"
|
|
|
|
#include "Game/pickup/pickup.h"
|
|
|
|
#include "Game/camera.h"
|
|
|
|
#include "Game/Lara/lara.h"
|
|
|
|
#include "Game/items.h"
|
|
|
|
#include "Game/control/flipeffect.h"
|
|
|
|
#include "Game/gui.h"
|
|
|
|
#include "Game/control/lot.h"
|
|
|
|
#include "Game/health.h"
|
|
|
|
#include "Game/savegame.h"
|
|
|
|
#include "Game/room.h"
|
2021-12-14 15:07:04 +03:00
|
|
|
#include "Game/effects/hair.h"
|
|
|
|
#include "Game/effects/effects.h"
|
|
|
|
#include "Game/effects/tomb4fx.h"
|
|
|
|
#include "Game/effects/debris.h"
|
|
|
|
#include "Game/effects/footprint.h"
|
|
|
|
#include "Game/effects/smoke.h"
|
|
|
|
#include "Game/effects/spark.h"
|
|
|
|
#include "Game/effects/explosion.h"
|
|
|
|
#include "Game/effects/drip.h"
|
|
|
|
#include "Game/effects/weather.h"
|
|
|
|
#include "Game/effects/lightning.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Game/spotcam.h"
|
2021-12-22 16:23:57 +03:00
|
|
|
#include "Game/particle/SimpleParticle.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Game/collision/sphere.h"
|
2021-12-22 16:23:57 +03:00
|
|
|
#include "Game/Lara/lara_one_gun.h"
|
|
|
|
#include "Game/Lara/lara_cheat.h"
|
|
|
|
#include "Game/Lara/lara_helpers.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Objects/Effects/tr4_locusts.h"
|
|
|
|
#include "Objects/Generic/Object/objects.h"
|
|
|
|
#include "Objects/Generic/Switches/generic_switch.h"
|
2022-03-06 01:26:27 +11:00
|
|
|
#include "Objects/TR4/Entity/tr4_beetle_swarm.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Objects/TR5/Emitter/tr5_rats_emitter.h"
|
|
|
|
#include "Objects/TR5/Emitter/tr5_bats_emitter.h"
|
|
|
|
#include "Objects/TR5/Emitter/tr5_spider_emitter.h"
|
|
|
|
#include "Sound/sound.h"
|
|
|
|
#include "Specific/clock.h"
|
|
|
|
#include "Specific/input.h"
|
|
|
|
#include "Specific/level.h"
|
|
|
|
#include "Specific/setup.h"
|
|
|
|
#include "Specific/prng.h"
|
|
|
|
#include "Specific/winmain.h"
|
2021-09-16 01:12:19 +03:00
|
|
|
#include "Scripting/GameFlowScript.h"
|
2021-09-25 11:27:47 +02:00
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
using std::vector;
|
2021-06-26 07:36:54 +02:00
|
|
|
using std::unordered_map;
|
|
|
|
using std::string;
|
2021-09-14 01:22:08 +03:00
|
|
|
|
|
|
|
using namespace TEN::Effects::Footprints;
|
2021-08-30 18:03:21 +03:00
|
|
|
using namespace TEN::Effects::Explosion;
|
|
|
|
using namespace TEN::Effects::Spark;
|
|
|
|
using namespace TEN::Effects::Smoke;
|
2021-10-08 13:58:51 +03:00
|
|
|
using namespace TEN::Effects::Drip;
|
2021-11-22 19:14:29 +03:00
|
|
|
using namespace TEN::Effects::Lightning;
|
2021-09-15 11:13:47 +03:00
|
|
|
using namespace TEN::Effects::Environment;
|
2021-08-30 18:03:21 +03:00
|
|
|
using namespace TEN::Effects;
|
2021-09-14 01:22:08 +03:00
|
|
|
using namespace TEN::Entities::Switches;
|
2021-11-22 19:14:29 +03:00
|
|
|
using namespace TEN::Entities::TR4;
|
2021-09-14 01:22:08 +03:00
|
|
|
using namespace TEN::Renderer;
|
2021-08-30 18:03:21 +03:00
|
|
|
using namespace TEN::Math::Random;
|
|
|
|
using namespace TEN::Floordata;
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2021-09-15 21:09:09 +03:00
|
|
|
int GameTimer = 0;
|
2021-10-22 16:33:15 +03:00
|
|
|
int GlobalCounter = 0;
|
2021-09-15 21:09:09 +03:00
|
|
|
int Wibble = 0;
|
|
|
|
|
|
|
|
bool InitialiseGame;
|
|
|
|
bool DoTheGame;
|
|
|
|
bool JustLoaded;
|
|
|
|
bool ThreadEnded;
|
|
|
|
|
|
|
|
int RequiredStartPos;
|
|
|
|
int CurrentLevel;
|
|
|
|
int LevelComplete;
|
|
|
|
|
|
|
|
bool InItemControlLoop;
|
2020-12-21 13:16:29 -03:00
|
|
|
short ItemNewRoomNo;
|
2021-10-27 08:35:11 +02:00
|
|
|
short ItemNewRooms[MAX_ROOMS];
|
2020-12-21 13:16:29 -03:00
|
|
|
short NextItemActive;
|
|
|
|
short NextItemFree;
|
2021-09-15 21:09:09 +03:00
|
|
|
short NextFxActive;
|
|
|
|
short NextFxFree;
|
|
|
|
|
2021-09-15 22:43:19 +03:00
|
|
|
int WeaponDelay;
|
|
|
|
int WeaponEnemyTimer;
|
|
|
|
|
2021-09-16 05:06:03 +03:00
|
|
|
int DrawPhase()
|
|
|
|
{
|
|
|
|
g_Renderer.Draw();
|
|
|
|
Camera.numberFrames = g_Renderer.SyncRenderer();
|
|
|
|
return Camera.numberFrames;
|
|
|
|
}
|
|
|
|
|
2022-03-14 22:44:10 +11:00
|
|
|
GameStatus ControlPhase(int numFrames, int demoMode)
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
|
|
|
short oldLaraFrame;
|
2022-03-14 15:18:11 +11:00
|
|
|
auto* level = g_GameFlow->GetLevel(CurrentLevel);
|
2020-12-21 13:16:29 -03:00
|
|
|
|
|
|
|
RegeneratePickups();
|
|
|
|
|
|
|
|
if (numFrames > 10)
|
|
|
|
numFrames = 10;
|
|
|
|
|
|
|
|
if (TrackCameraInit)
|
|
|
|
UseSpotCam = false;
|
|
|
|
|
|
|
|
SetDebounce = true;
|
|
|
|
|
2021-09-16 01:12:19 +03:00
|
|
|
g_GameScript->ProcessDisplayStrings(DELTA_TIME);
|
2021-08-30 18:44:21 +01:00
|
|
|
|
2021-12-14 15:07:04 +03:00
|
|
|
static int framesCount = 0;
|
|
|
|
for (framesCount += numFrames; framesCount > 0; framesCount -= 2)
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
|
|
|
GlobalCounter++;
|
|
|
|
|
2021-08-12 18:20:14 +01:00
|
|
|
// This might not be the exact amount of time that has passed, but giving it a
|
|
|
|
// value of 1/30 keeps it in lock-step with the rest of the game logic,
|
|
|
|
// which assumes 30 iterations per second.
|
2021-09-16 01:12:19 +03:00
|
|
|
g_GameScript->OnControlPhase(DELTA_TIME);
|
2020-12-21 13:16:29 -03:00
|
|
|
|
|
|
|
// Poll the keyboard and update input variables
|
|
|
|
if (CurrentLevel != 0)
|
|
|
|
{
|
|
|
|
if (S_UpdateInput() == -1)
|
2022-03-14 22:44:10 +11:00
|
|
|
return GameStatus::None;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Has Lara control been disabled?
|
2022-02-10 16:18:15 +11:00
|
|
|
if (Lara.Control.Locked || CurrentLevel == 0)
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
|
|
|
if (CurrentLevel != 0)
|
|
|
|
DbInput = 0;
|
2021-08-02 12:35:17 +03:00
|
|
|
TrInput &= IN_LOOK;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Does the player want to enter inventory?
|
|
|
|
SetDebounce = false;
|
2021-08-02 12:35:17 +03:00
|
|
|
|
2021-05-18 19:16:58 -05:00
|
|
|
if (CurrentLevel != 0 && !g_Renderer.isFading())
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (TrInput & IN_SAVE && LaraItem->HitPoints > 0 && g_Gui.GetInventoryMode() != InventoryMode::Save)
|
2021-10-12 15:05:07 -05:00
|
|
|
{
|
2021-10-29 02:22:26 +03:00
|
|
|
StopAllSounds();
|
2021-10-12 15:05:07 -05:00
|
|
|
|
2021-11-16 15:51:50 +03:00
|
|
|
g_Gui.SetInventoryMode(InventoryMode::Save);
|
2021-10-12 04:15:22 -05:00
|
|
|
|
2021-11-16 15:51:50 +03:00
|
|
|
if (g_Gui.CallInventory(false))
|
2022-03-14 22:44:10 +11:00
|
|
|
return GameStatus::LoadGame;
|
2021-10-12 15:05:07 -05:00
|
|
|
}
|
2021-11-16 15:51:50 +03:00
|
|
|
else if (TrInput & IN_LOAD && g_Gui.GetInventoryMode() != InventoryMode::Load)
|
2021-10-12 15:05:07 -05:00
|
|
|
{
|
2021-10-29 02:22:26 +03:00
|
|
|
StopAllSounds();
|
2021-10-12 15:05:07 -05:00
|
|
|
|
2021-11-16 15:51:50 +03:00
|
|
|
g_Gui.SetInventoryMode(InventoryMode::Load);
|
2021-10-12 15:05:07 -05:00
|
|
|
|
2021-11-16 15:51:50 +03:00
|
|
|
if (g_Gui.CallInventory(false))
|
2022-03-14 22:44:10 +11:00
|
|
|
return GameStatus::LoadGame;
|
2021-10-12 15:05:07 -05:00
|
|
|
}
|
2022-02-09 16:55:46 +11:00
|
|
|
else if (TrInput & IN_PAUSE && g_Gui.GetInventoryMode() != InventoryMode::Pause && LaraItem->HitPoints > 0)
|
2021-05-18 19:16:58 -05:00
|
|
|
{
|
2021-10-29 02:22:26 +03:00
|
|
|
StopAllSounds();
|
2021-05-18 19:16:58 -05:00
|
|
|
g_Renderer.DumpGameScene();
|
2021-11-16 15:51:50 +03:00
|
|
|
g_Gui.SetInventoryMode(InventoryMode::Pause);
|
|
|
|
g_Gui.SetMenuToDisplay(Menu::Pause);
|
|
|
|
g_Gui.SetSelectedOption(0);
|
2021-05-18 19:16:58 -05:00
|
|
|
}
|
2022-02-09 16:55:46 +11:00
|
|
|
else if ((DbInput & IN_DESELECT || g_Gui.GetEnterInventory() != NO_ITEM) && LaraItem->HitPoints > 0)
|
2021-05-18 19:16:58 -05:00
|
|
|
{
|
|
|
|
// Stop all sounds
|
2021-10-29 02:22:26 +03:00
|
|
|
StopAllSounds();
|
2021-05-18 19:16:58 -05:00
|
|
|
|
2021-11-16 15:51:50 +03:00
|
|
|
if (g_Gui.CallInventory(true))
|
2022-03-14 22:44:10 +11:00
|
|
|
return GameStatus::LoadGame;
|
2021-05-18 19:16:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-16 15:51:50 +03:00
|
|
|
while (g_Gui.GetInventoryMode() == InventoryMode::Pause)
|
2021-05-18 19:16:58 -05:00
|
|
|
{
|
2021-11-16 15:51:50 +03:00
|
|
|
g_Gui.DrawInventory();
|
2021-05-18 19:16:58 -05:00
|
|
|
g_Renderer.SyncRenderer();
|
|
|
|
|
2021-11-16 15:51:50 +03:00
|
|
|
if (g_Gui.DoPauseMenu() == InventoryResult::ExitToTitle)
|
2022-03-14 22:44:10 +11:00
|
|
|
return GameStatus::ExitToTitle;
|
2021-05-18 19:16:58 -05:00
|
|
|
}
|
2020-12-21 13:16:29 -03:00
|
|
|
|
|
|
|
// Has level been completed?
|
|
|
|
if (CurrentLevel != 0 && LevelComplete)
|
2022-03-14 22:44:10 +11:00
|
|
|
return GameStatus::LevelComplete;
|
2020-12-21 13:16:29 -03:00
|
|
|
|
|
|
|
int oldInput = TrInput;
|
|
|
|
|
|
|
|
// Is Lara dead?
|
2022-02-11 19:26:08 +11:00
|
|
|
if (CurrentLevel != 0 && (Lara.Control.Count.Death > 300 || Lara.Control.Count.Death > 60 && TrInput))
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
2022-03-14 22:44:10 +11:00
|
|
|
return GameStatus::ExitToTitle; // Maybe do game over menu like some PSX versions have??
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (demoMode && TrInput == -1)
|
|
|
|
{
|
|
|
|
oldInput = 0;
|
|
|
|
TrInput = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CurrentLevel == 0)
|
|
|
|
TrInput = 0;
|
|
|
|
|
|
|
|
// Handle lasersight and binocular
|
|
|
|
if (CurrentLevel != 0)
|
|
|
|
{
|
2021-11-04 20:23:26 +03:00
|
|
|
if (!(TrInput & IN_LOOK) || UseSpotCam || TrackCameraInit ||
|
2022-03-13 02:04:24 +11:00
|
|
|
((LaraItem->Animation.ActiveState != LS_IDLE || LaraItem->Animation.AnimNumber != LA_STAND_IDLE) && (!Lara.Control.IsLow || TrInput & IN_CROUCH || LaraItem->Animation.AnimNumber != LA_CROUCH_IDLE || LaraItem->Animation.TargetState != LS_CROUCH_IDLE)))
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
|
|
|
if (BinocularRange == 0)
|
|
|
|
{
|
2021-11-04 20:23:26 +03:00
|
|
|
if (UseSpotCam || TrackCameraInit)
|
2020-12-21 13:16:29 -03:00
|
|
|
TrInput &= ~IN_LOOK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-02 12:35:17 +03:00
|
|
|
// If any input but optic controls (directions + action), immediately exit binoculars mode.
|
|
|
|
if (TrInput != IN_NONE && ((TrInput & ~IN_OPTIC_CONTROLS) != IN_NONE))
|
|
|
|
BinocularRange = 0;
|
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
if (LaserSight)
|
|
|
|
{
|
|
|
|
BinocularRange = 0;
|
|
|
|
LaserSight = false;
|
|
|
|
AlterFOV(ANGLE(80));
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraItem->MeshBits = 0xFFFFFFFF;
|
2022-03-10 00:29:28 +11:00
|
|
|
Lara.Inventory.IsBusy = false;
|
2020-12-21 13:16:29 -03:00
|
|
|
Camera.type = BinocularOldCamera;
|
|
|
|
|
2021-12-14 15:07:04 +03:00
|
|
|
ResetLaraFlex(LaraItem);
|
2020-12-21 13:16:29 -03:00
|
|
|
|
|
|
|
Camera.bounce = 0;
|
|
|
|
BinocularOn = -8;
|
|
|
|
|
|
|
|
TrInput &= ~IN_LOOK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TrInput |= IN_LOOK;
|
2021-08-02 12:35:17 +03:00
|
|
|
DbInput = 0;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (BinocularRange == 0)
|
|
|
|
{
|
2022-03-09 20:37:26 +11:00
|
|
|
if (Lara.Control.HandStatus == HandStatus::WeaponReady && ((Lara.Control.Weapon.GunType == LaraWeaponType::Revolver && Lara.Weapons[(int)LaraWeaponType::Revolver].HasLasersight) ||
|
|
|
|
(Lara.Control.Weapon.GunType == LaraWeaponType::HK) ||
|
|
|
|
(Lara.Control.Weapon.GunType == LaraWeaponType::Crossbow && Lara.Weapons[(int)LaraWeaponType::Crossbow].HasLasersight)))
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
|
|
|
BinocularRange = 128;
|
|
|
|
BinocularOldCamera = Camera.oldType;
|
|
|
|
|
2022-03-10 00:29:28 +11:00
|
|
|
Lara.Inventory.IsBusy = true;
|
2020-12-21 13:16:29 -03:00
|
|
|
LaserSight = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update all items
|
|
|
|
InItemControlLoop = true;
|
|
|
|
|
2022-03-14 15:18:11 +11:00
|
|
|
short itemNumber = NextItemActive;
|
|
|
|
while (itemNumber != NO_ITEM)
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
2022-03-14 15:18:11 +11:00
|
|
|
auto* item = &g_Level.Items[itemNumber];
|
2022-02-09 16:55:46 +11:00
|
|
|
short nextItem = item->NextActive;
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->AfterDeath <= 128)
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (Objects[item->ObjectNumber].control)
|
2022-03-14 15:18:11 +11:00
|
|
|
Objects[item->ObjectNumber].control(itemNumber);
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->AfterDeath > 0 && item->AfterDeath < 128 && !(Wibble & 3))
|
|
|
|
item->AfterDeath++;
|
2022-03-14 15:18:11 +11:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->AfterDeath == 128)
|
2022-03-14 15:18:11 +11:00
|
|
|
KillItem(itemNumber);
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
else
|
2022-03-14 15:18:11 +11:00
|
|
|
KillItem(itemNumber);
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2022-03-14 15:18:11 +11:00
|
|
|
itemNumber = nextItem;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
InItemControlLoop = false;
|
|
|
|
KillMoveItems();
|
|
|
|
|
|
|
|
// Update all effects
|
|
|
|
InItemControlLoop = true;
|
|
|
|
|
2022-03-14 15:18:11 +11:00
|
|
|
short fxNumber = NextFxActive;
|
|
|
|
while (fxNumber != NO_ITEM)
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
2022-03-14 15:18:11 +11:00
|
|
|
short nextFx = EffectList[fxNumber].nextActive;
|
|
|
|
auto* fx = &EffectList[fxNumber];
|
2020-12-21 13:16:29 -03:00
|
|
|
if (Objects[fx->objectNumber].control)
|
2022-03-14 15:18:11 +11:00
|
|
|
Objects[fx->objectNumber].control(fxNumber);
|
|
|
|
|
|
|
|
fxNumber = nextFx;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
InItemControlLoop = false;
|
|
|
|
KillMoveEffects();
|
|
|
|
|
|
|
|
// Update some effect timers
|
|
|
|
if (SmokeCountL)
|
|
|
|
SmokeCountL--;
|
2022-03-14 15:18:11 +11:00
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
if (SmokeCountR)
|
|
|
|
SmokeCountR--;
|
2022-03-14 15:18:11 +11:00
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
if (SplashCount)
|
|
|
|
SplashCount--;
|
2022-03-14 15:18:11 +11:00
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
if (WeaponDelay)
|
|
|
|
WeaponDelay--;
|
2022-03-14 15:18:11 +11:00
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
if (WeaponEnemyTimer)
|
|
|
|
WeaponEnemyTimer--;
|
|
|
|
|
|
|
|
if (CurrentLevel != 0)
|
|
|
|
{
|
|
|
|
// Control Lara
|
|
|
|
InItemControlLoop = true;
|
2021-11-09 16:03:56 +11:00
|
|
|
LaraControl(LaraItem, &LaraCollision);
|
2020-12-21 13:16:29 -03:00
|
|
|
InItemControlLoop = false;
|
|
|
|
KillMoveItems();
|
|
|
|
|
|
|
|
g_Renderer.updateLaraAnimations(true);
|
|
|
|
|
2021-11-16 15:51:50 +03:00
|
|
|
if (g_Gui.GetInventoryItemChosen() != NO_ITEM)
|
2021-05-31 11:57:42 -05:00
|
|
|
{
|
|
|
|
SayNo();
|
2021-11-16 15:51:50 +03:00
|
|
|
g_Gui.SetInventoryItemChosen(NO_ITEM);
|
2021-05-31 11:57:42 -05:00
|
|
|
}
|
2021-10-12 00:26:46 -05:00
|
|
|
|
2022-02-15 20:36:27 +11:00
|
|
|
LaraCheatyBits(LaraItem);
|
2021-12-14 15:07:04 +03:00
|
|
|
TriggerLaraDrips(LaraItem);
|
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
// Update Lara's ponytails
|
2021-12-14 15:07:04 +03:00
|
|
|
HairControl(LaraItem, level->LaraType == LaraType::Young);
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (UseSpotCam)
|
|
|
|
{
|
|
|
|
// Draw flyby cameras
|
|
|
|
//if (CurrentLevel != 0)
|
|
|
|
// g_Renderer->EnableCinematicBars(true);
|
|
|
|
CalculateSpotCameras();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Do the standard camera
|
|
|
|
//g_Renderer->EnableCinematicBars(false);
|
|
|
|
TrackCameraInit = false;
|
|
|
|
CalculateCamera();
|
|
|
|
}
|
|
|
|
|
2021-09-16 01:12:19 +03:00
|
|
|
// Update oscillator seed
|
2021-11-22 19:14:29 +03:00
|
|
|
Wibble = (Wibble + WIBBLE_SPEED) & WIBBLE_MAX;
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2021-09-16 01:12:19 +03:00
|
|
|
// Smash shatters and clear stopper flags under them
|
|
|
|
UpdateShatters();
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2021-09-15 11:13:47 +03:00
|
|
|
// Update weather
|
|
|
|
Weather.Update();
|
|
|
|
|
2021-07-10 06:55:37 +02:00
|
|
|
// Update special FX
|
2020-12-21 13:16:29 -03:00
|
|
|
UpdateSparks();
|
|
|
|
UpdateFireSparks();
|
|
|
|
UpdateSmoke();
|
|
|
|
UpdateBlood();
|
|
|
|
UpdateBubbles();
|
|
|
|
UpdateDebris();
|
|
|
|
UpdateGunShells();
|
2021-09-14 01:22:08 +03:00
|
|
|
UpdateFootprints();
|
2020-12-21 13:16:29 -03:00
|
|
|
UpdateSplashes();
|
2021-11-22 19:14:29 +03:00
|
|
|
UpdateLightning();
|
2020-12-21 13:16:29 -03:00
|
|
|
UpdateDrips();
|
|
|
|
UpdateRats();
|
|
|
|
UpdateBats();
|
|
|
|
UpdateSpiders();
|
|
|
|
UpdateSparkParticles();
|
|
|
|
UpdateSmokeParticles();
|
|
|
|
updateSimpleParticles();
|
2021-11-22 19:14:29 +03:00
|
|
|
UpdateDripParticles();
|
2020-12-21 13:16:29 -03:00
|
|
|
UpdateExplosionParticles();
|
|
|
|
UpdateShockwaves();
|
2022-03-06 01:26:27 +11:00
|
|
|
UpdateBeetleSwarm();
|
2021-11-22 19:14:29 +03:00
|
|
|
UpdateLocusts();
|
2020-12-21 13:16:29 -03:00
|
|
|
AnimateWaterfalls();
|
|
|
|
|
2021-07-10 06:55:37 +02:00
|
|
|
// Rumble screen (like in submarine level of TRC)
|
2020-12-21 13:16:29 -03:00
|
|
|
if (level->Rumble)
|
|
|
|
RumbleScreen();
|
|
|
|
|
2021-09-15 17:49:01 +03:00
|
|
|
PlaySoundSources();
|
|
|
|
DoFlipEffect(FlipEffect);
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2022-01-13 07:40:13 +01:00
|
|
|
UpdateFadeScreenAndCinematicBars();
|
|
|
|
|
2021-08-29 23:53:58 +03:00
|
|
|
// Clear savegame loaded flag
|
|
|
|
JustLoaded = false;
|
|
|
|
|
2021-07-10 06:55:37 +02:00
|
|
|
// Update timers
|
2020-12-21 13:16:29 -03:00
|
|
|
HealthBarTimer--;
|
|
|
|
GameTimer++;
|
|
|
|
}
|
|
|
|
|
2022-03-14 22:44:10 +11:00
|
|
|
return GameStatus::None;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned CALLBACK GameMain(void *)
|
|
|
|
{
|
2021-09-16 01:12:19 +03:00
|
|
|
try
|
|
|
|
{
|
2021-10-31 10:50:36 +03:00
|
|
|
TENLog("Starting GameMain...", LogLevel::Info);
|
2021-09-16 01:12:19 +03:00
|
|
|
|
|
|
|
TimeInit();
|
|
|
|
|
2021-08-04 16:51:28 +01:00
|
|
|
if (g_GameFlow->IntroImagePath.empty())
|
2021-08-03 15:14:24 +01:00
|
|
|
throw TENScriptException("Intro image path is not set.");
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2021-08-03 15:14:24 +01:00
|
|
|
// Do a fixed time title image
|
|
|
|
g_Renderer.renderTitleImage();
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2022-03-14 15:18:11 +11:00
|
|
|
// Execute the Lua gameflow and play the game
|
2021-08-03 15:14:24 +01:00
|
|
|
g_GameFlow->DoGameflow();
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2021-08-03 15:14:24 +01:00
|
|
|
DoTheGame = false;
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2021-08-03 15:14:24 +01:00
|
|
|
// Finish the thread
|
|
|
|
PostMessage(WindowsHandle, WM_CLOSE, NULL, NULL);
|
|
|
|
EndThread();
|
|
|
|
}
|
2021-09-16 01:12:19 +03:00
|
|
|
catch (TENScriptException const& e)
|
|
|
|
{
|
2021-08-03 15:14:24 +01:00
|
|
|
std::string msg = std::string{ "An unrecoverable error occurred in " } + __func__ + ": " + e.what();
|
|
|
|
TENLog(msg, LogLevel::Error, LogConfig::All);
|
|
|
|
throw;
|
|
|
|
}
|
2020-12-21 13:16:29 -03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-03-14 22:44:10 +11:00
|
|
|
GameStatus DoTitle(int index)
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
2021-10-31 10:50:36 +03:00
|
|
|
TENLog("DoTitle", LogLevel::Info);
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2021-09-14 16:34:58 +03:00
|
|
|
// Reset all the globals for the game which needs this
|
2021-10-04 03:09:32 +03:00
|
|
|
CleanUp();
|
2021-09-14 16:34:58 +03:00
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
// Load the level
|
2021-10-04 03:09:32 +03:00
|
|
|
LoadLevelFile(index);
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2021-11-16 15:35:41 +03:00
|
|
|
InventoryResult inventoryResult;
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2021-08-07 19:25:13 +01:00
|
|
|
if (g_GameFlow->TitleType == TITLE_TYPE::FLYBY)
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
|
|
|
// Initialise items, effects, lots, camera
|
|
|
|
InitialiseFXArray(true);
|
|
|
|
InitialisePickupDisplay();
|
|
|
|
InitialiseCamera();
|
2021-10-29 02:22:26 +03:00
|
|
|
StopAllSounds();
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2021-07-10 17:51:01 +01:00
|
|
|
// Run the level script
|
2022-03-14 15:18:11 +11:00
|
|
|
auto* level = g_GameFlow->Levels[index];
|
|
|
|
|
2021-07-10 17:51:01 +01:00
|
|
|
std::string err;
|
|
|
|
if (!level->ScriptFileName.empty())
|
|
|
|
{
|
2021-08-03 15:14:24 +01:00
|
|
|
g_GameScript->ExecuteScript(level->ScriptFileName);
|
2021-07-10 17:51:01 +01:00
|
|
|
g_GameScript->InitCallbacks();
|
2021-08-27 19:02:10 +01:00
|
|
|
g_GameScript->SetCallbackDrawString([](std::string const key, D3DCOLOR col, int x, int y, int flags)
|
|
|
|
{
|
2021-08-29 21:08:07 +01:00
|
|
|
g_Renderer.drawString(float(x)/float(g_Configuration.Width) * ASSUMED_WIDTH_FOR_TEXT_DRAWING, float(y)/float(g_Configuration.Height) * ASSUMED_HEIGHT_FOR_TEXT_DRAWING, key.c_str(), col, flags);
|
2021-08-27 19:02:10 +01:00
|
|
|
});
|
2021-07-10 17:51:01 +01:00
|
|
|
}
|
2021-09-16 01:12:19 +03:00
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
RequiredStartPos = false;
|
|
|
|
if (InitialiseGame)
|
|
|
|
{
|
|
|
|
GameTimer = 0;
|
|
|
|
RequiredStartPos = false;
|
|
|
|
InitialiseGame = false;
|
|
|
|
}
|
|
|
|
|
2021-10-31 21:36:13 +03:00
|
|
|
Statistics.Level.Timer = 0;
|
2020-12-21 13:16:29 -03:00
|
|
|
|
|
|
|
// Initialise flyby cameras
|
|
|
|
InitSpotCamSequences();
|
2021-09-16 01:12:19 +03:00
|
|
|
InitialiseSpotCam(0);
|
2020-12-21 13:16:29 -03:00
|
|
|
UseSpotCam = true;
|
|
|
|
|
|
|
|
// Play background music
|
2021-10-29 02:22:26 +03:00
|
|
|
PlaySoundTrack(83);
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2021-11-16 14:38:04 +03:00
|
|
|
// Initialize menu
|
2021-11-16 15:51:50 +03:00
|
|
|
g_Gui.SetMenuToDisplay(Menu::Title);
|
|
|
|
g_Gui.SetSelectedOption(0);
|
2021-11-16 14:38:04 +03:00
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
// Initialise ponytails
|
|
|
|
InitialiseHair();
|
|
|
|
|
2021-09-27 07:12:30 +03:00
|
|
|
InitialiseItemBoxData();
|
|
|
|
|
2021-08-27 19:03:23 +01:00
|
|
|
g_GameScript->OnStart();
|
|
|
|
|
2022-01-25 05:42:41 +01:00
|
|
|
SetScreenFadeIn(FADE_SCREEN_SPEED);
|
2022-01-13 07:40:13 +01:00
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
ControlPhase(2, 0);
|
2021-10-12 00:26:46 -05:00
|
|
|
|
2021-11-16 15:35:41 +03:00
|
|
|
int frames = 0;
|
|
|
|
auto status = InventoryResult::None;
|
|
|
|
|
|
|
|
while (status == InventoryResult::None)
|
2021-05-18 19:16:58 -05:00
|
|
|
{
|
|
|
|
g_Renderer.renderTitle();
|
|
|
|
|
|
|
|
SetDebounce = true;
|
|
|
|
S_UpdateInput();
|
|
|
|
SetDebounce = false;
|
|
|
|
|
2021-11-16 15:51:50 +03:00
|
|
|
status = g_Gui.TitleOptions();
|
2021-05-18 19:16:58 -05:00
|
|
|
|
2021-11-16 15:35:41 +03:00
|
|
|
if (status != InventoryResult::None)
|
2021-05-18 19:16:58 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
Camera.numberFrames = g_Renderer.SyncRenderer();
|
|
|
|
frames = Camera.numberFrames;
|
|
|
|
ControlPhase(frames, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
inventoryResult = status;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
else
|
2021-11-16 15:51:50 +03:00
|
|
|
inventoryResult = g_Gui.TitleOptions();
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2021-09-16 01:12:19 +03:00
|
|
|
StopSoundTracks();
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2021-08-27 19:03:23 +01:00
|
|
|
g_GameScript->OnEnd();
|
|
|
|
g_GameScript->FreeLevelScripts();
|
2021-09-16 01:12:19 +03:00
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
switch (inventoryResult)
|
|
|
|
{
|
2021-11-16 15:35:41 +03:00
|
|
|
case InventoryResult::NewGame:
|
2022-03-14 22:44:10 +11:00
|
|
|
return GameStatus::NewGame;
|
2022-03-14 15:18:11 +11:00
|
|
|
|
2021-11-16 15:35:41 +03:00
|
|
|
case InventoryResult::LoadGame:
|
2022-03-14 22:44:10 +11:00
|
|
|
return GameStatus::LoadGame;
|
2022-03-14 15:18:11 +11:00
|
|
|
|
2021-11-16 15:35:41 +03:00
|
|
|
case InventoryResult::ExitGame:
|
2022-03-14 22:44:10 +11:00
|
|
|
return GameStatus::ExitGame;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
|
2022-03-14 22:44:10 +11:00
|
|
|
return GameStatus::NewGame;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
|
2022-03-14 22:44:10 +11:00
|
|
|
GameStatus DoLevel(int index, std::string ambient, bool loadFromSavegame)
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
|
|
|
// If not loading a savegame, then clear all the infos
|
|
|
|
if (!loadFromSavegame)
|
|
|
|
{
|
2021-10-31 21:36:13 +03:00
|
|
|
Statistics.Level.Timer = 0;
|
|
|
|
Statistics.Level.Distance = 0;
|
|
|
|
Statistics.Level.AmmoUsed = 0;
|
|
|
|
Statistics.Level.AmmoHits = 0;
|
|
|
|
Statistics.Level.Kills = 0;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
|
2021-08-05 14:26:23 +03:00
|
|
|
// Reset all the globals for the game which needs this
|
2021-10-04 03:09:32 +03:00
|
|
|
CleanUp();
|
2021-08-05 14:26:23 +03:00
|
|
|
|
2021-09-14 16:34:58 +03:00
|
|
|
// Load the level
|
2021-10-04 03:09:32 +03:00
|
|
|
LoadLevelFile(index);
|
2021-09-14 16:34:58 +03:00
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
// Initialise items, effects, lots, camera
|
|
|
|
InitialiseFXArray(true);
|
|
|
|
InitialisePickupDisplay();
|
|
|
|
InitialiseCamera();
|
2021-10-29 02:22:26 +03:00
|
|
|
StopAllSounds();
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2021-06-28 18:34:59 +01:00
|
|
|
// Run the level script
|
2022-03-14 15:18:11 +11:00
|
|
|
auto* level = g_GameFlow->Levels[index];
|
2021-08-03 15:14:24 +01:00
|
|
|
|
2021-07-06 11:54:34 +02:00
|
|
|
if (!level->ScriptFileName.empty())
|
|
|
|
{
|
2021-08-03 15:14:24 +01:00
|
|
|
g_GameScript->ExecuteScript(level->ScriptFileName);
|
2021-07-06 11:54:34 +02:00
|
|
|
g_GameScript->InitCallbacks();
|
2021-08-27 19:02:10 +01:00
|
|
|
g_GameScript->SetCallbackDrawString([](std::string const key, D3DCOLOR col, int x, int y, int flags)
|
|
|
|
{
|
2021-08-29 21:08:07 +01:00
|
|
|
g_Renderer.drawString(float(x)/float(g_Configuration.Width) * ASSUMED_WIDTH_FOR_TEXT_DRAWING, float(y)/float(g_Configuration.Height) * ASSUMED_HEIGHT_FOR_TEXT_DRAWING, key.c_str(), col, flags);
|
2021-08-27 19:02:10 +01:00
|
|
|
});
|
2021-07-06 11:54:34 +02:00
|
|
|
}
|
2021-06-28 18:34:59 +01:00
|
|
|
|
2021-10-29 03:39:22 +03:00
|
|
|
// Play default background music
|
|
|
|
PlaySoundTrack(ambient, SOUNDTRACK_PLAYTYPE::BGM);
|
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
// Restore the game?
|
|
|
|
if (loadFromSavegame)
|
|
|
|
{
|
2021-10-15 05:35:44 +02:00
|
|
|
SaveGame::Load(g_GameFlow->SelectedSaveGame);
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
Camera.pos.x = LaraItem->Position.xPos + 256;
|
|
|
|
Camera.pos.y = LaraItem->Position.yPos + 256;
|
|
|
|
Camera.pos.z = LaraItem->Position.zPos + 256;
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
Camera.target.x = LaraItem->Position.xPos;
|
|
|
|
Camera.target.y = LaraItem->Position.yPos;
|
|
|
|
Camera.target.z = LaraItem->Position.zPos;
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2022-03-09 17:04:19 +11:00
|
|
|
int x = Lara.Control.Weapon.WeaponItem;
|
2020-12-21 13:16:29 -03:00
|
|
|
|
|
|
|
RequiredStartPos = false;
|
|
|
|
InitialiseGame = false;
|
|
|
|
g_GameFlow->SelectedSaveGame = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RequiredStartPos = false;
|
|
|
|
if (InitialiseGame)
|
|
|
|
{
|
|
|
|
GameTimer = 0;
|
|
|
|
RequiredStartPos = false;
|
|
|
|
InitialiseGame = false;
|
|
|
|
}
|
|
|
|
|
2021-10-31 21:36:13 +03:00
|
|
|
Statistics.Level.Timer = 0;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
2021-05-20 14:19:11 -05:00
|
|
|
|
2021-11-16 15:51:50 +03:00
|
|
|
g_Gui.SetInventoryItemChosen(NO_ITEM);
|
|
|
|
g_Gui.SetEnterInventory(NO_ITEM);
|
2020-12-21 13:16:29 -03:00
|
|
|
|
|
|
|
// Initialise flyby cameras
|
|
|
|
InitSpotCamSequences();
|
|
|
|
|
|
|
|
// Initialise ponytails
|
|
|
|
InitialiseHair();
|
|
|
|
|
2021-09-27 07:12:30 +03:00
|
|
|
InitialiseItemBoxData();
|
|
|
|
|
2021-07-03 22:56:12 +01:00
|
|
|
g_GameScript->OnStart();
|
|
|
|
if (loadFromSavegame)
|
|
|
|
g_GameScript->OnLoad();
|
|
|
|
|
2022-03-14 15:18:11 +11:00
|
|
|
int nFrames = 2;
|
2020-12-21 13:16:29 -03:00
|
|
|
|
|
|
|
// First control phase
|
|
|
|
g_Renderer.resetAnimations();
|
2022-03-14 15:18:11 +11:00
|
|
|
auto result = ControlPhase(nFrames, 0);
|
2020-12-21 13:16:29 -03:00
|
|
|
|
|
|
|
// Fade in screen
|
2022-01-25 05:42:41 +01:00
|
|
|
SetScreenFadeIn(FADE_SCREEN_SPEED);
|
2020-12-21 13:16:29 -03:00
|
|
|
|
|
|
|
// The game loop, finally!
|
|
|
|
while (true)
|
|
|
|
{
|
2022-03-14 15:18:11 +11:00
|
|
|
result = ControlPhase(nFrames, 0);
|
|
|
|
nFrames = DrawPhase();
|
2021-08-06 11:06:43 +03:00
|
|
|
Sound_UpdateScene();
|
2020-12-21 13:16:29 -03:00
|
|
|
|
2022-03-14 22:44:10 +11:00
|
|
|
if (result == GameStatus::ExitToTitle ||
|
|
|
|
result == GameStatus::LoadGame ||
|
|
|
|
result == GameStatus::LevelComplete)
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
2021-07-01 19:32:10 +01:00
|
|
|
g_GameScript->OnEnd();
|
2021-08-23 02:02:47 +01:00
|
|
|
g_GameScript->FreeLevelScripts();
|
2020-12-21 13:16:29 -03:00
|
|
|
// Here is the only way for exiting from the loop
|
2021-10-29 02:22:26 +03:00
|
|
|
StopAllSounds();
|
2021-09-16 01:12:19 +03:00
|
|
|
StopSoundTracks();
|
2020-12-21 13:16:29 -03:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-16 01:12:19 +03:00
|
|
|
void UpdateShatters()
|
|
|
|
{
|
|
|
|
if (!SmashedMeshCount)
|
|
|
|
return;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
SmashedMeshCount--;
|
|
|
|
|
|
|
|
FLOOR_INFO* floor = GetFloor(
|
|
|
|
SmashedMesh[SmashedMeshCount]->pos.xPos,
|
|
|
|
SmashedMesh[SmashedMeshCount]->pos.yPos,
|
|
|
|
SmashedMesh[SmashedMeshCount]->pos.zPos,
|
|
|
|
&SmashedMeshRoom[SmashedMeshCount]);
|
|
|
|
|
|
|
|
TestTriggers(SmashedMesh[SmashedMeshCount]->pos.xPos,
|
|
|
|
SmashedMesh[SmashedMeshCount]->pos.yPos,
|
|
|
|
SmashedMesh[SmashedMeshCount]->pos.zPos,
|
|
|
|
SmashedMeshRoom[SmashedMeshCount], true);
|
|
|
|
|
|
|
|
floor->Stopper = false;
|
|
|
|
SmashedMesh[SmashedMeshCount] = 0;
|
|
|
|
} while (SmashedMeshCount != 0);
|
|
|
|
}
|
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
void KillMoveItems()
|
|
|
|
{
|
|
|
|
if (ItemNewRoomNo > 0)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < ItemNewRoomNo; i++)
|
|
|
|
{
|
|
|
|
short itemNumber = ItemNewRooms[2 * i];
|
|
|
|
if (itemNumber >= 0)
|
|
|
|
ItemNewRoom(itemNumber, ItemNewRooms[2 * i + 1]);
|
|
|
|
else
|
|
|
|
KillItem(itemNumber & 0x7FFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ItemNewRoomNo = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KillMoveEffects()
|
|
|
|
{
|
|
|
|
if (ItemNewRoomNo > 0)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < ItemNewRoomNo; i++)
|
|
|
|
{
|
|
|
|
short itemNumber = ItemNewRooms[2 * i];
|
|
|
|
if (itemNumber >= 0)
|
|
|
|
EffectNewRoom(itemNumber, ItemNewRooms[2 * i + 1]);
|
|
|
|
else
|
|
|
|
KillEffect(itemNumber & 0x7FFF);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ItemNewRoomNo = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetRandomControl()
|
|
|
|
{
|
2021-09-17 16:07:53 +03:00
|
|
|
return GenerateInt();
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
int GetRandomDraw()
|
|
|
|
{
|
2021-09-17 16:07:53 +03:00
|
|
|
return GenerateInt();
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
|
2022-02-02 13:09:24 +11:00
|
|
|
bool ExplodeItemNode(ITEM_INFO *item, int node, int noXZVel, int bits)
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (1 << node & item->MeshBits)
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
2022-03-14 15:18:11 +11:00
|
|
|
int number = bits;
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->ObjectNumber == ID_SHOOT_SWITCH1 && (CurrentLevel == 4 || CurrentLevel == 7)) // TODO: remove hardcoded think !
|
2022-03-31 00:24:22 +11:00
|
|
|
SoundEffect(SFX_TR5_SMASH_METAL, &item->Position, 0);
|
2022-03-14 15:18:11 +11:00
|
|
|
else if (number == 256)
|
|
|
|
number = -64;
|
2022-02-02 13:09:24 +11:00
|
|
|
|
2020-12-21 13:16:29 -03:00
|
|
|
GetSpheres(item, CreatureSpheres, SPHERES_SPACE_WORLD | SPHERES_SPACE_BONE_ORIGIN, Matrix::Identity);
|
2022-02-09 16:55:46 +11:00
|
|
|
ShatterItem.yRot = item->Position.yRot;
|
2022-02-02 13:09:24 +11:00
|
|
|
ShatterItem.bit = 1 << node;
|
2022-02-09 16:55:46 +11:00
|
|
|
ShatterItem.meshIndex = Objects[item->ObjectNumber].meshIndex + node;
|
2022-02-02 13:09:24 +11:00
|
|
|
ShatterItem.sphere.x = CreatureSpheres[node].x;
|
|
|
|
ShatterItem.sphere.y = CreatureSpheres[node].y;
|
|
|
|
ShatterItem.sphere.z = CreatureSpheres[node].z;
|
2022-02-09 16:55:46 +11:00
|
|
|
ShatterItem.flags = item->ObjectNumber == ID_CROSSBOW_BOLT ? 0x400 : 0;
|
2020-12-21 13:16:29 -03:00
|
|
|
ShatterImpactData.impactDirection = Vector3(0, -1, 0);
|
|
|
|
ShatterImpactData.impactLocation = {(float)ShatterItem.sphere.x, (float)ShatterItem.sphere.y, (float)ShatterItem.sphere.z};
|
2022-03-14 15:18:11 +11:00
|
|
|
ShatterObject(&ShatterItem, NULL, number, item->RoomNumber, noXZVel);
|
2022-02-09 16:55:46 +11:00
|
|
|
item->MeshBits &= ~ShatterItem.bit;
|
2022-02-02 13:09:24 +11:00
|
|
|
|
|
|
|
return true;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
2022-02-02 13:09:24 +11:00
|
|
|
|
|
|
|
return false;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
|
2021-10-04 03:09:32 +03:00
|
|
|
void CleanUp()
|
2021-08-05 14:26:23 +03:00
|
|
|
{
|
2021-09-15 21:09:09 +03:00
|
|
|
// Reset oscillator seed
|
|
|
|
Wibble = 0;
|
|
|
|
|
2021-09-14 15:54:49 +03:00
|
|
|
// Needs to be cleared or otherwise controls will lockup if user will exit to title
|
|
|
|
// while playing flyby with locked controls
|
2022-02-10 16:18:15 +11:00
|
|
|
Lara.Control.Locked = false;
|
2021-09-14 15:54:49 +03:00
|
|
|
|
2021-09-15 11:18:11 +03:00
|
|
|
// Weather.Clear resets lightning and wind parameters so user won't see prev weather in new level
|
2021-09-15 11:13:47 +03:00
|
|
|
Weather.Clear();
|
2021-09-14 16:00:06 +03:00
|
|
|
|
2021-09-14 15:54:49 +03:00
|
|
|
// Needs to be cleared because otherwise a list of active creatures from previous level
|
|
|
|
// will spill into new level
|
|
|
|
ActiveCreatures.clear();
|
2021-09-14 16:34:58 +03:00
|
|
|
|
|
|
|
// Clear spotcam array
|
|
|
|
ClearSpotCamSequences();
|
2021-10-04 03:09:32 +03:00
|
|
|
|
|
|
|
// Clear all kinds of particles
|
|
|
|
DisableSmokeParticles();
|
2021-10-08 13:58:51 +03:00
|
|
|
DisableDripParticles();
|
2021-10-04 03:09:32 +03:00
|
|
|
DisableBubbles();
|
|
|
|
DisableDebris();
|
2021-10-29 02:22:26 +03:00
|
|
|
|
|
|
|
// Clear soundtrack masks
|
|
|
|
ClearSoundTrackMasks();
|
2022-02-02 13:09:24 +11:00
|
|
|
}
|