Make weapon can target attacker itself an option.
This commit is contained in:
committed by
Matthias Mailänder
parent
aa878c9dc8
commit
e8d9e2dfa9
@@ -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<TargetableType> ValidTargets = new BitSet<TargetableType>("Ground", "Water");
|
||||
|
||||
@@ -206,6 +209,9 @@ namespace OpenRA.GameRules
|
||||
/// <summary>Checks if the weapon is valid against (can target) the actor.</summary>
|
||||
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
|
||||
/// <summary>Checks if the weapon is valid against (can target) the frozen actor.</summary>
|
||||
public bool IsValidAgainst(FrozenActor victim, Actor firedBy)
|
||||
{
|
||||
if (!CanTargetSelf && victim.Actor == firedBy)
|
||||
return false;
|
||||
|
||||
if (!IsValidTarget(victim.TargetTypes))
|
||||
return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user