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 class Player
|
||||||
{
|
{
|
||||||
public Actor PlayerActor;
|
public Actor PlayerActor;
|
||||||
public int Kills;
|
|
||||||
public int Deaths;
|
|
||||||
public WinState WinState = WinState.Undefined;
|
public WinState WinState = WinState.Undefined;
|
||||||
|
|
||||||
public readonly HSLColor Color;
|
public readonly HSLColor Color;
|
||||||
|
|||||||
@@ -137,9 +137,6 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
if (hp == 0)
|
if (hp == 0)
|
||||||
{
|
{
|
||||||
attacker.Owner.Kills++;
|
|
||||||
self.Owner.Deaths++;
|
|
||||||
|
|
||||||
foreach (var nd in self.TraitsImplementing<INotifyKilled>()
|
foreach (var nd in self.TraitsImplementing<INotifyKilled>()
|
||||||
.Concat(self.Owner.PlayerActor.TraitsImplementing<INotifyKilled>()))
|
.Concat(self.Owner.PlayerActor.TraitsImplementing<INotifyKilled>()))
|
||||||
nd.Killed(self, ai);
|
nd.Killed(self, ai);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.Mods.RA;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
namespace OpenRA.Mods.Cnc.Widgets.Logic
|
||||||
@@ -57,11 +58,17 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
item.Get<LabelWidget>("FACTION").GetText = () => pp.Country.Name;
|
item.Get<LabelWidget>("FACTION").GetText = () => pp.Country.Name;
|
||||||
|
|
||||||
var team = item.Get<LabelWidget>("TEAM");
|
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);
|
scrollpanel.AddChild(item);
|
||||||
|
|
||||||
item.Get<LabelWidget>("KILLS").GetText = () => pp.Kills.ToString();
|
var stats = pp.PlayerActor.TraitOrDefault<PlayerStatistics>();
|
||||||
item.Get<LabelWidget>("DEATHS").GetText = () => pp.Deaths.ToString();
|
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>();
|
var cargo = self.Trait<Cargo>();
|
||||||
while (!cargo.IsEmpty(self))
|
while (!cargo.IsEmpty(self))
|
||||||
{
|
{
|
||||||
if (chronosphere != null)
|
if (chronosphere != null && chronosphere.HasTrait<UpdatesPlayerStatistics>())
|
||||||
chronosphere.Owner.Kills++;
|
chronosphere.Owner.PlayerActor.Trait<PlayerStatistics>().UnitsKilled++;
|
||||||
|
|
||||||
var a = cargo.Unload(self);
|
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()
|
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);
|
fewDeaths.Text = FewDeathsTemplate.F(unitDeaths, DeathsThreshold);
|
||||||
OnObjectivesUpdated(false);
|
OnObjectivesUpdated(false);
|
||||||
if (unitDeaths >= DeathsThreshold && fewDeaths.Status == ObjectiveStatus.InProgress)
|
if (unitDeaths >= DeathsThreshold && fewDeaths.Status == ObjectiveStatus.InProgress)
|
||||||
|
|||||||
@@ -257,11 +257,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
power.GetText = () => powerRes.PowerDrained + "/" + powerRes.PowerProvided;
|
power.GetText = () => powerRes.PowerDrained + "/" + powerRes.PowerProvided;
|
||||||
power.GetColor = () => GetPowerColor(powerRes.PowerState);
|
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>();
|
var stats = player.PlayerActor.TraitOrDefault<PlayerStatistics>();
|
||||||
if (stats == null) return template;
|
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);
|
template.Get<LabelWidget>("ACTIONS_MIN").GetText = () => AverageOrdersPerMinute(stats.OrderCount);
|
||||||
|
|
||||||
return template;
|
return template;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
Guard:
|
Guard:
|
||||||
Guardable:
|
Guardable:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
UpdatesPlayerStatistics:
|
||||||
|
|
||||||
^Tank:
|
^Tank:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -74,6 +75,7 @@
|
|||||||
Guard:
|
Guard:
|
||||||
Guardable:
|
Guardable:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
UpdatesPlayerStatistics:
|
||||||
|
|
||||||
^Helicopter:
|
^Helicopter:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -100,6 +102,7 @@
|
|||||||
EmptyWeapon: HeliExplode
|
EmptyWeapon: HeliExplode
|
||||||
DebugMuzzlePositions:
|
DebugMuzzlePositions:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
UpdatesPlayerStatistics:
|
||||||
|
|
||||||
^Infantry:
|
^Infantry:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -156,6 +159,7 @@
|
|||||||
HealIfBelow: 1
|
HealIfBelow: 1
|
||||||
DamageCooldown: 125
|
DamageCooldown: 125
|
||||||
RequiresTech: InfantryHealing
|
RequiresTech: InfantryHealing
|
||||||
|
UpdatesPlayerStatistics:
|
||||||
|
|
||||||
^CivInfantry:
|
^CivInfantry:
|
||||||
Inherits: ^Infantry
|
Inherits: ^Infantry
|
||||||
@@ -232,6 +236,7 @@
|
|||||||
ScanRadius: 4
|
ScanRadius: 4
|
||||||
AttackMove:
|
AttackMove:
|
||||||
AttackFrontal:
|
AttackFrontal:
|
||||||
|
UpdatesPlayerStatistics:
|
||||||
|
|
||||||
^Plane:
|
^Plane:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -270,6 +275,7 @@
|
|||||||
Guard:
|
Guard:
|
||||||
Guardable:
|
Guardable:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
|
UpdatesPlayerStatistics:
|
||||||
|
|
||||||
^Building:
|
^Building:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -318,6 +324,7 @@
|
|||||||
Range: 3
|
Range: 3
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
FrozenUnderFog:
|
FrozenUnderFog:
|
||||||
|
UpdatesPlayerStatistics:
|
||||||
|
|
||||||
^CivBuilding:
|
^CivBuilding:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ Player:
|
|||||||
RemapIndex: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190
|
RemapIndex: 176, 178, 180, 182, 184, 186, 189, 191, 177, 179, 181, 183, 185, 187, 188, 190
|
||||||
BaseAttackNotifier:
|
BaseAttackNotifier:
|
||||||
Shroud:
|
Shroud:
|
||||||
|
PlayerStatistics:
|
||||||
|
|
||||||
World:
|
World:
|
||||||
LoadWidgetAtGameStart:
|
LoadWidgetAtGameStart:
|
||||||
|
|||||||
@@ -269,7 +269,6 @@
|
|||||||
ProximityCaptor:
|
ProximityCaptor:
|
||||||
Types:Wall
|
Types:Wall
|
||||||
Sellable:
|
Sellable:
|
||||||
UpdatesPlayerStatistics:
|
|
||||||
Guardable:
|
Guardable:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
FrozenUnderFog:
|
FrozenUnderFog:
|
||||||
|
|||||||
Reference in New Issue
Block a user