diff --git a/OpenRA.Game/GameRules/WeaponInfo.cs b/OpenRA.Game/GameRules/WeaponInfo.cs index b7bc147545..ae7b57ce9e 100644 --- a/OpenRA.Game/GameRules/WeaponInfo.cs +++ b/OpenRA.Game/GameRules/WeaponInfo.cs @@ -99,6 +99,9 @@ namespace OpenRA.GameRules [Desc("Number of shots in a single ammo magazine.")] public readonly int Burst = 1; + [Desc("Can this weapon target attacker itself.")] + public readonly bool CanTargetSelf = false; + [Desc("What types of targets are affected.")] public readonly BitSet ValidTargets = new BitSet("Ground", "Water"); @@ -206,6 +209,9 @@ namespace OpenRA.GameRules /// Checks if the weapon is valid against (can target) the actor. public bool IsValidAgainst(Actor victim, Actor firedBy) { + if (!CanTargetSelf && victim == firedBy) + return false; + var targetTypes = victim.GetEnabledTargetTypes(); if (!IsValidTarget(targetTypes)) @@ -222,6 +228,9 @@ namespace OpenRA.GameRules /// Checks if the weapon is valid against (can target) the frozen actor. public bool IsValidAgainst(FrozenActor victim, Actor firedBy) { + if (!CanTargetSelf && victim.Actor == firedBy) + return false; + if (!IsValidTarget(victim.TargetTypes)) return false;