Merge pull request #3662 from Mailaender/player-stats
Cleanup kill/death counts
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -137,9 +137,6 @@ namespace OpenRA.Traits
|
||||
|
||||
if (hp == 0)
|
||||
{
|
||||
attacker.Owner.Kills++;
|
||||
self.Owner.Deaths++;
|
||||
|
||||
foreach (var nd in self.TraitsImplementing<INotifyKilled>()
|
||||
.Concat(self.Owner.PlayerActor.TraitsImplementing<INotifyKilled>()))
|
||||
nd.Killed(self, ai);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
@@ -57,11 +58,17 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||
item.Get<LabelWidget>("FACTION").GetText = () => pp.Country.Name;
|
||||
|
||||
var team = item.Get<LabelWidget>("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);
|
||||
|
||||
item.Get<LabelWidget>("KILLS").GetText = () => pp.Kills.ToString();
|
||||
item.Get<LabelWidget>("DEATHS").GetText = () => pp.Deaths.ToString();
|
||||
var stats = pp.PlayerActor.TraitOrDefault<PlayerStatistics>();
|
||||
if (stats == null)
|
||||
break;
|
||||
var totalKills = stats.UnitsKilled + stats.BuildingsKilled;
|
||||
var totalDeaths = stats.UnitsDead + stats.BuildingsDead;
|
||||
item.Get<LabelWidget>("KILLS").GetText = () => totalKills.ToString();
|
||||
item.Get<LabelWidget>("DEATHS").GetText = () => totalDeaths.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,10 +42,12 @@ namespace OpenRA.Mods.RA.Activities
|
||||
var cargo = self.Trait<Cargo>();
|
||||
while (!cargo.IsEmpty(self))
|
||||
{
|
||||
if (chronosphere != null)
|
||||
chronosphere.Owner.Kills++;
|
||||
if (chronosphere != null && chronosphere.HasTrait<UpdatesPlayerStatistics>())
|
||||
chronosphere.Owner.PlayerActor.Trait<PlayerStatistics>().UnitsKilled++;
|
||||
|
||||
var a = cargo.Unload(self);
|
||||
a.Owner.Deaths++;
|
||||
if (a.HasTrait<UpdatesPlayerStatistics>())
|
||||
a.Owner.PlayerActor.Trait<PlayerStatistics>().UnitsDead++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace OpenRA.Mods.RA.Missions
|
||||
|
||||
void UpdateDeaths()
|
||||
{
|
||||
var unitDeaths = allies1.Deaths + allies2.Deaths;
|
||||
var unitDeaths = allies1.PlayerActor.Trait<PlayerStatistics>().UnitsDead + allies2.PlayerActor.Trait<PlayerStatistics>().UnitsDead;
|
||||
fewDeaths.Text = FewDeathsTemplate.F(unitDeaths, DeathsThreshold);
|
||||
OnObjectivesUpdated(false);
|
||||
if (unitDeaths >= DeathsThreshold && fewDeaths.Status == ObjectiveStatus.InProgress)
|
||||
|
||||
@@ -257,11 +257,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
power.GetText = () => powerRes.PowerDrained + "/" + powerRes.PowerProvided;
|
||||
power.GetColor = () => GetPowerColor(powerRes.PowerState);
|
||||
|
||||
template.Get<LabelWidget>("KILLS").GetText = () => player.Kills.ToString();
|
||||
template.Get<LabelWidget>("DEATHS").GetText = () => player.Deaths.ToString();
|
||||
|
||||
var stats = player.PlayerActor.TraitOrDefault<PlayerStatistics>();
|
||||
if (stats == null) return template;
|
||||
template.Get<LabelWidget>("KILLS").GetText = () => (stats.UnitsKilled + stats.BuildingsKilled).ToString();
|
||||
template.Get<LabelWidget>("DEATHS").GetText = () => (stats.UnitsDead + stats.UnitsDead).ToString();
|
||||
template.Get<LabelWidget>("ACTIONS_MIN").GetText = () => AverageOrdersPerMinute(stats.OrderCount);
|
||||
|
||||
return template;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -269,7 +269,6 @@
|
||||
ProximityCaptor:
|
||||
Types:Wall
|
||||
Sellable:
|
||||
UpdatesPlayerStatistics:
|
||||
Guardable:
|
||||
BodyOrientation:
|
||||
FrozenUnderFog:
|
||||
|
||||
Reference in New Issue
Block a user