Disable lane bias on gunboat and lst

This commit is contained in:
Paul Chote
2010-08-21 21:40:52 +12:00
parent c35e3b4bd7
commit f38e4d27be
3 changed files with 30 additions and 7 deletions

View File

@@ -61,13 +61,19 @@ namespace OpenRA
return this; return this;
} }
public PathSearch WithoutLaneBias()
{
LaneBias = 0f;
return this;
}
public PathSearch FromPoint(int2 from) public PathSearch FromPoint(int2 from)
{ {
AddInitialCell( self.World, from ); AddInitialCell( self.World, from );
return this; return this;
} }
const float LaneBias = .5f; float LaneBias = .5f;
public int2 Expand( World world ) public int2 Expand( World world )
{ {

View File

@@ -37,6 +37,19 @@ namespace OpenRA.Traits.Activities
Game.world.SharedRandom.Next(-spreadTicksBeforePathing, spreadTicksBeforePathing); Game.world.SharedRandom.Next(-spreadTicksBeforePathing, spreadTicksBeforePathing);
} }
// Scriptable move order
// Ignores lane bias and nearby units
public Move( int2 destination )
: this()
{
this.getPath = (self,mobile) =>
self.World.PathFinder.FindPath(
PathSearch.FromPoint( self, mobile.toCell, destination, false )
.WithoutLaneBias());
this.destination = destination;
this.nearEnough = 0;
}
public Move( int2 destination, int nearEnough ) public Move( int2 destination, int nearEnough )
: this() : this()
{ {
@@ -45,7 +58,7 @@ namespace OpenRA.Traits.Activities
this.destination = destination; this.destination = destination;
this.nearEnough = nearEnough; this.nearEnough = nearEnough;
} }
public Move(int2 destination, Actor ignoreBuilding) public Move(int2 destination, Actor ignoreBuilding)
: this() : this()
{ {

View File

@@ -102,8 +102,8 @@ namespace OpenRA.Mods.RA
void SetGunboatPath() void SetGunboatPath()
{ {
Actors["Gunboat"].QueueActivity(new Move( Map.Waypoints["gunboatLeft"],1)); Actors["Gunboat"].QueueActivity(new Move( Map.Waypoints["gunboatLeft"] ));
Actors["Gunboat"].QueueActivity(new Move( Map.Waypoints["gunboatRight"],1)); Actors["Gunboat"].QueueActivity(new Move( Map.Waypoints["gunboatRight"] ));
Actors["Gunboat"].QueueActivity(new CallFunc(() => SetGunboatPath())); Actors["Gunboat"].QueueActivity(new CallFunc(() => SetGunboatPath()));
} }
@@ -122,10 +122,14 @@ namespace OpenRA.Mods.RA
var cargo = a.Trait<Cargo>(); var cargo = a.Trait<Cargo>();
foreach (var i in items) foreach (var i in items)
cargo.Load(a, world.CreateActor(false, i.ToLowerInvariant(), new TypeDictionary { new OwnerInit( Players["GoodGuy"] ) })); cargo.Load(a, world.CreateActor(false, i.ToLowerInvariant(), new TypeDictionary
{
new OwnerInit( Players["GoodGuy"] ),
new FacingInit( 0 ),
}));
a.CancelActivity(); a.CancelActivity();
a.QueueActivity(new Move(endPos, 0)); a.QueueActivity(new Move(endPos));
a.QueueActivity(new CallFunc(() => a.QueueActivity(new CallFunc(() =>
{ {
while (!cargo.IsEmpty(a)) while (!cargo.IsEmpty(a))
@@ -140,7 +144,7 @@ namespace OpenRA.Mods.RA
} }
})); }));
a.QueueActivity(new Wait(25)); a.QueueActivity(new Wait(25));
a.QueueActivity(new Move(startPos,0)); a.QueueActivity(new Move(startPos));
a.QueueActivity(new RemoveSelf()); a.QueueActivity(new RemoveSelf());
}); });
} }