Added support to GivesBounty for setting player Stances which give bounties
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Mods.RA.Effects;
|
using OpenRA.Mods.RA.Effects;
|
||||||
using OpenRA.Mods.RA.Buildings;
|
using OpenRA.Mods.RA.Buildings;
|
||||||
@@ -18,6 +19,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public readonly int Percentage = 10;
|
public readonly int Percentage = 10;
|
||||||
public readonly int LevelMod = 125;
|
public readonly int LevelMod = 125;
|
||||||
|
public readonly Stance[] Stances = {Stance.Neutral, Stance.Enemy};
|
||||||
}
|
}
|
||||||
|
|
||||||
class GivesBounty : INotifyKilled
|
class GivesBounty : INotifyKilled
|
||||||
@@ -37,9 +39,10 @@ namespace OpenRA.Mods.RA
|
|||||||
public void Killed(Actor self, AttackInfo e)
|
public void Killed(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
var info = self.Info.Traits.Get<GivesBountyInfo>();
|
var info = self.Info.Traits.Get<GivesBountyInfo>();
|
||||||
// Prevent TK from giving Bounty
|
|
||||||
if (e.Attacker == null || e.Attacker.Destroyed || e.Attacker.Owner.Stances[self.Owner] == Stance.Ally)
|
if (e.Attacker == null || e.Attacker.Destroyed) return;
|
||||||
return;
|
|
||||||
|
if (!info.Stances.Contains(e.Attacker.Owner.Stances[self.Owner])) return;
|
||||||
|
|
||||||
var cost = self.GetSellValue();
|
var cost = self.GetSellValue();
|
||||||
// 2 hundreds because of GetMultiplier and info.Percentage.
|
// 2 hundreds because of GetMultiplier and info.Percentage.
|
||||||
@@ -50,6 +53,5 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
e.Attacker.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(bounty);
|
e.Attacker.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(bounty);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user