autotarget retal; most units are aggressive now
This commit is contained in:
@@ -5,15 +5,24 @@ using System.Text;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class AutoTarget : ITick
|
||||
class AutoTarget : ITick, INotifyDamage
|
||||
{
|
||||
public AutoTarget(Actor self) {}
|
||||
|
||||
public void Tick(Actor self)
|
||||
void AttackTarget(Actor self, Actor target)
|
||||
{
|
||||
var attack = self.traits.WithInterface<AttackBase>().First();
|
||||
|
||||
if (target != null)
|
||||
attack.ResolveOrder(self, new Order("Attack", self, target, int2.Zero, null));
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (!self.IsIdle) return;
|
||||
|
||||
var attack = self.traits.WithInterface<AttackBase>().First();
|
||||
var range = Rules.WeaponInfo[self.Info.Primary].Range;
|
||||
|
||||
if (attack.target == null ||
|
||||
(attack.target.Location - self.Location).LengthSquared > range * range + 2)
|
||||
attack.target = ChooseTarget(self, range);
|
||||
@@ -27,5 +36,20 @@ namespace OpenRa.Game.Traits
|
||||
.OrderBy(a => (a.Location - self.Location).LengthSquared)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
// not a lot we can do about things we can't hurt... although maybe we should automatically run away?
|
||||
if (!Combat.HasAnyValidWeapons(self, e.Attacker))
|
||||
return;
|
||||
|
||||
if (e.Attacker.Owner == self.Owner)
|
||||
return; // don't retaliate against own units force-firing on us. it's usually not what the player wanted.
|
||||
|
||||
var attack = self.traits.WithInterface<AttackBase>().First();
|
||||
if (attack.target != null) return;
|
||||
|
||||
AttackTarget(self, e.Attacker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
74
units.ini
74
units.ini
@@ -15,32 +15,53 @@ MNLY
|
||||
|
||||
[V2RL]
|
||||
Description=V2 Rocket
|
||||
Traits=Unit, Mobile, AttackBase, RenderUnitReload
|
||||
Traits=Unit, Mobile, AttackBase, RenderUnitReload, AutoTarget
|
||||
Voice=VehicleVoice
|
||||
LongDesc=Long-range rocket artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft
|
||||
[1TNK]
|
||||
Description=Light Tank
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget
|
||||
Recoil=2
|
||||
Voice=VehicleVoice
|
||||
LongDesc=Light Tank, good for scouting.\n Strong vs Light Vehicles\n Weak vs Tanks, Aircraft
|
||||
[2TNK]
|
||||
Description=Medium Tank
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget
|
||||
Recoil=3
|
||||
Voice=VehicleVoice
|
||||
LongDesc=Allied Main Battle Tank.\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft
|
||||
[3TNK]
|
||||
Description=Heavy Tank
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget
|
||||
Recoil=3
|
||||
Voice=VehicleVoice
|
||||
LongDesc=Soviet Main Battle Tank, with dual cannons\n Strong vs Tanks, Light Vehicles\n Weak vs Infantry, Aircraft
|
||||
[4TNK]
|
||||
Description=Mammoth Tank
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget
|
||||
Voice=VehicleVoice
|
||||
LongDesc=Big and slow tank, with anti-air capability.\n Strong vs Tanks, Aircraft\n Weak vs Infantry
|
||||
[ARTY]
|
||||
Description=Artillery
|
||||
Traits=Unit, Mobile, AttackBase, RenderUnit, Explodes, AutoTarget
|
||||
Voice=VehicleVoice
|
||||
LongDesc=Long-range artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft
|
||||
[JEEP]
|
||||
Description=Ranger
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget
|
||||
PrimaryOffset=0,0,0,-2
|
||||
MuzzleFlash=yes
|
||||
Voice=VehicleVoice
|
||||
LongDesc=Fast scout & anti-infantry vehicle.\n Strong vs Infantry\n Weak vs Tanks, Aircraft
|
||||
[APC]
|
||||
Description=Armored Personnel Carrier
|
||||
Traits=Unit, Mobile, AttackBase, RenderUnitMuzzleFlash, AutoTarget
|
||||
PrimaryOffset=0,0,0,-4
|
||||
MuzzleFlash=yes
|
||||
Voice=VehicleVoice
|
||||
LongDesc=Tough infantry transport.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft
|
||||
|
||||
;; non-combat vehicles
|
||||
[MRJ]
|
||||
Description=Radar Jammer
|
||||
Traits=Unit, Mobile, RenderUnitSpinner
|
||||
@@ -55,11 +76,6 @@ PrimaryOffset=0,6,0,-3
|
||||
SelectionPriority=3
|
||||
Voice=VehicleVoice
|
||||
LongDesc=Regenerates Fog of War in a small area \naround the unit.\n Unarmed
|
||||
[ARTY]
|
||||
Description=Artillery
|
||||
Traits=Unit, Mobile, AttackBase, RenderUnit, Explodes
|
||||
Voice=VehicleVoice
|
||||
LongDesc=Long-range artillery.\n Strong vs Infantry, Buildings\n Weak vs Tanks, Aircraft
|
||||
[HARV]
|
||||
Description=Ore Truck
|
||||
Traits=Harvester, Unit, Mobile, RenderUnit
|
||||
@@ -72,20 +88,6 @@ Traits=Unit, Mobile, McvDeploy, RenderUnit
|
||||
SelectionPriority=3
|
||||
Voice=VehicleVoice
|
||||
LongDesc=Deploys into another Construction Yard.\n Unarmed
|
||||
[JEEP]
|
||||
Description=Ranger
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
||||
PrimaryOffset=0,0,0,-2
|
||||
MuzzleFlash=yes
|
||||
Voice=VehicleVoice
|
||||
LongDesc=Fast scout & anti-infantry vehicle.\n Strong vs Infantry\n Weak vs Tanks, Aircraft
|
||||
[APC]
|
||||
Description=Armored Personnel Carrier
|
||||
Traits=Unit, Mobile, AttackBase, RenderUnitMuzzleFlash
|
||||
PrimaryOffset=0,0,0,-4
|
||||
MuzzleFlash=yes
|
||||
Voice=VehicleVoice
|
||||
LongDesc=Tough infantry transport.\n Strong vs Infantry, Light Vehicles\n Weak vs Tanks, Aircraft
|
||||
[MNLY]
|
||||
Description=Minelayer
|
||||
Traits=Unit, Mobile, RenderUnit
|
||||
@@ -113,14 +115,14 @@ LongDesc=Submerged anti-ship unit armed with \ntorpedoes.\n Strong vs Ships\n
|
||||
Description=Destroyer
|
||||
WaterBound=yes
|
||||
BuiltAt=syrd
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget
|
||||
PrimaryOffset=0,-8,0,-3
|
||||
LongDesc=Fast multi-role ship. \n Strong vs Submarines, Aircraft\n Weak vs Infantry, Tanks
|
||||
[CA]
|
||||
Description=Cruiser
|
||||
WaterBound=yes
|
||||
BuiltAt=syrd
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget
|
||||
PrimaryOffset=0,17,0,-2
|
||||
SecondaryOffset=0,-17,0,-2
|
||||
LongDesc=Very slow long-range ship. \n Strong vs Buildings\n Weak vs Ships, Submarines
|
||||
@@ -134,7 +136,7 @@ LongDesc=General-purpose naval transport.\nCan carry infantry and tanks.\n Unar
|
||||
Description=Gunboat
|
||||
WaterBound=yes
|
||||
BuiltAt=syrd
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted
|
||||
Traits=Unit, Mobile, Turreted, AttackTurreted, RenderUnitTurreted, AutoTarget
|
||||
PrimaryOffset=0,-6,0,-1
|
||||
LongDesc=Light scout & support ship. \n Strong vs Ships, Submarines\n Weak vs Aircraft
|
||||
|
||||
@@ -246,18 +248,11 @@ InitialFacing=224
|
||||
LongDesc=Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks
|
||||
[FTUR]
|
||||
Description=Flame Turret
|
||||
Traits=Building, RenderBuilding
|
||||
Traits=Building, RenderBuilding, AttackTurreted, AutoTarget
|
||||
Dimensions=1,1
|
||||
Footprint=x
|
||||
SelectionPriority=3
|
||||
LongDesc=Anti-Infantry base defense.\n Strong vs Infantry\n Weak vs Aircraft
|
||||
[GAP]
|
||||
Description=Gap Generator
|
||||
Traits=Building, RenderBuilding
|
||||
Dimensions=1,2
|
||||
Footprint=_ x
|
||||
SelectionPriority=3
|
||||
LongDesc=Regenerates the Fog of War nearby, \nobscuring the area.\n Unarmed
|
||||
[SAM]
|
||||
Description=SAM Site
|
||||
Traits=Building, Turreted, RenderBuildingTurreted, AttackTurreted, AutoTarget
|
||||
@@ -265,6 +260,7 @@ Dimensions=2,1
|
||||
Footprint=xx
|
||||
SelectionPriority=3
|
||||
LongDesc=Anti-Air base defense.\n Strong vs Aircraft\n Weak vs Infantry, Tanks
|
||||
|
||||
[MSLO]
|
||||
Description=Missile Silo
|
||||
Traits=Building, RenderBuilding
|
||||
@@ -286,7 +282,13 @@ Dimensions=2,2
|
||||
Footprint=xx xx
|
||||
SelectionPriority=3
|
||||
LongDesc=Teleports a group of units from one place \nto another, for a limited time.\n Special Ability: Chronoshift
|
||||
|
||||
[GAP]
|
||||
Description=Gap Generator
|
||||
Traits=Building, RenderBuilding
|
||||
Dimensions=1,2
|
||||
Footprint=_ x
|
||||
SelectionPriority=3
|
||||
LongDesc=Regenerates the Fog of War nearby, \nobscuring the area.\n Unarmed
|
||||
|
||||
|
||||
[BuildingTypes]
|
||||
|
||||
Reference in New Issue
Block a user