Skip to content

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.

feat(gameengine): comanche chin gun on a turret with a limited arc

Olcay Seygan7aca3159e465
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 00be918bf..147f46b3c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -41,6 +41,7 @@ found and fixed — EA's own, not port damage.**
- Every helicopter in the game, on every side and for every general, used to drive like a tank with rotors. Told to go somewhere behind it, a Comanche swung its nose all the way round on the spot and only then flew off nose first. Now it flies where it is sent, backwards or sideways, with its nose left where it was. Sent 300 behind itself, a Comanche turned 178 degrees before it went and was 30 out after a second and a half; now it goes tail first, never turns, and is 30 out after one second. On a long flight the nose comes round into the direction of travel while the helicopter is already on its way.
- A Comanche keeps its guns on what it is shooting at while it flies. Its cannon and missiles only fire straight ahead, so a Comanche ordered to move in the middle of a fight turned away from its target. It now holds its nose on the target and slides along beside it: one sent across in front of an Overlord it had been shooting stayed within a degree of the tank the whole way, where it used to point 84 degrees off on average. One flying past a supply truck 120 off its line now turns to it and shoots, where it used to fly straight by.
+- The Comanche's chin gun turns, as the real one does, 120 degrees either side of the nose. EA bolted the cannon and the missiles straight ahead, so a Comanche had to swing its whole body round to shoot anything. Now the missiles still fly where the nose points, and the cannon tracks on its own: making a pass along four Red Guards, a Comanche turned 34 degrees where it used to turn 132, and its gun held within 4 degrees of the target while the nose stayed on the flight. A target behind the gun's reach turns the helicopter just far enough to bring it back in.
- Pull a helicopter out of a fight and it keeps shooting on the way out. Told to move while attacking, it used to drop the target at once; now it holds its gun on it for as long as the target is alive and in range, and the move goes exactly where and when it would have. A Comanche backs or slides away with its nose on the target: sent 350 straight back from three Battlemasters it fired 10 more rounds before they fell out of range, and 14 sliding off to the side, where it used to fire one. A plain move never starts a new fight; a helicopter that was not attacking anything just flies.
- A Helix with the gattling cannon on its back lets the cannon do the aiming. The cannon sits on a turret that turns all the way round, yet the whole Helix used to swing round to point at whatever it was shooting. Now it holds its heading and only the turret tracks. With a Crusader driving circles round it, a Helix that used to turn 336 degrees following the tank does not turn at all, and its cannon fired 458 times where it fired 251. Infantry shooting out of a Helix bunker leave the Helix just as free once they are on its target. The Helix's own nose gun only fires forward, so while the cannon has the target it fires only when the target crosses in front.
- A helicopter leans into the move. It dips its nose to speed up and lifts it to stop, rolls into a slide sideways and comes level again in a hover, never past about 12 degrees and never with a jerk: the lean moves by at most a degree and a half from one frame to the next.
diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifest
index b868f1ae3..29208367e 100644
--- a/GeneralsMD/Code/BuildFingerprint.manifest
+++ b/GeneralsMD/Code/BuildFingerprint.manifest
@@ -42,6 +42,7 @@ Data/Scenarios/airbelowfar.txt
Data/Scenarios/bridgecross.txt
Data/Scenarios/bridgelong.txt
Data/Scenarios/chokeprobe.txt
+Data/Scenarios/comturret.txt
Data/Scenarios/crowdbattle.txt
Data/Scenarios/helislide.txt
Data/Scenarios/helitypes.txt
diff --git a/GeneralsMD/Code/Data/INI/BalanceReforged.ini b/GeneralsMD/Code/Data/INI/BalanceReforged.ini
index 4d19fc5e9..d236d087f 100644
--- a/GeneralsMD/Code/Data/INI/BalanceReforged.ini
+++ b/GeneralsMD/Code/Data/INI/BalanceReforged.ini
@@ -319,3 +319,102 @@ End
Weapon BuggyRocketREDWeapon
AttackRange = 235.0 ; EA: 300
End
+
+; ---- the Comanche's chin gun turns ---------------------------------------------------------------
+;
+; EA put the cannon and the missiles on one invisible "turret" with no turn rate, only so the
+; Comanche could fire on the move, which left both pointing straight ahead and the whole helicopter
+; swinging round to aim. The cannon now sits on a turret of its own that slews 120 degrees a second
+; and reaches 120 degrees either side of the nose (TurretYawLimit); a target further round turns
+; the body just far enough to bring it into that arc. The missiles stay fixed forward on a second
+; turret that does not turn, so a missile shot still puts the nose on the target. The turret does
+; not pitch: the model has no gun bone to show it, and the cannon's hit does not depend on pitch.
+; Every Comanche gets the same module; the replaced JetAIUpdate keeps the object's Locomotor sets.
+
+Object AmericaVehicleComanche
+ ReplaceModule ModuleTag_06
+ Behavior = JetAIUpdate ModuleTag_06_Reforged
+ MinHeight = 5
+ NeedsRunway = No
+ KeepsParkingSpaceWhenAirborne = No
+ AutoAcquireEnemiesWhenIdle = Yes
+ Turret
+ TurretTurnRate = 120
+ TurretPitchRate = 0
+ TurretYawLimit = 120
+ ControlledWeaponSlots = PRIMARY
+ End
+ AltTurret
+ TurretTurnRate = 0
+ TurretPitchRate = 0
+ ControlledWeaponSlots = SECONDARY
+ End
+ End
+ End
+End
+
+Object AirF_AmericaVehicleComanche
+ ReplaceModule ModuleTag_06
+ Behavior = JetAIUpdate ModuleTag_06_Reforged
+ MinHeight = 5
+ NeedsRunway = No
+ KeepsParkingSpaceWhenAirborne = No
+ AutoAcquireEnemiesWhenIdle = Yes
+ Turret
+ TurretTurnRate = 120
+ TurretPitchRate = 0
+ TurretYawLimit = 120
+ ControlledWeaponSlots = PRIMARY
+ End
+ AltTurret
+ TurretTurnRate = 0
+ TurretPitchRate = 0
+ ControlledWeaponSlots = SECONDARY
+ End
+ End
+ End
+End
+
+Object Lazr_AmericaVehicleComanche
+ ReplaceModule ModuleTag_06
+ Behavior = JetAIUpdate ModuleTag_06_Reforged
+ MinHeight = 5
+ NeedsRunway = No
+ KeepsParkingSpaceWhenAirborne = No
+ AutoAcquireEnemiesWhenIdle = Yes
+ Turret
+ TurretTurnRate = 120
+ TurretPitchRate = 0
+ TurretYawLimit = 120
+ ControlledWeaponSlots = PRIMARY
+ End
+ AltTurret
+ TurretTurnRate = 0
+ TurretPitchRate = 0
+ ControlledWeaponSlots = SECONDARY
+ End
+ End
+ End
+End
+
+Object SupW_AmericaVehicleComanche
+ ReplaceModule ModuleTag_06
+ Behavior = JetAIUpdate ModuleTag_06_Reforged
+ MinHeight = 5
+ NeedsRunway = No
+ KeepsParkingSpaceWhenAirborne = No
+ AutoAcquireEnemiesWhenIdle = Yes
+ Turret
+ TurretTurnRate = 120
+ TurretPitchRate = 0
+ TurretYawLimit = 120
+ ControlledWeaponSlots = PRIMARY
+ End
+ AltTurret
+ TurretTurnRate = 0
+ TurretPitchRate = 0
+ ControlledWeaponSlots = SECONDARY
+ End
+ End
+ End
+End
diff --git a/GeneralsMD/Code/Data/Scenarios/comturret.txt b/GeneralsMD/Code/Data/Scenarios/comturret.txt
new file mode 100644
index 000000000..2148f129c
--- /dev/null
+++ b/GeneralsMD/Code/Data/Scenarios/comturret.txt
@@ -0,0 +1,47 @@
+# Two Comanches, in slot 1 so the targets in slot 0 take the scenario's orders rather than the
+# computer's. The first hovers while an Overlord, which cannot shoot at aircraft, drives two laps of
+# a circle 100 round it with the Comanche on it. The second is put on four Red Guards and 50 frames
+# later sent 800 east, past them 130 off its line.
+#
+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit
+# -map "Maps\Twilight Flame\Twilight Flame.map" -autoskirmish 2 -takeover
+# -side 0 FactionAmerica -side 1 FactionChina -seed 7 -maxframes 1300
+# -scenario comturret -logPrefix comturret_
+#
+# Measured 2026-10-03 with a temporary per-frame log of heading, gun angle and last shot. Before,
+# the cannon and the missiles shared a turret that could not turn, so the gun always pointed down
+# the nose: the strafing Comanche turned 132 degrees to keep its nose on the Red Guards and slid
+# along beside them. After, it turns 34 degrees, flies with its nose 64 degrees off the target on
+# average, and the chin gun swings 207 degrees, out to the full 120 off the nose, and stays within
+# 4 degrees of the target; 18 shots against 19. Against the circling Overlord the missiles still
+# turn the nose, and between volleys the gun takes over: the body turned 673 degrees over two laps
+# where it turned 712, the gun 689 out to 120 off the nose, and the nose sat 63 degrees off the tank
+# on average where it sat on it. 256 shots against 285; the Overlord ended on 84 health against 42.
+
+30 spawn 1 AmericaVehicleComanche 1 1200 3700
+30 spawn 0 ChinaTankOverlord 1 1300 3700
+150 attack 1 AmericaVehicleComanche 0 ChinaTankOverlord
+160 move 0 ChinaTankOverlord 1271 3771
+220 move 0 ChinaTankOverlord 1200 3800
+280 move 0 ChinaTankOverlord 1129 3771
+340 move 0 ChinaTankOverlord 1100 3700
+400 move 0 ChinaTankOverlord 1129 3629
+460 move 0 ChinaTankOverlord 1200 3600
+520 move 0 ChinaTankOverlord 1271 3629
+580 move 0 ChinaTankOverlord 1300 3700
+640 move 0 ChinaTankOverlord 1271 3771
+700 move 0 ChinaTankOverlord 1200 3800
+760 move 0 ChinaTankOverlord 1129 3771
+820 move 0 ChinaTankOverlord 1100 3700
+880 move 0 ChinaTankOverlord 1129 3629
+940 move 0 ChinaTankOverlord 1200 3600
+1000 move 0 ChinaTankOverlord 1271 3629
+1060 move 0 ChinaTankOverlord 1300 3700
+1200 tally 0 ChinaTankOverlord
+
+30 spawn 1 AirF_AmericaVehicleComanche 1 1100 4500
+30 spawn 0 ChinaInfantryRedguard 4 1300 4630
+150 attack 1 AirF_AmericaVehicleComanche 0 ChinaInfantryRedguard
+200 move 1 AirF_AmericaVehicleComanche 1900 4500
+200 tally 0 ChinaInfantryRedguard
+500 tally 0 ChinaInfantryRedguard
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h
index 6f9217e5c..7ebd23329 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h
@@ -452,6 +452,8 @@ public:
Bool isWeaponSlotOnTurretAndAimingAtTarget(WeaponSlotType wslot, const Object* victim) const;
Bool getTurretRotAndPitch(WhichTurretType tur, Real* turretAngle, Real* turretPitch) const;
Real getTurretTurnRate(WhichTurretType tur) const;
+ Real getTurretArcShortfall(WhichTurretType tur, Real relAngle) const;
+ WhichTurretType getAimingTurret(Bool *noseAims) const; ///< the turret the current attack aims with, and whether the nose has to
void setTurretTargetObject(WhichTurretType tur, Object* o, Bool isForceAttacking = FALSE);
Object *getTurretTargetObject( WhichTurretType tur, Bool clearDeadTargets = TRUE );
void setTurretTargetPosition(WhichTurretType tur, const Coord3D* pos);
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/TurretAI.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/TurretAI.h
index d96db1504..73df8e57d 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/TurretAI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/TurretAI.h
@@ -221,6 +221,7 @@ public:
Real m_turnRate;
Real m_pitchRate;
Real m_naturalTurretAngle;
+ Real m_yawLimit; ///< how far either side of the natural angle the turret can swing; PI is all the way round
Real m_naturalTurretPitch;
Real m_turretFireAngleSweep[WEAPONSLOT_COUNT]; ///< if nonzero, sweep within +/- this angle range while firing
Real m_turretSweepSpeedModifier[WEAPONSLOT_COUNT]; ///< While sweeping, change your speed by this
@@ -274,6 +275,8 @@ public:
Bool isAllowsPitch() const { return m_data->m_isAllowsPitch; }
Real getTurnRate() const { return m_data->m_turnRate; }
Real getNaturalTurretAngle() const { return m_data->m_naturalTurretAngle; }
+ Real getYawLimit() const { return m_data->m_yawLimit; }
+ Real getArcShortfall(Real relAngle) const;
Real getPitchRate() const { return m_data->m_pitchRate; }
Real getFirePitch() const { return m_data->m_firePitch; }
Real getGroundUnitPitch() const { return m_data->m_groundUnitPitch; }
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp
index d682e204b..bfd79a9b9 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp
@@ -5663,8 +5663,23 @@ StateReturnType AIAttackAimAtTargetState::update()
// if we have a turret, but it is incapable of turning, turn ourself.
// (gotta do this for units like the Comanche, which have fake "turrets"
// solely to allow for attacking-on-the-move...)
- if (sourceAI->getTurretTurnRate(tur) != 0.0f)
+ if (sourceAI->getTurretTurnRate(tur) != 0.0f)
{
+ // a turret with a limited arc (the Comanche's chin gun) needs the body turned just far enough
+ // to bring a target behind it into the arc; inside it, the body is left alone
+ if (m_canTurnInPlace)
+ {
+ Real relAngle = m_isAttackingObject ?
+ ThePartitionManager->getRelativeAngle2D( source, victim ) :
+ ThePartitionManager->getRelativeAngle2D( source, getMachineGoalPosition() );
+ Real shortfall = sourceAI->getTurretArcShortfall(tur, relAngle);
+ if (shortfall != 0.0f)
+ {
+ sourceAI->setLocomotorGoalOrientation(source->getOrientation() + shortfall);
+ m_setLocomotor = true;
+ }
+ }
+
// The Body can never return Success if the weapon is on the turret, or else we end
// up shooting the current weapon (which is on the turret) in the wrong direction.
// We always say Continue, so the Turret can do its own Aiming state.
@@ -5677,7 +5692,28 @@ StateReturnType AIAttackAimAtTargetState::update()
// else fall thru!
}
-
+
+ // a fixed gun reloading its clip cannot fire, so a turret that turns has the aiming meanwhile
+ // (the Comanche's chin gun between missile volleys) and the body turns only for its arc
+ Bool noseAims;
+ WhichTurretType aimTurret = sourceAI->getAimingTurret(&noseAims);
+ if (!noseAims)
+ {
+ if (m_canTurnInPlace)
+ {
+ Real relAngle = m_isAttackingObject ?
+ ThePartitionManager->getRelativeAngle2D( source, victim ) :
+ ThePartitionManager->getRelativeAngle2D( source, getMachineGoalPosition() );
+ Real shortfall = sourceAI->getTurretArcShortfall(aimTurret, relAngle);
+ if (shortfall != 0.0f)
+ {
+ sourceAI->setLocomotorGoalOrientation(source->getOrientation() + shortfall);
+ m_setLocomotor = true;
+ }
+ }
+ return STATE_CONTINUE;
+ }
+
// no else here!
{
Real relAngle = m_isAttackingObject ?
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp
index 7bf610444..16a2822d6 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/TurretAI.cpp
@@ -186,6 +186,7 @@ TurretAIData::TurretAIData()
m_turnRate = DEFAULT_TURN_RATE;
m_pitchRate = DEFAULT_PITCH_RATE;
m_naturalTurretAngle = 0.0f;
+ m_yawLimit = PI;
m_naturalTurretPitch = 0.0f;
for( Int slotIndex = 0; slotIndex < WEAPONSLOT_COUNT; ++slotIndex )
{
@@ -248,6 +249,7 @@ void TurretAIData::buildFieldParse(MultiIniFieldParse& p)
{ "TurretTurnRate", INI::parseAngularVelocityReal, NULL, offsetof( TurretAIData, m_turnRate ) },
{ "TurretPitchRate", INI::parseAngularVelocityReal, NULL, offsetof( TurretAIData, m_pitchRate ) },
{ "NaturalTurretAngle", INI::parseAngleReal, NULL, offsetof( TurretAIData, m_naturalTurretAngle ) },
+ { "TurretYawLimit", INI::parseAngleReal, NULL, offsetof( TurretAIData, m_yawLimit ) },
{ "NaturalTurretPitch", INI::parseAngleReal, NULL, offsetof( TurretAIData, m_naturalTurretPitch ) },
{ "FirePitch", INI::parseAngleReal, NULL, offsetof( TurretAIData, m_firePitch ) },
{ "MinPhysicalPitch", INI::parseAngleReal, NULL, offsetof( TurretAIData, m_minPitch ) },
@@ -407,6 +409,29 @@ Bool TurretAI::friend_turnTowardsAngle(Real desiredAngle, Real rateModifier, Rea
Real turnRate = getTurnRate() * rateModifier;
Real angleDiff = normalizeAngle(desiredAngle - actualAngle);
+ /* A turret with a limited arc stops at its edge when the angle asked for is outside it, and is
+ not aligned there. Measured from the natural angle both ends sit inside the arc, so the turn
+ between them never takes the short way round through the back it cannot reach. */
+ Bool beyondArc = FALSE;
+ Real limit = getYawLimit();
+ if (limit < PI)
+ {
+ Real natural = getNaturalTurretAngle();
+ Real wanted = normalizeAngle(desiredAngle - natural);
+ if (wanted > limit)
+ {
+ wanted = limit;
+ beyondArc = TRUE;
+ }
+ else if (wanted < -limit)
+ {
+ wanted = -limit;
+ beyondArc = TRUE;
+ }
+ desiredAngle = normalizeAngle(natural + wanted);
+ angleDiff = wanted - normalizeAngle(actualAngle - natural);
+ }
+
// Are we close enough to the desired angle to just snap there?
if (fabs(angleDiff) < turnRate)
{
@@ -431,11 +456,32 @@ Bool TurretAI::friend_turnTowardsAngle(Real desiredAngle, Real rateModifier, Rea
if( m_angle != origAngle )
getOwner()->reactToTurretChange( m_whichTurret, origAngle, m_pitch );
- Bool aligned = fabs(m_angle - desiredAngle) <= relThresh;
+ Bool aligned = fabs(m_angle - desiredAngle) <= relThresh && !beyondArc;
return aligned;
}
+//----------------------------------------------------------------------------------------------------------
+/**
+ How far the turret's owner has to turn so a target at relAngle from its nose sits inside the
+ turret's arc, ARC_MARGIN in from the edge so it does not hang on the boundary; 0 when it is inside
+ already or the turret goes all the way round.
+*/
+Real TurretAI::getArcShortfall(Real relAngle) const
+{
+ const Real ARC_MARGIN = 0.17f; // about 10 degrees
+ Real limit = getYawLimit();
+ if (limit >= PI)
+ return 0.0f;
+
+ Real off = normalizeAngle(relAngle - getNaturalTurretAngle());
+ if (off > limit)
+ return off - (limit - ARC_MARGIN);
+ if (off < -limit)
+ return off + (limit - ARC_MARGIN);
+ return 0.0f;
+}
+
//----------------------------------------------------------------------------------------------------------
Bool TurretAI::friend_turnTowardsPitch(Real desiredPitch, Real rateModifier)
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
index b62b52bc0..9181cab94 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
@@ -897,6 +897,51 @@ Real AIUpdateInterface::getTurretTurnRate(WhichTurretType tur) const
0.0f;
}
+//=============================================================================
+/**
+ Which turret the current attack aims with, and whether that leaves the nose to do it. A gun with no
+ turret, or on one that cannot turn, aims with the nose; but while its clip reloads it cannot fire,
+ so a turret that turns does the aiming instead and the nose is free. That is the Comanche between
+ missile volleys, its pod reloading for fifteen seconds while the chin gun keeps firing.
+*/
+WhichTurretType AIUpdateInterface::getAimingTurret(Bool *noseAims) const
+{
+ WhichTurretType tur = getWhichTurretForCurWeapon();
+ if (getTurretTurnRate(tur) != 0.0f)
+ {
+ *noseAims = FALSE;
+ return tur;
+ }
+
+ // the turret is found first: Weapon::getStatus refreshes the weapon's saved status, so it is asked
+ // only of a unit that has somewhere else to aim from
+ for (Int i = 0; i < MAX_TURRETS; ++i)
+ {
+ if (getTurretTurnRate((WhichTurretType)i) != 0.0f)
+ {
+ const Weapon *weapon = getObject()->getCurrentWeapon();
+ if (weapon && weapon->getStatus() == RELOADING_CLIP)
+ {
+ *noseAims = FALSE;
+ return (WhichTurretType)i;
+ }
+ break;
+ }
+ }
+
+ *noseAims = TRUE;
+ return tur;
+}
+
+//=============================================================================
+/// how far the body has to turn to bring a target at relAngle into turret tur's arc (TurretAI::getArcShortfall)
+Real AIUpdateInterface::getTurretArcShortfall(WhichTurretType tur, Real relAngle) const
+{
+ return (tur != TURRET_INVALID && m_turretAI[tur] != NULL) ?
+ m_turretAI[tur]->getArcShortfall(relAngle) :
+ 0.0f;
+}
+
//=============================================================================
WhichTurretType AIUpdateInterface::getWhichTurretForCurWeapon() const
{
@@ -3920,12 +3965,13 @@ UpdateSleepTime AIUpdateInterface::doLocomotor( void )
{
updateWithdrawTarget();
Object *target = NULL;
- WhichTurretType tur = getWhichTurretForCurWeapon();
- if (tur == TURRET_INVALID)
+ Bool noseAims;
+ WhichTurretType tur = getAimingTurret(&noseAims);
+ if (noseAims && tur == TURRET_INVALID)
{
target = getCurrentVictim();
}
- else if (getTurretTurnRate(tur) == 0.0f)
+ else if (noseAims)
{
target = getTurretTargetObject(tur, FALSE);
if (target == NULL)
@@ -3936,6 +3982,26 @@ UpdateSleepTime AIUpdateInterface::doLocomotor( void )
faceTargetPos = *target->getPosition();
faceTarget = &faceTargetPos;
}
+ else if (!noseAims)
+ {
+ // a turret with a limited arc: turn the body only as far as brings its target into the arc
+ const Real HEADING_POINT_DIST = 100.0f; // any distance does; the nose is turned to its bearing
+ Object *turretTarget = getTurretTargetObject(tur, FALSE);
+ if (turretTarget == NULL)
+ turretTarget = getCurrentVictim();
+ if (turretTarget && !turretTarget->isEffectivelyDead())
+ {
+ Real shortfall = getTurretArcShortfall(tur, ThePartitionManager->getRelativeAngle2D(getObject(), turretTarget->getPosition()));
+ if (shortfall != 0.0f)
+ {
+ Real heading = getObject()->getOrientation() + shortfall;
+ faceTargetPos = *getObject()->getPosition();
+ faceTargetPos.x += Cos(heading) * HEADING_POINT_DIST;
+ faceTargetPos.y += Sin(heading) * HEADING_POINT_DIST;
+ faceTarget = &faceTargetPos;
+ }
+ }
+ }
}
switch (m_locomotorGoalType)