diff --git a/OpenRA.Mods.RA/GainsExperience.cs b/OpenRA.Mods.RA/GainsExperience.cs index fd2d880d45..fe3605d2bb 100644 --- a/OpenRA.Mods.RA/GainsExperience.cs +++ b/OpenRA.Mods.RA/GainsExperience.cs @@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA [Sync] int Experience = 0; [Sync] - int Level = 0; + public int Level { get; private set; } public void GiveOneLevel() { diff --git a/OpenRA.Mods.RA/GivesBounty.cs b/OpenRA.Mods.RA/GivesBounty.cs new file mode 100644 index 0000000000..5d6e3173e2 --- /dev/null +++ b/OpenRA.Mods.RA/GivesBounty.cs @@ -0,0 +1,59 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using OpenRA.Traits; +using OpenRA.Mods.RA.Effects; + +namespace OpenRA.Mods.RA +{ + class GivesBountyInfo : TraitInfo + { + public readonly int Percentage = 10; + public readonly int LevelMod = 125; + } + + class GivesBounty : INotifyDamage + { + + int GetMultiplier(Actor self) + { + // returns 100's as 1, so as to keep accuracy for longer. + var info = self.Info.Traits.Get(); + var gainsExp = self.TraitOrDefault(); + if (gainsExp == null) + return 100; + + var slevel = self.Trait().Level; + return (slevel > 0) ? slevel * info.LevelMod : 100; + } + + public void Damaged(Actor self, AttackInfo e) + { + if (e.DamageState == DamageState.Dead) + { + var info = self.Info.Traits.Get(); + // Prevent TK from giving Bounty + if (e.Attacker == null || e.Attacker.Destroyed || e.Attacker.Owner.Stances[self.Owner] == Stance.Ally) + return; + + var valued = self.Info.Traits.GetOrDefault(); + var cost = valued != null ? valued.Cost : 0; + // 2 hundreds because of GetMultiplier and info.Percentage. + var bounty = (int)(cost * GetMultiplier(self) * info.Percentage / 10000); + + e.Attacker.World.AddFrameEndTask(w => w.Add(new CashTick(bounty, 20, 1, self.CenterLocation, e.Attacker.Owner.ColorRamp.GetColor(0)))); + + e.Attacker.Owner.PlayerActor.Trait().GiveCash(bounty); + + } + } + + } +} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 456ad29eb7..09aebb2ef9 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -3,7 +3,7 @@ Debug AnyCPU - 9.0.21022 + 9.0.30729 2.0 {4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E} Library @@ -52,11 +52,11 @@ - + - + @@ -66,6 +66,7 @@ + @@ -109,7 +110,7 @@ - + diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 8cdf83a20b..572447c502 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -27,7 +27,8 @@ Notification: unitlst1.aud ProximityCaptor: Types:Vehicle - + GivesBounty: + ^Tank: AppearsOnRadar: Mobile: @@ -57,6 +58,7 @@ Notification: unitlst1.aud ProximityCaptor: Types:Tank + GivesBounty: ^Infantry: AppearsOnRadar: @@ -93,6 +95,7 @@ Notification: unitlst1.aud ProximityCaptor: Types:Infantry + GivesBounty: ^Ship: AppearsOnRadar: @@ -115,6 +118,7 @@ Notification: navylst1.aud ProximityCaptor: Types:Ship + GivesBounty: ^Plane: AppearsOnRadar: @@ -139,6 +143,7 @@ EjectOnDeath: PilotActor: E1 SuccessRate: 50 + GivesBounty: ^Building: AppearsOnRadar: @@ -168,6 +173,7 @@ Types:Building Sellable: AcceptsSupplies: + GivesBounty: ^Wall: AppearsOnRadar: