FIX works

This commit is contained in:
Chris Forbes
2010-01-02 09:05:41 +13:00
parent 5487edf369
commit 37bc4f2279
9 changed files with 103 additions and 28 deletions

View File

@@ -162,6 +162,7 @@ namespace OpenRa.Game
else else
return Cursor.MoveBlocked; return Cursor.MoveBlocked;
case "Enter": return Cursor.Enter; case "Enter": return Cursor.Enter;
case "Infiltrate": return Cursor.Enter;
case "Capture": return Cursor.Capture; case "Capture": return Cursor.Capture;
case "Harvest": return Cursor.Attack; // TODO: special harvest cursor? case "Harvest": return Cursor.Attack; // TODO: special harvest cursor?
default: default:

View File

@@ -198,6 +198,7 @@
<Compile Include="Traits\MineImmune.cs" /> <Compile Include="Traits\MineImmune.cs" />
<Compile Include="Traits\Minelayer.cs" /> <Compile Include="Traits\Minelayer.cs" />
<Compile Include="Traits\LimitedAmmo.cs" /> <Compile Include="Traits\LimitedAmmo.cs" />
<Compile Include="Traits\Repairable.cs" />
<Compile Include="Traits\Reservable.cs" /> <Compile Include="Traits\Reservable.cs" />
<Compile Include="Traits\SquishByTank.cs" /> <Compile Include="Traits\SquishByTank.cs" />
<Compile Include="Traits\Plane.cs" /> <Compile Include="Traits\Plane.cs" />

View File

