make repath much less aggressive while attacking, to fix perf
This commit is contained in:
@@ -23,6 +23,11 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
int Range;
|
int Range;
|
||||||
bool AllowMovement;
|
bool AllowMovement;
|
||||||
|
|
||||||
|
int nextPathTime;
|
||||||
|
|
||||||
|
const int delayBetweenPathingAttempts = 20;
|
||||||
|
const int delaySpread = 5;
|
||||||
|
|
||||||
public Attack(Target target, int range, bool allowMovement)
|
public Attack(Target target, int range, bool allowMovement)
|
||||||
{
|
{
|
||||||
Target = target;
|
Target = target;
|
||||||
@@ -33,10 +38,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
AllowMovement = allowMovement;
|
AllowMovement = allowMovement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Attack(Target target, int range) : this(target, range, true)
|
public Attack(Target target, int range) : this(target, range, true) {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IActivity Tick( Actor self )
|
public override IActivity Tick( Actor self )
|
||||||
{
|
{
|
||||||
@@ -56,9 +58,17 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
if (targetable != null && !targetable.TargetableBy(Target.Actor, self))
|
if (targetable != null && !targetable.TargetableBy(Target.Actor, self))
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
if (!Combat.IsInRange(self.CenterLocation, Range, Target))
|
if (!Combat.IsInRange(self.CenterLocation, Range, Target))
|
||||||
return (AllowMovement) ? Util.SequenceActivities(self.Trait<Mobile>().MoveWithinRange(Target, Range), this) : NextActivity;
|
{
|
||||||
|
if (--nextPathTime > 0)
|
||||||
|
return this;
|
||||||
|
|
||||||
|
nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread,
|
||||||
|
delayBetweenPathingAttempts + delaySpread);
|
||||||
|
|
||||||
|
return (AllowMovement) ? Util.SequenceActivities(self.Trait<Mobile>().MoveWithinRange(Target, Range), this) : NextActivity;
|
||||||
|
}
|
||||||
|
|
||||||
var desiredFacing = Util.GetFacing(Target.CenterLocation - self.CenterLocation, 0);
|
var desiredFacing = Util.GetFacing(Target.CenterLocation - self.CenterLocation, 0);
|
||||||
if (facing.Facing != desiredFacing)
|
if (facing.Facing != desiredFacing)
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
{
|
{
|
||||||
Target Target;
|
Target Target;
|
||||||
int Range;
|
int Range;
|
||||||
|
int nextPathTime;
|
||||||
|
|
||||||
|
const int delayBetweenPathingAttempts = 20;
|
||||||
|
const int delaySpread = 5;
|
||||||
|
|
||||||
public Follow(Target target, int range)
|
public Follow(Target target, int range)
|
||||||
{
|
{
|
||||||
@@ -33,8 +37,12 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
var inRange = ( Util.CellContaining( Target.CenterLocation ) - self.Location ).LengthSquared < Range * Range;
|
var inRange = ( Util.CellContaining( Target.CenterLocation ) - self.Location ).LengthSquared < Range * Range;
|
||||||
|
|
||||||
if( inRange ) return this;
|
if( inRange ) return this;
|
||||||
|
if (--nextPathTime > 0) return this;
|
||||||
|
|
||||||
var mobile = self.Trait<Mobile>();
|
nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread,
|
||||||
|
delayBetweenPathingAttempts + delaySpread);
|
||||||
|
|
||||||
|
var mobile = self.Trait<Mobile>();
|
||||||
return Util.SequenceActivities( mobile.MoveWithinRange( Target, Range ), this );
|
return Util.SequenceActivities( mobile.MoveWithinRange( Target, Range ), this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user