move to range actually uses weapon's range now
This commit is contained in:
@@ -82,18 +82,27 @@ namespace OpenRa.Game.Traits
|
||||
public readonly Actor Attacker;
|
||||
public readonly Actor Target;
|
||||
|
||||
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
|
||||
|
||||
public AttackOrder( Actor attacker, Actor target )
|
||||
{
|
||||
this.Attacker = attacker;
|
||||
this.Target = target;
|
||||
}
|
||||
|
||||
public override void Apply()
|
||||
{
|
||||
var mobile = Attacker.traits.GetOrDefault<Mobile>();
|
||||
if (mobile != null)
|
||||
{
|
||||
var weapon = Attacker.unitInfo.Primary ?? Attacker.unitInfo.Secondary;
|
||||
/* todo: choose the appropriate weapon, when only one works against this target */
|
||||
var range = Rules.WeaponInfo[weapon].Range;
|
||||
|
||||
mobile.Cancel(Attacker);
|
||||
mobile.QueueActivity(new Mobile.MoveTo(Target, 3)); /* todo: get range properly */
|
||||
mobile.QueueActivity(
|
||||
new Mobile.MoveTo(Target,
|
||||
Math.Max(0, (int)range - RangeTolerance)));
|
||||
}
|
||||
|
||||
Attacker.traits.Get<AttackTurreted>().target = Target;
|
||||
|
||||
Reference in New Issue
Block a user