diff --git a/OpenRa.Game/Traits/AutoTarget.cs b/OpenRa.Game/Traits/AutoTarget.cs index 82a7aee886..77ad306377 100644 --- a/OpenRa.Game/Traits/AutoTarget.cs +++ b/OpenRa.Game/Traits/AutoTarget.cs @@ -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().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().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); @@ -23,9 +32,29 @@ namespace OpenRa.Game.Traits { var inRange = Game.FindUnitsInCircle(self.CenterLocation, Game.CellSize * range); - return inRange.Where(a => a.Owner != null && a.Owner != self.Owner) /* todo: one day deal with friendly players */ + return inRange + .Where(a => a.Owner != null && a.Owner != self.Owner) /* todo: one day deal with friendly players */ + .Where(a => Combat.HasAnyValidWeapons(self, a)) .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. + + if (e.Damage < 0) + return; // don't retaliate against healers + + var attack = self.traits.WithInterface().First(); + if (attack.target != null) return; + + AttackTarget(self, e.Attacker); + } } } diff --git a/OpenRa.Game/Traits/RenderInfantry.cs b/OpenRa.Game/Traits/RenderInfantry.cs index 7e2198576f..04ae828be7 100644 --- a/OpenRa.Game/Traits/RenderInfantry.cs +++ b/OpenRa.Game/Traits/RenderInfantry.cs @@ -50,7 +50,10 @@ namespace OpenRa.Game.Traits var prefix = IsProne(self) ? "prone-shoot-" : "shoot-"; - anim.PlayThen(prefix + dir, () => inAttack = false); + if (anim.HasSequence(prefix + dir)) + anim.PlayThen(prefix + dir, () => inAttack = false); + else if (anim.HasSequence("heal")) + anim.PlayThen("heal", () => inAttack = false); } public override void Tick(Actor self) diff --git a/rules.ini b/rules.ini index 0f0b948965..ce3e93ff4e 100644 --- a/rules.ini +++ b/rules.ini @@ -2134,7 +2134,7 @@ Report=DOGG5P [Heal] Damage=-50 ROF=80 -Range=1.83 +Range=4 ;; 1.83 Projectile=Invisible Speed=100 Warhead=Organic diff --git a/session.ini b/session.ini index c4714e409f..ac2d39b77d 100644 --- a/session.ini +++ b/session.ini @@ -7,8 +7,4 @@ s0=Multi0,mcv,600,2841,0,Guard,None s1=Multi2,mcv,600,12445,0,Guard,None s2=Multi1,mcv,600,12505,0,Guard,None -s3=Multi3,mcv,600,2910,0,Guard,None - -s4=Multi7,3tnk,600,13017,0,Guard,None -s5=Multi7,ca,600,13765,0,Guard,None - +s3=Multi3,mcv,600,2910,0,Guard,None \ No newline at end of file diff --git a/units.ini b/units.ini index 5024eb410e..d13d1df087 100755 --- a/units.ini +++ b/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, Minelayer @@ -114,14 +116,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 @@ -135,7 +137,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 @@ -247,18 +249,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 @@ -266,6 +261,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 @@ -287,7 +283,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] @@ -531,26 +533,26 @@ MEDI Description=Attack Dog BuiltAt=KENN Voice=DogVoice -Traits=Unit, Mobile, RenderInfantry, Infantry +Traits=Unit, Mobile, RenderInfantry, Infantry, AutoTarget LongDesc=Anti-infantry unit. Not fooled by the \nSpy's disguise.\n Strong vs Infantry\n Weak vs Vehicles [E1] Description=Rifle Infantry -Traits=Unit, Mobile, RenderInfantry, AttackBase, TakeCover, Infantry +Traits=Unit, Mobile, RenderInfantry, AttackBase, TakeCover, Infantry, AutoTarget LongDesc=General-purpose infantry. Strong vs Infantry\n Weak vs Vehicles [E2] Description=Grenadier -Traits=Unit, Mobile, RenderInfantry, AttackBase, TakeCover, Infantry +Traits=Unit, Mobile, RenderInfantry, AttackBase, TakeCover, Infantry, AutoTarget FireDelay=15 PrimaryOffset=0,0,0,-13 LongDesc=Infantry armed with grenades. \n Strong vs Buildings, Infantry\n Weak vs Vehicles [E3] Description=Rocket Soldier -Traits=Unit, Mobile, RenderInfantry, AttackBase, TakeCover, Infantry +Traits=Unit, Mobile, RenderInfantry, AttackBase, TakeCover, Infantry, AutoTarget PrimaryOffset=0,0,0,-13 LongDesc=Anti-tank/Anti-aircraft infantry.\n Strong vs Tanks, Aircraft\n Weak vs Infantry [E4] Description=Flamethrower -Traits=Unit, Mobile, RenderInfantry, AttackBase, TakeCover, Infantry +Traits=Unit, Mobile, RenderInfantry, AttackBase, TakeCover, Infantry, AutoTarget FireDelay=8 LongDesc=Advanced Anti-infantry unit.\n Strong vs Infantry, Buildings\n Weak vs Vehicles [E6] @@ -571,12 +573,12 @@ LongDesc=Infiltrates enemy refineries & \nsilos, and steals money stored there.\ [E7] Description=Tanya Voice=TanyaVoice -Traits=Unit, Mobile, RenderInfantry, AttackBase, TakeCover, Infantry +Traits=Unit, Mobile, RenderInfantry, AttackBase, TakeCover, Infantry, AutoTarget LongDesc=Elite commando infantry, armed with \ndual pistols and C4.\n Strong vs Infantry, Buildings\n Weak vs Vehicles\n Special Ability: Destroy Building with C4 [MEDI] Description=Medic Voice=MedicVoice -Traits=Unit, Mobile, RenderInfantry, AttackBase, TakeCover, Infantry +Traits=Unit, Mobile, RenderInfantry, AttackBase, TakeCover, Infantry, AutoTarget LongDesc=Heals nearby infantry.\n Strong vs Nothing\n Weak vs Everything