Some network fixes with sidearm

This commit is contained in:
viktorljung
2016-03-12 17:34:32 +01:00
parent f7363eeea4
commit 944d10f4bb
2 changed files with 45 additions and 43 deletions
@@ -14,6 +14,7 @@ bool MultiplayerSnapshotFilter::FilterComponent(EntityWrapper entity, SharedComp
|| component.Info.Name == "Physics" || component.Info.Name == "Physics"
|| component.Info.Name == "AssaultWeapon" || component.Info.Name == "AssaultWeapon"
|| component.Info.Name == "DefenderWeapon" || component.Info.Name == "DefenderWeapon"
|| component.Info.Name == "SidearmWeapon"
|| component.Info.Name == "Animation" || component.Info.Name == "Animation"
|| component.Info.Name == "Blend" || component.Info.Name == "Blend"
|| component.Info.Name == "BlendAdditive" || component.Info.Name == "BlendAdditive"
+44 -43
View File
@@ -8,51 +8,52 @@ BoostSystem::BoostSystem(SystemParams params)
bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e) bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
{ {
if (e.Victim.ID == e.Inflictor.ID) { if (!IsClient) {
return false;
}
if (!e.Victim.Valid() || !LocalPlayer.Valid()) { if (e.Victim.ID == e.Inflictor.ID) {
return false; return false;
} }
if (e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) { if (!e.Victim.Valid() || !LocalPlayer.Valid()) {
return false; return false;
} }
if (!e.Inflictor.Valid()) { if (e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) {
return false; return false;
} }
//if its not friendly fire, return if (!e.Inflictor.Valid()) {
if ((int)m_World->GetComponent(e.Inflictor.ID, "Team")["Team"] != (int)m_World->GetComponent(e.Victim.ID, "Team")["Team"]) { return false;
return false; }
}
//if its not friendly fire, return
//determine the inflictors class if ((int)m_World->GetComponent(e.Inflictor.ID, "Team")["Team"] != (int)m_World->GetComponent(e.Victim.ID, "Team")["Team"]) {
auto className = DetermineClass(e.Inflictor); return false;
if (className == "") { }
return false;
} //determine the inflictors class
auto className = DetermineClass(e.Inflictor);
if (className == "") {
LOG_INFO("intflictor: %s, vicitm: %s", e.Inflictor.Name().c_str(), e.Victim.Name().c_str()); return false;
if(className == "SidearmWeapon") { // give ammo }
giveAmmo(e.Inflictor, e.Victim);
} else { //give boost if (className == "SidearmWeapon") { // give ammo
//get the XML file, example: "Schema/Entities/BoostclassName.xml" giveAmmo(e.Inflictor, e.Victim);
std::string classXML = "Schema/Entities/" + className + ".xml"; } else { //give boost
//get the XML file, example: "Schema/Entities/BoostclassName.xml"
//check if player already has a child with the component, if so delete that child std::string classXML = "Schema/Entities/" + className + ".xml";
auto playerBoostAssaultEntity = e.Victim.FirstChildByName(className);
if (playerBoostAssaultEntity.Valid()) { //check if player already has a child with the component, if so delete that child
m_World->DeleteEntity(playerBoostAssaultEntity.ID); 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);
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<EntityFile>(classXML);
EntityWrapper boostAssaultEntity = entityFile->MergeInto(m_World);
m_World->SetName(boostAssaultEntity.ID, className);
m_World->SetParent(boostAssaultEntity.ID, e.Victim.ID);
} }
return true; return true;