Merge branch 'Movement' of github.com:teamfisk/TacticalZ into Movement

This commit is contained in:
Tleety
2016-03-13 21:01:15 +01:00
6 changed files with 248 additions and 44 deletions
+9 -11
View File
@@ -8,21 +8,16 @@ BoostSystem::BoostSystem(SystemParams params)
bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
{
if (e.Victim.ID == e.Inflictor.ID) {
if (e.Victim == e.Inflictor) {
return false;
}
if (!e.Victim.Valid() || !LocalPlayer.Valid()) {
if (!e.Victim.Valid() || !e.Inflictor.Valid()) {
return false;
}
if (e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) {
return false;
}
if (!e.Inflictor.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"]) {
@@ -38,6 +33,9 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
if (className == "SidearmWeapon") { // give ammo
giveAmmo(e.Inflictor, e.Victim);
} else { //give boost
if (!IsServer) {
return false;
}
//get the XML file, example: "Schema/Entities/BoostclassName.xml"
std::string classXML = "Schema/Entities/" + className + ".xml";
@@ -86,7 +84,7 @@ void BoostSystem::giveAmmo(EntityWrapper giver, EntityWrapper receiver)
int maxAmmo = receiver["AssaultWeapon"]["MaxAmmo"];
Field<int> ammo = receiver["AssaultWeapon"]["Ammo"];
int givenAmmo = 3;
int givenAmmo = 20;
magazineAmmo = glm::clamp(magazineAmmo + givenAmmo, 0, magazineSize);
if (magazineAmmo > prevMagazineAmmo) {
@@ -102,7 +100,7 @@ void BoostSystem::giveAmmo(EntityWrapper giver, EntityWrapper receiver)
int maxAmmo = receiver["DefenderWeapon"]["MaxAmmo"];
Field<int> ammo = receiver["DefenderWeapon"]["Ammo"];
int givenAmmo = 1;
int givenAmmo = 3;
magazineAmmo = glm::clamp(magazineAmmo + givenAmmo, 0, magazineSize);
if (magazineAmmo > prevMagazineAmmo) {
+8 -3
View File
@@ -392,17 +392,22 @@ void PlayerMovementSystem::spawnHexagon(EntityWrapper target)
bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e)
{
EntityWrapper player(m_World, e.Player);
if (!player.Valid()){// || !IsClient || player.ID == LocalPlayer.ID) {
EntityWrapper eventPlayer(m_World, e.Player);
if (!eventPlayer.Valid()){// || IsServer || eventPlayer.ID == LocalPlayer.ID) {
return false;
}
// auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DashEffect.xml");
// EntityWrapper dashEffect = entityFile->MergeInto(m_World);
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
EntityWrapper playerModel = eventPlayer.FirstChildByName("PlayerModel");
for (auto& kv : m_PlayerInputControllers) {
EntityWrapper player = kv.first;
if(player != eventPlayer) {
continue;
}
auto& controller = kv.second;
if (!player.Valid()) {
@@ -10,6 +10,7 @@ void AssaultWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWra
void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt)
{
CheckBoost(cWeapon, wi);
// Start reloading automatically if at 0 mag ammo
Field<int> magAmmo = cWeapon["MagazineAmmo"];
if (m_ConfigAutoReload && magAmmo <= 0) {
@@ -385,13 +386,11 @@ void AssaultWeaponBehaviour::CheckBoost(ComponentWrapper cWeapon, WeaponInfo& wi
PickData pickData = m_Renderer->Pick(centerScreen);
EntityWrapper victim(m_World, pickData.Entity);
if (!victim.Valid()) {
RemoveBoostCheckHUD(wi);
return;
}
// Don't let us somehow shoot ourselves in the foot
if (victim == LocalPlayer) {
RemoveBoostCheckHUD(wi);
return;
}
@@ -400,59 +399,111 @@ void AssaultWeaponBehaviour::CheckBoost(ComponentWrapper cWeapon, WeaponInfo& wi
victim = victim.FirstParentWithComponent("Player");
}
if (!victim.Valid()) {
RemoveBoostCheckHUD(wi);
return;
}
// 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"]) {
EntityWrapper friendlyBoostHudSpawner = wi.FirstPersonPlayerModel.FirstChildByName("FriendlyBoostAttachment");
if (friendlyBoostHudSpawner.Valid()) {
EntityWrapper assaultBoost = victim.FirstChildByName("BoostAssault");
EntityWrapper defenderBoost = victim.FirstChildByName("BoostDefender");
EntityWrapper sniperBoost = victim.FirstChildByName("BoostSniper");
auto children = m_World->GetDirectChildren(friendlyBoostHudSpawner.ID);
if (children.first == children.second) {
if (friendlyBoostHudSpawner.HasComponent("Spawner")) {
EntityWrapper friendlyAmmoHud = SpawnerSystem::Spawn(friendlyBoostHudSpawner, friendlyBoostHudSpawner);
if (friendlyAmmoHud.Valid()) {
EntityWrapper textEntity = friendlyAmmoHud.FirstChildByName("MagazineAmmo");
if (textEntity.Valid()) {
if (textEntity.HasComponent("Text")) {
// (std::string&)textEntity["Text"]["Content"] = std::to_string(magazineAmmo);
EntityWrapper friendlyBoostHud = SpawnerSystem::Spawn(friendlyBoostHudSpawner, friendlyBoostHudSpawner);
if (friendlyBoostHud.Valid()) {
EntityWrapper assaultBoostEntity = friendlyBoostHud.FirstChildByName("AssaultBoost");
if (assaultBoostEntity.Valid()) {
EntityWrapper active = assaultBoostEntity.FirstChildByName("Active");
if (active.HasComponent("Text")) {
if (assaultBoost.Valid()) {
(Field<bool>)active["Text"]["Visible"] = true;
} else {
(Field<bool>)active["Text"]["Visible"] = false;
}
}
}
EntityWrapper ammoTextEntity = friendlyAmmoHud.FirstChildByName("Ammo");
if (ammoTextEntity.Valid()) {
if (ammoTextEntity.HasComponent("Text")) {
// (std::string&)ammoTextEntity["Text"]["Content"] = std::to_string(ammo);
EntityWrapper defenderBoostEntity = friendlyBoostHud.FirstChildByName("DefenderBoost");
if (defenderBoostEntity.Valid()) {
EntityWrapper active = defenderBoostEntity.FirstChildByName("Active");
if (active.HasComponent("Text")) {
if (defenderBoost.Valid()) {
(Field<bool>)active["Text"]["Visible"] = true;
} else {
(Field<bool>)active["Text"]["Visible"] = false;
}
}
}
EntityWrapper sniperBoostEntity = friendlyBoostHud.FirstChildByName("SniperBoost");
if (sniperBoostEntity.Valid()) {
EntityWrapper active = sniperBoostEntity.FirstChildByName("Active");
if (active.HasComponent("Text")) {
if (sniperBoost.Valid()) {
(Field<bool>)active["Text"]["Visible"] = true;
} else {
(Field<bool>)active["Text"]["Visible"] = false;
}
}
}
}
}
} else {
EntityWrapper textEntity = friendlyBoostHudSpawner.FirstChildByName("MagazineAmmo");
if (textEntity.Valid()) {
if (textEntity.HasComponent("Text")) {
// (std::string&)textEntity["Text"]["Content"] = std::to_string(magazineAmmo);
EntityWrapper friendlyBoostHud = friendlyBoostHudSpawner.FirstChildByName("FriendlyBoostHUD");
if (friendlyBoostHud.Valid()) {
if(friendlyBoostHud.HasComponent("Lifetime")) {
(Field<double>)friendlyBoostHud["Lifetime"]["Lifetime"] = 0.5;
}
}
EntityWrapper ammoTextEntity = friendlyBoostHudSpawner.FirstChildByName("Ammo");
if (ammoTextEntity.Valid()) {
if (ammoTextEntity.HasComponent("Text")) {
// (std::string&)ammoTextEntity["Text"]["Content"] = std::to_string(ammo);
EntityWrapper assaultBoostEntity = friendlyBoostHud.FirstChildByName("AssaultBoost");
if (assaultBoostEntity.Valid()) {
EntityWrapper active = assaultBoostEntity.FirstChildByName("Active");
if (active.HasComponent("Text")) {
if (assaultBoost.Valid()) {
(Field<bool>)active["Text"]["Visible"] = true;
} else {
(Field<bool>)active["Text"]["Visible"] = false;
}
}
}
EntityWrapper defenderBoostEntity = friendlyBoostHud.FirstChildByName("DefenderBoost");
if (defenderBoostEntity.Valid()) {
EntityWrapper active = defenderBoostEntity.FirstChildByName("Active");
if (active.HasComponent("Text")) {
if (defenderBoost.Valid()) {
(Field<bool>)active["Text"]["Visible"] = true;
} else {
(Field<bool>)active["Text"]["Visible"] = false;
}
}
}
EntityWrapper sniperBoostEntity = friendlyBoostHud.FirstChildByName("SniperBoost");
if (sniperBoostEntity.Valid()) {
EntityWrapper active = sniperBoostEntity.FirstChildByName("Active");
if (active.HasComponent("Text")) {
if (sniperBoost.Valid()) {
(Field<bool>)active["Text"]["Visible"] = true;
} else {
(Field<bool>)active["Text"]["Visible"] = false;
}
}
}
}
}
}
}
}
void AssaultWeaponBehaviour::RemoveBoostCheckHUD(WeaponInfo& wi)
{
}