@@ -49,7 +49,7 @@ namespace OpenRa.Game
} }
} }
Func<int2, bool> AvoidUnitsNear(int2 p, int dist) public Func<int2, bool> AvoidUnitsNear(int2 p, int dist)
{ {
return q => return q =>
p != q && p != q &&

View File

@@ -15,6 +15,7 @@ namespace OpenRa.Game
Func<int2, bool> customBlock; Func<int2, bool> customBlock;
public bool checkForBlocked; public bool checkForBlocked;
public bool ignoreTerrain; public bool ignoreTerrain;
public Actor ignoreBuilding;
public PathSearch() public PathSearch()
{ {
@@ -28,6 +29,12 @@ namespace OpenRa.Game
return this; return this;
} }
public PathSearch WithIgnoredBuilding(Actor b)
{
ignoreBuilding = b;
return this;
}
public int2 Expand( float[][ , ] passableCost ) public int2 Expand( float[][ , ] passableCost )
{ {
var p = queue.Pop(); var p = queue.Pop();
@@ -49,7 +56,8 @@ namespace OpenRa.Game
{ {
if (passableCost[(int)umt][newHere.X, newHere.Y] == float.PositiveInfinity) if (passableCost[(int)umt][newHere.X, newHere.Y] == float.PositiveInfinity)
continue; continue;
if (!Game.BuildingInfluence.CanMoveHere(newHere)) if (!Game.BuildingInfluence.CanMoveHere(newHere) &&
Game.BuildingInfluence.GetBuildingAt(newHere) != ignoreBuilding)
continue; continue;
if (Rules.Map.IsOverlaySolid(newHere)) if (Rules.Map.IsOverlaySolid(newHere))
continue; continue;

View File

@@ -14,6 +14,7 @@ namespace OpenRa.Game.Traits.Activities
int nearEnough; int nearEnough;
public List<int2> path; public List<int2> path;
Func<Actor, Mobile, List<int2>> getPath; Func<Actor, Mobile, List<int2>> getPath;
public Actor ignoreBuilding;
MovePart move; MovePart move;
@@ -26,6 +27,18 @@ namespace OpenRa.Game.Traits.Activities
this.nearEnough = nearEnough; this.nearEnough = nearEnough;
} }
public Move(int2 destination, Actor ignoreBuilding)
{
this.getPath = (self, mobile) =>
Game.PathFinder.FindPath(
PathSearch.FromPoint( self.Location, destination, mobile.GetMovementType(), false )
.WithCustomBlocker( Game.PathFinder.AvoidUnitsNear( self.Location, 4 )).WithIgnoredBuilding( ignoreBuilding ));
this.destination = destination;
this.nearEnough = 0;
this.ignoreBuilding = ignoreBuilding;
}
public Move( Actor target, int range ) public Move( Actor target, int range )
{ {
this.getPath = ( self, mobile ) => Game.PathFinder.FindUnitPathToRange( this.getPath = ( self, mobile ) => Game.PathFinder.FindUnitPathToRange(
@@ -42,9 +55,11 @@ namespace OpenRa.Game.Traits.Activities
this.nearEnough = 0; this.nearEnough = 0;
} }
static bool CanEnterCell( int2 c, Actor self ) bool CanEnterCell( int2 c, Actor self )
{ {
if (!Game.BuildingInfluence.CanMoveHere(c)) return false; if (!Game.BuildingInfluence.CanMoveHere(c)
&& Game.BuildingInfluence.GetBuildingAt(c) != ignoreBuilding)
return false;
// Cannot enter a cell if any unit inside is uncrushable // Cannot enter a cell if any unit inside is uncrushable
// This will need to be updated for multiple-infantry-in-a-cell // This will need to be updated for multiple-infantry-in-a-cell

View File

@@ -16,13 +16,13 @@ namespace OpenRa.Game.Traits
// todo: other bits // todo: other bits
return new Order(underCursor.Health <= EngineerDamage ? "Capture" : "Enter", return new Order(underCursor.Health <= EngineerDamage ? "Capture" : "Infiltrate",
self, underCursor, int2.Zero, null); self, underCursor, int2.Zero, null);
} }
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)
{ {
if (order.OrderString == "Enter" || order.OrderString == "Capture") if (order.OrderString == "Infiltrate" || order.OrderString == "Capture")
{ {
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(new Move(order.TargetActor, 1)); self.QueueActivity(new Move(order.TargetActor, 1));

View File

@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRa.Game.Traits.Activities;
namespace OpenRa.Game.Traits
{
class Repairable : IOrder
{
IDisposable reservation;
public Repairable(Actor self) { }
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
if (mi.Button != MouseButton.Right) return null;
if (underCursor == null) return null;
if (underCursor.Info == Rules.UnitInfo["FIX"]
&& underCursor.Owner == self.Owner
&& !Reservable.IsReserved(underCursor))
return new Order("Enter", self, underCursor, int2.Zero, null);
return null;
}
public void ResolveOrder(Actor self, Order order)
{
if (reservation != null)
{
reservation.Dispose();
reservation = null;
}
if (order.OrderString == "Enter")
{
if (Reservable.IsReserved(order.TargetActor))
return;
var res = order.TargetActor.traits.GetOrDefault<Reservable>();
if (res != null) reservation = res.Reserve(self);
self.CancelActivity();
self.QueueActivity(new Move(((1 / 24f) * order.TargetActor.CenterLocation).ToInt2(), order.TargetActor));
self.QueueActivity(new Rearm());
self.QueueActivity(new Repair());
}
}
}
}

View File

@@ -22,7 +22,7 @@ All tracked vehicles
Light vehicles Light vehicles
V2RL Works V2RL Works
APC Cargo doesn't work APC Cargo doesn't work
MNLY Can't reload at FIX MNLY Works
MGG No gap MGG No gap
MRJ No radar MRJ No radar
JEEP Works JEEP Works
@@ -31,15 +31,15 @@ HARV Works
ARTY Works ARTY Works
Helicopters Helicopters
- Repair as FIX doesn't work - Return to base after attack doesnt work
TRAN Cargo doesn't work TRAN Cargo doesn't work
HELI Weapon offsets wrong HELI Works
HIND Weapon offsets wrong HIND Works
Planes Planes
- Repair at FIX doesn't work [fix doesn't work?] - Ammo/ROF are funky
YAK Ammo/ROF are funky YAK Works
MIG Ammo/ROF are funky MIG Works
Ships Ships

View File

@@ -16,47 +16,47 @@ MNLY.AT
[V2RL] [V2RL]
Description=V2 Rocket Description=V2 Rocket
Traits=Unit, Mobile, AttackBase, RenderUnitReload, AutoTarget Traits=Unit, Mobile, AttackBase, RenderUnitReload, AutoTarget, Repairable
Voice=VehicleVoice Voice=VehicleVoice
LongDesc=Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft LongDesc=Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft
[1TNK] [1TNK]
Description=Light Tank Description=Light Tank
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget, Repairable
Recoil=2 Recoil=2
Voice=VehicleVoice Voice=VehicleVoice
LongDesc=Light Tank, good for scouting.\n Strong vs Light Vehicles\n Weak vs Tanks, Aircraft LongDesc=Light Tank, good for scouting.\n Strong vs Light Vehicles\n Weak vs Tanks, Aircraft
[2TNK] [2TNK]
Description=Medium Tank Description=Medium Tank
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget, Repairable
Recoil=3 Recoil=3
Voice=VehicleVoice Voice=VehicleVoice
LongDesc=Allied Main Battle Tank.\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft LongDesc=Allied Main Battle Tank.\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft
[3TNK] [3TNK]
Description=Heavy Tank Description=Heavy Tank
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget, Repairable
Recoil=3 Recoil=3
Voice=VehicleVoice Voice=VehicleVoice
LongDesc=Soviet Main Battle Tank, with dual cannons\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft LongDesc=Soviet Main Battle Tank, with dual cannons\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft
[4TNK] [4TNK]
Description=Mammoth Tank Description=Mammoth Tank
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget, Repairable
Voice=VehicleVoice Voice=VehicleVoice
LongDesc=Big and slow tank, with anti-air capability.\n Strong vs Tanks, Aircraft\n Weak vs Infantry LongDesc=Big and slow tank, with anti-air capability.\n Strong vs Tanks, Aircraft\n Weak vs Infantry
[ARTY] [ARTY]
Description=Artillery Description=Artillery
Traits=Unit, Mobile, AttackBase, RenderUnit, Explodes, AutoTarget Traits=Unit, Mobile, AttackBase, RenderUnit, Explodes, AutoTarget, Repairable
Voice=VehicleVoice Voice=VehicleVoice
LongDesc=Long-range artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft LongDesc=Long-range artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft
[JEEP] [JEEP]
Description=Ranger Description=Ranger
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget, Repairable
PrimaryOffset=0,0,0,-2 PrimaryOffset=0,0,0,-2
MuzzleFlash=yes MuzzleFlash=yes
Voice=VehicleVoice Voice=VehicleVoice
LongDesc=Fast scout & anti-infantry vehicle.\n Strong vs Infantry\n Weak vs Tanks, Aircraft LongDesc=Fast scout & anti-infantry vehicle.\n Strong vs Infantry\n Weak vs Tanks, Aircraft
[APC] [APC]
Description=Armored Personnel Carrier Description=Armored Personnel Carrier
Traits=Unit, Mobile, AttackBase, RenderUnitMuzzleFlash, AutoTarget Traits=Unit, Mobile, AttackBase, RenderUnitMuzzleFlash, AutoTarget, Repairable
PrimaryOffset=0,0,0,-4 PrimaryOffset=0,0,0,-4
MuzzleFlash=yes MuzzleFlash=yes
Voice=VehicleVoice Voice=VehicleVoice
@@ -65,40 +65,40 @@ LongDesc=Tough infantry transport.\n Strong vs Infantry, Light Vehicles\n Weak
;; non-combat vehicles ;; non-combat vehicles
[MRJ] [MRJ]
Description=Radar Jammer Description=Radar Jammer
Traits=Unit, Mobile, RenderUnitSpinner Traits=Unit, Mobile, RenderUnitSpinner, Repairable
PrimaryOffset=0,4,0,-6 PrimaryOffset=0,4,0,-6
SelectionPriority=3 SelectionPriority=3
Voice=VehicleVoice Voice=VehicleVoice
LongDesc=Hides nearby units on the enemy's minimap.\n Unarmed LongDesc=Hides nearby units on the enemy's minimap.\n Unarmed
[MGG] [MGG]
Description=Mobile Gap Generator Description=Mobile Gap Generator
Traits=Unit, Mobile, RenderUnitSpinner Traits=Unit, Mobile, RenderUnitSpinner, Repairable
PrimaryOffset=0,6,0,-3 PrimaryOffset=0,6,0,-3
SelectionPriority=3 SelectionPriority=3
Voice=VehicleVoice Voice=VehicleVoice
LongDesc=Regenerates Fog of War in a small area \naround the unit.\n Unarmed LongDesc=Regenerates Fog of War in a small area \naround the unit.\n Unarmed
[HARV] [HARV]
Description=Ore Truck Description=Ore Truck
Traits=Harvester, Unit, Mobile, RenderUnit Traits=Harvester, Unit, Mobile, RenderUnit, Repairable
SelectionPriority=7 SelectionPriority=7
Voice=VehicleVoice Voice=VehicleVoice
LongDesc=Collects Ore and Gems for processing.\n Unarmed LongDesc=Collects Ore and Gems for processing.\n Unarmed
[MCV] [MCV]
Description=Mobile Construction Vehicle Description=Mobile Construction Vehicle
Traits=Unit, Mobile, McvDeploy, RenderUnit Traits=Unit, Mobile, McvDeploy, RenderUnit, Repairable
SelectionPriority=3 SelectionPriority=3
Voice=VehicleVoice Voice=VehicleVoice
LongDesc=Deploys into another Construction Yard.\n Unarmed LongDesc=Deploys into another Construction Yard.\n Unarmed
[MNLY.AP] [MNLY.AP]
Description=Minelayer (Anti-Personnel) Description=Minelayer (Anti-Personnel)
Traits=Unit, Mobile, RenderUnit, Minelayer, MineImmune Traits=Unit, Mobile, RenderUnit, Minelayer, MineImmune, Repairable
Voice=VehicleVoice Voice=VehicleVoice
LongDesc=Lays mines to destroy unwary enemy units.\n Unarmed LongDesc=Lays mines to destroy unwary enemy units.\n Unarmed
Primary=MINP ;; temporary hack Primary=MINP ;; temporary hack
[MNLY.AT] [MNLY.AT]
Description=Minelayer (Anti-Tank) Description=Minelayer (Anti-Tank)
Traits=Unit, Mobile, RenderUnit, Minelayer, MineImmune Traits=Unit, Mobile, RenderUnit, Minelayer, MineImmune, Repairable
Voice=VehicleVoice Voice=VehicleVoice
LongDesc=Lays mines to destroy unwary enemy units.\n Unarmed LongDesc=Lays mines to destroy unwary enemy units.\n Unarmed
Primary=MINV ;; temporary hack Primary=MINV ;; temporary hack