TombEngine/TombEngine/Game/control/control.cpp

763 lines
18 KiB
C++
Raw Normal View History

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/volume.h"
2021-12-22 16:23:57 +03:00
#include "Game/control/lot.h"
#include "Game/health.h"
#include "Game/savegame.h"
#include "Game/room.h"
#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"
#include "Game/effects/simple_particle.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"
2021-09-17 17:14:15 +03:00
#include "Specific/clock.h"
2021-12-24 03:32:19 +03:00
#include "Specific/input.h"
#include "Specific/level.h"
#include "Specific/setup.h"
#include "Specific/prng.h"
#include "Specific/winmain.h"
2022-06-22 18:52:22 +03:00
#include "Scripting/Include/Flow/ScriptInterfaceFlowHandler.h"
#include "Scripting/Include/ScriptInterfaceGame.h"
#include "Scripting/Include/Objects/ScriptInterfaceObjectsHandler.h"
#include "Scripting/Include/Strings/ScriptInterfaceStringsHandler.h"
2021-09-25 11:27:47 +02:00
2020-12-21 13:16:29 -03:00
using std::vector;
using std::unordered_map;
using std::string;
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;
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;
using namespace TEN::Entities::Switches;
2021-11-22 19:14:29 +03:00
using namespace TEN::Entities::TR4;
using namespace TEN::Renderer;
2021-08-30 18:03:21 +03:00
using namespace TEN::Math::Random;
using namespace TEN::Floordata;
OIS input system (#556) * Work * Add ois.lib * Add OIS headers/libs to project * Fix small mistakes * Update input.cpp * Update input.cpp * Update input.cpp * Remove unnecessary event handlers as we are using direct polling * Fix numpad controls not polling * Enclose all input code under namespace, provide debug OIS lib variation * Fix incorrect inventory call binding, add pause to control dialog * Deselect by pushing inventory button as well, fix crossbow ammo string draw * Demagic NUM_CONTROLS * Verbose input init logging * Calibrate and properly register movement analog axis input * Fix crash when empty string is being displayed * Initialize vibration interface, if it exists * Register keyboard directional input as analog axis input as well * Fix statistics exiting * Fix weird UpdateInput call * Copy current layout to configuration * Fix issues with saving controls * Register axis values for POVs too * Register several POV directions at once * Increase deadzone a bit * Simplify enums * Update input.cpp * Move includes out of input.h * Bump deadzone even further as it seems xbox controllers have massive axis errors * Prevent event spamming in case OIS polling failed * Destroy input system on exit, cosmetic changes * Take deadzone into account when normalizing axis values * Update TombEngine.vcxproj * Resolve small precision loss in axis normalizing * Clean up unused control constants and enums * Update input.h * Demagic InputActions enum * Render pause menu header * Introduce helper functions to modulate Lara turn rates and begin replacements * Make turn directions explicit * Conduct remaining replacements of turn rate modulations * Update lara_helpers.cpp * Add smoothstep function to math library * Use scaled axis value for true analog input * Update input.cpp * Add Joey's camera rotation from old branch * Fix camera not going back to previous position when stick is released * Simplify ModulateLaraTurnRate() * Widen look angle * Avoid collisions with actions bound to non-directional axis * Small tidying * Remove unused header * Remove copypasted code * Mask flare animation * Rename 5th and 6th axis to LT/RT * Prototype force feedback support * Add directional rumble support (probably XInput-only) * Shake controller on startup if supports vibration * Update OIS libs to support XInput FF * Simplify ModulateLaraTurnRate() * Update player modulation functions; simplify turning, leaning, and flexing in state functions; lara.h cleanup * Update Win32ForceFeedback.h * Fix crawl flex function * Revert "Update Win32ForceFeedback.h" This reverts commit aa7099ed5bf2bc8402029aa2fcdece16ebabd5bf. * Update OIS libs * Add options for thumbstick camera and vibration * Make use of autotarget option * Display NON-SCREAMING names in controls, add hack to cancel axis value on both right+left input events * Remove useless control hacks for simultaneous directional input * Delete ten_itemdata_generated.h * Add scroll lock to bindable controls * Update input.cpp * Update input.cpp * Make input device namings consistent * Bring back IN_SELECT override * Fix crashing on startup and some other bugs * Add rumble to some in-game events * Add some more vibration events, stop them when going to menus * Some changes to rumble power * Add rumble for rocket/grenade launchers and explosive damage * Add rumble for screen shake effect * Fix 2 mistakes in inventory strings * Rumble for camera more precisely * Fix debounce in binocular mode * Update camera.cpp * Add HK lasersight rumble * Simplify ModulateLaraLean() * Update input.cpp * Fix crawl flex modulation(?) * Add slight rumble to harpoon and crossbow fire * Remove the confusing counteracting turn rate reset in favour of something simpler * Simplify turn rate reset input checks; leanup * Clamp turn rate axis coeff when airborne * Remove empty line * Simplify a function * Cleanup * Fix rumble being constant * Use shorter rumble time for shooting guns * Fix single arm shooting * Fix leaning left with joystick; clamp crawl flex max; tweak walk lean max; cleanup * Don't do too long splat and jump smash vibrations * Cancel turn rate when exiting water, grabbing ledge, or doing a splat * Rename function * Move ModulateLaraTurnRateY() callsin crawl and crouch turn states * Reset turn rate when performing crawl vault * Convert all health decrease events to DoDamage calls * Remove SpasmEffectCount and unify touching with DoDamage * Give specific time delay before sprint jump is possible * Don't rumble on zero damage * Reorder input pipeline to prevent left+right collisions * Rename shady global * Rumble when breaking neck in swandive * Update lara_jump.cpp * Don't vibrate on soft splat * Fix combine item text alignment * Vibrate in settings only if setting was changed * Pulse gamepad on critical health condition * Don't get out of water into objects * Add critical air constant Co-authored-by: Sezz
2022-06-25 16:53:58 +03:00
using namespace TEN::Input;
2020-12-21 13:16:29 -03:00
int GameTimer = 0;
2021-10-22 16:33:15 +03:00
int GlobalCounter = 0;
int Wibble = 0;
bool InitialiseGame;
bool DoTheGame;
bool JustLoaded;
bool ThreadEnded;
int RequiredStartPos;
int CurrentLevel;
int LevelComplete;
int SystemNameHash = 0;
bool InItemControlLoop;
2020-12-21 13:16:29 -03:00
short ItemNewRoomNo;
short ItemNewRooms[MAX_ROOMS];
2020-12-21 13:16:29 -03:00
short NextItemActive;
short NextItemFree;
short NextFxActive;
short NextFxFree;
2021-09-15 22:43:19 +03:00
int WeaponDelay;
int WeaponEnemyTimer;
int DrawPhase()
{
g_Renderer.Draw();
Camera.numberFrames = g_Renderer.SyncRenderer();
return Camera.numberFrames;
}
GameStatus ControlPhase(int numFrames, int demoMode)
2020-12-21 13:16:29 -03:00
{
short oldLaraFrame;
Merge branch 'state_cleaning_tier_2' into luarefactor # Conflicts: # .gitignore # Common/Game/collision/collide_room.h # Common/Game/control/control.h # Common/Game/items.h # Common/Specific/phd_global.h # Common/Specific/trmath.h # Scripting/src/TEN/Flow/Animations/Animations.h # Scripting/src/TEN/Flow/FlowHandler.cpp # Scripts/Settings.lua # TR5Main/Game/Lara/lara.cpp # TR5Main/Game/Lara/lara_basic.cpp # TR5Main/Game/Lara/lara_cheat.cpp # TR5Main/Game/Lara/lara_collide.cpp # TR5Main/Game/Lara/lara_crawl.cpp # TR5Main/Game/Lara/lara_helpers.cpp # TR5Main/Game/Lara/lara_jump.cpp # TR5Main/Game/Lara/lara_monkey.cpp # TR5Main/Game/Lara/lara_swim.cpp # TR5Main/Game/Lara/lara_tests.cpp # TR5Main/Game/animation.cpp # TR5Main/Game/camera.cpp # TR5Main/Game/collision/collide_item.cpp # TR5Main/Game/collision/collide_room.cpp # TR5Main/Game/collision/floordata.cpp # TR5Main/Game/control/control.cpp # TR5Main/Game/control/los.cpp # TR5Main/Game/control/volume.cpp # TR5Main/Game/effects/hair.cpp # TR5Main/Game/gui.cpp # TR5Main/Game/health.cpp # TR5Main/Game/items.cpp # TR5Main/Game/room.cpp # TR5Main/Game/savegame.cpp # TR5Main/Renderer/ConstantBuffers/MiscBuffer.h # TR5Main/Renderer/RenderPipelineState/RenderPipelineState.cpp # TR5Main/Renderer/RenderPipelineState/RenderPipelineState.h # TR5Main/Renderer/Renderer11Draw.cpp # TR5Main/Renderer/Renderer11Frame.cpp # TR5Main/Renderer/Renderer11Helper.cpp # TR5Main/Renderer/Renderer11Lara.cpp # TR5Main/Renderer/Renderer11PostProcess.cpp # TR5Main/Renderer/Renderer11Settings.cpp # TR5Main/Renderer/Renderer11String.cpp # TR5Main/Renderer/RendererSprites.h # TR5Main/Scripting/GameLogicScript.cpp # TR5Main/Scripting/GameScriptAnimations.cpp # TR5Main/Scripting/GameScriptItemInfo.cpp # TR5Main/Scripting/GameScriptItemInfo.h # TR5Main/Scripting/GameScriptMeshInfo.cpp # TR5Main/Scripting/GameScriptPosition.cpp # TR5Main/Specific/input.cpp # TR5Main/Specific/level.cpp # TR5Main/Specific/savegame/flatbuffers/ten_savegame_generated.h # TR5Main/TombEngine.vcxproj.filters # common/game/collision/collide_item.h
2022-05-05 06:28:43 +02:00
ScriptInterfaceLevel* level = g_GameFlow->GetLevel(CurrentLevel);
2020-12-21 13:16:29 -03:00
RegeneratePickups();
if (numFrames > 10)
numFrames = 10;
if (TrackCameraInit)
UseSpotCam = false;
g_GameStringsHandler->ProcessDisplayStrings(DELTA_TIME);
static int framesCount = 0;
for (framesCount += numFrames; framesCount > 0; framesCount -= 2)
2020-12-21 13:16:29 -03:00
{
GlobalCounter++;
// 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)
OIS input system (#556) * Work * Add ois.lib * Add OIS headers/libs to project * Fix small mistakes * Update input.cpp * Update input.cpp * Update input.cpp * Remove unnecessary event handlers as we are using direct polling * Fix numpad controls not polling * Enclose all input code under namespace, provide debug OIS lib variation * Fix incorrect inventory call binding, add pause to control dialog * Deselect by pushing inventory button as well, fix crossbow ammo string draw * Demagic NUM_CONTROLS * Verbose input init logging * Calibrate and properly register movement analog axis input * Fix crash when empty string is being displayed * Initialize vibration interface, if it exists * Register keyboard directional input as analog axis input as well * Fix statistics exiting * Fix weird UpdateInput call * Copy current layout to configuration * Fix issues with saving controls * Register axis values for POVs too * Register several POV directions at once * Increase deadzone a bit * Simplify enums * Update input.cpp * Move includes out of input.h * Bump deadzone even further as it seems xbox controllers have massive axis errors * Prevent event spamming in case OIS polling failed * Destroy input system on exit, cosmetic changes * Take deadzone into account when normalizing axis values * Update TombEngine.vcxproj * Resolve small precision loss in axis normalizing * Clean up unused control constants and enums * Update input.h * Demagic InputActions enum * Render pause menu header * Introduce helper functions to modulate Lara turn rates and begin replacements * Make turn directions explicit * Conduct remaining replacements of turn rate modulations * Update lara_helpers.cpp * Add smoothstep function to math library * Use scaled axis value for true analog input * Update input.cpp * Add Joey's camera rotation from old branch * Fix camera not going back to previous position when stick is released * Simplify ModulateLaraTurnRate() * Widen look angle * Avoid collisions with actions bound to non-directional axis * Small tidying * Remove unused header * Remove copypasted code * Mask flare animation * Rename 5th and 6th axis to LT/RT * Prototype force feedback support * Add directional rumble support (probably XInput-only) * Shake controller on startup if supports vibration * Update OIS libs to support XInput FF * Simplify ModulateLaraTurnRate() * Update player modulation functions; simplify turning, leaning, and flexing in state functions; lara.h cleanup * Update Win32ForceFeedback.h * Fix crawl flex function * Revert "Update Win32ForceFeedback.h" This reverts commit aa7099ed5bf2bc8402029aa2fcdece16ebabd5bf. * Update OIS libs * Add options for thumbstick camera and vibration * Make use of autotarget option * Display NON-SCREAMING names in controls, add hack to cancel axis value on both right+left input events * Remove useless control hacks for simultaneous directional input * Delete ten_itemdata_generated.h * Add scroll lock to bindable controls * Update input.cpp * Update input.cpp * Make input device namings consistent * Bring back IN_SELECT override * Fix crashing on startup and some other bugs * Add rumble to some in-game events * Add some more vibration events, stop them when going to menus * Some changes to rumble power * Add rumble for rocket/grenade launchers and explosive damage * Add rumble for screen shake effect * Fix 2 mistakes in inventory strings * Rumble for camera more precisely * Fix debounce in binocular mode * Update camera.cpp * Add HK lasersight rumble * Simplify ModulateLaraLean() * Update input.cpp * Fix crawl flex modulation(?) * Add slight rumble to harpoon and crossbow fire * Remove the confusing counteracting turn rate reset in favour of something simpler * Simplify turn rate reset input checks; leanup * Clamp turn rate axis coeff when airborne * Remove empty line * Simplify a function * Cleanup * Fix rumble being constant * Use shorter rumble time for shooting guns * Fix single arm shooting * Fix leaning left with joystick; clamp crawl flex max; tweak walk lean max; cleanup * Don't do too long splat and jump smash vibrations * Cancel turn rate when exiting water, grabbing ledge, or doing a splat * Rename function * Move ModulateLaraTurnRateY() callsin crawl and crouch turn states * Reset turn rate when performing crawl vault * Convert all health decrease events to DoDamage calls * Remove SpasmEffectCount and unify touching with DoDamage * Give specific time delay before sprint jump is possible * Don't rumble on zero damage * Reorder input pipeline to prevent left+right collisions * Rename shady global * Rumble when breaking neck in swandive * Update lara_jump.cpp * Don't vibrate on soft splat * Fix combine item text alignment * Vibrate in settings only if setting was changed * Pulse gamepad on critical health condition * Don't get out of water into objects * Add critical air constant Co-authored-by: Sezz
2022-06-25 16:53:58 +03:00
UpdateInput();
2020-12-21 13:16:29 -03:00
// Has Lara control been disabled?
if (Lara.Control.Locked || CurrentLevel == 0)
2020-12-21 13:16:29 -03:00
{
if (CurrentLevel != 0)
DbInput = 0;
TrInput &= IN_LOOK;
2020-12-21 13:16:29 -03:00
}
if (CurrentLevel != 0)
2021-05-18 19:16:58 -05:00
{
OIS input system (#556) * Work * Add ois.lib * Add OIS headers/libs to project * Fix small mistakes * Update input.cpp * Update input.cpp * Update input.cpp * Remove unnecessary event handlers as we are using direct polling * Fix numpad controls not polling * Enclose all input code under namespace, provide debug OIS lib variation * Fix incorrect inventory call binding, add pause to control dialog * Deselect by pushing inventory button as well, fix crossbow ammo string draw * Demagic NUM_CONTROLS * Verbose input init logging * Calibrate and properly register movement analog axis input * Fix crash when empty string is being displayed * Initialize vibration interface, if it exists * Register keyboard directional input as analog axis input as well * Fix statistics exiting * Fix weird UpdateInput call * Copy current layout to configuration * Fix issues with saving controls * Register axis values for POVs too * Register several POV directions at once * Increase deadzone a bit * Simplify enums * Update input.cpp * Move includes out of input.h * Bump deadzone even further as it seems xbox controllers have massive axis errors * Prevent event spamming in case OIS polling failed * Destroy input system on exit, cosmetic changes * Take deadzone into account when normalizing axis values * Update TombEngine.vcxproj * Resolve small precision loss in axis normalizing * Clean up unused control constants and enums * Update input.h * Demagic InputActions enum * Render pause menu header * Introduce helper functions to modulate Lara turn rates and begin replacements * Make turn directions explicit * Conduct remaining replacements of turn rate modulations * Update lara_helpers.cpp * Add smoothstep function to math library * Use scaled axis value for true analog input * Update input.cpp * Add Joey's camera rotation from old branch * Fix camera not going back to previous position when stick is released * Simplify ModulateLaraTurnRate() * Widen look angle * Avoid collisions with actions bound to non-directional axis * Small tidying * Remove unused header * Remove copypasted code * Mask flare animation * Rename 5th and 6th axis to LT/RT * Prototype force feedback support * Add directional rumble support (probably XInput-only) * Shake controller on startup if supports vibration * Update OIS libs to support XInput FF * Simplify ModulateLaraTurnRate() * Update player modulation functions; simplify turning, leaning, and flexing in state functions; lara.h cleanup * Update Win32ForceFeedback.h * Fix crawl flex function * Revert "Update Win32ForceFeedback.h" This reverts commit aa7099ed5bf2bc8402029aa2fcdece16ebabd5bf. * Update OIS libs * Add options for thumbstick camera and vibration * Make use of autotarget option * Display NON-SCREAMING names in controls, add hack to cancel axis value on both right+left input events * Remove useless control hacks for simultaneous directional input * Delete ten_itemdata_generated.h * Add scroll lock to bindable controls * Update input.cpp * Update input.cpp * Make input device namings consistent * Bring back IN_SELECT override * Fix crashing on startup and some other bugs * Add rumble to some in-game events * Add some more vibration events, stop them when going to menus * Some changes to rumble power * Add rumble for rocket/grenade launchers and explosive damage * Add rumble for screen shake effect * Fix 2 mistakes in inventory strings * Rumble for camera more precisely * Fix debounce in binocular mode * Update camera.cpp * Add HK lasersight rumble * Simplify ModulateLaraLean() * Update input.cpp * Fix crawl flex modulation(?) * Add slight rumble to harpoon and crossbow fire * Remove the confusing counteracting turn rate reset in favour of something simpler * Simplify turn rate reset input checks; leanup * Clamp turn rate axis coeff when airborne * Remove empty line * Simplify a function * Cleanup * Fix rumble being constant * Use shorter rumble time for shooting guns * Fix single arm shooting * Fix leaning left with joystick; clamp crawl flex max; tweak walk lean max; cleanup * Don't do too long splat and jump smash vibrations * Cancel turn rate when exiting water, grabbing ledge, or doing a splat * Rename function * Move ModulateLaraTurnRateY() callsin crawl and crouch turn states * Reset turn rate when performing crawl vault * Convert all health decrease events to DoDamage calls * Remove SpasmEffectCount and unify touching with DoDamage * Give specific time delay before sprint jump is possible * Don't rumble on zero damage * Reorder input pipeline to prevent left+right collisions * Rename shady global * Rumble when breaking neck in swandive * Update lara_jump.cpp * Don't vibrate on soft splat * Fix combine item text alignment * Vibrate in settings only if setting was changed * Pulse gamepad on critical health condition * Don't get out of water into objects * Add critical air constant Co-authored-by: Sezz
2022-06-25 16:53:58 +03:00
// Does the player want to enter inventory?
if (TrInput & IN_SAVE && LaraItem->HitPoints > 0 && g_Gui.GetInventoryMode() != InventoryMode::Save)
{
2021-10-29 02:22:26 +03:00
StopAllSounds();
OIS input system (#556) * Work * Add ois.lib * Add OIS headers/libs to project * Fix small mistakes * Update input.cpp * Update input.cpp * Update input.cpp * Remove unnecessary event handlers as we are using direct polling * Fix numpad controls not polling * Enclose all input code under namespace, provide debug OIS lib variation * Fix incorrect inventory call binding, add pause to control dialog * Deselect by pushing inventory button as well, fix crossbow ammo string draw * Demagic NUM_CONTROLS * Verbose input init logging * Calibrate and properly register movement analog axis input * Fix crash when empty string is being displayed * Initialize vibration interface, if it exists * Register keyboard directional input as analog axis input as well * Fix statistics exiting * Fix weird UpdateInput call * Copy current layout to configuration * Fix issues with saving controls * Register axis values for POVs too * Register several POV directions at once * Increase deadzone a bit * Simplify enums * Update input.cpp * Move includes out of input.h * Bump deadzone even further as it seems xbox controllers have massive axis errors * Prevent event spamming in case OIS polling failed * Destroy input system on exit, cosmetic changes * Take deadzone into account when normalizing axis values * Update TombEngine.vcxproj * Resolve small precision loss in axis normalizing * Clean up unused control constants and enums * Update input.h * Demagic InputActions enum * Render pause menu header * Introduce helper functions to modulate Lara turn rates and begin replacements * Make turn directions explicit * Conduct remaining replacements of turn rate modulations * Update lara_helpers.cpp * Add smoothstep function to math library * Use scaled axis value for true analog input * Update input.cpp * Add Joey's camera rotation from old branch * Fix camera not going back to previous position when stick is released * Simplify ModulateLaraTurnRate() * Widen look angle * Avoid collisions with actions bound to non-directional axis * Small tidying * Remove unused header * Remove copypasted code * Mask flare animation * Rename 5th and 6th axis to LT/RT * Prototype force feedback support * Add directional rumble support (probably XInput-only) * Shake controller on startup if supports vibration * Update OIS libs to support XInput FF * Simplify ModulateLaraTurnRate() * Update player modulation functions; simplify turning, leaning, and flexing in state functions; lara.h cleanup * Update Win32ForceFeedback.h * Fix crawl flex function * Revert "Update Win32ForceFeedback.h" This reverts commit aa7099ed5bf2bc8402029aa2fcdece16ebabd5bf. * Update OIS libs * Add options for thumbstick camera and vibration * Make use of autotarget option * Display NON-SCREAMING names in controls, add hack to cancel axis value on both right+left input events * Remove useless control hacks for simultaneous directional input * Delete ten_itemdata_generated.h * Add scroll lock to bindable controls * Update input.cpp * Update input.cpp * Make input device namings consistent * Bring back IN_SELECT override * Fix crashing on startup and some other bugs * Add rumble to some in-game events * Add some more vibration events, stop them when going to menus * Some changes to rumble power * Add rumble for rocket/grenade launchers and explosive damage * Add rumble for screen shake effect * Fix 2 mistakes in inventory strings * Rumble for camera more precisely * Fix debounce in binocular mode * Update camera.cpp * Add HK lasersight rumble * Simplify ModulateLaraLean() * Update input.cpp * Fix crawl flex modulation(?) * Add slight rumble to harpoon and crossbow fire * Remove the confusing counteracting turn rate reset in favour of something simpler * Simplify turn rate reset input checks; leanup * Clamp turn rate axis coeff when airborne * Remove empty line * Simplify a function * Cleanup * Fix rumble being constant * Use shorter rumble time for shooting guns * Fix single arm shooting * Fix leaning left with joystick; clamp crawl flex max; tweak walk lean max; cleanup * Don't do too long splat and jump smash vibrations * Cancel turn rate when exiting water, grabbing ledge, or doing a splat * Rename function * Move ModulateLaraTurnRateY() callsin crawl and crouch turn states * Reset turn rate when performing crawl vault * Convert all health decrease events to DoDamage calls * Remove SpasmEffectCount and unify touching with DoDamage * Give specific time delay before sprint jump is possible * Don't rumble on zero damage * Reorder input pipeline to prevent left+right collisions * Rename shady global * Rumble when breaking neck in swandive * Update lara_jump.cpp * Don't vibrate on soft splat * Fix combine item text alignment * Vibrate in settings only if setting was changed * Pulse gamepad on critical health condition * Don't get out of water into objects * Add critical air constant Co-authored-by: Sezz
2022-06-25 16:53:58 +03:00
StopRumble();
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))
return GameStatus::SaveGame;
}
2021-11-16 15:51:50 +03:00
else if (TrInput & IN_LOAD && g_Gui.GetInventoryMode() != InventoryMode::Load)
{
2021-10-29 02:22:26 +03:00
StopAllSounds();
OIS input system (#556) * Work * Add ois.lib * Add OIS headers/libs to project * Fix small mistakes * Update input.cpp * Update input.cpp * Update input.cpp * Remove unnecessary event handlers as we are using direct polling * Fix numpad controls not polling * Enclose all input code under namespace, provide debug OIS lib variation * Fix incorrect inventory call binding, add pause to control dialog * Deselect by pushing inventory button as well, fix crossbow ammo string draw * Demagic NUM_CONTROLS * Verbose input init logging * Calibrate and properly register movement analog axis input * Fix crash when empty string is being displayed * Initialize vibration interface, if it exists * Register keyboard directional input as analog axis input as well * Fix statistics exiting * Fix weird UpdateInput call * Copy current layout to configuration * Fix issues with saving controls * Register axis values for POVs too * Register several POV directions at once * Increase deadzone a bit * Simplify enums * Update input.cpp * Move includes out of input.h * Bump deadzone even further as it seems xbox controllers have massive axis errors * Prevent event spamming in case OIS polling failed * Destroy input system on exit, cosmetic changes * Take deadzone into account when normalizing axis values * Update TombEngine.vcxproj * Resolve small precision loss in axis normalizing * Clean up unused control constants and enums * Update input.h * Demagic InputActions enum * Render pause menu header * Introduce helper functions to modulate Lara turn rates and begin replacements * Make turn directions explicit * Conduct remaining replacements of turn rate modulations * Update lara_helpers.cpp * Add smoothstep function to math library * Use scaled axis value for true analog input * Update input.cpp * Add Joey's camera rotation from old branch * Fix camera not going back to previous position when stick is released * Simplify ModulateLaraTurnRate() * Widen look angle * Avoid collisions with actions bound to non-directional axis * Small tidying * Remove unused header * Remove copypasted code * Mask flare animation * Rename 5th and 6th axis to LT/RT * Prototype force feedback support * Add directional rumble support (probably XInput-only) * Shake controller on startup if supports vibration * Update OIS libs to support XInput FF * Simplify ModulateLaraTurnRate() * Update player modulation functions; simplify turning, leaning, and flexing in state functions; lara.h cleanup * Update Win32ForceFeedback.h * Fix crawl flex function * Revert "Update Win32ForceFeedback.h" This reverts commit aa7099ed5bf2bc8402029aa2fcdece16ebabd5bf. * Update OIS libs * Add options for thumbstick camera and vibration * Make use of autotarget option * Display NON-SCREAMING names in controls, add hack to cancel axis value on both right+left input events * Remove useless control hacks for simultaneous directional input * Delete ten_itemdata_generated.h * Add scroll lock to bindable controls * Update input.cpp * Update input.cpp * Make input device namings consistent * Bring back IN_SELECT override * Fix crashing on startup and some other bugs * Add rumble to some in-game events * Add some more vibration events, stop them when going to menus * Some changes to rumble power * Add rumble for rocket/grenade launchers and explosive damage * Add rumble for screen shake effect * Fix 2 mistakes in inventory strings * Rumble for camera more precisely * Fix debounce in binocular mode * Update camera.cpp * Add HK lasersight rumble * Simplify ModulateLaraLean() * Update input.cpp * Fix crawl flex modulation(?) * Add slight rumble to harpoon and crossbow fire * Remove the confusing counteracting turn rate reset in favour of something simpler * Simplify turn rate reset input checks; leanup * Clamp turn rate axis coeff when airborne * Remove empty line * Simplify a function * Cleanup * Fix rumble being constant * Use shorter rumble time for shooting guns * Fix single arm shooting * Fix leaning left with joystick; clamp crawl flex max; tweak walk lean max; cleanup * Don't do too long splat and jump smash vibrations * Cancel turn rate when exiting water, grabbing ledge, or doing a splat * Rename function * Move ModulateLaraTurnRateY() callsin crawl and crouch turn states * Reset turn rate when performing crawl vault * Convert all health decrease events to DoDamage calls * Remove SpasmEffectCount and unify touching with DoDamage * Give specific time delay before sprint jump is possible * Don't rumble on zero damage * Reorder input pipeline to prevent left+right collisions * Rename shady global * Rumble when breaking neck in swandive * Update lara_jump.cpp * Don't vibrate on soft splat * Fix combine item text alignment * Vibrate in settings only if setting was changed * Pulse gamepad on critical health condition * Don't get out of water into objects * Add critical air constant Co-authored-by: Sezz
2022-06-25 16:53:58 +03:00
StopRumble();
2021-11-16 15:51:50 +03:00
g_Gui.SetInventoryMode(InventoryMode::Load);
2021-11-16 15:51:50 +03:00
if (g_Gui.CallInventory(false))
return GameStatus::LoadGame;
}
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();
OIS input system (#556) * Work * Add ois.lib * Add OIS headers/libs to project * Fix small mistakes * Update input.cpp * Update input.cpp * Update input.cpp * Remove unnecessary event handlers as we are using direct polling * Fix numpad controls not polling * Enclose all input code under namespace, provide debug OIS lib variation * Fix incorrect inventory call binding, add pause to control dialog * Deselect by pushing inventory button as well, fix crossbow ammo string draw * Demagic NUM_CONTROLS * Verbose input init logging * Calibrate and properly register movement analog axis input * Fix crash when empty string is being displayed * Initialize vibration interface, if it exists * Register keyboard directional input as analog axis input as well * Fix statistics exiting * Fix weird UpdateInput call * Copy current layout to configuration * Fix issues with saving controls * Register axis values for POVs too * Register several POV directions at once * Increase deadzone a bit * Simplify enums * Update input.cpp * Move includes out of input.h * Bump deadzone even further as it seems xbox controllers have massive axis errors * Prevent event spamming in case OIS polling failed * Destroy input system on exit, cosmetic changes * Take deadzone into account when normalizing axis values * Update TombEngine.vcxproj * Resolve small precision loss in axis normalizing * Clean up unused control constants and enums * Update input.h * Demagic InputActions enum * Render pause menu header * Introduce helper functions to modulate Lara turn rates and begin replacements * Make turn directions explicit * Conduct remaining replacements of turn rate modulations * Update lara_helpers.cpp * Add smoothstep function to math library * Use scaled axis value for true analog input * Update input.cpp * Add Joey's camera rotation from old branch * Fix camera not going back to previous position when stick is released * Simplify ModulateLaraTurnRate() * Widen look angle * Avoid collisions with actions bound to non-directional axis * Small tidying * Remove unused header * Remove copypasted code * Mask flare animation * Rename 5th and 6th axis to LT/RT * Prototype force feedback support * Add directional rumble support (probably XInput-only) * Shake controller on startup if supports vibration * Update OIS libs to support XInput FF * Simplify ModulateLaraTurnRate() * Update player modulation functions; simplify turning, leaning, and flexing in state functions; lara.h cleanup * Update Win32ForceFeedback.h * Fix crawl flex function * Revert "Update Win32ForceFeedback.h" This reverts commit aa7099ed5bf2bc8402029aa2fcdece16ebabd5bf. * Update OIS libs * Add options for thumbstick camera and vibration * Make use of autotarget option * Display NON-SCREAMING names in controls, add hack to cancel axis value on both right+left input events * Remove useless control hacks for simultaneous directional input * Delete ten_itemdata_generated.h * Add scroll lock to bindable controls * Update input.cpp * Update input.cpp * Make input device namings consistent * Bring back IN_SELECT override * Fix crashing on startup and some other bugs * Add rumble to some in-game events * Add some more vibration events, stop them when going to menus * Some changes to rumble power * Add rumble for rocket/grenade launchers and explosive damage * Add rumble for screen shake effect * Fix 2 mistakes in inventory strings * Rumble for camera more precisely * Fix debounce in binocular mode * Update camera.cpp * Add HK lasersight rumble * Simplify ModulateLaraLean() * Update input.cpp * Fix crawl flex modulation(?) * Add slight rumble to harpoon and crossbow fire * Remove the confusing counteracting turn rate reset in favour of something simpler * Simplify turn rate reset input checks; leanup * Clamp turn rate axis coeff when airborne * Remove empty line * Simplify a function * Cleanup * Fix rumble being constant * Use shorter rumble time for shooting guns * Fix single arm shooting * Fix leaning left with joystick; clamp crawl flex max; tweak walk lean max; cleanup * Don't do too long splat and jump smash vibrations * Cancel turn rate when exiting water, grabbing ledge, or doing a splat * Rename function * Move ModulateLaraTurnRateY() callsin crawl and crouch turn states * Reset turn rate when performing crawl vault * Convert all health decrease events to DoDamage calls * Remove SpasmEffectCount and unify touching with DoDamage * Give specific time delay before sprint jump is possible * Don't rumble on zero damage * Reorder input pipeline to prevent left+right collisions * Rename shady global * Rumble when breaking neck in swandive * Update lara_jump.cpp * Don't vibrate on soft splat * Fix combine item text alignment * Vibrate in settings only if setting was changed * Pulse gamepad on critical health condition * Don't get out of water into objects * Add critical air constant Co-authored-by: Sezz
2022-06-25 16:53:58 +03:00
StopRumble();
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
}
OIS input system (#556) * Work * Add ois.lib * Add OIS headers/libs to project * Fix small mistakes * Update input.cpp * Update input.cpp * Update input.cpp * Remove unnecessary event handlers as we are using direct polling * Fix numpad controls not polling * Enclose all input code under namespace, provide debug OIS lib variation * Fix incorrect inventory call binding, add pause to control dialog * Deselect by pushing inventory button as well, fix crossbow ammo string draw * Demagic NUM_CONTROLS * Verbose input init logging * Calibrate and properly register movement analog axis input * Fix crash when empty string is being displayed * Initialize vibration interface, if it exists * Register keyboard directional input as analog axis input as well * Fix statistics exiting * Fix weird UpdateInput call * Copy current layout to configuration * Fix issues with saving controls * Register axis values for POVs too * Register several POV directions at once * Increase deadzone a bit * Simplify enums * Update input.cpp * Move includes out of input.h * Bump deadzone even further as it seems xbox controllers have massive axis errors * Prevent event spamming in case OIS polling failed * Destroy input system on exit, cosmetic changes * Take deadzone into account when normalizing axis values * Update TombEngine.vcxproj * Resolve small precision loss in axis normalizing * Clean up unused control constants and enums * Update input.h * Demagic InputActions enum * Render pause menu header * Introduce helper functions to modulate Lara turn rates and begin replacements * Make turn directions explicit * Conduct remaining replacements of turn rate modulations * Update lara_helpers.cpp * Add smoothstep function to math library * Use scaled axis value for true analog input * Update input.cpp * Add Joey's camera rotation from old branch * Fix camera not going back to previous position when stick is released * Simplify ModulateLaraTurnRate() * Widen look angle * Avoid collisions with actions bound to non-directional axis * Small tidying * Remove unused header * Remove copypasted code * Mask flare animation * Rename 5th and 6th axis to LT/RT * Prototype force feedback support * Add directional rumble support (probably XInput-only) * Shake controller on startup if supports vibration * Update OIS libs to support XInput FF * Simplify ModulateLaraTurnRate() * Update player modulation functions; simplify turning, leaning, and flexing in state functions; lara.h cleanup * Update Win32ForceFeedback.h * Fix crawl flex function * Revert "Update Win32ForceFeedback.h" This reverts commit aa7099ed5bf2bc8402029aa2fcdece16ebabd5bf. * Update OIS libs * Add options for thumbstick camera and vibration * Make use of autotarget option * Display NON-SCREAMING names in controls, add hack to cancel axis value on both right+left input events * Remove useless control hacks for simultaneous directional input * Delete ten_itemdata_generated.h * Add scroll lock to bindable controls * Update input.cpp * Update input.cpp * Make input device namings consistent * Bring back IN_SELECT override * Fix crashing on startup and some other bugs * Add rumble to some in-game events * Add some more vibration events, stop them when going to menus * Some changes to rumble power * Add rumble for rocket/grenade launchers and explosive damage * Add rumble for screen shake effect * Fix 2 mistakes in inventory strings * Rumble for camera more precisely * Fix debounce in binocular mode * Update camera.cpp * Add HK lasersight rumble * Simplify ModulateLaraLean() * Update input.cpp * Fix crawl flex modulation(?) * Add slight rumble to harpoon and crossbow fire * Remove the confusing counteracting turn rate reset in favour of something simpler * Simplify turn rate reset input checks; leanup * Clamp turn rate axis coeff when airborne * Remove empty line * Simplify a function * Cleanup * Fix rumble being constant * Use shorter rumble time for shooting guns * Fix single arm shooting * Fix leaning left with joystick; clamp crawl flex max; tweak walk lean max; cleanup * Don't do too long splat and jump smash vibrations * Cancel turn rate when exiting water, grabbing ledge, or doing a splat * Rename function * Move ModulateLaraTurnRateY() callsin crawl and crouch turn states * Reset turn rate when performing crawl vault * Convert all health decrease events to DoDamage calls * Remove SpasmEffectCount and unify touching with DoDamage * Give specific time delay before sprint jump is possible * Don't rumble on zero damage * Reorder input pipeline to prevent left+right collisions * Rename shady global * Rumble when breaking neck in swandive * Update lara_jump.cpp * Don't vibrate on soft splat * Fix combine item text alignment * Vibrate in settings only if setting was changed * Pulse gamepad on critical health condition * Don't get out of water into objects * Add critical air constant Co-authored-by: Sezz
2022-06-25 16:53:58 +03:00
else if ((DbInput & IN_OPTION || g_Gui.GetEnterInventory() != NO_ITEM) &&
LaraItem->HitPoints > 0 && !BinocularOn)
2021-05-18 19:16:58 -05:00
{
2021-10-29 02:22:26 +03:00
StopAllSounds();
OIS input system (#556) * Work * Add ois.lib * Add OIS headers/libs to project * Fix small mistakes * Update input.cpp * Update input.cpp * Update input.cpp * Remove unnecessary event handlers as we are using direct polling * Fix numpad controls not polling * Enclose all input code under namespace, provide debug OIS lib variation * Fix incorrect inventory call binding, add pause to control dialog * Deselect by pushing inventory button as well, fix crossbow ammo string draw * Demagic NUM_CONTROLS * Verbose input init logging * Calibrate and properly register movement analog axis input * Fix crash when empty string is being displayed * Initialize vibration interface, if it exists * Register keyboard directional input as analog axis input as well * Fix statistics exiting * Fix weird UpdateInput call * Copy current layout to configuration * Fix issues with saving controls * Register axis values for POVs too * Register several POV directions at once * Increase deadzone a bit * Simplify enums * Update input.cpp * Move includes out of input.h * Bump deadzone even further as it seems xbox controllers have massive axis errors * Prevent event spamming in case OIS polling failed * Destroy input system on exit, cosmetic changes * Take deadzone into account when normalizing axis values * Update TombEngine.vcxproj * Resolve small precision loss in axis normalizing * Clean up unused control constants and enums * Update input.h * Demagic InputActions enum * Render pause menu header * Introduce helper functions to modulate Lara turn rates and begin replacements * Make turn directions explicit * Conduct remaining replacements of turn rate modulations * Update lara_helpers.cpp * Add smoothstep function to math library * Use scaled axis value for true analog input * Update input.cpp * Add Joey's camera rotation from old branch * Fix camera not going back to previous position when stick is released * Simplify ModulateLaraTurnRate() * Widen look angle * Avoid collisions with actions bound to non-directional axis * Small tidying * Remove unused header * Remove copypasted code * Mask flare animation * Rename 5th and 6th axis to LT/RT * Prototype force feedback support * Add directional rumble support (probably XInput-only) * Shake controller on startup if supports vibration * Update OIS libs to support XInput FF * Simplify ModulateLaraTurnRate() * Update player modulation functions; simplify turning, leaning, and flexing in state functions; lara.h cleanup * Update Win32ForceFeedback.h * Fix crawl flex function * Revert "Update Win32ForceFeedback.h" This reverts commit aa7099ed5bf2bc8402029aa2fcdece16ebabd5bf. * Update OIS libs * Add options for thumbstick camera and vibration * Make use of autotarget option * Display NON-SCREAMING names in controls, add hack to cancel axis value on both right+left input events * Remove useless control hacks for simultaneous directional input * Delete ten_itemdata_generated.h * Add scroll lock to bindable controls * Update input.cpp * Update input.cpp * Make input device namings consistent * Bring back IN_SELECT override * Fix crashing on startup and some other bugs * Add rumble to some in-game events * Add some more vibration events, stop them when going to menus * Some changes to rumble power * Add rumble for rocket/grenade launchers and explosive damage * Add rumble for screen shake effect * Fix 2 mistakes in inventory strings * Rumble for camera more precisely * Fix debounce in binocular mode * Update camera.cpp * Add HK lasersight rumble * Simplify ModulateLaraLean() * Update input.cpp * Fix crawl flex modulation(?) * Add slight rumble to harpoon and crossbow fire * Remove the confusing counteracting turn rate reset in favour of something simpler * Simplify turn rate reset input checks; leanup * Clamp turn rate axis coeff when airborne * Remove empty line * Simplify a function * Cleanup * Fix rumble being constant * Use shorter rumble time for shooting guns * Fix single arm shooting * Fix leaning left with joystick; clamp crawl flex max; tweak walk lean max; cleanup * Don't do too long splat and jump smash vibrations * Cancel turn rate when exiting water, grabbing ledge, or doing a splat * Rename function * Move ModulateLaraTurnRateY() callsin crawl and crouch turn states * Reset turn rate when performing crawl vault * Convert all health decrease events to DoDamage calls * Remove SpasmEffectCount and unify touching with DoDamage * Give specific time delay before sprint jump is possible * Don't rumble on zero damage * Reorder input pipeline to prevent left+right collisions * Rename shady global * Rumble when breaking neck in swandive * Update lara_jump.cpp * Don't vibrate on soft splat * Fix combine item text alignment * Vibrate in settings only if setting was changed * Pulse gamepad on critical health condition * Don't get out of water into objects * Add critical air constant Co-authored-by: Sezz
2022-06-25 16:53:58 +03:00
StopRumble();
2021-05-18 19:16:58 -05:00
2021-11-16 15:51:50 +03:00
if (g_Gui.CallInventory(true))
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)
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)
return GameStatus::LevelComplete;
2020-12-21 13:16:29 -03:00
int oldInput = TrInput;
// Is Lara dead?
if (CurrentLevel != 0 && (Lara.Control.Count.Death > 300 || Lara.Control.Count.Death > 60 && TrInput))
2020-12-21 13:16:29 -03: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)
OIS input system (#556) * Work * Add ois.lib * Add OIS headers/libs to project * Fix small mistakes * Update input.cpp * Update input.cpp * Update input.cpp * Remove unnecessary event handlers as we are using direct polling * Fix numpad controls not polling * Enclose all input code under namespace, provide debug OIS lib variation * Fix incorrect inventory call binding, add pause to control dialog * Deselect by pushing inventory button as well, fix crossbow ammo string draw * Demagic NUM_CONTROLS * Verbose input init logging * Calibrate and properly register movement analog axis input * Fix crash when empty string is being displayed * Initialize vibration interface, if it exists * Register keyboard directional input as analog axis input as well * Fix statistics exiting * Fix weird UpdateInput call * Copy current layout to configuration * Fix issues with saving controls * Register axis values for POVs too * Register several POV directions at once * Increase deadzone a bit * Simplify enums * Update input.cpp * Move includes out of input.h * Bump deadzone even further as it seems xbox controllers have massive axis errors * Prevent event spamming in case OIS polling failed * Destroy input system on exit, cosmetic changes * Take deadzone into account when normalizing axis values * Update TombEngine.vcxproj * Resolve small precision loss in axis normalizing * Clean up unused control constants and enums * Update input.h * Demagic InputActions enum * Render pause menu header * Introduce helper functions to modulate Lara turn rates and begin replacements * Make turn directions explicit * Conduct remaining replacements of turn rate modulations * Update lara_helpers.cpp * Add smoothstep function to math library * Use scaled axis value for true analog input * Update input.cpp * Add Joey's camera rotation from old branch * Fix camera not going back to previous position when stick is released * Simplify ModulateLaraTurnRate() * Widen look angle * Avoid collisions with actions bound to non-directional axis * Small tidying * Remove unused header * Remove copypasted code * Mask flare animation * Rename 5th and 6th axis to LT/RT * Prototype force feedback support * Add directional rumble support (probably XInput-only) * Shake controller on startup if supports vibration * Update OIS libs to support XInput FF * Simplify ModulateLaraTurnRate() * Update player modulation functions; simplify turning, leaning, and flexing in state functions; lara.h cleanup * Update Win32ForceFeedback.h * Fix crawl flex function * Revert "Update Win32ForceFeedback.h" This reverts commit aa7099ed5bf2bc8402029aa2fcdece16ebabd5bf. * Update OIS libs * Add options for thumbstick camera and vibration * Make use of autotarget option * Display NON-SCREAMING names in controls, add hack to cancel axis value on both right+left input events * Remove useless control hacks for simultaneous directional input * Delete ten_itemdata_generated.h * Add scroll lock to bindable controls * Update input.cpp * Update input.cpp * Make input device namings consistent * Bring back IN_SELECT override * Fix crashing on startup and some other bugs * Add rumble to some in-game events * Add some more vibration events, stop them when going to menus * Some changes to rumble power * Add rumble for rocket/grenade launchers and explosive damage * Add rumble for screen shake effect * Fix 2 mistakes in inventory strings * Rumble for camera more precisely * Fix debounce in binocular mode * Update camera.cpp * Add HK lasersight rumble * Simplify ModulateLaraLean() * Update input.cpp * Fix crawl flex modulation(?) * Add slight rumble to harpoon and crossbow fire * Remove the confusing counteracting turn rate reset in favour of something simpler * Simplify turn rate reset input checks; leanup * Clamp turn rate axis coeff when airborne * Remove empty line * Simplify a function * Cleanup * Fix rumble being constant * Use shorter rumble time for shooting guns * Fix single arm shooting * Fix leaning left with joystick; clamp crawl flex max; tweak walk lean max; cleanup * Don't do too long splat and jump smash vibrations * Cancel turn rate when exiting water, grabbing ledge, or doing a splat * Rename function * Move ModulateLaraTurnRateY() callsin crawl and crouch turn states * Reset turn rate when performing crawl vault * Convert all health decrease events to DoDamage calls * Remove SpasmEffectCount and unify touching with DoDamage * Give specific time delay before sprint jump is possible * Don't rumble on zero damage * Reorder input pipeline to prevent left+right collisions * Rename shady global * Rumble when breaking neck in swandive * Update lara_jump.cpp * Don't vibrate on soft splat * Fix combine item text alignment * Vibrate in settings only if setting was changed * Pulse gamepad on critical health condition * Don't get out of water into objects * Add critical air constant Co-authored-by: Sezz
2022-06-25 16:53:58 +03:00
HandleOptics();
2020-12-21 13:16:29 -03:00
// Update all items
InItemControlLoop = true;
short itemNumber = NextItemActive;
while (itemNumber != NO_ITEM)
2020-12-21 13:16:29 -03:00
{
auto* item = &g_Level.Items[itemNumber];
short nextItem = item->NextActive;
2020-12-21 13:16:29 -03:00
if (item->AfterDeath <= 128)
2020-12-21 13:16:29 -03:00
{
if (Objects[item->ObjectNumber].control)
Objects[item->ObjectNumber].control(itemNumber);
2020-12-21 13:16:29 -03:00
Merge branch 'state_cleaning_tier_2' into luarefactor # Conflicts: # .gitignore # Common/Game/collision/collide_room.h # Common/Game/control/control.h # Common/Game/items.h # Common/Specific/phd_global.h # Common/Specific/trmath.h # Scripting/src/TEN/Flow/Animations/Animations.h # Scripting/src/TEN/Flow/FlowHandler.cpp # Scripts/Settings.lua # TR5Main/Game/Lara/lara.cpp # TR5Main/Game/Lara/lara_basic.cpp # TR5Main/Game/Lara/lara_cheat.cpp # TR5Main/Game/Lara/lara_collide.cpp # TR5Main/Game/Lara/lara_crawl.cpp # TR5Main/Game/Lara/lara_helpers.cpp # TR5Main/Game/Lara/lara_jump.cpp # TR5Main/Game/Lara/lara_monkey.cpp # TR5Main/Game/Lara/lara_swim.cpp # TR5Main/Game/Lara/lara_tests.cpp # TR5Main/Game/animation.cpp # TR5Main/Game/camera.cpp # TR5Main/Game/collision/collide_item.cpp # TR5Main/Game/collision/collide_room.cpp # TR5Main/Game/collision/floordata.cpp # TR5Main/Game/control/control.cpp # TR5Main/Game/control/los.cpp # TR5Main/Game/control/volume.cpp # TR5Main/Game/effects/hair.cpp # TR5Main/Game/gui.cpp # TR5Main/Game/health.cpp # TR5Main/Game/items.cpp # TR5Main/Game/room.cpp # TR5Main/Game/savegame.cpp # TR5Main/Renderer/ConstantBuffers/MiscBuffer.h # TR5Main/Renderer/RenderPipelineState/RenderPipelineState.cpp # TR5Main/Renderer/RenderPipelineState/RenderPipelineState.h # TR5Main/Renderer/Renderer11Draw.cpp # TR5Main/Renderer/Renderer11Frame.cpp # TR5Main/Renderer/Renderer11Helper.cpp # TR5Main/Renderer/Renderer11Lara.cpp # TR5Main/Renderer/Renderer11PostProcess.cpp # TR5Main/Renderer/Renderer11Settings.cpp # TR5Main/Renderer/Renderer11String.cpp # TR5Main/Renderer/RendererSprites.h # TR5Main/Scripting/GameLogicScript.cpp # TR5Main/Scripting/GameScriptAnimations.cpp # TR5Main/Scripting/GameScriptItemInfo.cpp # TR5Main/Scripting/GameScriptItemInfo.h # TR5Main/Scripting/GameScriptMeshInfo.cpp # TR5Main/Scripting/GameScriptPosition.cpp # TR5Main/Specific/input.cpp # TR5Main/Specific/level.cpp # TR5Main/Specific/savegame/flatbuffers/ten_savegame_generated.h # TR5Main/TombEngine.vcxproj.filters # common/game/collision/collide_item.h
2022-05-05 06:28:43 +02:00
TEN::Control::Volumes::TestVolumes(itemNumber);
if (item->AfterDeath > 0 && item->AfterDeath < 128 && !(Wibble & 3))
item->AfterDeath++;
if (item->AfterDeath == 128)
KillItem(itemNumber);
2020-12-21 13:16:29 -03:00
}
else
KillItem(itemNumber);
2020-12-21 13:16:29 -03:00
itemNumber = nextItem;
2020-12-21 13:16:29 -03:00
}
InItemControlLoop = false;
KillMoveItems();
// Update all effects
InItemControlLoop = true;
short fxNumber = NextFxActive;
while (fxNumber != NO_ITEM)
2020-12-21 13:16:29 -03:00
{
short nextFx = EffectList[fxNumber].nextActive;
auto* fx = &EffectList[fxNumber];
2020-12-21 13:16:29 -03:00
if (Objects[fx->objectNumber].control)
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--;
2020-12-21 13:16:29 -03:00
if (SmokeCountR)
SmokeCountR--;
2020-12-21 13:16:29 -03:00
if (SplashCount)
SplashCount--;
2020-12-21 13:16:29 -03:00
if (WeaponDelay)
WeaponDelay--;
2020-12-21 13:16:29 -03:00
if (WeaponEnemyTimer)
WeaponEnemyTimer--;
if (CurrentLevel != 0)
{
g_GameScriptEntities->TestCollidingObjects();
2020-12-21 13:16:29 -03:00
// 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);
2020-12-21 13:16:29 -03:00
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
LaraCheatyBits(LaraItem);
TriggerLaraDrips(LaraItem);
2020-12-21 13:16:29 -03:00
// Update Lara's ponytails
HairControl(LaraItem, level->GetLaraType() == 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();
// Update special FX
2020-12-21 13:16:29 -03:00
UpdateSparks();
UpdateFireSparks();
UpdateSmoke();
UpdateBlood();
UpdateBubbles();
UpdateDebris();
UpdateGunShells();
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();
// 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, LaraItem);
2020-12-21 13:16:29 -03:00
UpdateFadeScreenAndCinematicBars();
// Clear savegame loaded flag
JustLoaded = false;
// Update timers
2020-12-21 13:16:29 -03:00
HealthBarTimer--;
GameTimer++;
}
return GameStatus::None;
2020-12-21 13:16:29 -03:00
}
unsigned CALLBACK GameMain(void *)
{
2021-09-16 01:12:19 +03:00
try
{
TENLog("Starting GameMain...", LogLevel::Info);
2021-09-16 01:12:19 +03:00
TimeInit();
if (g_GameFlow->IntroImagePath.empty())
throw TENScriptException("Intro image path is not set.");
2020-12-21 13:16:29 -03:00
// Do a fixed time title image
g_Renderer.RenderTitleImage();
2020-12-21 13:16:29 -03:00
// Execute the LUA gameflow and play the game
g_GameFlow->DoFlow();
2020-12-21 13:16:29 -03:00
DoTheGame = false;
2020-12-21 13:16:29 -03:00
// Finish the thread
PostMessage(WindowsHandle, WM_CLOSE, NULL, NULL);
EndThread();
}
2021-09-16 01:12:19 +03:00
catch (TENScriptException const& e)
{
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;
}
Merge branch 'state_cleaning_tier_2' into luarefactor # Conflicts: # .gitignore # Common/Game/collision/collide_room.h # Common/Game/control/control.h # Common/Game/items.h # Common/Specific/phd_global.h # Common/Specific/trmath.h # Scripting/src/TEN/Flow/Animations/Animations.h # Scripting/src/TEN/Flow/FlowHandler.cpp # Scripts/Settings.lua # TR5Main/Game/Lara/lara.cpp # TR5Main/Game/Lara/lara_basic.cpp # TR5Main/Game/Lara/lara_cheat.cpp # TR5Main/Game/Lara/lara_collide.cpp # TR5Main/Game/Lara/lara_crawl.cpp # TR5Main/Game/Lara/lara_helpers.cpp # TR5Main/Game/Lara/lara_jump.cpp # TR5Main/Game/Lara/lara_monkey.cpp # TR5Main/Game/Lara/lara_swim.cpp # TR5Main/Game/Lara/lara_tests.cpp # TR5Main/Game/animation.cpp # TR5Main/Game/camera.cpp # TR5Main/Game/collision/collide_item.cpp # TR5Main/Game/collision/collide_room.cpp # TR5Main/Game/collision/floordata.cpp # TR5Main/Game/control/control.cpp # TR5Main/Game/control/los.cpp # TR5Main/Game/control/volume.cpp # TR5Main/Game/effects/hair.cpp # TR5Main/Game/gui.cpp # TR5Main/Game/health.cpp # TR5Main/Game/items.cpp # TR5Main/Game/room.cpp # TR5Main/Game/savegame.cpp # TR5Main/Renderer/ConstantBuffers/MiscBuffer.h # TR5Main/Renderer/RenderPipelineState/RenderPipelineState.cpp # TR5Main/Renderer/RenderPipelineState/RenderPipelineState.h # TR5Main/Renderer/Renderer11Draw.cpp # TR5Main/Renderer/Renderer11Frame.cpp # TR5Main/Renderer/Renderer11Helper.cpp # TR5Main/Renderer/Renderer11Lara.cpp # TR5Main/Renderer/Renderer11PostProcess.cpp # TR5Main/Renderer/Renderer11Settings.cpp # TR5Main/Renderer/Renderer11String.cpp # TR5Main/Renderer/RendererSprites.h # TR5Main/Scripting/GameLogicScript.cpp # TR5Main/Scripting/GameScriptAnimations.cpp # TR5Main/Scripting/GameScriptItemInfo.cpp # TR5Main/Scripting/GameScriptItemInfo.h # TR5Main/Scripting/GameScriptMeshInfo.cpp # TR5Main/Scripting/GameScriptPosition.cpp # TR5Main/Specific/input.cpp # TR5Main/Specific/level.cpp # TR5Main/Specific/savegame/flatbuffers/ten_savegame_generated.h # TR5Main/TombEngine.vcxproj.filters # common/game/collision/collide_item.h
2022-05-05 06:28:43 +02:00
GameStatus DoTitle(int index, std::string const& ambient)
2020-12-21 13:16:29 -03:00
{
TENLog("DoTitle", LogLevel::Info);
2020-12-21 13:16:29 -03:00
// Load the title. Exit game if unsuccessful.
if (!LoadLevelFile(index))
return GameStatus::ExitGame;
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();
g_GameScript->ResetScripts(true);
2021-07-10 17:51:01 +01:00
// Run the level script
ScriptInterfaceLevel* level = g_GameFlow->GetLevel(index);
2021-07-10 17:51:01 +01:00
if (!level->ScriptFileName.empty())
{
2021-11-29 21:50:38 +00:00
g_GameScript->ExecuteScriptFile(level->ScriptFileName);
2021-07-10 17:51:01 +01:00
g_GameScript->InitCallbacks();
g_GameStringsHandler->SetCallbackDrawString([](std::string const key, D3DCOLOR col, int x, int y, int flags)
{
g_Renderer.DrawString(float(x)/float(g_Configuration.Width) * REFERENCE_RES_WIDTH, float(y)/float(g_Configuration.Height) * REFERENCE_RES_HEIGHT, key.c_str(), col, flags);
});
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;
}
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
Merge branch 'state_cleaning_tier_2' into luarefactor # Conflicts: # .gitignore # Common/Game/collision/collide_room.h # Common/Game/control/control.h # Common/Game/items.h # Common/Specific/phd_global.h # Common/Specific/trmath.h # Scripting/src/TEN/Flow/Animations/Animations.h # Scripting/src/TEN/Flow/FlowHandler.cpp # Scripts/Settings.lua # TR5Main/Game/Lara/lara.cpp # TR5Main/Game/Lara/lara_basic.cpp # TR5Main/Game/Lara/lara_cheat.cpp # TR5Main/Game/Lara/lara_collide.cpp # TR5Main/Game/Lara/lara_crawl.cpp # TR5Main/Game/Lara/lara_helpers.cpp # TR5Main/Game/Lara/lara_jump.cpp # TR5Main/Game/Lara/lara_monkey.cpp # TR5Main/Game/Lara/lara_swim.cpp # TR5Main/Game/Lara/lara_tests.cpp # TR5Main/Game/animation.cpp # TR5Main/Game/camera.cpp # TR5Main/Game/collision/collide_item.cpp # TR5Main/Game/collision/collide_room.cpp # TR5Main/Game/collision/floordata.cpp # TR5Main/Game/control/control.cpp # TR5Main/Game/control/los.cpp # TR5Main/Game/control/volume.cpp # TR5Main/Game/effects/hair.cpp # TR5Main/Game/gui.cpp # TR5Main/Game/health.cpp # TR5Main/Game/items.cpp # TR5Main/Game/room.cpp # TR5Main/Game/savegame.cpp # TR5Main/Renderer/ConstantBuffers/MiscBuffer.h # TR5Main/Renderer/RenderPipelineState/RenderPipelineState.cpp # TR5Main/Renderer/RenderPipelineState/RenderPipelineState.h # TR5Main/Renderer/Renderer11Draw.cpp # TR5Main/Renderer/Renderer11Frame.cpp # TR5Main/Renderer/Renderer11Helper.cpp # TR5Main/Renderer/Renderer11Lara.cpp # TR5Main/Renderer/Renderer11PostProcess.cpp # TR5Main/Renderer/Renderer11Settings.cpp # TR5Main/Renderer/Renderer11String.cpp # TR5Main/Renderer/RendererSprites.h # TR5Main/Scripting/GameLogicScript.cpp # TR5Main/Scripting/GameScriptAnimations.cpp # TR5Main/Scripting/GameScriptItemInfo.cpp # TR5Main/Scripting/GameScriptItemInfo.h # TR5Main/Scripting/GameScriptMeshInfo.cpp # TR5Main/Scripting/GameScriptPosition.cpp # TR5Main/Specific/input.cpp # TR5Main/Specific/level.cpp # TR5Main/Specific/savegame/flatbuffers/ten_savegame_generated.h # TR5Main/TombEngine.vcxproj.filters # common/game/collision/collide_item.h
2022-05-05 06:28:43 +02:00
// MERGE: PlaySoundTrack(index);
2020-12-21 13:16:29 -03:00
OIS input system (#556) * Work * Add ois.lib * Add OIS headers/libs to project * Fix small mistakes * Update input.cpp * Update input.cpp * Update input.cpp * Remove unnecessary event handlers as we are using direct polling * Fix numpad controls not polling * Enclose all input code under namespace, provide debug OIS lib variation * Fix incorrect inventory call binding, add pause to control dialog * Deselect by pushing inventory button as well, fix crossbow ammo string draw * Demagic NUM_CONTROLS * Verbose input init logging * Calibrate and properly register movement analog axis input * Fix crash when empty string is being displayed * Initialize vibration interface, if it exists * Register keyboard directional input as analog axis input as well * Fix statistics exiting * Fix weird UpdateInput call * Copy current layout to configuration * Fix issues with saving controls * Register axis values for POVs too * Register several POV directions at once * Increase deadzone a bit * Simplify enums * Update input.cpp * Move includes out of input.h * Bump deadzone even further as it seems xbox controllers have massive axis errors * Prevent event spamming in case OIS polling failed * Destroy input system on exit, cosmetic changes * Take deadzone into account when normalizing axis values * Update TombEngine.vcxproj * Resolve small precision loss in axis normalizing * Clean up unused control constants and enums * Update input.h * Demagic InputActions enum * Render pause menu header * Introduce helper functions to modulate Lara turn rates and begin replacements * Make turn directions explicit * Conduct remaining replacements of turn rate modulations * Update lara_helpers.cpp * Add smoothstep function to math library * Use scaled axis value for true analog input * Update input.cpp * Add Joey's camera rotation from old branch * Fix camera not going back to previous position when stick is released * Simplify ModulateLaraTurnRate() * Widen look angle * Avoid collisions with actions bound to non-directional axis * Small tidying * Remove unused header * Remove copypasted code * Mask flare animation * Rename 5th and 6th axis to LT/RT * Prototype force feedback support * Add directional rumble support (probably XInput-only) * Shake controller on startup if supports vibration * Update OIS libs to support XInput FF * Simplify ModulateLaraTurnRate() * Update player modulation functions; simplify turning, leaning, and flexing in state functions; lara.h cleanup * Update Win32ForceFeedback.h * Fix crawl flex function * Revert "Update Win32ForceFeedback.h" This reverts commit aa7099ed5bf2bc8402029aa2fcdece16ebabd5bf. * Update OIS libs * Add options for thumbstick camera and vibration * Make use of autotarget option * Display NON-SCREAMING names in controls, add hack to cancel axis value on both right+left input events * Remove useless control hacks for simultaneous directional input * Delete ten_itemdata_generated.h * Add scroll lock to bindable controls * Update input.cpp * Update input.cpp * Make input device namings consistent * Bring back IN_SELECT override * Fix crashing on startup and some other bugs * Add rumble to some in-game events * Add some more vibration events, stop them when going to menus * Some changes to rumble power * Add rumble for rocket/grenade launchers and explosive damage * Add rumble for screen shake effect * Fix 2 mistakes in inventory strings * Rumble for camera more precisely * Fix debounce in binocular mode * Update camera.cpp * Add HK lasersight rumble * Simplify ModulateLaraLean() * Update input.cpp * Fix crawl flex modulation(?) * Add slight rumble to harpoon and crossbow fire * Remove the confusing counteracting turn rate reset in favour of something simpler * Simplify turn rate reset input checks; leanup * Clamp turn rate axis coeff when airborne * Remove empty line * Simplify a function * Cleanup * Fix rumble being constant * Use shorter rumble time for shooting guns * Fix single arm shooting * Fix leaning left with joystick; clamp crawl flex max; tweak walk lean max; cleanup * Don't do too long splat and jump smash vibrations * Cancel turn rate when exiting water, grabbing ledge, or doing a splat * Rename function * Move ModulateLaraTurnRateY() callsin crawl and crouch turn states * Reset turn rate when performing crawl vault * Convert all health decrease events to DoDamage calls * Remove SpasmEffectCount and unify touching with DoDamage * Give specific time delay before sprint jump is possible * Don't rumble on zero damage * Reorder input pipeline to prevent left+right collisions * Rename shady global * Rumble when breaking neck in swandive * Update lara_jump.cpp * Don't vibrate on soft splat * Fix combine item text alignment * Vibrate in settings only if setting was changed * Pulse gamepad on critical health condition * Don't get out of water into objects * Add critical air constant Co-authored-by: Sezz
2022-06-25 16:53:58 +03:00
// Initialise 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();
g_GameScript->OnStart();
SetScreenFadeIn(FADE_SCREEN_SPEED);
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 && DoTheGame)
2021-05-18 19:16:58 -05:00
{
g_Renderer.RenderTitle();
2021-05-18 19:16:58 -05:00
OIS input system (#556) * Work * Add ois.lib * Add OIS headers/libs to project * Fix small mistakes * Update input.cpp * Update input.cpp * Update input.cpp * Remove unnecessary event handlers as we are using direct polling * Fix numpad controls not polling * Enclose all input code under namespace, provide debug OIS lib variation * Fix incorrect inventory call binding, add pause to control dialog * Deselect by pushing inventory button as well, fix crossbow ammo string draw * Demagic NUM_CONTROLS * Verbose input init logging * Calibrate and properly register movement analog axis input * Fix crash when empty string is being displayed * Initialize vibration interface, if it exists * Register keyboard directional input as analog axis input as well * Fix statistics exiting * Fix weird UpdateInput call * Copy current layout to configuration * Fix issues with saving controls * Register axis values for POVs too * Register several POV directions at once * Increase deadzone a bit * Simplify enums * Update input.cpp * Move includes out of input.h * Bump deadzone even further as it seems xbox controllers have massive axis errors * Prevent event spamming in case OIS polling failed * Destroy input system on exit, cosmetic changes * Take deadzone into account when normalizing axis values * Update TombEngine.vcxproj * Resolve small precision loss in axis normalizing * Clean up unused control constants and enums * Update input.h * Demagic InputActions enum * Render pause menu header * Introduce helper functions to modulate Lara turn rates and begin replacements * Make turn directions explicit * Conduct remaining replacements of turn rate modulations * Update lara_helpers.cpp * Add smoothstep function to math library * Use scaled axis value for true analog input * Update input.cpp * Add Joey's camera rotation from old branch * Fix camera not going back to previous position when stick is released * Simplify ModulateLaraTurnRate() * Widen look angle * Avoid collisions with actions bound to non-directional axis * Small tidying * Remove unused header * Remove copypasted code * Mask flare animation * Rename 5th and 6th axis to LT/RT * Prototype force feedback support * Add directional rumble support (probably XInput-only) * Shake controller on startup if supports vibration * Update OIS libs to support XInput FF * Simplify ModulateLaraTurnRate() * Update player modulation functions; simplify turning, leaning, and flexing in state functions; lara.h cleanup * Update Win32ForceFeedback.h * Fix crawl flex function * Revert "Update Win32ForceFeedback.h" This reverts commit aa7099ed5bf2bc8402029aa2fcdece16ebabd5bf. * Update OIS libs * Add options for thumbstick camera and vibration * Make use of autotarget option * Display NON-SCREAMING names in controls, add hack to cancel axis value on both right+left input events * Remove useless control hacks for simultaneous directional input * Delete ten_itemdata_generated.h * Add scroll lock to bindable controls * Update input.cpp * Update input.cpp * Make input device namings consistent * Bring back IN_SELECT override * Fix crashing on startup and some other bugs * Add rumble to some in-game events * Add some more vibration events, stop them when going to menus * Some changes to rumble power * Add rumble for rocket/grenade launchers and explosive damage * Add rumble for screen shake effect * Fix 2 mistakes in inventory strings * Rumble for camera more precisely * Fix debounce in binocular mode * Update camera.cpp * Add HK lasersight rumble * Simplify ModulateLaraLean() * Update input.cpp * Fix crawl flex modulation(?) * Add slight rumble to harpoon and crossbow fire * Remove the confusing counteracting turn rate reset in favour of something simpler * Simplify turn rate reset input checks; leanup * Clamp turn rate axis coeff when airborne * Remove empty line * Simplify a function * Cleanup * Fix rumble being constant * Use shorter rumble time for shooting guns * Fix single arm shooting * Fix leaning left with joystick; clamp crawl flex max; tweak walk lean max; cleanup * Don't do too long splat and jump smash vibrations * Cancel turn rate when exiting water, grabbing ledge, or doing a splat * Rename function * Move ModulateLaraTurnRateY() callsin crawl and crouch turn states * Reset turn rate when performing crawl vault * Convert all health decrease events to DoDamage calls * Remove SpasmEffectCount and unify touching with DoDamage * Give specific time delay before sprint jump is possible * Don't rumble on zero damage * Reorder input pipeline to prevent left+right collisions * Rename shady global * Rumble when breaking neck in swandive * Update lara_jump.cpp * Don't vibrate on soft splat * Fix combine item text alignment * Vibrate in settings only if setting was changed * Pulse gamepad on critical health condition * Don't get out of water into objects * Add critical air constant Co-authored-by: Sezz
2022-06-25 16:53:58 +03:00
UpdateInput();
2021-05-18 19:16:58 -05:00
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
g_GameScript->OnEnd();
g_GameScript->FreeLevelScripts();
2022-02-02 19:54:01 +00:00
g_GameScriptEntities->FreeEntities();
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:
return GameStatus::NewGame;
2021-11-16 15:35:41 +03:00
case InventoryResult::LoadGame:
return GameStatus::LoadGame;
2021-11-16 15:35:41 +03:00
case InventoryResult::ExitGame:
return GameStatus::ExitGame;
2020-12-21 13:16:29 -03:00
}
return GameStatus::NewGame;
2020-12-21 13:16:29 -03:00
}
Merge branch 'state_cleaning_tier_2' into luarefactor # Conflicts: # .gitignore # Common/Game/collision/collide_room.h # Common/Game/control/control.h # Common/Game/items.h # Common/Specific/phd_global.h # Common/Specific/trmath.h # Scripting/src/TEN/Flow/Animations/Animations.h # Scripting/src/TEN/Flow/FlowHandler.cpp # Scripts/Settings.lua # TR5Main/Game/Lara/lara.cpp # TR5Main/Game/Lara/lara_basic.cpp # TR5Main/Game/Lara/lara_cheat.cpp # TR5Main/Game/Lara/lara_collide.cpp # TR5Main/Game/Lara/lara_crawl.cpp # TR5Main/Game/Lara/lara_helpers.cpp # TR5Main/Game/Lara/lara_jump.cpp # TR5Main/Game/Lara/lara_monkey.cpp # TR5Main/Game/Lara/lara_swim.cpp # TR5Main/Game/Lara/lara_tests.cpp # TR5Main/Game/animation.cpp # TR5Main/Game/camera.cpp # TR5Main/Game/collision/collide_item.cpp # TR5Main/Game/collision/collide_room.cpp # TR5Main/Game/collision/floordata.cpp # TR5Main/Game/control/control.cpp # TR5Main/Game/control/los.cpp # TR5Main/Game/control/volume.cpp # TR5Main/Game/effects/hair.cpp # TR5Main/Game/gui.cpp # TR5Main/Game/health.cpp # TR5Main/Game/items.cpp # TR5Main/Game/room.cpp # TR5Main/Game/savegame.cpp # TR5Main/Renderer/ConstantBuffers/MiscBuffer.h # TR5Main/Renderer/RenderPipelineState/RenderPipelineState.cpp # TR5Main/Renderer/RenderPipelineState/RenderPipelineState.h # TR5Main/Renderer/Renderer11Draw.cpp # TR5Main/Renderer/Renderer11Frame.cpp # TR5Main/Renderer/Renderer11Helper.cpp # TR5Main/Renderer/Renderer11Lara.cpp # TR5Main/Renderer/Renderer11PostProcess.cpp # TR5Main/Renderer/Renderer11Settings.cpp # TR5Main/Renderer/Renderer11String.cpp # TR5Main/Renderer/RendererSprites.h # TR5Main/Scripting/GameLogicScript.cpp # TR5Main/Scripting/GameScriptAnimations.cpp # TR5Main/Scripting/GameScriptItemInfo.cpp # TR5Main/Scripting/GameScriptItemInfo.h # TR5Main/Scripting/GameScriptMeshInfo.cpp # TR5Main/Scripting/GameScriptPosition.cpp # TR5Main/Specific/input.cpp # TR5Main/Specific/level.cpp # TR5Main/Specific/savegame/flatbuffers/ten_savegame_generated.h # TR5Main/TombEngine.vcxproj.filters # common/game/collision/collide_item.h
2022-05-05 06:28:43 +02:00
GameStatus DoLevel(int index, std::string const& ambient, bool loadFromSavegame)
2020-12-21 13:16:29 -03:00
{
// Load the level and fall back to title, if load was unsuccessful
if (!LoadLevelFile(index))
return GameStatus::ExitToTitle;
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();
g_GameScript->ResetScripts(loadFromSavegame);
// Run the level script
ScriptInterfaceLevel* level = g_GameFlow->GetLevel(index);
Merge branch 'state_cleaning_tier_2' into luarefactor # Conflicts: # .gitignore # Common/Game/collision/collide_room.h # Common/Game/control/control.h # Common/Game/items.h # Common/Specific/phd_global.h # Common/Specific/trmath.h # Scripting/src/TEN/Flow/Animations/Animations.h # Scripting/src/TEN/Flow/FlowHandler.cpp # Scripts/Settings.lua # TR5Main/Game/Lara/lara.cpp # TR5Main/Game/Lara/lara_basic.cpp # TR5Main/Game/Lara/lara_cheat.cpp # TR5Main/Game/Lara/lara_collide.cpp # TR5Main/Game/Lara/lara_crawl.cpp # TR5Main/Game/Lara/lara_helpers.cpp # TR5Main/Game/Lara/lara_jump.cpp # TR5Main/Game/Lara/lara_monkey.cpp # TR5Main/Game/Lara/lara_swim.cpp # TR5Main/Game/Lara/lara_tests.cpp # TR5Main/Game/animation.cpp # TR5Main/Game/camera.cpp # TR5Main/Game/collision/collide_item.cpp # TR5Main/Game/collision/collide_room.cpp # TR5Main/Game/collision/floordata.cpp # TR5Main/Game/control/control.cpp # TR5Main/Game/control/los.cpp # TR5Main/Game/control/volume.cpp # TR5Main/Game/effects/hair.cpp # TR5Main/Game/gui.cpp # TR5Main/Game/health.cpp # TR5Main/Game/items.cpp # TR5Main/Game/room.cpp # TR5Main/Game/savegame.cpp # TR5Main/Renderer/ConstantBuffers/MiscBuffer.h # TR5Main/Renderer/RenderPipelineState/RenderPipelineState.cpp # TR5Main/Renderer/RenderPipelineState/RenderPipelineState.h # TR5Main/Renderer/Renderer11Draw.cpp # TR5Main/Renderer/Renderer11Frame.cpp # TR5Main/Renderer/Renderer11Helper.cpp # TR5Main/Renderer/Renderer11Lara.cpp # TR5Main/Renderer/Renderer11PostProcess.cpp # TR5Main/Renderer/Renderer11Settings.cpp # TR5Main/Renderer/Renderer11String.cpp # TR5Main/Renderer/RendererSprites.h # TR5Main/Scripting/GameLogicScript.cpp # TR5Main/Scripting/GameScriptAnimations.cpp # TR5Main/Scripting/GameScriptItemInfo.cpp # TR5Main/Scripting/GameScriptItemInfo.h # TR5Main/Scripting/GameScriptMeshInfo.cpp # TR5Main/Scripting/GameScriptPosition.cpp # TR5Main/Specific/input.cpp # TR5Main/Specific/level.cpp # TR5Main/Specific/savegame/flatbuffers/ten_savegame_generated.h # TR5Main/TombEngine.vcxproj.filters # common/game/collision/collide_item.h
2022-05-05 06:28:43 +02:00
if (!level->ScriptFileName.empty())
{
2021-11-29 21:50:38 +00:00
g_GameScript->ExecuteScriptFile(level->ScriptFileName);
g_GameScript->InitCallbacks();
g_GameStringsHandler->SetCallbackDrawString([](std::string const key, D3DCOLOR col, int x, int y, int flags)
{
g_Renderer.DrawString(float(x)/float(g_Configuration.Width) * REFERENCE_RES_WIDTH, float(y)/float(g_Configuration.Height) * REFERENCE_RES_HEIGHT, key.c_str(), col, flags);
});
}
// Play default background music
PlaySoundTrack(ambient, SoundTrackType::BGM);
2020-12-21 13:16:29 -03:00
// Restore the game?
if (loadFromSavegame)
{
SaveGame::Load(g_GameFlow->SelectedSaveGame);
2020-12-21 13:16:29 -03:00
2022-03-31 23:55:54 +11:00
Camera.pos.x = LaraItem->Pose.Position.x + 256;
Camera.pos.y = LaraItem->Pose.Position.y + 256;
Camera.pos.z = LaraItem->Pose.Position.z + 256;
2020-12-21 13:16:29 -03:00
2022-03-31 23:55:54 +11:00
Camera.target.x = LaraItem->Pose.Position.x;
Camera.target.y = LaraItem->Pose.Position.y;
Camera.target.z = LaraItem->Pose.Position.z;
2020-12-21 13:16:29 -03:00
int x = Lara.Control.Weapon.WeaponItem;
2020-12-21 13:16:29 -03:00
RequiredStartPos = false;
InitialiseGame = false;
g_GameFlow->SelectedSaveGame = 0;
}
else
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
// If not loading a savegame, then clear all the infos
Statistics.Level = {};
2020-12-21 13:16:29 -03:00
RequiredStartPos = false;
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
2020-12-21 13:16:29 -03:00
if (InitialiseGame)
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
// Clear all game infos as well
Statistics.Game = {};
2020-12-21 13:16:29 -03:00
GameTimer = 0;
InitialiseGame = false;
}
}
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();
if (loadFromSavegame)
g_GameScript->OnLoad();
else
g_GameScript->OnStart();
int nFrames = 2;
2020-12-21 13:16:29 -03:00
// First control phase
g_Renderer.ResetAnimations();
Merge branch 'state_cleaning_tier_2' into luarefactor # Conflicts: # .gitignore # Common/Game/collision/collide_room.h # Common/Game/control/control.h # Common/Game/items.h # Common/Specific/phd_global.h # Common/Specific/trmath.h # Scripting/src/TEN/Flow/Animations/Animations.h # Scripting/src/TEN/Flow/FlowHandler.cpp # Scripts/Settings.lua # TR5Main/Game/Lara/lara.cpp # TR5Main/Game/Lara/lara_basic.cpp # TR5Main/Game/Lara/lara_cheat.cpp # TR5Main/Game/Lara/lara_collide.cpp # TR5Main/Game/Lara/lara_crawl.cpp # TR5Main/Game/Lara/lara_helpers.cpp # TR5Main/Game/Lara/lara_jump.cpp # TR5Main/Game/Lara/lara_monkey.cpp # TR5Main/Game/Lara/lara_swim.cpp # TR5Main/Game/Lara/lara_tests.cpp # TR5Main/Game/animation.cpp # TR5Main/Game/camera.cpp # TR5Main/Game/collision/collide_item.cpp # TR5Main/Game/collision/collide_room.cpp # TR5Main/Game/collision/floordata.cpp # TR5Main/Game/control/control.cpp # TR5Main/Game/control/los.cpp # TR5Main/Game/control/volume.cpp # TR5Main/Game/effects/hair.cpp # TR5Main/Game/gui.cpp # TR5Main/Game/health.cpp # TR5Main/Game/items.cpp # TR5Main/Game/room.cpp # TR5Main/Game/savegame.cpp # TR5Main/Renderer/ConstantBuffers/MiscBuffer.h # TR5Main/Renderer/RenderPipelineState/RenderPipelineState.cpp # TR5Main/Renderer/RenderPipelineState/RenderPipelineState.h # TR5Main/Renderer/Renderer11Draw.cpp # TR5Main/Renderer/Renderer11Frame.cpp # TR5Main/Renderer/Renderer11Helper.cpp # TR5Main/Renderer/Renderer11Lara.cpp # TR5Main/Renderer/Renderer11PostProcess.cpp # TR5Main/Renderer/Renderer11Settings.cpp # TR5Main/Renderer/Renderer11String.cpp # TR5Main/Renderer/RendererSprites.h # TR5Main/Scripting/GameLogicScript.cpp # TR5Main/Scripting/GameScriptAnimations.cpp # TR5Main/Scripting/GameScriptItemInfo.cpp # TR5Main/Scripting/GameScriptItemInfo.h # TR5Main/Scripting/GameScriptMeshInfo.cpp # TR5Main/Scripting/GameScriptPosition.cpp # TR5Main/Specific/input.cpp # TR5Main/Specific/level.cpp # TR5Main/Specific/savegame/flatbuffers/ten_savegame_generated.h # TR5Main/TombEngine.vcxproj.filters # common/game/collision/collide_item.h
2022-05-05 06:28:43 +02:00
GameStatus result = ControlPhase(nFrames, 0);
2020-12-21 13:16:29 -03:00
// Fade in screen
SetScreenFadeIn(FADE_SCREEN_SPEED);
2020-12-21 13:16:29 -03:00
// The game loop, finally!
while (DoTheGame)
2020-12-21 13:16:29 -03:00
{
result = ControlPhase(nFrames, 0);
2020-12-21 13:16:29 -03:00
if (result == GameStatus::ExitToTitle ||
result == GameStatus::LoadGame ||
result == GameStatus::LevelComplete)
2020-12-21 13:16:29 -03:00
{
g_GameScript->OnEnd();
g_GameScript->FreeLevelScripts();
2022-02-02 19:54:01 +00:00
g_GameScriptEntities->FreeEntities();
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();
OIS input system (#556) * Work * Add ois.lib * Add OIS headers/libs to project * Fix small mistakes * Update input.cpp * Update input.cpp * Update input.cpp * Remove unnecessary event handlers as we are using direct polling * Fix numpad controls not polling * Enclose all input code under namespace, provide debug OIS lib variation * Fix incorrect inventory call binding, add pause to control dialog * Deselect by pushing inventory button as well, fix crossbow ammo string draw * Demagic NUM_CONTROLS * Verbose input init logging * Calibrate and properly register movement analog axis input * Fix crash when empty string is being displayed * Initialize vibration interface, if it exists * Register keyboard directional input as analog axis input as well * Fix statistics exiting * Fix weird UpdateInput call * Copy current layout to configuration * Fix issues with saving controls * Register axis values for POVs too * Register several POV directions at once * Increase deadzone a bit * Simplify enums * Update input.cpp * Move includes out of input.h * Bump deadzone even further as it seems xbox controllers have massive axis errors * Prevent event spamming in case OIS polling failed * Destroy input system on exit, cosmetic changes * Take deadzone into account when normalizing axis values * Update TombEngine.vcxproj * Resolve small precision loss in axis normalizing * Clean up unused control constants and enums * Update input.h * Demagic InputActions enum * Render pause menu header * Introduce helper functions to modulate Lara turn rates and begin replacements * Make turn directions explicit * Conduct remaining replacements of turn rate modulations * Update lara_helpers.cpp * Add smoothstep function to math library * Use scaled axis value for true analog input * Update input.cpp * Add Joey's camera rotation from old branch * Fix camera not going back to previous position when stick is released * Simplify ModulateLaraTurnRate() * Widen look angle * Avoid collisions with actions bound to non-directional axis * Small tidying * Remove unused header * Remove copypasted code * Mask flare animation * Rename 5th and 6th axis to LT/RT * Prototype force feedback support * Add directional rumble support (probably XInput-only) * Shake controller on startup if supports vibration * Update OIS libs to support XInput FF * Simplify ModulateLaraTurnRate() * Update player modulation functions; simplify turning, leaning, and flexing in state functions; lara.h cleanup * Update Win32ForceFeedback.h * Fix crawl flex function * Revert "Update Win32ForceFeedback.h" This reverts commit aa7099ed5bf2bc8402029aa2fcdece16ebabd5bf. * Update OIS libs * Add options for thumbstick camera and vibration * Make use of autotarget option * Display NON-SCREAMING names in controls, add hack to cancel axis value on both right+left input events * Remove useless control hacks for simultaneous directional input * Delete ten_itemdata_generated.h * Add scroll lock to bindable controls * Update input.cpp * Update input.cpp * Make input device namings consistent * Bring back IN_SELECT override * Fix crashing on startup and some other bugs * Add rumble to some in-game events * Add some more vibration events, stop them when going to menus * Some changes to rumble power * Add rumble for rocket/grenade launchers and explosive damage * Add rumble for screen shake effect * Fix 2 mistakes in inventory strings * Rumble for camera more precisely * Fix debounce in binocular mode * Update camera.cpp * Add HK lasersight rumble * Simplify ModulateLaraLean() * Update input.cpp * Fix crawl flex modulation(?) * Add slight rumble to harpoon and crossbow fire * Remove the confusing counteracting turn rate reset in favour of something simpler * Simplify turn rate reset input checks; leanup * Clamp turn rate axis coeff when airborne * Remove empty line * Simplify a function * Cleanup * Fix rumble being constant * Use shorter rumble time for shooting guns * Fix single arm shooting * Fix leaning left with joystick; clamp crawl flex max; tweak walk lean max; cleanup * Don't do too long splat and jump smash vibrations * Cancel turn rate when exiting water, grabbing ledge, or doing a splat * Rename function * Move ModulateLaraTurnRateY() callsin crawl and crouch turn states * Reset turn rate when performing crawl vault * Convert all health decrease events to DoDamage calls * Remove SpasmEffectCount and unify touching with DoDamage * Give specific time delay before sprint jump is possible * Don't rumble on zero damage * Reorder input pipeline to prevent left+right collisions * Rename shady global * Rumble when breaking neck in swandive * Update lara_jump.cpp * Don't vibrate on soft splat * Fix combine item text alignment * Vibrate in settings only if setting was changed * Pulse gamepad on critical health condition * Don't get out of water into objects * Add critical air constant Co-authored-by: Sezz
2022-06-25 16:53:58 +03:00
StopRumble();
2020-12-21 13:16:29 -03:00
return result;
}
nFrames = DrawPhase();
Sound_UpdateScene();
2020-12-21 13:16:29 -03:00
}
g_GameScript->ResetScripts(true);
return GameStatus::ExitGame;
2020-12-21 13:16:29 -03:00
}
2021-09-16 01:12:19 +03:00
void UpdateShatters()
{
if (!SmashedMeshCount)
return;
do
{
SmashedMeshCount--;
FloorInfo* floor = GetFloor(
2022-03-31 23:55:54 +11:00
SmashedMesh[SmashedMeshCount]->pos.Position.x,
SmashedMesh[SmashedMeshCount]->pos.Position.y,
SmashedMesh[SmashedMeshCount]->pos.Position.z,
2021-09-16 01:12:19 +03:00
&SmashedMeshRoom[SmashedMeshCount]);
2022-03-31 23:55:54 +11:00
TestTriggers(SmashedMesh[SmashedMeshCount]->pos.Position.x,
SmashedMesh[SmashedMeshCount]->pos.Position.y,
SmashedMesh[SmashedMeshCount]->pos.Position.z,
2021-09-16 01:12:19 +03:00
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-05-05 07:08:14 +02:00
bool ExplodeItemNode(ItemInfo *item, int node, int noXZVel, int bits)
2020-12-21 13:16:29 -03:00
{
if (1 << node & item->MeshBits)
2020-12-21 13:16:29 -03:00
{
int number = bits;
if (item->ObjectNumber == ID_SHOOT_SWITCH1 && (CurrentLevel == 4 || CurrentLevel == 7)) // TODO: remove hardcoded think !
2022-05-29 16:33:56 +03:00
SoundEffect(SFX_TR5_SMASH_METAL, &item->Pose);
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-03-31 23:55:54 +11:00
ShatterItem.yRot = item->Pose.Orientation.y;
2022-02-02 13:09:24 +11:00
ShatterItem.bit = 1 << node;
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;
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};
ShatterObject(&ShatterItem, NULL, number, item->RoomNumber, noXZVel);
item->MeshBits &= ~ShatterItem.bit;
2020-12-21 13:16:29 -03:00
2022-02-02 13:09:24 +11:00
return true;
2020-12-21 13:16:29 -03:00
}
2021-09-24 13:50:31 +03:00
2022-02-02 13:09:24 +11:00
return false;
2021-09-24 13:50:31 +03:00
}
void CleanUp()
{
// 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
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();
// Clear all kinds of particles
DisableSmokeParticles();
DisableDripParticles();
DisableBubbles();
DisableDebris();
2021-10-29 02:22:26 +03:00
// Clear soundtrack masks
ClearSoundTrackMasks();
2022-02-02 13:09:24 +11:00
}