more... Combat.GetSecondaryWeapon() dies, etc
This commit is contained in:
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.RA
|
||||
Weapons.Add(new Weapon(info.PrimaryWeapon,
|
||||
info.PrimaryOffset, info.PrimaryLocalOffset));
|
||||
|
||||
if (self.GetSecondaryWeapon() != null)
|
||||
if (info.SecondaryWeapon != null)
|
||||
Weapons.Add(new Weapon(info.SecondaryWeapon,
|
||||
info.SecondaryOffset ?? info.PrimaryOffset, info.SecondaryLocalOffset));
|
||||
}
|
||||
@@ -302,12 +302,12 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
protected virtual void QueueAttack(Actor self, Order order)
|
||||
{
|
||||
/* todo: choose the appropriate weapon, when only one works against this target */
|
||||
var weapon = self.GetPrimaryWeapon() ?? self.GetSecondaryWeapon();
|
||||
var weapon = ChooseWeaponForTarget(Target.FromOrder(order));
|
||||
|
||||
self.QueueActivity(
|
||||
new Activities.Attack(
|
||||
Target.FromOrder(order),
|
||||
Math.Max(0, (int)weapon.Range)));
|
||||
Math.Max(0, (int)weapon.Info.Range)));
|
||||
}
|
||||
|
||||
/* temp hack */
|
||||
@@ -316,5 +316,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public bool HasAnyValidWeapons(Target t) { return Weapons.Any(w => w.IsValidAgainst(t)); }
|
||||
public float GetMaximumRange() { return Weapons.Max(w => w.Info.Range); }
|
||||
|
||||
public Weapon ChooseWeaponForTarget(Target t) { return Weapons.First(w => w.IsValidAgainst(t)); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
||||
/* todo: choose the appropriate weapon, when only one works against this target */
|
||||
var weapon = order.Subject.GetPrimaryWeapon() ?? order.Subject.GetSecondaryWeapon();
|
||||
var weapon = ChooseWeaponForTarget(Target.FromOrder(order));
|
||||
|
||||
target = Target.FromOrder(order);
|
||||
|
||||
if (self.traits.Contains<Mobile>())
|
||||
self.QueueActivity( new Follow( target,
|
||||
Math.Max( 0, (int)weapon.Range - RangeTolerance ) ) );
|
||||
Math.Max( 0, (int)weapon.Info.Range - RangeTolerance ) ) );
|
||||
}
|
||||
|
||||
bool buildComplete = false;
|
||||
|
||||
@@ -187,17 +187,6 @@ namespace OpenRA.Mods.RA
|
||||
return Rules.Weapons[weapon.ToLowerInvariant()];
|
||||
}
|
||||
|
||||
public static WeaponInfo GetSecondaryWeapon(this Actor self)
|
||||
{
|
||||
var info = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
|
||||
if (info == null) return null;
|
||||
|
||||
var weapon = info.SecondaryWeapon;
|
||||
if (weapon == null) return null;
|
||||
|
||||
return Rules.Weapons[weapon.ToLowerInvariant()];
|
||||
}
|
||||
|
||||
static float2 GetRecoil(Actor self, float recoil)
|
||||
{
|
||||
var abInfo = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
|
||||
|
||||
Reference in New Issue
Block a user