From b976447d67f0a556b8e185a1efbc0fb4461a7c64 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 26 Feb 2010 20:43:17 +1300 Subject: [PATCH] fixed #75 missiles fly forever --- OpenRa.Game/Effects/Missile.cs | 20 +++++++----- OpenRa.Game/GameRules/ProjectileInfo.cs | 10 ++---- mods/cnc/weapons.ini | 5 +-- mods/ra/rules.ini | 41 +++---------------------- 4 files changed, 21 insertions(+), 55 deletions(-) diff --git a/OpenRa.Game/Effects/Missile.cs b/OpenRa.Game/Effects/Missile.cs index 5bdfadb662..5ec6ee70cc 100755 --- a/OpenRa.Game/Effects/Missile.cs +++ b/OpenRa.Game/Effects/Missile.cs @@ -81,13 +81,7 @@ namespace OpenRa.Effects var dist = Target.CenterLocation - Pos; if (dist.LengthSquared < MissileCloseEnough * MissileCloseEnough || Target.IsDead) - { - world.AddFrameEndTask(w => w.Remove(this)); - - if (t > Projectile.Arm * 40) /* don't blow up in our launcher's face! */ - Combat.DoImpact(Pos.ToInt2(), Pos.ToInt2(), Weapon, Projectile, Warhead, FiredBy); - return; - } + Explode(world); var speed = Scale * Weapon.Speed * ((targetAltitude > 0 && Weapon.TurboBoost) ? 1.5f : 1f); @@ -99,7 +93,17 @@ namespace OpenRa.Effects world.AddFrameEndTask(w => w.Add( new Smoke(w, (Pos - 1.5f * move - new int2( 0, Altitude )).ToInt2(), Projectile.Trail))); - // todo: running out of fuel + if (Projectile.RangeLimit != 0 && t > Projectile.RangeLimit * 40) + Explode(world); + } + + void Explode(World world) + { + world.AddFrameEndTask(w => w.Remove(this)); + + if (t > Projectile.Arm * 40) /* don't blow up in our launcher's face! */ + Combat.DoImpact(Pos.ToInt2(), Pos.ToInt2(), Weapon, Projectile, Warhead, FiredBy); + return; } public IEnumerable Render() diff --git a/OpenRa.Game/GameRules/ProjectileInfo.cs b/OpenRa.Game/GameRules/ProjectileInfo.cs index 216743648b..860dbc91b7 100644 --- a/OpenRa.Game/GameRules/ProjectileInfo.cs +++ b/OpenRa.Game/GameRules/ProjectileInfo.cs @@ -25,25 +25,21 @@ namespace OpenRa.GameRules public readonly bool AA = false; public readonly bool AG = true; public readonly bool ASW = false; - public readonly string Trail = null; public readonly bool Arcing = false; public readonly int Arm = 0; public readonly bool Degenerates = false; - public readonly bool Dropping = false; - public readonly int Frames = 1; - public readonly bool Gigundo = false; public readonly bool High = false; public readonly string Image = null; public readonly bool Inaccurate = false; - public readonly bool Inviso = false; public readonly bool Parachuted = false; public readonly bool Proximity = false; public readonly int ROT = 0; - public readonly bool Ranged = false; public readonly bool Rotates = false; public readonly bool Shadow = true; - public readonly bool Translucent = false; public readonly bool UnderWater = false; public readonly int RangeLimit = 0; + + // OpenRA-specific: + public readonly string Trail = null; } } diff --git a/mods/cnc/weapons.ini b/mods/cnc/weapons.ini index 199cab513d..b5787dd133 100644 --- a/mods/cnc/weapons.ini +++ b/mods/cnc/weapons.ini @@ -74,8 +74,6 @@ HeatSeeker Cannon [Invisible] -Inviso=yes -Image=none [HeatSeeker] Arm=2 @@ -83,13 +81,12 @@ High=yes Shadow=no Proximity=yes Trail=smokey -Ranged=yes Inaccurate=yes AA=yes Image=DRAGON ROT=5 Rotates=yes -Translucent=yes +RangeLimit=6 [Cannon] Image=120MM diff --git a/mods/ra/rules.ini b/mods/ra/rules.ini index b83df75c06..9c2eaf4b16 100644 --- a/mods/ra/rules.ini +++ b/mods/ra/rules.ini @@ -456,35 +456,27 @@ Report=MISSILE1 ; AA = Can this weapon fire upon flying aircraft (def=no)? ; AG = Can this weapon fire upon ground objects (def=yes)? ; ASW = Is this an Anti-Submarine-Warfare projectile (def=no)? -; Animates = Does it animate [this means smoke puffs] (def=no)? ; Arcing = Does it have a ballistic trajectory (def=no)? ; Arm = arming delay (def=0) ; Degenerates = Does the bullet strength weaken as it travels (def=no)? -; Dropping = Does it fall from a starting height (def=no)? -; Frames = number of image frames for animation purposes (def=1) -; Gigundo = Is the projectile larger than normal (def=no)? ; High = Can it fly over walls (def=no)? ; Image = image to use during flight ; Inaccurate = Is it inherently inaccurate (def=no)? -; Inviso = Is the projectile invisible as it travels (def=no)? ; Parachuted = Equipped with a parachute for dropping from plane (def=no)? ; Proximity = Does it blow up when near its target (def=no)? ; ROT = Rate Of Turn [non zero implies homing] (def=0) -; Ranged = Can it run out of fuel (def=no)? ; Rotates = Does the projectile have rotation specific imagery (def=no)? ; Shadow = If High, does this bullet need to have a shadow drawn? (def = yes) -; Translucent = Are translucent colors used in artwork (def=no)? ; UnderWater = Does the projectile travel under water? +; Trail = image to use for smoke puffs etc (def=null) +; RangeLimit = maximum flight time (def=0=unlimited) ; invisible flight to target [Invisible] -Inviso=yes -Image=none ; special case for dog [LeapDog] Image=DOGBULLT -Translucent=yes Rotates=yes Proximity=yes ROT=20 @@ -495,8 +487,6 @@ Image=120MM ; anti aircraft artillery projectile [Ack] -Image=none -Inviso=yes AA=true AG=false @@ -514,7 +504,6 @@ High=yes Shadow=no Proximity=yes Trail=smokey -Ranged=yes Inaccurate=yes Image=V2 Rotates=yes @@ -526,13 +515,12 @@ High=yes Shadow=no Proximity=yes Trail=smokey -Ranged=yes Inaccurate=yes AA=yes Image=DRAGON ROT=5 Rotates=yes -Translucent=yes +RangeLimit=5 ; small missile with deadly accuracy [LaserGuided] @@ -541,12 +529,11 @@ High=yes Shadow=no Proximity=yes Trail=smokey -Ranged=yes AA=yes Image=DRAGON ROT=20 Rotates=yes -Translucent=yes +RangeLimit=5 ; anti aircraft missile [AAMissile] @@ -555,13 +542,12 @@ High=yes Shadow=no Proximity=yes Trail=smokey -Ranged=yes AA=yes AG=no Image=MISSILE ROT=20 Rotates=yes -Translucent=yes +RangeLimit=5 ; lobbed tumbling grenade [Lobbed] @@ -569,8 +555,6 @@ High=yes Arcing=yes Inaccurate=yes Image=BOMB -Frames=8 -Translucent=yes ; Depth charge catapult [Catapult] @@ -578,20 +562,15 @@ High=yes Arcing=yes Inaccurate=yes Image=BOMB -Frames=8 ASW=yes AG=no -Translucent=yes ; dropped from plane tumbling object [Bomblet] Arm=24 RangeLimit=24 High=yes -Dropping=yes Image=BOMBLET -Frames=6 -Translucent=yes ; arcing ballistic projectile [Ballistic] @@ -605,37 +584,27 @@ Image=120MM Arm=24 RangeLimit=24 High=yes -Dropping=yes -Parachuted=yes ;Image=PARABOMB ; Allied free radar (GPS satellite) [GPSSatellite] -Gigundo=yes High=yes Image=SPUTNIK -Frames=4 ; Nuclear missile, flying up [NukeUp] -Gigundo=yes High=yes Image=ATOMICUP -Frames=4 ; Nuclear missile, flying down [NukeDown] -Gigundo=yes High=yes Image=ATOMICDN -Frames=4 ; wizard's fireball [Fireball] Trail=fb2 Image=FB1 -Frames=8 - ; ******* Warhead Characteristics ******* ; This is what gives the "rock, paper, scissors" character to the game.