From 0b26f23188e38caae27cf69fcdffd1e6aab49394 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Sat, 12 Mar 2016 15:47:19 +0100 Subject: [PATCH 1/2] 3rd person animations idle bug fixed --- .../Engine/Input/FirstPersonInputController.h | 19 ++-- include/Engine/Rendering/BlendTree.h | 3 +- .../Schema/Entities/PlayerAssaultBlue.xml | 94 +++++-------------- .../Schema/Entities/PlayerDefenderBlue.xml | 85 ++++------------- src/Engine/Rendering/AnimationSystem.cpp | 12 ++- src/Game/Systems/PlayerMovementSystem.cpp | 2 + .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 2 +- .../Systems/Weapon/SidearmWeaponBehaviour.cpp | 3 +- 8 files changed, 67 insertions(+), 153 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 30d1f945..68c8a430 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -163,6 +163,7 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm aeb.Duration = 0.1; aeb.NodeName = "Run"; aeb.RootNode = firstPersonModel; + aeb.SingleLevelBlend = true; aeb.Start = true; m_EventBroker->Publish(aeb); } @@ -172,6 +173,7 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm aeb.Duration = 0.1; aeb.NodeName = "Run"; aeb.RootNode = firstPersonModel; + aeb.SingleLevelBlend = true; aeb.Start = true; aeb.Reverse = true; m_EventBroker->Publish(aeb); @@ -211,10 +213,10 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } } - //Animation - if (glm::length2(m_Movement) < 0.25f) { - //Blend to Idle - if (m_PlayerEntity.Valid()) { + if (m_PlayerEntity.Valid()) { + glm::vec2 movementXZ = glm::vec2(m_Movement.x, m_Movement.z); + if (glm::length(movementXZ) < 0.1f) { + //Blend to Idle EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); if (playerModel.Valid()) { Events::AutoAnimationBlend aeb; @@ -233,10 +235,8 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm aeb.Start = true; m_EventBroker->Publish(aeb); } - } - } else { - //Blend to movement - if (m_PlayerEntity.Valid()) { + } else { + //Blend to movement EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); if (playerModel.Valid()) { Events::AutoAnimationBlend aeb; @@ -248,8 +248,7 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } } - - if (glm::length2(m_Movement) > 0) { + if (glm::length(m_Movement) > 0) { m_Movement = glm::normalize(m_Movement); //Animation diff --git a/include/Engine/Rendering/BlendTree.h b/include/Engine/Rendering/BlendTree.h index 502a1cc9..46ea7f0c 100644 --- a/include/Engine/Rendering/BlendTree.h +++ b/include/Engine/Rendering/BlendTree.h @@ -49,9 +49,7 @@ public: next = next->Child[0]; } } - return next; - } }; @@ -82,6 +80,7 @@ public: BlendTree::Node* FirstCommonParent(Node* node1, Node* node2); EntityWrapper GetSubTreeRoot(std::string nodeName); + std::vector GetSubTreeRoots(std::string nodeName); std::vector GetSingleLevelRoots(std::string name); std::vector GetEntitesByName(std::string name); diff --git a/resources/Schema/Entities/PlayerAssaultBlue.xml b/resources/Schema/Entities/PlayerAssaultBlue.xml index 4ca636da..4797ec09 100644 --- a/resources/Schema/Entities/PlayerAssaultBlue.xml +++ b/resources/Schema/Entities/PlayerAssaultBlue.xml @@ -583,8 +583,8 @@ Schema/Entities/WeaponAssaultBlueWorld.xml - - + + AssaultWeapon @@ -604,8 +604,8 @@ Schema/Entities/SidearmWeaponBlueWorld.xml - - + + SidearmWeapon @@ -959,7 +959,7 @@ - MovementBlend + IdleAssault ActionBlend @@ -998,41 +998,17 @@ - + - - Idle - Run - 0 - + + IdleAssaultRifleU + + true + true + - - - - - IdleAssaultRifleU - - true - true - - - - - - - - - IdleAssaultRifleU - - true - true - - - - - - + @@ -1063,44 +1039,12 @@ - MovementBlend2 + IdleSidearm ActionBlend - - - - Idle - Run - 0 - - - - - - - - IdleSecWepU - true - - - - - - - - - IdleSecWepU - true - - - - - - - @@ -1133,6 +1077,16 @@ + + + + IdleSecWepU + true + + + + + diff --git a/resources/Schema/Entities/PlayerDefenderBlue.xml b/resources/Schema/Entities/PlayerDefenderBlue.xml index 5fcc6c64..84324379 100644 --- a/resources/Schema/Entities/PlayerDefenderBlue.xml +++ b/resources/Schema/Entities/PlayerDefenderBlue.xml @@ -857,48 +857,12 @@ - MovementBlend2 + IdleDefender FinalBlend - - - - Idle - Run - 0 - - - - - - - - IdleAssaultRifleU - - true - true - - - - - - - - - IdleAssaultRifleU - - true - true - - - - - - - @@ -980,6 +944,18 @@ + + + + IdleAssaultRifleU + + true + true + + + + + @@ -1007,7 +983,7 @@ - MovementBlend2 + IdleSidearm ActionBlend @@ -1044,36 +1020,15 @@ - + - - Idle - Run - + + IdleSecWepU + true + - - - - - IdleSecWepU - true - - - - - - - - - IdleSecWepU - true - - - - - - + diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index e30c2e9f..3895dc4a 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -127,8 +127,8 @@ void AnimationSystem::UpdateAnimations(double dt) void AnimationSystem::UpdateWeights(double dt) { for (auto it = m_AutoBlendQueues.begin(); it != m_AutoBlendQueues.end(); ) { - /* LOG_INFO("%s", it->first.Name().c_str()); - it->second.PrintQueue();*/ + //LOG_INFO("%s", it->first.Name().c_str()); + //it->second.PrintQueue(); if(it->second.HasActiveBlendJob()) { AutoBlendQueue::AutoBlendJob& blendJob = it->second.GetActiveBlendJob(); @@ -158,12 +158,13 @@ void AnimationSystem::UpdateWeights(double dt) bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) { - if (!e.RootNode.Valid()) { + LOG_ERROR("%s, RootNode invalid %s", e.NodeName, e.RootNode.Name().c_str()); return false; } if (!e.RootNode.HasComponent("Model")) { + LOG_ERROR("%s, RootNode has no model %s", e.NodeName, e.RootNode.Name().c_str()); return false; } @@ -171,11 +172,13 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) try { model = ResourceManager::Load<::Model, true>((std::string)e.RootNode["Model"]["Resource"]); } catch (const std::exception&) { + LOG_ERROR("%s, RootNode model not finished loading %s", e.NodeName, e.RootNode.Name().c_str()); return false; } Skeleton* skeleton = model->m_RawModel->m_Skeleton; if (skeleton == nullptr) { + LOG_ERROR("%s, RootNode skeleton invalid %s", e.NodeName, e.RootNode.Name().c_str()); return false; } @@ -183,6 +186,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) if (skeleton->BlendTrees.find(e.RootNode) != skeleton->BlendTrees.end()) { blendTree = skeleton->BlendTrees.at(e.RootNode); } else { + LOG_ERROR("%s, No blendtree was found invalid %s", e.NodeName, e.RootNode.Name().c_str()); return false; } @@ -193,6 +197,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) subTreeRoot = blendTree->GetSubTreeRoot(e.NodeName); if (!subTreeRoot.Valid()) { + LOG_ERROR("%s, subTreeRoot invalid", e.NodeName); return false; } @@ -237,6 +242,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) subTreeRoot = entity; if (!subTreeRoot.Valid()) { + LOG_ERROR("%s, subTreeRoot invalid", e.NodeName); return false; } diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index b86d4140..51d7bcef 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -24,6 +24,8 @@ void PlayerMovementSystem::Update(double dt) if (LocalPlayer.Valid()){ updateVelocity(LocalPlayer, dt); } + + m_SprintEffectTimer += dt; if (m_SprintEffectTimer < 0.016f) { return; diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index cf2aa9c5..0662cbaa 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -74,7 +74,7 @@ void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& float animationWeight = glm::min(speed, movementSpeed) / movementSpeed; EntityWrapper rootNode = wi.FirstPersonEntity; if (rootNode.Valid()) { - EntityWrapper blend = rootNode.FirstChildByName("MovementBlend"); + EntityWrapper blend = rootNode.FirstChildByName("MovementBlendAssault"); if (blend.Valid()) { (double&)blend["Blend"]["Weight"] = animationWeight; } diff --git a/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp b/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp index 9c12bb2c..f87f1f81 100644 --- a/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp @@ -14,7 +14,6 @@ void SidearmWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWra void SidearmWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) { - CheckAmmo(cWeapon, wi); // Start reloading automatically if at 0 mag ammo @@ -64,7 +63,7 @@ void SidearmWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& float animationWeight = glm::min(speed, movementSpeed) / movementSpeed; EntityWrapper rootNode = wi.FirstPersonEntity; if (rootNode.Valid()) { - EntityWrapper blend = rootNode.FirstChildByName("MovementBlend"); + EntityWrapper blend = rootNode.FirstChildByName("MovementBlendSidearm"); if (blend.Valid()) { (double&)blend["Blend"]["Weight"] = animationWeight; } From 4ba011a098c3adbd82821c67ce518d83c118dc57 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Sat, 12 Mar 2016 17:01:46 +0100 Subject: [PATCH 2/2] Ammosharing over network test WIP --- include/Game/Systems/BoostSystem.h | 3 + .../Systems/Weapon/SidearmWeaponBehaviour.h | 2 +- include/Game/Systems/Weapon/WeaponBehaviour.h | 2 + .../Schema/Entities/PlayerAssaultBlue.xml | 865 +++++++++--------- .../Schema/Entities/PlayerDefenderBlue.xml | 803 ++++++++-------- src/Game/Systems/BoostSystem.cpp | 94 +- .../Systems/Weapon/SidearmWeaponBehaviour.cpp | 5 +- 7 files changed, 941 insertions(+), 833 deletions(-) diff --git a/include/Game/Systems/BoostSystem.h b/include/Game/Systems/BoostSystem.h index f02e9472..925ef438 100644 --- a/include/Game/Systems/BoostSystem.h +++ b/include/Game/Systems/BoostSystem.h @@ -6,6 +6,7 @@ #include "Core/EntityFile.h" #include "Core/EPlayerDamage.h" #include "Common.h" +#include "SpawnerSystem.h" class BoostSystem : public System { @@ -17,5 +18,7 @@ private: bool OnPlayerDamage(Events::PlayerDamage& e); std::string DetermineClass(EntityWrapper player); + + void giveAmmo(EntityWrapper giver, EntityWrapper receiver); }; #endif \ No newline at end of file diff --git a/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h b/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h index 7aa20025..3123b460 100644 --- a/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h @@ -37,7 +37,7 @@ private: bool playerInFirstPerson(EntityWrapper player); bool dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi); - void giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi, EntityWrapper receiver); + // void giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi, EntityWrapper receiver); void CheckAmmo(ComponentWrapper cWeapon, WeaponInfo& wi); diff --git a/include/Game/Systems/Weapon/WeaponBehaviour.h b/include/Game/Systems/Weapon/WeaponBehaviour.h index cd067f36..6d13e741 100644 --- a/include/Game/Systems/Weapon/WeaponBehaviour.h +++ b/include/Game/Systems/Weapon/WeaponBehaviour.h @@ -305,6 +305,8 @@ private: wi.ThirdPersonEntity = thirdPersonWeapon; wi.ThirdPersonPlayerModel = thirdPersonWeapon.FirstParentWithComponent("Model"); + player["Player"]["CurrentWeapon"] = cWeapon.Info.Name; + OnEquip(cWeapon, wi); } diff --git a/resources/Schema/Entities/PlayerAssaultBlue.xml b/resources/Schema/Entities/PlayerAssaultBlue.xml index 4797ec09..c73a4c46 100644 --- a/resources/Schema/Entities/PlayerAssaultBlue.xml +++ b/resources/Schema/Entities/PlayerAssaultBlue.xml @@ -59,447 +59,466 @@ - - - + + Schema/Entities/PlayerHUD.xml + + - - - - false - Models/Core/UnitQuad.mesh - - Textures/Weapons/Crosshair/SmallThickHoleDot.png - - - - - - - - - - - - Schema/Entities/HitMarker.xml - - - - - - + - - + - + - - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - 2 - - - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - 3 - - - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 1 - - - - 4 - - - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - 1 - - - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 1 - - - - - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - - - - - Models/Widgets/Arrows/Arrow5.mesh - - - - - - - - - - - - - - - - - - - - - 1 - - - - 100/100 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - 1 - - - - - Models/Core/UnitQuad.mesh - - Textures/HealthHUD3.png - - - - - - - - - - - - - - - - - - - - - - - false - Models/Core/UnitQuad.mesh - - Textures/Icons/Boosts/Assault-01.png - - - - - - - - - - - - - - - - - false - Models/Core/UnitQuad.mesh - - Textures/Icons/Boosts/Defender-01.png - - - - - - - - - - - - - - - - - false - Models/Core/UnitQuad.mesh - - Textures/Icons/Boosts/Sniper-01.png - - - - - - - - - - - - - - - - - - false Models/Core/UnitQuad.mesh - Textures\Icons\Abilities\Superman-01.png - + Textures/Weapons/Crosshair/SmallThickHoleDot.png - - - + + + + + + + + + + Schema/Entities/HitMarker.xml + + + + + + + + + + - + + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon.png + + true + + + + + + + + + + 1 + + + + 4 + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon_Rotated.png + true + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon.png + + true + + + + + + + + + + + + + 2 + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon_Rotated.png + true + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon.png + + true + + + + + + + + + + + + + 3 + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon_Rotated.png + true + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon.png + + true + + + + + + + + + + + + + 1 + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon_Rotated.png + true + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon.png + + true + + + + + + + + + + 1 + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon_Rotated.png + true + + + + + + + + + + + + + + + + + + + + + + + - 0.0 + Fonts/DroidSans.ttf,64 - - false + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + - - - + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + Models/Widgets/Arrows/ArrowBlue.mesh + + + + + + + + + + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + 1 + + + + + Models/Core/UnitQuad.mesh + + Textures/HealthHUD3.png + + true + + + + + + + + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Icons/Boosts/Assault-01.png + + true + + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Icons/Boosts/Defender-01.png + + true + + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Icons/Boosts/Sniper-01.png + + false + true + + + + + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Icons/Abilities/Long/Superman-01.png + + true + + + + + @@ -904,10 +923,10 @@ - + - DashRightF + DashLeftF 1.7999999523162842 false @@ -916,10 +935,10 @@ - + - DashLeftF + DashRightF 1.7999999523162842 false diff --git a/resources/Schema/Entities/PlayerDefenderBlue.xml b/resources/Schema/Entities/PlayerDefenderBlue.xml index 84324379..c75f50fd 100644 --- a/resources/Schema/Entities/PlayerDefenderBlue.xml +++ b/resources/Schema/Entities/PlayerDefenderBlue.xml @@ -92,446 +92,473 @@ - - - + + Schema/Entities/PlayerHUD.xml + + - - - - false - Models/Core/UnitQuad.mesh - - Textures/Weapons/Crosshair/SmallThickHoleDot.png - - - - - - - - - - - - Schema/Entities/HitMarker.xml - - - - - - + - - + - + false Models/Core/UnitQuad.mesh - Textures/Core/UnitHexagon.png - + Textures/Weapons/Crosshair/SmallThickHoleDot.png - + + - - - - - - - - 2 - - - false - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - + - + - - false - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - 3 - - - false - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - false - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 1 - - - - 4 - - - false - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - false - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - 1 - - - false - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - false - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 1 - - - - - false - Models/Core/UnitQuad.mesh - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - + + Schema/Entities/HitMarker.xml + - + - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - - - - - Models/Widgets/Arrows/Arrow5.mesh - - - - - - - - - - - - - - - - - - - - 1 - - - - 150/150 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - 1 - - - - - Models/Core/UnitQuad.mesh - - Textures/HealthHUD3.png - - - - - - - - - - - - - + + - + - - - false Models/Core/UnitQuad.mesh - Textures/Icons/Boosts/Assault-01.png - + Textures/Core/UnitHexagon.png + + true - - - + + + + + + + + 1 + + + + 4 + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon_Rotated.png + true + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon.png + + true + + + + + + + + + + + + + 2 + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon_Rotated.png + true + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon.png + + true + + + + + + + + + + + + + 3 + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon_Rotated.png + true + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon.png + + true + + + + + + + + + + + + + 1 + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon_Rotated.png + true + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon.png + + true + + + + + + + + + + 1 + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Core/UnitHexagon_Rotated.png + true + + + + + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + - + - - - - - false - Models/Core/UnitQuad.mesh - - Textures/Icons/Boosts/Defender-01.png - - + + + Fonts/DroidSans.ttf,64 + + + + - - - - - - - - - - - - - - false - Models/Core/UnitQuad.mesh - - Textures/Icons/Boosts/Sniper-01.png - - - - - - + - + - - - inf - - - - false - Models/Core/UnitQuad.mesh - - Textures\Icons\Abilities\SheildDots-01.png - - + + + + + + + + Models/Widgets/Arrows/ArrowBlue.mesh + - - - + + + + + + + + + + + + + + + 1 + + + + 150/150 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + 1 + + + + + Models/Core/UnitQuad.mesh + + Textures/HealthHUD3.png + + true + + + + + + + + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Icons/Boosts/Assault-01.png + + true + + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Icons/Boosts/Defender-01.png + + true + + + + + + + + + + + + + + + + false + Models/Core/UnitQuad.mesh + + Textures/Icons/Boosts/Sniper-01.png + + false + true + + + + + + + + + + + + + + + + 1 + + + + false + Models/Core/UnitQuad.mesh + + Textures/Icons/Abilities/Long/SheildDots-01.png + + true + + + + + + + + + + + diff --git a/src/Game/Systems/BoostSystem.cpp b/src/Game/Systems/BoostSystem.cpp index c3dc1f2b..2ebfff73 100644 --- a/src/Game/Systems/BoostSystem.cpp +++ b/src/Game/Systems/BoostSystem.cpp @@ -35,19 +35,25 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e) return false; } - //get the XML file, example: "Schema/Entities/BoostclassName.xml" - std::string classXML = "Schema/Entities/" + className + ".xml"; - //check if player already has a child with the component, if so delete that child - auto playerBoostAssaultEntity = e.Victim.FirstChildByName(className); - if (playerBoostAssaultEntity.Valid()) { - m_World->DeleteEntity(playerBoostAssaultEntity.ID); + LOG_INFO("intflictor: %s, vicitm: %s", e.Inflictor.Name().c_str(), e.Victim.Name().c_str()); + if(className == "SidearmWeapon") { // give ammo + giveAmmo(e.Inflictor, e.Victim); + } else { //give boost + //get the XML file, example: "Schema/Entities/BoostclassName.xml" + std::string classXML = "Schema/Entities/" + className + ".xml"; + + //check if player already has a child with the component, if so delete that child + auto playerBoostAssaultEntity = e.Victim.FirstChildByName(className); + if (playerBoostAssaultEntity.Valid()) { + m_World->DeleteEntity(playerBoostAssaultEntity.ID); + } + //load boost XML file, set it entity parented with the victim player + auto entityFile = ResourceManager::Load(classXML); + EntityWrapper boostAssaultEntity = entityFile->MergeInto(m_World); + m_World->SetName(boostAssaultEntity.ID, className); + m_World->SetParent(boostAssaultEntity.ID, e.Victim.ID); } - //load boost XML file, set it entity parented with the victim player - auto entityFile = ResourceManager::Load(classXML); - EntityWrapper boostAssaultEntity = entityFile->MergeInto(m_World); - m_World->SetName(boostAssaultEntity.ID, className); - m_World->SetParent(boostAssaultEntity.ID, e.Victim.ID); return true; } @@ -55,14 +61,64 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e) std::string BoostSystem::DetermineClass(EntityWrapper inflictorPlayer) { //determine the class based on what component the inflictor-player has - if (m_World->HasComponent(inflictorPlayer.ID, "DashAbility")) { - return "BoostAssault"; - } - if (m_World->HasComponent(inflictorPlayer.ID, "ShieldAbility")) { - return "BoostDefender"; - } - if (m_World->HasComponent(inflictorPlayer.ID, "SprintAbility")) { - return "BoostSniper"; + if (inflictorPlayer.HasComponent("Player")) { + if ((std::string)inflictorPlayer["Player"]["CurrentWeapon"] == "AssaultWeapon") { + return "BoostAssault"; + } + if ((std::string)inflictorPlayer["Player"]["CurrentWeapon"] == "DefenderWeapon") { + return "BoostDefender"; + } + if ((std::string)inflictorPlayer["Player"]["CurrentWeapon"] == "SniperWeapon") { + return "BoostSniper"; + } + if ((std::string)inflictorPlayer["Player"]["CurrentWeapon"] == "SidearmWeapon") { + return "SidearmWeapon"; + } } return ""; } + +void BoostSystem::giveAmmo(EntityWrapper giver, EntityWrapper receiver) +{ + bool gaveAmmo = false; + + if (receiver.HasComponent("AssaultWeapon")) { + int magazineSize = receiver["AssaultWeapon"]["MagazineSize"]; + int& magazineAmmo = receiver["AssaultWeapon"]["MagazineAmmo"]; + + int maxAmmo = receiver["AssaultWeapon"]["MaxAmmo"]; + int& ammo = receiver["AssaultWeapon"]["Ammo"]; + + if (magazineAmmo < magazineSize) { + magazineAmmo += 1; + gaveAmmo = true; + } else if (ammo < maxAmmo) { + ammo += 1; + gaveAmmo = true; + } + } else if (receiver.HasComponent("DefenderWeapon")) { + int magazineSize = receiver["DefenderWeapon"]["MagazineSize"]; + int& magazineAmmo = receiver["DefenderWeapon"]["MagazineAmmo"]; + + int maxAmmo = receiver["DefenderWeapon"]["MaxAmmo"]; + int& ammo = receiver["DefenderWeapon"]["Ammo"]; + + if (magazineAmmo < magazineSize) { + magazineAmmo += 1; + gaveAmmo = true; + } else if (ammo < maxAmmo) { + ammo += 1; + gaveAmmo = true; + } + } + + + if (gaveAmmo) { + EntityWrapper effectSpawner = giver.FirstChildByName("AmmoShareEffectSpawner"); + if (effectSpawner.Valid()) { + if (effectSpawner.HasComponent("Spawner")) { + SpawnerSystem::Spawn(effectSpawner, effectSpawner); + } + } + } +} diff --git a/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp b/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp index f87f1f81..517d17fb 100644 --- a/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp @@ -281,7 +281,7 @@ bool SidearmWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi // If friendly fire, reduce damage to 0 (needed to make Boosts, Ammosharing work) if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)wi.Player["Team"]["Team"]) { damage = 0; - giveAmmo(cWeapon, wi, victim); + //giveAmmo(cWeapon, wi, victim); } // Deal damage! @@ -293,6 +293,7 @@ bool SidearmWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi return damage > 0; } +/* void SidearmWeaponBehaviour::giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi, EntityWrapper receiver) { @@ -337,7 +338,7 @@ void SidearmWeaponBehaviour::giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi, } } } -} +}*/ void SidearmWeaponBehaviour::CheckAmmo(ComponentWrapper cWeapon, WeaponInfo& wi) {