Merge pull request #119 from teamfisk/AssaultBoost

BoostSystem
This commit is contained in:
Tobias Dahl
2016-03-02 16:44:49 +01:00
22 changed files with 5590 additions and 12 deletions
+21
View File
@@ -0,0 +1,21 @@
#ifndef BoostSystem_h__
#define BoostSystem_h__
#include "Core/System.h"
#include "Core/ResourceManager.h"
#include "Core/EntityFileParser.h"
#include "Core/EPlayerDamage.h"
#include "Common.h"
class BoostSystem : public System
{
public:
BoostSystem(SystemParams params);
private:
EventRelay<BoostSystem, Events::PlayerDamage> m_EPlayerDamage;
bool OnPlayerDamage(Events::PlayerDamage& e);
std::string DetermineClass(EntityWrapper player);
};
#endif
+5
View File
@@ -35,7 +35,12 @@
<xs:include schemaLocation="Components/AmmoPickup.xsd"/>
<xs:include schemaLocation="Components/AnimationOffset.xsd"/>
<xs:include schemaLocation="Components/DashAbility.xsd"/>
<xs:include schemaLocation="Components/ShieldAbility.xsd"/>
<xs:include schemaLocation="Components/SprintAbility.xsd"/>
<xs:include schemaLocation="Components/AssaultWeapon.xsd"/>
<xs:include schemaLocation="Components/BoostAssault.xsd"/>
<xs:include schemaLocation="Components/BoostDefender.xsd"/>
<xs:include schemaLocation="Components/BoostSniper.xsd"/>
<xs:include schemaLocation="Components/Shield.xsd"/>
<xs:include schemaLocation="Components/Sprite.xsd"/>
<xs:include schemaLocation="Components/Shielded.xsd"/>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<BoostAssault xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BoostAssault.xsd">
<StrengthOfEffect>2</StrengthOfEffect>
</BoostAssault>
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="BoostAssault">
<xs:annotation>
<xs:documentation>This is the assault's class boost component</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="StrengthOfEffect" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>This is the strength of the boost effect</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<BoostDefender xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BoostDefender.xsd">
<StrengthOfEffect>10</StrengthOfEffect>
</BoostDefender>
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="BoostDefender">
<xs:annotation>
<xs:documentation>This is the defender's class boost component</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="StrengthOfEffect" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>This is the strength of the boost effect</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<BoostSniper xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BoostSniper.xsd">
<StrengthOfEffect>10</StrengthOfEffect>
</BoostSniper>
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="BoostSniper">
<xs:annotation>
<xs:documentation>This is the sniper's class boost component</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="StrengthOfEffect" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>This is the strength of the boost effect</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ShieldAbility xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ShieldAbility.xsd">
<CoolDownMaxTimer>2.0</CoolDownMaxTimer>
</ShieldAbility>
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="ShieldAbility">
<xs:annotation>
<xs:documentation>A shield component for one of the classes</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="CoolDownMaxTimer" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>This is the cooldown on shield</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<SprintAbility xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SprintAbility.xsd">
<CoolDownMaxTimer>2.0</CoolDownMaxTimer>
</SprintAbility>
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="SprintAbility">
<xs:annotation>
<xs:documentation>A sprint component for one of the classes</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="CoolDownMaxTimer" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>This is the cooldown on sprint</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:BoostAssault/>
<c:Lifetime>
<Lifetime>10</Lifetime>
</c:Lifetime>
<c:Transform/>
</Components>
<Children/>
</Entity>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:BoostDefender/>
<c:Lifetime>
<Lifetime>10</Lifetime>
</c:Lifetime>
<c:Transform/>
</Components>
<Children/>
</Entity>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:BoostSniper/>
<c:Lifetime>
<Lifetime>10</Lifetime>
</c:Lifetime>
<c:Transform/>
</Components>
<Children/>
</Entity>
+10 -10
View File
@@ -5019,7 +5019,7 @@
</Team>
</c:Team>
<c:Transform>
<Position X="-60.3695679" Y="5.64500046" Z="-79.3789597"/>
<Position X="-60.3695679" Y="5.14500046" Z="-79.3789597"/>
</c:Transform>
</Components>
<Children>
@@ -5089,7 +5089,7 @@
</Team>
</c:Team>
<c:Transform>
<Position X="60.0169258" Y="5.78000021" Z="76.2893906"/>
<Position X="60.0169258" Y="6.0800004" Z="76.2893906"/>
</c:Transform>
</Components>
<Children>
@@ -5165,7 +5165,7 @@
<c:Transform>
<Position X="48.9189453" Y="7.06223536" Z="-78.9347992"/>
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
<Orientation X="0" Y="75.6124268" Z="0"/>
<Orientation X="0" Y="74.6042328" Z="0"/>
</c:Transform>
<c:Trigger/>
</Components>
@@ -5184,7 +5184,7 @@
<c:Transform>
<Position X="-59.3499641" Y="7.46932745" Z="-20.6276321"/>
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
<Orientation X="0" Y="72.2667694" Z="0"/>
<Orientation X="0" Y="71.2585754" Z="0"/>
</c:Transform>
<c:Trigger/>
</Components>
@@ -5203,7 +5203,7 @@
<c:Transform>
<Position X="-1.13644195" Y="1.38919806" Z="38.9768829"/>
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
<Orientation X="0" Y="69.8748016" Z="0"/>
<Orientation X="0" Y="68.8666077" Z="0"/>
</c:Transform>
<c:Trigger/>
</Components>
@@ -5222,7 +5222,7 @@
<c:Transform>
<Position X="54.7225227" Y="6.51863909" Z="29.0052128"/>
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
<Orientation X="0" Y="70.1887283" Z="0"/>
<Orientation X="0" Y="69.180542" Z="0"/>
</c:Transform>
<c:Trigger/>
</Components>
@@ -5241,7 +5241,7 @@
<c:Transform>
<Position X="-51.6792374" Y="8.44526482" Z="32.5153465"/>
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
<Orientation X="0" Y="69.6374512" Z="0"/>
<Orientation X="0" Y="68.6292572" Z="0"/>
</c:Transform>
<c:Trigger/>
</Components>
@@ -5260,7 +5260,7 @@
<c:Transform>
<Position X="-42.3974304" Y="7.28327894" Z="81.9305344"/>
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
<Orientation X="0" Y="67.7666702" Z="0"/>
<Orientation X="0" Y="66.7584839" Z="0"/>
</c:Transform>
<c:Trigger/>
</Components>
@@ -5279,7 +5279,7 @@
<c:Transform>
<Position X="-9.85184956" Y="8.25567532" Z="39.6119232"/>
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
<Orientation X="0" Y="66.8154602" Z="0"/>
<Orientation X="0" Y="65.8073425" Z="0"/>
</c:Transform>
<c:Trigger/>
</Components>
@@ -5298,7 +5298,7 @@
<c:Transform>
<Position X="49.2257118" Y="7.39368248" Z="-31.1810112"/>
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
<Orientation X="0" Y="64.0265808" Z="0"/>
<Orientation X="0" Y="63.0184822" Z="0"/>
</c:Transform>
<c:Trigger/>
</Components>
+10
View File
@@ -26,6 +26,7 @@
#include "Network/MultiplayerSnapshotFilter.h"
#include "Game/Systems/AmmunitionHUDSystem.h"
#include "Game/Systems/KillFeedSystem.h"
#include "Game/Systems/BoostSystem.h"
#include "GUI/ButtonSystem.h"
#include "GUI/MainMenuSystem.h"
@@ -132,6 +133,15 @@ Game::Game(int argc, char* argv[])
m_SystemPipeline->AddSystem<DamageIndicatorSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<AmmunitionHUDSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<KillFeedSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<LifetimeSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<CapturePointSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<CapturePointHUDSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<PickupSpawnSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<AmmoPickupSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<DamageIndicatorSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<AmmunitionHUDSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<KillFeedSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<BoostSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<ButtonSystem>(updateOrderLevel, m_Renderer);
m_SystemPipeline->AddSystem<MainMenuSystem>(updateOrderLevel, m_Renderer);
// Populate Octree with collidables
+63
View File
@@ -0,0 +1,63 @@
#include "Systems/BoostSystem.h"
BoostSystem::BoostSystem(SystemParams params)
: System(params)
{
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &BoostSystem::OnPlayerDamage);
}
bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
{
if (e.Victim.ID == e.Inflictor.ID) {
return false;
}
if (!e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) {
return false;
}
if (!e.Inflictor.Valid() || !e.Victim.Valid()) {
return false;
}
//if its not friendly fire, return
if ((int)m_World->GetComponent(e.Inflictor.ID, "Team")["Team"] != (int)m_World->GetComponent(e.Victim.ID, "Team")["Team"]) {
return false;
}
//determine the inflictors class
auto className = DetermineClass(e.Inflictor);
if (className == "") {
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);
}
//load boost XML file, set it entity parented with the victim player
auto entityFile = ResourceManager::Load<EntityFile>(classXML);
EntityFileParser parser(entityFile);
EntityID boostAssaultEntity = parser.MergeEntities(m_World);
m_World->SetName(boostAssaultEntity, className);
m_World->SetParent(boostAssaultEntity, e.Victim.ID);
return true;
}
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";
}
return "";
}
+5
View File
@@ -30,6 +30,11 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e)
ComponentWrapper cHealth = e.Victim["Health"];
double& health = cHealth["Health"];
//if player has the boost from a defender, subtract the damage taken by StrengthOfEffect amount
auto playerBoostDefenderEntity = e.Victim.FirstChildByName("BoostDefender");
if (playerBoostDefenderEntity.Valid()) {
e.Damage -= (double)playerBoostDefenderEntity["BoostDefender"]["StrengthOfEffect"];
}
health -= e.Damage;
return true;
+10
View File
@@ -61,6 +61,12 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
float playerMovementSpeed = player["Player"]["MovementSpeed"];
float playerCrouchSpeed = player["Player"]["CrouchSpeed"];
glm::vec3& wishDirection = player["Player"]["CurrentWishDirection"];
auto playerBoostAssaultEntity = player.FirstChildByName("BoostAssault");
if (playerBoostAssaultEntity.Valid()) {
playerMovementSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"];
playerCrouchSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"];
}
if (player.HasComponent("Physics")) {
ComponentWrapper cPhysics = player["Physics"];
@@ -112,6 +118,10 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
//if doubleTapped do Assault Dash - but only boost maximum 50.0f
float doubleTapDashBoost = controller->AssaultDashDoubleTapped() ? 40.0f : 1.0f;
accelerationSpeed = glm::min(doubleTapDashBoost*glm::min(accelerationSpeed, addSpeed), 50.0f);
//if player has Boost from an Assault class, accelerate the player faster
if (playerBoostAssaultEntity.Valid()) {
accelerationSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"];
}
velocity += accelerationSpeed * wishDirection;
ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity));
}
@@ -366,9 +366,10 @@ bool AssaultWeaponBehaviour::shoot(double damage)
return false;
}
// Check for friendly fire
// If friendly fire - reduce damage to 0 (needed to make Boosts, Ammosharing work)
if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)m_Player["Team"]["Team"]) {
return false;
damage = 0;
}
// Deal damage!