Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(gameengine): artillery shells land on a fixed flight time
Olcay Seyganf62051671922
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex cf4dda563..b2de930ed 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -374,7 +374,7 @@ found and fixed, EA's own, not port damage.**- Tell a tank to fire at the ground and it fires from where it stands. On any slope the game read the spot as hidden behind the very hill it was lying on, so a tank with the spot well inside its range drove off looking for a better angle, swinging its hull round under its own turret, and fired on the way. Pulled off a building to shell the ground 140 behind them, a Battlemaster took 84 frames to its first shell on the new spot and now takes 45, which is how long its turret needs to come round, and a pair of Scorpions that used to wander about 200 away over eight seconds now stay where they were put. Replays recorded before this play back differently.- Tank shells fly straight at the target. EA's shell climbed ten over the highest ground on the way and dropped back down, so once the shells glowed, every Crusader shot looked like a lob: it left the barrel 12 degrees high, rose 7 over the line and hit coming down at 25 degrees. Now it flies the line, rising off it by nothing, and only a hill between the tank and its target still lifts it over. This goes for every tank cannon, the Battlemaster, Overlord, Scorpion and Marauder too.- Artillery shells leave along the barrel. A Nuke Cannon's shell used to come out six and a half degrees under its raised barrel and jerk onto its arc; it now leaves the muzzle at the barrel's angle and the arc grows from there. Inferno and Nuke Cannon shells still lob as high as they did.-- The Fire Base lobs its shells again. Its howitzer fires the tanks' shell, so once tank shells went straight it fired flat as well: the barrel stood 46 degrees up and the shell went out ten degrees down, straight along the line to the target. A shell from a raised barrel now follows the barrel, climbs 35 over the line on a 105 shot and drops onto the target at about 67 degrees, and the Air Force, Laser and Superweapon generals' Fire Bases do the same. Tank barrels sit level, so tank shells still fly straight, at a target close below them too. The campaign's battleships were off the other way: the front turret's art faces backward, the game read its barrels as pointing down, and the demo battleship's shells went out flat under barrels drawn 12 degrees up while the USS Bender's went up at 43 from barrels at 20. Both now leave along the barrel and still land on the target.+- Artillery lands on time. The Fire Base, the Inferno Cannon, the Nuke Cannon and the campaign's battleships fire like real guns now: the shell flies a true arc and comes down the same time after it left at any range, 1.2 seconds for a Fire Base and 1.6 for the Inferno and Nuke Cannons, and the gun raises its barrel to that arc before it fires. A target close in gets a steep lob from a barrel near upright (a Fire Base fires at 57 degrees on a 108 shot, an Inferno at 77 on a 55 one), a far one a flatter shot (34 degrees at 225, 49 at 235), and the drawn barrel and the shell's way out agree to under a degree. Each flight time is the old shot's average over the gun's range, so a tank has as long to drive out from under it as it had, and a shell still follows a target that keeps moving. Before this the barrel's angle and the arc came from two places and never met. The Fire Base's howitzer fires the tanks' shell, so when tank shells went straight it fired flat under a barrel 46 degrees up; the Inferno's barrel sat at 45 whatever the range. The battleships fired from a point 65 past their front guns and from under the waterline behind them, and both turrets aimed for the front gun; every shell now leaves its own drawn muzzle. A Technical's cannon shell left 17 in front of its gun and now leaves the gun. Tank shells still fly straight.- A SCUD or a Tomahawk flies one smooth curve to its target. A SCUD went straight up, flipped over the top at six degrees a frame, glided flat for a moment and then kinked again into its dive. Now it rolls over and comes down in a single sweep that only ever eases off, its sharpest turn 4.6 degrees a frame. The Scud Storm takes the same curve and lands within half a second of when it did. Replays recorded before this play back differently.- Machine gun fire looks fast. The tracers of a Humvee, a Technical or a Quad Cannon crawled across the field at 300 a second and took half a second to reach a target 150 away; they now cross it in a tenth of a second, at 1,500, as streaks twice as long. Rangers, Rebels, Gattling Tanks and Cannons, Comanches and the Spectre got the same treatment. Only the picture changed: every bullet lands when it always did.diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifestindex 93e39370f..700ae454b 100644--- a/GeneralsMD/Code/BuildFingerprint.manifest+++ b/GeneralsMD/Code/BuildFingerprint.manifest@@ -229,6 +229,7 @@ Data/Scenarios/alphaaurora.txtData/Scenarios/ambulanceclean.txtData/Scenarios/ambulancegiveup.txtData/Scenarios/ambulanceguard.txt+Data/Scenarios/artillery.txtData/Scenarios/aurorablast.txtData/Scenarios/aurorafog.txtData/Scenarios/avengerlasers.txtdiff --git a/GeneralsMD/Code/Data/INI/BalanceReforged.ini b/GeneralsMD/Code/Data/INI/BalanceReforged.iniindex 71bf6ad91..babc760a1 100644--- a/GeneralsMD/Code/Data/INI/BalanceReforged.ini+++ b/GeneralsMD/Code/Data/INI/BalanceReforged.ini@@ -1688,6 +1688,59 @@ Object Nuke_OverlordTankShellEndEnd+; ---- artillery shells land on time ---------------------------------------------------------------+;+; EA's artillery shell flew a fixed curve at a speed: the arc's height came from the shell, the+; barrel's angle from the turret, and the two never met. A Fire Base drew its barrel at 46 degrees+; and its shell left along it, came down at 70 and peaked anywhere from 36 to 62 over the line; an+; Inferno's barrel sat at 45 whatever the range. With BallisticFlightTime the shell flies a true+; parabola that lands that long after it left, at any range, peaking BallisticPeakHeight over the+; line, and the turret raises the barrel to the parabola's launch angle before it fires. A close+; target gets a steep lob, a far one a flatter shot, and barrel, launch and flight agree. Each time+; is the old shot's average over the weapon's range (EA's flight in brackets, min to max range), so+; a moving target gets as long to walk out of the blast as it had. The battleships' fixed fire+; pitch (12 to 20 degrees) goes the same way.++Weapon FireBaseHowitzerGun+ BallisticFlightTime = 1200 ; EA: 0.9 s at 50 to 1.67 s at 275+ BallisticPeakHeight = 50+End++Weapon InfernoCannonGun+ BallisticFlightTime = 1600 ; EA: 2.07 s at 50 to 1.47 s at 300+ BallisticPeakHeight = 75+End++Weapon InfernoCannonGunUpgraded+ BallisticFlightTime = 1600+ BallisticPeakHeight = 75+End++Weapon NukeCannonGun+ BallisticFlightTime = 1600 ; EA: 1.13 s at 150 to 2.03 s at 350+ BallisticPeakHeight = 80+End++Weapon NukeCannonNeutronWeapon+ BallisticFlightTime = 1600+ BallisticPeakHeight = 80+End++Weapon BattleShipGunReal+ BallisticFlightTime = 800 ; EA: 500 a second, 0.8 s at 400+ BallisticPeakHeight = 30+End++Weapon BattleshipDemoGun+ BallisticFlightTime = 800+ BallisticPeakHeight = 30+End++Weapon BattleshipUSSBenderGun+ BallisticFlightTime = 750 ; EA: 0.7 to 0.75 s on its lane+ BallisticPeakHeight = 60+End+; ---- a tank shell does its damage to the man it hits ---------------------------------------------;; HumanArmor took armor-piercing at 10%, so a Crusader's 60 did 6 to a Ranger with 180 health:diff --git a/GeneralsMD/Code/Data/INI/FixesReforged.ini b/GeneralsMD/Code/Data/INI/FixesReforged.iniindex 384345557..4301f6de5 100644--- a/GeneralsMD/Code/Data/INI/FixesReforged.ini+++ b/GeneralsMD/Code/Data/INI/FixesReforged.ini@@ -6784,6 +6784,123 @@ Object SupW_AuroraFuelAirBombGeometryMajorRadius = 2.0End+; ==== Campaign battleships ========================================================================++; The battleships name a flash bone at each muzzle and no launch bone, so a shell left from the+; ship's origin swung round the turret's pivot: about 65 past the front guns' muzzles and under the+; waterline for the back guns'. The muzzles are now the launch bones too, three a turret as drawn.+; EA's draw blocks otherwise unchanged.++Object AmericaVehicleBattleShip+ ReplaceModule ModuleTag_01+ Draw = W3DTankDraw ModuleTag_01_LaunchBones+ OkToChangeModelColor = Yes+ InitialRecoilSpeed = 120+ MaxRecoilDistance = 8+ RecoilSettleSpeed = 6+ ConditionState = NONE+ Model = AVBattleSh+ Animation = AVBattleSh.AVBattleSh+ AnimationMode = LOOP+ Turret = Turret01+ TurretPitch = TurretEL01+ TurretArtAngle = 180+ AltTurret = Turret02+ AltTurretPitch = TurretEL02+ WeaponFireFXBone = PRIMARY Tur1Muzzle+ WeaponRecoilBone = PRIMARY Tur1Barrel+ WeaponLaunchBone = PRIMARY Tur1Muzzle+ WeaponFireFXBone = SECONDARY Tur2Muzzle+ WeaponRecoilBone = SECONDARY Tur2Barrel+ WeaponLaunchBone = SECONDARY Tur2Muzzle+ ParticleSysBone = TreadFX02 BattleShipWaterRipples+ ParticleSysBone = TreadFX03 BattleShipWaterRipples+ ParticleSysBone = TreadFX04 BattleShipWaterRipples+ End+ End+ End+End++Object AmericaVehicleBattleShipDemo+ ReplaceModule ModuleTag_01+ Draw = W3DTankDraw ModuleTag_01_LaunchBones+ OkToChangeModelColor = Yes+ InitialRecoilSpeed = 120+ MaxRecoilDistance = 8+ RecoilSettleSpeed = 6+ ConditionState = NONE+ Model = avbattlesh+ Animation = avbattlesh.avbattlesh+ AnimationMode = LOOP+ Turret = Turret01+ TurretPitch = TurretEL01+ TurretArtAngle = 180+ AltTurret = Turret02+ AltTurretPitch = TurretEL02+ WeaponFireFXBone = PRIMARY Tur1Muzzle+ WeaponRecoilBone = PRIMARY Tur1Barrel+ WeaponLaunchBone = PRIMARY Tur1Muzzle+ WeaponFireFXBone = SECONDARY Tur2Muzzle+ WeaponRecoilBone = SECONDARY Tur2Barrel+ WeaponLaunchBone = SECONDARY Tur2Muzzle+ ParticleSysBone = TreadFX02 BattleShipWaterRipples+ ParticleSysBone = TreadFX03 BattleShipWaterRipples+ ParticleSysBone = TreadFX04 BattleShipWaterRipples+ End+ ConditionState = DAMAGED+ Model = avbattlesh_D+ Animation = avbattlesh_D.avbattlesh_D+ AnimationMode = LOOP+ End+ ConditionState = REALLYDAMAGED RUBBLE+ Model = avbattlesh_D1+ Animation = avbattlesh_D1.avbattlesh_D1+ AnimationMode = LOOP+ End+ End+ End+End++Object AmericaVehicleBattleShipUSSBender+ ReplaceModule ModuleTag_01+ Draw = W3DTankDraw ModuleTag_01_LaunchBones+ OkToChangeModelColor = Yes+ InitialRecoilSpeed = 120+ MaxRecoilDistance = 8+ RecoilSettleSpeed = 6+ ConditionState = NONE+ Model = avbattlesh+ Animation = avbattlesh.avbattlesh+ AnimationMode = LOOP+ Turret = Turret01+ TurretPitch = TurretEL01+ TurretArtAngle = 180+ AltTurret = Turret02+ AltTurretPitch = TurretEL02+ WeaponFireFXBone = PRIMARY Tur1Muzzle+ WeaponRecoilBone = PRIMARY Tur1Barrel+ WeaponLaunchBone = PRIMARY Tur1Muzzle+ WeaponFireFXBone = SECONDARY Tur2Muzzle+ WeaponRecoilBone = SECONDARY Tur2Barrel+ WeaponLaunchBone = SECONDARY Tur2Muzzle+ ParticleSysBone = TreadFX02 BattleShipWaterRipples+ ParticleSysBone = TreadFX03 BattleShipWaterRipples+ ParticleSysBone = TreadFX04 BattleShipWaterRipples+ End+ ConditionState = DAMAGED+ Model = avbattlesh_D+ Animation = avbattlesh_D.avbattlesh_D+ AnimationMode = LOOP+ End+ ConditionState = REALLYDAMAGED RUBBLE+ Model = avbattlesh_D1+ Animation = avbattlesh_D1.avbattlesh_D1+ AnimationMode = LOOP+ End+ End+ End+End+; ==== Powers and abilities ========================================================================; The American generals' promotion screen offered the Pathfinder and the Stealth Fighter throughdiff --git a/GeneralsMD/Code/Data/Scenarios/artillery.txt b/GeneralsMD/Code/Data/Scenarios/artillery.txtnew file mode 100644index 000000000..a4bc4c1a9--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/artillery.txt@@ -0,0 +1,55 @@+# Artillery on a fixed flight time: each gun shoots near, mid and far in its range, so the log shows+# the same flight time and a different barrel pitch at each distance. A Fire Base takes no attack+# order from a scenario and shoots the nearest enemy, so three of them each get a car at their own+# distance: the Air Force one near, the plain one at a car and then something of the enemy's further+# west, the Superweapon one far. The Inferno Cannon (range 50 to 300) shoots at 60, 140 and 235; the+# Nuke Cannon (150 to 350) near, at 245 and 330; the demo battleship and the USS Bender each at a+# far car and then a near one, both turrets at once. A Crusader keeps its straight shot. The numbers+# are only in the log with a temporary trace at launch and at detonation in DumbProjectileBehavior.+#+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit+# -randommap 1 2 small -autoskirmish 2 -takeover+# -side 0 FactionAmerica -side 1 FactionGLA -seed 1 -maxframes 2600+# -scenario artillery -logPrefix artillery_+#+# See mobstress.txt for the line grammar.++30 spawn 0 AmericaFireBase 1 500 1500+30 spawn 1 CarCompact 1 630 1500+30 spawn 0 AmericaPowerPlant 1 650 1400+30 spawn 0 AirF_AmericaFireBase 1 1050 1400+30 spawn 1 CarLimo1 1 1050 1495+30 spawn 0 SupW_AmericaFireBase 1 250 1400+30 spawn 1 CarLimo2 1 250 1150+30 spawn 0 ChinaVehicleInfernoCannon 1 560 650+30 spawn 1 CarTaxiCab01 1 630 650+30 spawn 1 CarTaxiCab02 1 720 650+30 spawn 1 CarTaxiCab04 1 810 650+30 spawn 0 ChinaVehicleNukeLauncher 1 500 800+30 spawn 1 CarBug1 1 690 770+30 spawn 1 CarBug3 1 700 740+30 spawn 1 CarCamaro 1 750 800+30 spawn 1 CarSport01 1 840 800+30 spawn 0 AmericaVehicleBattleShipDemo 1 1400 1550+30 spawn 1 CarLuxury01 1 1000 1250+30 spawn 1 CarLuxury02 1 1200 1350+30 spawn 0 AmericaVehicleBattleShipUSSBender 1 1400 1100+30 spawn 1 CarBug2 1 1000 1000+30 spawn 1 CarSport02 1 1150 950+30 spawn 0 AmericaTankCrusader 1 500 500+30 spawn 1 AmericaVehicleDozer 1 630 500++60 attack 0 ChinaVehicleInfernoCannon 1 CarTaxiCab01+60 attack 0 ChinaVehicleNukeLauncher 1 CarBug1+60 attack 0 AmericaVehicleBattleShipDemo 1 CarLuxury01+60 attack 0 AmericaVehicleBattleShipUSSBender 1 CarBug2+60 attack 0 AmericaTankCrusader 1 AmericaVehicleDozer+260 attack 0 ChinaVehicleNukeLauncher 1 CarBug3+460 attack 0 ChinaVehicleInfernoCannon 1 CarTaxiCab02+470 move 1 CarTaxiCab02 760 520+500 move 1 CarLimo2 400 1150+460 attack 0 ChinaVehicleNukeLauncher 1 CarCamaro+460 attack 0 AmericaVehicleBattleShipDemo 1 CarLuxury02+460 attack 0 AmericaVehicleBattleShipUSSBender 1 CarSport02+860 attack 0 ChinaVehicleInfernoCannon 1 CarTaxiCab04+860 attack 0 ChinaVehicleNukeLauncher 1 CarSport01diff --git a/GeneralsMD/Code/Data/Scenarios/shellpaths.txt b/GeneralsMD/Code/Data/Scenarios/shellpaths.txtindex 5f10691f5..3fb8c12c4 100644--- a/GeneralsMD/Code/Data/Scenarios/shellpaths.txt+++ b/GeneralsMD/Code/Data/Scenarios/shellpaths.txt@@ -32,6 +32,10 @@# cruise missiles' single curve (2026-10-13): tank shell 13.7 to 1.9 and 7.2 to 0 over the line, Nuke# Cannon 6.5 to 3.8, Inferno 5.4 to 5.5, Scud 6.0 to 4.6, Tomahawk 6.0 to 5.5, Rocket Buggy 3.3 both.#+# Since the fixed flight time (2026-10-25) the Fire Bases, the Inferno and Nuke Cannons and the+# battleships fly a parabola set by their weapon, and the numbers above for them are history;+# artillery.txt measures them now.+## See mobstress.txt for the line grammar.30 spawn 0 AmericaTankCrusader 1 500 500diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.hindex 98d2f175b..07f8ba436 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h@@ -420,6 +420,9 @@ public:inline Real getWeaponSpeed() const { return m_weaponSpeed; }inline Real getMinWeaponSpeed() const { return m_minWeaponSpeed; }inline Bool isScaleWeaponSpeed() const { return m_isScaleWeaponSpeed; }+ inline UnsignedInt getBallisticFlightFrames() const { return m_ballisticFlightFrames; }+ inline Real getBallisticPeakHeight() const { return m_ballisticPeakHeight; }+ Real getBallisticLaunchPitch(const Coord3D& from, const Coord3D& to) const;inline Real getWeaponRecoilAmount() const { return m_weaponRecoil; }inline Real getMinTargetPitch() const { return m_minTargetPitch; }inline Real getMaxTargetPitch() const { return m_maxTargetPitch; }@@ -522,6 +525,8 @@ private:Real m_weaponSpeed; ///< speed of damage travel, in dist/frameReal m_minWeaponSpeed; ///< speed of damage travel, in dist/frameBool m_isScaleWeaponSpeed; ///< Scale from min to normal based on range (for lobbers)+ UnsignedInt m_ballisticFlightFrames; ///< nonzero: the shell flies a parabola and lands this many frames after launch, at any range+ Real m_ballisticPeakHeight; ///< how far that parabola rises over the line from muzzle to target, at mid flightReal m_weaponRecoil; ///< amt of recoil caused to firer, in radsReal m_minTargetPitch; ///< min pitch from source->victim allowable in order to targetReal m_maxTargetPitch; ///< max pitch from source->victim allowable in order to target@@ -698,6 +703,7 @@ public:inline const WeaponTemplate* getTemplate() const { return m_template; }inline WeaponSlotType getWeaponSlot() const { return m_wslot; }+ inline Int getCurBarrel() const { return m_curBarrel; }inline AsciiString getName() const { return m_template->getName(); }inline UnsignedInt getLastShotFrame() const { return m_lastFireFrame; } ///< frame a shot was last fired on// If we are "reloading", then m_ammoInClip is a lie. It will say full.diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cppindex 828818d62..f09797737 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp@@ -1058,6 +1058,7 @@ StateReturnType TurretAIAimTurretState::update()TurretTargetType targetType = turret->friend_getTurretTarget(enemy, enemyPosition);Object *enemyForDistanceCheckOnly = enemy; // Note: Do not use this anywhere except for the range check.Bool aimingAtGround = (targetType != TARGET_OBJECT); // a position, or a building; decided before enemy is nulled+ Real bodyMiddleHeight = 0.0f; // a shot at an object lands somewhere on its body (Weapon::randomPointOnBody), on average its middleBool nothingInRange = false;switch (targetType)@@ -1113,9 +1114,11 @@ StateReturnType TurretAIAimTurretState::update()enemyPosition = info.attackPoint1;}}- else+ else{enemyPosition = *enemy->getPosition();+ const GeometryInfo& geom = enemy->getGeometryInfo();+ bodyMiddleHeight = (geom.getMaxHeightAbovePosition() - geom.getMaxHeightBelowPosition()) / 2;}enemyAI = enemy ? enemy->getAI() : NULL;@@ -1192,8 +1195,43 @@ StateReturnType TurretAIAimTurretState::update(){Real desiredPitch = 0;+ // Linked turrets fire every weapon at once (the battleship's two), so a turret aims for the+ // weapon it carries, which need not be the current one.+ const Weapon* turretWeapon = curWeapon;+ if( !turret->isWeaponSlotOnTurret( slot ) )+ {+ for( Int other = PRIMARY_WEAPON; other < WEAPONSLOT_COUNT; ++other )+ {+ const Weapon* carried = obj->getWeaponInWeaponSlot( (WeaponSlotType)other );+ if( carried && turret->isWeaponSlotOnTurret( (WeaponSlotType)other ) )+ {+ turretWeapon = carried;+ break;+ }+ }+ }+ const WeaponTemplate* shot = turretWeapon->getTemplate();+ // A shell with a flight time leaves along the parabola that lands it on time, so the barrel goes to+ // that pitch, measured from where the shell will leave the muzzle. The muzzle moves as the barrel+ // does, and the next frame's aim takes the moved muzzle; the gun's own art pitch (the Fire Base's+ // barrel is modelled 25 degrees up) comes out of the difference between barrel and turret.+ if( shot->getBallisticFlightFrames() > 0 )+ {+ Matrix3D launchTransform(true);+ Coord3D launchPos;+ Weapon::calcProjectileLaunchPosition( obj, turretWeapon->getWeaponSlot(), turretWeapon->getCurBarrel(), launchTransform, launchPos );+ Vector3 barrel = launchTransform.Get_X_Vector();+ Real barrelPitch = ATan2( barrel.Z, sqrtf( sqr( barrel.X ) + sqr( barrel.Y ) ) );+ Coord3D landing = enemyPosition;+ landing.z += bodyMiddleHeight;+ desiredPitch = turret->getTurretPitch() + shot->getBallisticLaunchPitch( launchPos, landing ) - barrelPitch;+ if( desiredPitch < turret->getMinPitch() )+ {+ desiredPitch = turret->getMinPitch();+ }+ }// Some turrets want to fire at a set pitch, and some want to fire straight to the target- if( turret->getFirePitch() > 0 )+ else if( turret->getFirePitch() > 0 ){desiredPitch = turret->getFirePitch();}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cppindex 58b3c33bd..5941b5456 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp@@ -451,6 +451,40 @@ Bool DumbProjectileBehavior::calcFlightPath(Bool recalcNumSegments)return false;}+ // An artillery shell with a flight time flies a true parabola and lands that many frames after it+ // left, near or far, the way a gunner sets the charge and the elevation for a time on target. A+ // Bezier whose inner points sit a third of the way along the launch and landing tangents is that+ // parabola exactly, at an even pace, so one sample a frame is where the shell is each frame. The+ // turret raised the barrel to the same launch pitch (WeaponTemplate::getBallisticLaunchPitch), aimed+ // at the middle of the target, and the shot lands on a point of its body a few feet off that: the+ // peak takes up the difference, so the shell still leaves along the barrel. A barrel nowhere near+ // the solution (one held at its lowest pitch) moves the peak a quarter at most.+ UnsignedInt ballisticFrames = m_detonationWeaponTmpl ? m_detonationWeaponTmpl->getBallisticFlightFrames() : 0;+ if( ballisticFrames > 0 )+ {+ const Real LAUNCH_RISE_TO_PEAK_HEIGHT = 0.25f;+ const Real PEAK_HEIGHT_TO_INNER_POINT_RISE = 4.0f / 3.0f;+ const Real PEAK_HEIGHT_SHIFT_LIMIT = 0.25f;+ Coord3D span;+ span.set( &controlPoints[3] );+ span.sub( &controlPoints[0] );+ Real peakHeight = m_detonationWeaponTmpl->getBallisticPeakHeight();+ Real barrelPeakHeight = LAUNCH_RISE_TO_PEAK_HEIGHT * ( m_launchSlope * sqrtf( sqr( span.x ) + sqr( span.y ) ) - span.z );+ peakHeight = clamp( peakHeight * ( 1.0f - PEAK_HEIGHT_SHIFT_LIMIT ), barrelPeakHeight, peakHeight * ( 1.0f + PEAK_HEIGHT_SHIFT_LIMIT ) );+ Real innerRise = PEAK_HEIGHT_TO_INNER_POINT_RISE * peakHeight;+ for( Int inner = 1; inner <= 2; ++inner )+ {+ Real share = inner / 3.0f;+ controlPoints[inner].x = controlPoints[0].x + share * span.x;+ controlPoints[inner].y = controlPoints[0].y + share * span.y;+ controlPoints[inner].z = controlPoints[0].z + share * span.z + innerRise;+ }+ if( recalcNumSegments )+ m_flightPathSegments = ballisticFrames + 1;+ BezierSegment( controlPoints ).getSegmentPoints( m_flightPathSegments, &m_flightPath );+ return true;+ }+// X and Y for inner points are along the line between us, so normalize and scale a vector between us, but// only use the x and y of the resultVector3 targetVector;// 0 origin vector between me and himdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cppindex e57e52341..5f116b97c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp@@ -245,7 +245,9 @@ const FieldParse WeaponTemplate::TheWeaponTemplateFieldParseTable[] ={ "DeathType", INI::parseIndexList, TheDeathNames, offsetof(WeaponTemplate, m_deathType) },{ "WeaponSpeed", INI::parseVelocityReal, NULL, offsetof(WeaponTemplate, m_weaponSpeed) },{ "MinWeaponSpeed", INI::parseVelocityReal, NULL, offsetof(WeaponTemplate, m_minWeaponSpeed) },- { "ScaleWeaponSpeed", INI::parseBool, NULL, offsetof(WeaponTemplate, m_isScaleWeaponSpeed) },+ { "ScaleWeaponSpeed", INI::parseBool, NULL, offsetof(WeaponTemplate, m_isScaleWeaponSpeed) },+ { "BallisticFlightTime", INI::parseDurationUnsignedInt, NULL, offsetof(WeaponTemplate, m_ballisticFlightFrames) },+ { "BallisticPeakHeight", INI::parseReal, NULL, offsetof(WeaponTemplate, m_ballisticPeakHeight) },{ "WeaponRecoil", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_weaponRecoil) },{ "MinTargetPitch", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_minTargetPitch) },{ "MaxTargetPitch", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_maxTargetPitch) },@@ -336,6 +338,8 @@ WeaponTemplate::WeaponTemplate() : m_nextTemplate(NULL)m_weaponSpeed = 999999.0f; // effectively instantm_minWeaponSpeed = 999999.0f; // effectively instantm_isScaleWeaponSpeed = FALSE;+ m_ballisticFlightFrames = 0;+ m_ballisticPeakHeight = 0.0f;m_weaponRecoil = 0.0f; // no recoilm_minTargetPitch = -PI;m_maxTargetPitch = PI;@@ -568,6 +572,17 @@ Real WeaponTemplate::getUnmodifiedAttackRange() constreturn m_attackRange;}+//-------------------------------------------------------------------------------------------------+// A parabola that lands on time and peaks h over the line at mid flight leaves at a vertical speed of+// (rise + 4h) over the flight time, against a horizontal speed of distance over the same time, so+// the time cancels out of the pitch. A close target gets the steep lob, a far one the flat shot.+Real WeaponTemplate::getBallisticLaunchPitch(const Coord3D& from, const Coord3D& to) const+{+ const Real PEAK_HEIGHT_TO_LAUNCH_RISE = 4.0f;+ Real run = sqrtf(sqr(to.x - from.x) + sqr(to.y - from.y));+ return ATan2(to.z - from.z + PEAK_HEIGHT_TO_LAUNCH_RISE * m_ballisticPeakHeight, run);+}+//-------------------------------------------------------------------------------------------------Int WeaponTemplate::getDelayBetweenShots(const WeaponBonus& bonus) const{diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cppindex b0d40c039..d205bee15 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp@@ -3985,11 +3985,20 @@ Bool W3DModelDraw::getProjectileLaunchOffset(// The art angle turns a launch bone, posed the way the turret's art faces, to the front. With// no launch bone the matrix is the object's own, facing the front already, and turned by the// art it faced backward, so the turret's pitch tipped it down: the battleship's front guns- // fired 12 degrees under barrels drawn 12 degrees up.+ // fired 12 degrees under barrels drawn 12 degrees up. The bone turns about the turret's pivot,+ // as the drawn turret does; turned about the model's origin, a turret off the centre threw it+ // across: a technical's cannon shell left 17 in front of its gun.if (tur != TURRET_INVALID && wbvec[specificBarrelToUse].m_hasProjectileLaunchBone){- launchPos->Pre_Rotate_Z(stateToUse->m_turrets[tur].m_turretArtAngle);- launchPos->Pre_Rotate_Y(-stateToUse->m_turrets[tur].m_turretArtPitch);+ const ModelConditionInfo::TurretInfo& artTurret = stateToUse->m_turrets[tur];+ Coord3D artPivot;+ artPivot.zero();+ if (artTurret.m_turretAngleNameKey != NAMEKEY_INVALID)+ stateToUse->findPristineBonePos(artTurret.m_turretAngleNameKey, artPivot);+ launchPos->Adjust_Translation(Vector3(-artPivot.x, -artPivot.y, 0.0f));+ launchPos->Pre_Rotate_Z(artTurret.m_turretArtAngle);+ launchPos->Adjust_Translation(Vector3(artPivot.x, artPivot.y, 0.0f));+ launchPos->Pre_Rotate_Y(-artTurret.m_turretArtPitch);}#ifdef CACHE_ATTACH_BONE#else