From b81bb9eeead495e600517d9ec5b54d806512a398 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 18 Feb 2016 15:17:19 +0100 Subject: [PATCH 1/3] Changed SprintAbility to take StrengthOfEffect. PlayerMovementSystem: if Sniper is sprinting he will now move faster. --- include/Engine/Input/FirstPersonInputController.h | 9 +++++++++ resources/Schema/Components/SprintAbility.xml | 2 +- resources/Schema/Components/SprintAbility.xsd | 4 ++-- src/Game/Systems/PlayerMovementSystem.cpp | 12 +++++++++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 7dc24a2c..21833864 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -28,6 +28,7 @@ public: virtual void Reset(); void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer); + bool SniperSprintingCheck(); virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; } virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; } @@ -241,4 +242,12 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool m_EventBroker->Publish(e); } +template +bool FirstPersonInputController::SniperSprintingCheck() { + if (m_SpecialAbilityKeyDown) { + return true; + } else { + return false; + } +} #endif \ No newline at end of file diff --git a/resources/Schema/Components/SprintAbility.xml b/resources/Schema/Components/SprintAbility.xml index 2aac99d6..5cc59a3a 100644 --- a/resources/Schema/Components/SprintAbility.xml +++ b/resources/Schema/Components/SprintAbility.xml @@ -1,4 +1,4 @@ - 2.0 + 2.0 \ No newline at end of file diff --git a/resources/Schema/Components/SprintAbility.xsd b/resources/Schema/Components/SprintAbility.xsd index 4207dee2..9eabb450 100644 --- a/resources/Schema/Components/SprintAbility.xsd +++ b/resources/Schema/Components/SprintAbility.xsd @@ -9,8 +9,8 @@ - - This is the cooldown on sprint + + This is the strength of the sprint effect diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index cb28c7e6..ee2f9ca3 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -58,7 +58,14 @@ void PlayerMovementSystem::updateMovementControllers(double dt) playerMovementSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"]; playerCrouchSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"]; } - + bool sniperSprinting = false; + if (player.HasComponent("SprintAbility")) { + if (controller->SniperSprintingCheck()) { + playerMovementSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; + playerCrouchSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; + sniperSprinting = true; + } + } if (player.HasComponent("Physics")) { ComponentWrapper cPhysics = player["Physics"]; @@ -114,6 +121,9 @@ void PlayerMovementSystem::updateMovementControllers(double dt) if (playerBoostAssaultEntity.Valid()) { accelerationSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"]; } + if (sniperSprinting) { + accelerationSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; + } velocity += accelerationSpeed * wishDirection; ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); } From c5f3bfc0cd7881437e6fba55a0512a03e18b8def Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 3 Mar 2016 17:33:41 +0100 Subject: [PATCH 2/3] Fixed the stuff in comments --- .../Engine/Input/FirstPersonInputController.h | 25 ++++++------------- src/Game/Systems/PlayerMovementSystem.cpp | 2 +- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 28795a7f..e5e6c0d5 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -28,9 +28,9 @@ public: virtual void Reset(); void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer); - bool SniperSprintingCheck(); virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; } virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; } + bool SpecialAbilityKeyDown() const { return m_SpecialAbilityKeyDown; } protected: const int m_PlayerID; @@ -145,10 +145,10 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm if (m_NumberOfMovementKeysDown == 0) { m_MovementKeyDown = false; } - //you have just released the key, store what key it was and reset the doubletap-sensitivity-timer - m_AssaultDashTapDirection = m_CurrentDirectionVector; - m_AssaultDashDoubleTapDeltaTime = 0.f; - + //you have just released the key, store what key it was and reset the doubletap-sensitivity-timer + m_AssaultDashTapDirection = m_CurrentDirectionVector; + m_AssaultDashDoubleTapDeltaTime = 0.f; + } } @@ -161,12 +161,9 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } if (e.Command == "SpecialAbility") { - if (e.Value > 0) { - m_SpecialAbilityKeyDown = true; - } else { - m_SpecialAbilityKeyDown = false; - } + m_SpecialAbilityKeyDown = e.Value > 0; } + if (m_SpecialAbilityKeyDown && m_MovementKeyDown) { m_ShiftDashing = true; } else { @@ -241,12 +238,4 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool m_EventBroker->Publish(e); } -template -bool FirstPersonInputController::SniperSprintingCheck() { - if (m_SpecialAbilityKeyDown) { - return true; - } else { - return false; - } -} #endif \ No newline at end of file diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 8bcf092f..07090425 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -68,7 +68,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt) } bool sniperSprinting = false; if (player.HasComponent("SprintAbility")) { - if (controller->SniperSprintingCheck()) { + if (controller->SpecialAbilityKeyDown()) { playerMovementSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; playerCrouchSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; sniperSprinting = true; From be331cb778665a670004cfebdea0d2b8f6dbf486 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 3 Mar 2016 18:05:10 +0100 Subject: [PATCH 3/3] fixed --- include/Engine/Input/FirstPersonInputController.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index f106a9eb..ed9469bd 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -165,11 +165,7 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm m_SpecialAbilityKeyDown = e.Value > 0; } - if (m_SpecialAbilityKeyDown && m_MovementKeyDown) { - m_ShiftDashing = true; - } else { - m_ShiftDashing = false; - } + m_ShiftDashing = m_SpecialAbilityKeyDown && m_MovementKeyDown; return true; }