From f38e4d27be67328fcf3d6400dd693df685bdd2ff Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 21 Aug 2010 21:40:52 +1200 Subject: [PATCH] Disable lane bias on gunboat and lst --- OpenRA.Game/PathSearch.cs | 8 +++++++- OpenRA.Game/Traits/Activities/Move.cs | 15 ++++++++++++++- OpenRA.Mods.Cnc/Missions/Gdi01Script.cs | 14 +++++++++----- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/OpenRA.Game/PathSearch.cs b/OpenRA.Game/PathSearch.cs index 72fcb55cd5..eb2d22aab4 100755 --- a/OpenRA.Game/PathSearch.cs +++ b/OpenRA.Game/PathSearch.cs @@ -61,13 +61,19 @@ namespace OpenRA return this; } + public PathSearch WithoutLaneBias() + { + LaneBias = 0f; + return this; + } + public PathSearch FromPoint(int2 from) { AddInitialCell( self.World, from ); return this; } - const float LaneBias = .5f; + float LaneBias = .5f; public int2 Expand( World world ) { diff --git a/OpenRA.Game/Traits/Activities/Move.cs b/OpenRA.Game/Traits/Activities/Move.cs index 9292fd06d9..71087f77e8 100755 --- a/OpenRA.Game/Traits/Activities/Move.cs +++ b/OpenRA.Game/Traits/Activities/Move.cs @@ -37,6 +37,19 @@ namespace OpenRA.Traits.Activities 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 ) : this() { @@ -45,7 +58,7 @@ namespace OpenRA.Traits.Activities this.destination = destination; this.nearEnough = nearEnough; } - + public Move(int2 destination, Actor ignoreBuilding) : this() { diff --git a/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs b/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs index 99d6ca0db5..c024f9f015 100644 --- a/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs +++ b/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs @@ -102,8 +102,8 @@ namespace OpenRA.Mods.RA void SetGunboatPath() { - Actors["Gunboat"].QueueActivity(new Move( Map.Waypoints["gunboatLeft"],1)); - Actors["Gunboat"].QueueActivity(new Move( Map.Waypoints["gunboatRight"],1)); + Actors["Gunboat"].QueueActivity(new Move( Map.Waypoints["gunboatLeft"] )); + Actors["Gunboat"].QueueActivity(new Move( Map.Waypoints["gunboatRight"] )); Actors["Gunboat"].QueueActivity(new CallFunc(() => SetGunboatPath())); } @@ -122,10 +122,14 @@ namespace OpenRA.Mods.RA var cargo = a.Trait(); 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.QueueActivity(new Move(endPos, 0)); + a.QueueActivity(new Move(endPos)); a.QueueActivity(new CallFunc(() => { while (!cargo.IsEmpty(a)) @@ -140,7 +144,7 @@ namespace OpenRA.Mods.RA } })); a.QueueActivity(new Wait(25)); - a.QueueActivity(new Move(startPos,0)); + a.QueueActivity(new Move(startPos)); a.QueueActivity(new RemoveSelf()); }); }