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): stagger passenger fire within each weapon group
Olcay Seygancc092ba78cf2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 563ba830f..a2db20001 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -272,6 +272,11 @@ found and fixed — EA's own, not port damage.**switched off once it had finished swinging back, so the whole swing was still a firing window.- Passengers do not step out of a transport that is itself inside something. They would haveappeared inside whatever was carrying it.+- A loaded transport or a garrisoned building no longer empties every launcher on the same frame. Five+ rocket soldiers in a Humvee used to put five rockets into a tank at once, before it could back off or+ anyone could react. Soldiers with the same weapon now take turns across their reload: the Humvee still+ fires five rockets a reload, one after another. Rifles keep their own turns and never wait behind the+ rockets.## Weapons and units that were quietly wrongdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cppindex 972cedc08..a06366643 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp@@ -5719,6 +5719,53 @@ StateReturnType AIAttackFireWeaponState::onEnter()return STATE_CONTINUE;}+//----------------------------------------------------------------------------------------------------------+/**+ * Passengers firing out of the same transport or building take turns with the others carrying the same+ * weapon, instead of all loosing on the one frame the attack order reached them. After the group's last+ * shot the rest wait that shooter's reload divided by the size of the group, so five rocket soldiers in a+ * Humvee still put five rockets out per reload, spread across it rather than stacked on one frame. Rifles+ * and rockets are separate groups, so a rifle never waits behind a rocket.+ *+ * Only a shot already fired is read, and the object walk is the same on every machine, so this adds no+ * state of its own.+ */+static Bool isWaitingForPassengerTurn(const Object *passenger, const Weapon *weapon)+{+ const Object *container = passenger->getContainedBy();+ if (!container || !container->getContain()->isPassengerAllowedToFire(passenger->getID()))+ return FALSE;++ const ContainedItemsList *passengers = container->getContain()->getContainedItemsList();+ Int groupSize = 0;+ UnsignedInt groupLastShotFrame = 0;+ UnsignedInt groupReloadFrames = 0;+ for (ContainedItemsList::const_iterator it = passengers->begin(); it != passengers->end(); ++it)+ {+ const Weapon *otherWeapon = (*it)->getCurrentWeapon();+ if (!otherWeapon || otherWeapon->getTemplate() != weapon->getTemplate())+ continue;++ ++groupSize;+ // an empty weapon that does not reload by itself never fires again, and its next shot frame is+ // parked at the end of time+ if (*it == passenger || otherWeapon->getStatus() == OUT_OF_AMMO)+ continue;++ if (otherWeapon->getLastShotFrame() > groupLastShotFrame)+ {+ groupLastShotFrame = otherWeapon->getLastShotFrame();+ groupReloadFrames = otherWeapon->getPossibleNextShotFrame() - groupLastShotFrame;+ }+ }++ if (groupLastShotFrame == 0)+ return FALSE;++ UnsignedInt turnFrames = groupReloadFrames / groupSize;+ return TheGameLogic->getFrame() - groupLastShotFrame < turnFrames;+}+//----------------------------------------------------------------------------------------------------------/*** Fire the owner's weapon once and exit.@@ -5790,6 +5837,12 @@ StateReturnType AIAttackFireWeaponState::update()return STATE_FAILURE;}+ // back to aiming, the same way a reload waits+ if (isWaitingForPassengerTurn(obj, weapon))+ {+ return STATE_FAILURE;+ }+/**this is the weird case where we have multi turrets, and turret 'a' wantsto fire, but someone has changed the current weapon to be one not on him.