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(gameengine): god mode survives an EMP on aircraft

Olcay Seyganbfb75777788a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7f6dd92ea..08e0ee445 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -945,6 +945,7 @@ A third pass went through the generals' powers, promotions and unit abilities.
- `help` lists what it takes, `clear` empties it, `echo` says a line back. The up and down arrows walk back through the last thirty-two things you typed.
- It opens in the main menu as well as in a match.
- Cheats for campaign and skirmish, listed by `cheats`: `money` and `points` hand over cash and general's points, `rankup` raises the general's rank, `heroic` makes every unit you own heroic and `reveal` lifts the shroud for good. `power`, `nocooldown`, `god`, `instantbuild` and `onehitkill` switch on and off: power that never runs short, general's powers and superweapons always ready, your side taking no damage, anything built or trained in an instant, and every hit you land a kill. `money 50000` takes an amount. They are recorded in the replay like any order. In a LAN or online game, a replay or the main menu the console does not offer them at all.
+- With `god` on, an EMP no longer blows your helicopters out of the sky and drops the pilot. The helicopter goes dark, sinks to the ground, sits there until the EMP wears off and lifts back up to where it was. A plane that needs a runway flies straight through the blast instead, since it would have nowhere to take off from.
- The general's promotion screen moved off that key onto the backslash beside it.
- One press is one letter. Holding a key repeats it, and the game timed that wait in frames: a third of a second at the 30 frames a second it was written for, 70 milliseconds on a 144 Hz screen, which is shorter than an ordinary keypress. It waits 0.4 seconds now whatever the frame rate, in the console, the chat box and every text field.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
index a7a0abfec..0752fa0f8 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
@@ -380,9 +380,11 @@ void ActiveBody::attemptDamage( DamageInfo *damageInfo )
return;
// God mode stops every hit but an explicit kill (a script, a sale) and a unit's own suicide
- // weapon, so a terrorist or a demo trap still goes off.
+ // weapon, so a terrorist or a demo trap still goes off. A fall is the unit's own damage too but
+ // not a suicide: an EMPed helicopter drops out of the sky and has to survive the landing.
Player *victimPlayer = obj->getControllingPlayer();
- if( damageInfo->in.m_damageType != DAMAGE_HEALING && !damageInfo->in.m_kill && damager != obj
+ if( damageInfo->in.m_damageType != DAMAGE_HEALING && !damageInfo->in.m_kill
+ && ( damager != obj || damageInfo->in.m_damageType == DAMAGE_FALLING )
&& victimPlayer && victimPlayer->hasCheat( CHEAT_GOD_MODE ) )
return;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/EMPUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/EMPUpdate.cpp
index 9c7e5790b..cc396f0ea 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/EMPUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/EMPUpdate.cpp
@@ -43,6 +43,7 @@
#include "GameLogic/PartitionManager.h"
#include "GameLogic/Module/AIUpdate.h"
#include "GameLogic/Module/ContainModule.h"
+#include "GameLogic/Module/JetAIUpdate.h"
#include "GameLogic/Module/PhysicsUpdate.h"
#include "GameLogic/Object.h"
#include "GameClient/Drawable.h"
@@ -268,13 +269,26 @@ void EMPUpdate::doDisableAttack( void )
if ( curVictim->isKindOf( KINDOF_EMP_HARDENED ) ) // self-explanitory
continue;
- curVictim->kill();// @todo this should use some sort of DEADSTICK DIE or something...
- Drawable *drw = curVictim->getDrawable();
- if ( drw )
+ // God mode: kill() walks past ActiveBody's no-damage check, so the aircraft is disabled
+ // like a tank instead. It drops to the ground and lifts off again when the EMP wears off.
+ // A plane that needs a runway would be stranded out there, so it just flies through.
+ Player *victimPlayer = curVictim->getControllingPlayer();
+ if ( victimPlayer && victimPlayer->hasCheat( CHEAT_GOD_MODE ) )
{
- drw->setTintStatus( TINT_STATUS_DISABLED );// paint it black
+ const JetAIUpdate *jet = curVictim->getAI() ? curVictim->getAI()->getJetAIUpdate() : NULL;
+ if ( jet && jet->friend_needsRunway() )
+ continue;
+ }
+ else
+ {
+ curVictim->kill();// @todo this should use some sort of DEADSTICK DIE or something...
+ Drawable *drw = curVictim->getDrawable();
+ if ( drw )
+ {
+ drw->setTintStatus( TINT_STATUS_DISABLED );// paint it black
+ }
+ continue;
}
- continue;
}
else if ( curVictim->isKindOf( KINDOF_STRUCTURE ) )
{