From 771c32255c3aea2038a0ba3da6ba4aaff138362f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 10 Aug 2013 11:41:28 +0200 Subject: [PATCH 1/5] use advanced player statistics in cnc mod --- .../Widgets/Logic/CncConquestObjectivesLogic.cs | 10 ++++++++-- mods/cnc/rules/defaults.yaml | 7 +++++++ mods/cnc/rules/system.yaml | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs index 6953dbc75d..d10a55ea9f 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs @@ -10,6 +10,7 @@ using System.Drawing; using System.Linq; +using OpenRA.Mods.RA; using OpenRA.Widgets; namespace OpenRA.Mods.Cnc.Widgets.Logic @@ -60,8 +61,13 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic team.GetText = () => (pp.PlayerReference.Team == 0) ? "-" : pp.PlayerReference.Team.ToString(); scrollpanel.AddChild(item); - item.Get("KILLS").GetText = () => pp.Kills.ToString(); - item.Get("DEATHS").GetText = () => pp.Deaths.ToString(); + var stats = pp.PlayerActor.TraitOrDefault(); + if (stats == null) + break; + var totalKills = stats.UnitsKilled + stats.BuildingsKilled; + var totalDeaths = stats.UnitsDead + stats.BuildingsDead; + item.Get("KILLS").GetText = () => totalKills.ToString(); + item.Get("DEATHS").GetText = () => totalDeaths.ToString(); } } } diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 751e5b4014..f110faa08f 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -34,6 +34,7 @@ Guard: Guardable: BodyOrientation: + UpdatesPlayerStatistics: ^Tank: AppearsOnRadar: @@ -74,6 +75,7 @@ Guard: Guardable: BodyOrientation: + UpdatesPlayerStatistics: ^Helicopter: AppearsOnRadar: @@ -100,6 +102,7 @@ EmptyWeapon: HeliExplode DebugMuzzlePositions: BodyOrientation: + UpdatesPlayerStatistics: ^Infantry: AppearsOnRadar: @@ -156,6 +159,7 @@ HealIfBelow: 1 DamageCooldown: 125 RequiresTech: InfantryHealing + UpdatesPlayerStatistics: ^CivInfantry: Inherits: ^Infantry @@ -232,6 +236,7 @@ ScanRadius: 4 AttackMove: AttackFrontal: + UpdatesPlayerStatistics: ^Plane: AppearsOnRadar: @@ -270,6 +275,7 @@ Guard: Guardable: BodyOrientation: + UpdatesPlayerStatistics: ^Building: AppearsOnRadar: @@ -318,6 +324,7 @@ Range: 3 BodyOrientation: FrozenUnderFog: + UpdatesPlayerStatistics: ^CivBuilding: Inherits: ^Building diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index 1f1d4c1268..99c425c102 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -202,6 +202,7 @@ Player: RemapIndex: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190 BaseAttackNotifier: Shroud: + PlayerStatistics: World: LoadWidgetAtGameStart: From d2e4c2904f695a67674f4a12d1e1135a03c13014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 10 Aug 2013 11:45:05 +0200 Subject: [PATCH 2/5] fix broken team display in cnc objectives --- OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs index d10a55ea9f..5888712a66 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs @@ -58,7 +58,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic item.Get("FACTION").GetText = () => pp.Country.Name; var team = item.Get("TEAM"); - team.GetText = () => (pp.PlayerReference.Team == 0) ? "-" : pp.PlayerReference.Team.ToString(); + var teamNumber = world.LobbyInfo.ClientWithIndex(pp.ClientIndex).Team; + team.GetText = () => (teamNumber == 0) ? "-" : teamNumber.ToString(); scrollpanel.AddChild(item); var stats = pp.PlayerActor.TraitOrDefault(); From c98dfd0439677424dca3053c78e053788e8b3774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 10 Aug 2013 11:41:49 +0200 Subject: [PATCH 3/5] don't count walls as building kills for player stats --- mods/ra/rules/defaults.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index f1dc99b41c..d105ef291a 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -269,7 +269,6 @@ ProximityCaptor: Types:Wall Sellable: - UpdatesPlayerStatistics: Guardable: BodyOrientation: FrozenUnderFog: From 5dcf1c755c2b03e265903730f066e3ad5f07df25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 10 Aug 2013 11:42:31 +0200 Subject: [PATCH 4/5] use the player statistics everywhere --- OpenRA.Mods.RA/Activities/Teleport.cs | 8 +++++--- OpenRA.Mods.RA/Missions/Allies02Script.cs | 2 +- OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs | 5 ++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.RA/Activities/Teleport.cs b/OpenRA.Mods.RA/Activities/Teleport.cs index 39ad10bd0d..99ce99e4ee 100755 --- a/OpenRA.Mods.RA/Activities/Teleport.cs +++ b/OpenRA.Mods.RA/Activities/Teleport.cs @@ -42,10 +42,12 @@ namespace OpenRA.Mods.RA.Activities var cargo = self.Trait(); while (!cargo.IsEmpty(self)) { - if (chronosphere != null) - chronosphere.Owner.Kills++; + if (chronosphere != null && chronosphere.HasTrait()) + chronosphere.Owner.PlayerActor.Trait().UnitsKilled++; + var a = cargo.Unload(self); - a.Owner.Deaths++; + if (a.HasTrait()) + a.Owner.PlayerActor.Trait().UnitsDead++; } } diff --git a/OpenRA.Mods.RA/Missions/Allies02Script.cs b/OpenRA.Mods.RA/Missions/Allies02Script.cs index f6a63cd091..fcd455985f 100644 --- a/OpenRA.Mods.RA/Missions/Allies02Script.cs +++ b/OpenRA.Mods.RA/Missions/Allies02Script.cs @@ -252,7 +252,7 @@ namespace OpenRA.Mods.RA.Missions void UpdateDeaths() { - var unitDeaths = allies1.Deaths + allies2.Deaths; + var unitDeaths = allies1.PlayerActor.Trait().UnitsDead + allies2.PlayerActor.Trait().UnitsDead; fewDeaths.Text = FewDeathsTemplate.F(unitDeaths, DeathsThreshold); OnObjectivesUpdated(false); if (unitDeaths >= DeathsThreshold && fewDeaths.Status == ObjectiveStatus.InProgress) diff --git a/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs index c0a268aee4..4b03b0818a 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs @@ -257,11 +257,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic power.GetText = () => powerRes.PowerDrained + "/" + powerRes.PowerProvided; power.GetColor = () => GetPowerColor(powerRes.PowerState); - template.Get("KILLS").GetText = () => player.Kills.ToString(); - template.Get("DEATHS").GetText = () => player.Deaths.ToString(); - var stats = player.PlayerActor.TraitOrDefault(); if (stats == null) return template; + template.Get("KILLS").GetText = () => (stats.UnitsKilled + stats.BuildingsKilled).ToString(); + template.Get("DEATHS").GetText = () => (stats.UnitsDead + stats.UnitsDead).ToString(); template.Get("ACTIONS_MIN").GetText = () => AverageOrdersPerMinute(stats.OrderCount); return template; From bbff99d95888c64c24d47429c14a935145d1499c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 10 Aug 2013 11:43:15 +0200 Subject: [PATCH 5/5] remove kill/death count in player/health --- OpenRA.Game/Player.cs | 2 -- OpenRA.Game/Traits/Health.cs | 3 --- 2 files changed, 5 deletions(-) diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index 7e36e2ca15..5d9648dd8a 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -22,8 +22,6 @@ namespace OpenRA public class Player { public Actor PlayerActor; - public int Kills; - public int Deaths; public WinState WinState = WinState.Undefined; public readonly HSLColor Color; diff --git a/OpenRA.Game/Traits/Health.cs b/OpenRA.Game/Traits/Health.cs index fc91a75023..b82d29e5de 100755 --- a/OpenRA.Game/Traits/Health.cs +++ b/OpenRA.Game/Traits/Health.cs @@ -137,9 +137,6 @@ namespace OpenRA.Traits if (hp == 0) { - attacker.Owner.Kills++; - self.Owner.Deaths++; - foreach (var nd in self.TraitsImplementing() .Concat(self.Owner.PlayerActor.TraitsImplementing())) nd.Killed(self, ai);