Fix CombatProperties not accounting for multiple AttackBase traits

This commit is contained in:
abcdefg30
2018-09-11 17:26:46 +02:00
committed by Paul Chote
parent 2d4d6cdc1b
commit 9b4db3468b

View File

@@ -78,12 +78,12 @@ namespace OpenRA.Mods.Common.Scripting
[ScriptPropertyGroup("Combat")] [ScriptPropertyGroup("Combat")]
public class GeneralCombatProperties : ScriptActorProperties, Requires<AttackBaseInfo> public class GeneralCombatProperties : ScriptActorProperties, Requires<AttackBaseInfo>
{ {
readonly AttackBase attackBase; readonly AttackBase[] attackBases;
public GeneralCombatProperties(ScriptContext context, Actor self) public GeneralCombatProperties(ScriptContext context, Actor self)
: base(context, self) : base(context, self)
{ {
attackBase = self.Trait<AttackBase>(); attackBases = self.TraitsImplementing<AttackBase>().ToArray();
} }
[Desc("Attack the target actor. The target actor needs to be visible.")] [Desc("Attack the target actor. The target actor needs to be visible.")]
@@ -96,7 +96,8 @@ namespace OpenRA.Mods.Common.Scripting
if (!targetActor.Info.HasTraitInfo<FrozenUnderFogInfo>() && !targetActor.CanBeViewedByPlayer(Self.Owner)) if (!targetActor.Info.HasTraitInfo<FrozenUnderFogInfo>() && !targetActor.CanBeViewedByPlayer(Self.Owner))
Log.Write("lua", "{1} is not revealed for player {0}!", Self.Owner, targetActor); Log.Write("lua", "{1} is not revealed for player {0}!", Self.Owner, targetActor);
attackBase.AttackTarget(target, true, allowMove, forceAttack); foreach (var attack in attackBases)
attack.AttackTarget(target, true, allowMove, forceAttack);
} }
[Desc("Checks if the targeted actor is a valid target for this actor.")] [Desc("Checks if the targeted actor is a valid target for this actor.")]