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.

fix(gamelogic): jammed projectiles, dry jets, and dying containers

Olcay Seygan445016ccdb7b
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
index 1d8edc338..4bc759bfa 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
@@ -1374,6 +1374,11 @@ Bool ActiveBody::isSubdued() const
health across that line while the object was already subdued (a repair, a heal, a max health
upgrade) made the answer disagree with the state the object is actually in, and a Battle Bus
could be held down forever. */
+ // Except for projectiles, which never take a disabled flag of any kind when they are jammed,
+ // so for those the arithmetic is the only answer there is.
+ if (getObject()->isKindOf( KINDOF_PROJECTILE ))
+ return m_maxHealth <= m_currentSubdualDamage;
+
return getObject()->isDisabledByType( DISABLED_SUBDUED );
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp
index 414612ad9..231807142 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp
@@ -890,6 +890,12 @@ void OpenContain::onDie( const DamageInfo * damageInfo )
if (!getOpenContainModuleData()->m_dieMuxData.isDieApplicable(getObject(), damageInfo))
return;
+ /* Kill the ones who have nowhere to get out to first. This used to run after the damage pass,
+ and the damage pass can kill an occupant - whose own container then tries to empty itself into
+ a container that is already dying, so the occupants of the occupants were left standing in a
+ wreck. */
+ killRidersWhoAreNotFreeToExit();
+
//Check to see if we are going to inflict damage on contained units.
if( getDamagePercentageToUnits() > 0 )
{
@@ -897,8 +903,6 @@ void OpenContain::onDie( const DamageInfo * damageInfo )
processDamageToContained(getDamagePercentageToUnits());
}
- killRidersWhoAreNotFreeToExit();
-
// Leaving this commented out to show it can't work. We are about to die, so they will have zero
// chance to hit an exitState::Update. At least we would clean them up in onDelete.
// orderAllPassengersToExit( CMD_FROM_AI, FALSE );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/TransportContain.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/TransportContain.cpp
index a544284f2..34e8c91d9 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/TransportContain.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/TransportContain.cpp
@@ -551,7 +551,10 @@ void TransportContain::killRidersWhoAreNotFreeToExit()
if (d->m_destroyRidersWhoAreNotFreeToExit)
TheGameLogic->destroyObject(obj);
else
- obj->kill();
+ // Named death, not the default one: a burned death leaves no corpse, and the plain
+ // kill dropped infantry bodies out of a container they could not have got out of.
+ obj->kill( DAMAGE_UNRESISTABLE,
+ d->m_isBurnedDeathToUnits ? DEATH_BURNED : DEATH_NORMAL );
}
}
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp
index b1a72b4e5..7721b5ca1 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp
@@ -2493,6 +2493,27 @@ void JetAIUpdate::aiDoCommand(const AICommandParms* parms)
// don't need (or want) to take off for these
break;
+ /* A jet parked with no ammo used to take off the moment it was given an attack order, fly
+ to the target, find it had nothing to shoot with and fly home again. Hold the order
+ instead: it is carried out when the rearming finishes, which is what the player meant. */
+ case AICMD_ATTACKMOVE_TO_POSITION:
+ case AICMD_ATTACK_AREA:
+ case AICMD_ATTACK_OBJECT:
+ case AICMD_ATTACK_POSITION:
+ case AICMD_ATTACK_TEAM:
+ case AICMD_FORCE_ATTACK_OBJECT:
+ case AICMD_GUARD_AREA:
+ case AICMD_GUARD_OBJECT:
+ case AICMD_GUARD_POSITION:
+ case AICMD_GUARD_RETALIATE:
+ case AICMD_HUNT:
+ if (isOutOfSpecialReloadAmmo())
+ {
+ setFlag(HAS_PENDING_COMMAND, true);
+ return;
+ }
+ // falls through
+
case AICMD_ENTER:
case AICMD_GET_REPAIRED: