diff --git a/OpenRA.Mods.RA/GainsExperience.cs b/OpenRA.Mods.RA/GainsExperience.cs
new file mode 100644
index 0000000000..fc63a54572
--- /dev/null
+++ b/OpenRA.Mods.RA/GainsExperience.cs
@@ -0,0 +1,67 @@
+#region Copyright & License Information
+/*
+ * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
+ * This file is part of OpenRA.
+ *
+ * OpenRA is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenRA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OpenRA. If not, see .
+ */
+#endregion
+
+using OpenRA.Traits;
+using System.Linq;
+using System.Collections.Generic;
+namespace OpenRA.Mods.RA
+{
+ public class GainsExperienceInfo : ITraitInfo
+ {
+ //public readonly float[] LevelThresholds = {2,4,8};
+ public readonly float[] LevelThresholds = {1, 1.5f, 2};
+ public object Create(Actor self) { return new GainsExperience(self); }
+ }
+
+ public class GainsExperience
+ {
+ readonly Actor self;
+ readonly List Levels;
+ public GainsExperience(Actor self)
+ {
+ this.self = self;
+ System.Console.WriteLine(self.Info.Name);
+ var cost = self.Info.Traits.Get().Cost;
+ Levels = self.Info.Traits.Get().LevelThresholds.Select(t => t*cost).ToList();
+ }
+
+ [Sync]
+ int Experience = 0;
+ [Sync]
+ int Level = 0;
+
+ public void GiveExperience(int amount)
+ {
+ // Already at max level
+ if (Level == Levels.Count() - 1)
+ return;
+
+ Experience += amount;
+
+ if (Experience > Levels[Level])
+ {
+ Level++;
+
+ // TODO: Show an effect or play a sound or something
+ System.Console.WriteLine("{0} became Level {1}",self.Info.Name, Level);
+ }
+ }
+ }
+}
diff --git a/OpenRA.Mods.RA/GivesExperience.cs b/OpenRA.Mods.RA/GivesExperience.cs
new file mode 100644
index 0000000000..3d7acef53e
--- /dev/null
+++ b/OpenRA.Mods.RA/GivesExperience.cs
@@ -0,0 +1,50 @@
+#region Copyright & License Information
+/*
+ * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
+ * This file is part of OpenRA.
+ *
+ * OpenRA is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenRA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OpenRA. If not, see .
+ */
+#endregion
+
+using OpenRA.Traits;
+using System.Linq;
+
+namespace OpenRA.Mods.RA
+{
+ class GivesExperienceInfo : TraitInfo { public readonly int Experience = -1; }
+
+ class GivesExperience : INotifyDamage
+ {
+ public void Damaged(Actor self, AttackInfo e)
+ {
+ if (e.DamageState == DamageState.Dead)
+ {
+ // Prevent TK from giving exp
+ //if (self.Owner == e.Attacker.Owner)
+ // return;
+
+ var exp = 0;
+ if (self.Info.Traits.Get() != null)
+ exp = self.Info.Traits.Get().Cost;
+ if (self.Info.Traits.Get().Experience >= 0)
+ exp = self.Info.Traits.Get().Experience;
+
+ var killer = e.Attacker.traits.WithInterface().FirstOrDefault();
+ if (killer != null)
+ killer.GiveExperience(exp);
+ }
+ }
+ }
+}
diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
index 2f1639cffa..f34813230d 100644
--- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
+++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
@@ -178,6 +178,8 @@
+
+
diff --git a/mods/ra/defaults.yaml b/mods/ra/defaults.yaml
index 2b762e5640..cb205b9283 100644
--- a/mods/ra/defaults.yaml
+++ b/mods/ra/defaults.yaml
@@ -12,6 +12,8 @@
IronCurtainable:
HiddenUnderFog:
RevealsShroud:
+ GainsExperience:
+ GivesExperience:
^Infantry:
Category: Infantry
@@ -27,6 +29,8 @@
HiddenUnderFog:
RevealsShroud:
TeslaInstantKills:
+ GainsExperience:
+ GivesExperience:
^Ship:
Category: Ship
@@ -36,6 +40,8 @@
Selectable:
HiddenUnderFog:
RevealsShroud:
+ GainsExperience:
+ GivesExperience:
^Plane:
Category: Plane
@@ -44,6 +50,8 @@
Selectable:
HiddenUnderFog:
RevealsShroud:
+ GainsExperience:
+ GivesExperience:
^Building:
Category: Building
@@ -56,6 +64,7 @@
EmitInfantryOnSell:
ActorTypes: e1,e1,e1,c1,c2,e6
MustBeDestroyed:
+ GivesExperience:
^Wall:
Category: Building
@@ -78,6 +87,7 @@
HasMakeAnimation: false
Palette: terrain
DamageStates: 2
+ GivesExperience:
^Tree:
Category: Building
diff --git a/mods/ra/structures.yaml b/mods/ra/structures.yaml
index 17c3200582..28f35e7471 100644
--- a/mods/ra/structures.yaml
+++ b/mods/ra/structures.yaml
@@ -771,6 +771,9 @@ WEAF:
SYRF:
Inherits: ^Building
+ Valued:
+ Cost: 50
+ Description: Fake Shipyard
# Buildable:
# BuildPaletteOrder: 900
# Prerequisites: @Power Plant
@@ -813,6 +816,9 @@ SPEF:
DOMF:
Inherits: ^Building
+ Valued:
+ Cost: 50
+ Description: Fake Radar Dome
# Buildable:
# BuildPaletteOrder: 900
# Prerequisites: proc
diff --git a/mods/ra/vehicles.yaml b/mods/ra/vehicles.yaml
index c6c9203a73..6d2b970ba0 100644
--- a/mods/ra/vehicles.yaml
+++ b/mods/ra/vehicles.yaml
@@ -15,7 +15,8 @@ BADR:
Cargo:
Passengers: 10
-Selectable:
-
+ -GainsExperience:
+
BADR.bomber:
CarpetBomb:
Range: 3
@@ -35,6 +36,7 @@ BADR.bomber:
WithShadow:
IronCurtainable:
-Selectable:
+ -GainsExperience:
V2RL:
Inherits: ^Vehicle