diff --git a/README.md b/README.md index f7d5da7e8d..ca0eeb4b10 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Credits - SMxReaver - help with docs - 4SG - help with docs - wiktorderelf - overhauled Unicode font -- Thrifinesma (Uranusian) - Mind Control enhancement, custom warhead splash list, harvesters counter, promoted spawns, shields, overhauled Unicode font, help with docs +- Thrifinesma (Uranusian) - Mind Control enhancement, custom warhead splash list, harvesters counter, promoted spawns, shields, death after dead fix, overhauled Unicode font, help with docs - SEC-SOME (secsome) - debug info dump hotkey, refactoring & porting of Ares helper code, introducing more Ares-derived stuff, disguise removal warhead, Mind Control removal warhead, Mind Control enhancement, shields - Otamaa (BoredEXE) - help with CellSpread, ported and fixed custom RadType code, togglable ElectricBolt bolts, customizable Chrono Locomotor properties per TechnoClass - E1 Elite - TileSet 255 and above bridge repair fix diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index 6a0e49010f..5b099a0fa0 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -5,6 +5,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho ## Bugfixes and miscellanous - Fixed the bug when deploying mindcontrolled vehicle into a building permanently trasferred the control to the house which mindcontrolled it. +- Fixed the bug when units are already dead but still in map (for sinking, crashing, dying animation, etc.), they could die again. - SHP debris shadows now respect the `Shadow` tag. - Allowed usage of TileSet of 255 and above without making NE-SW broken bridges unrepairable. - `TurretOffset` tag for voxel turreted technos now accepts FLH (forward, lateral, height) values like `TurretOffset=F,L` or `TurretOffset=F,L,H`, which means turret location can be adjusted in all three axes. diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 34cb9248d9..056f863009 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -44,6 +44,7 @@ Vanilla fixes: - Tileset 255+ bridge fix (by E1 Elite) - Fixed fatal errors when `Blowfish.dll` couldn't be registered in the system properly due to missing admin rights (by Belonit) - Fix to take Burst into account for aircraft weapon shots beyond the first one (by Starkku) +- Fixed the bug when units are already dead but still in map (for sinking, crashing, dying animation, etc.), they could die again (by Uranusian) Phobos fixes: - Properly rewritten a fix for mind-controlled vehicles deploying into buildings (by FS-21) diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index 68ef4db868..3abacce5ab 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -2,7 +2,7 @@ #include #include #include - +#include //Replace: checking of HasExtras = > checking of (HasExtras && Shadow) DEFINE_HOOK(423365, Phobos_BugFixes_SHPShadowCheck, 8) { @@ -26,3 +26,38 @@ DEFINE_HOOK(423365, Phobos_BugFixes_SHPShadowCheck, 8) DEFINE_LJMP(0x545CE2, 0x545CE9) //Phobos_BugFixes_Tileset255_RemoveNonMMArrayFill DEFINE_LJMP(0x546C23, 0x546C8B) //Phobos_BugFixes_Tileset255_RefNonMMArray + +// WWP's shit code! Wrong check. +// To avoid units dying when they are already dead. +DEFINE_HOOK(5F53AA, ObjectClass_ReceiveDamage_DyingFix, 6) +{ + GET(int, health, EAX); + GET(ObjectClass*, pThis, ESI); + + if (health <= 0 || !pThis->IsAlive) + return 0x5F583E; // return DamageState::PostMortem + + return 0x5F53B0; //continue vanilla check +} + +DEFINE_HOOK(4D7431, FootClass_ReceiveDamage_DyingFix, 5) +{ + GET(FootClass*, pThis, ESI); + GET(DamageState, result, EAX); + + if (result != DamageState::PostMortem && (pThis->IsSinking || pThis->IsCrashing)) + R->EAX(DamageState::PostMortem); + + return 0; +} + +DEFINE_HOOK(737D57, UnitClass_ReceiveDamage_DyingFix, 7) +{ + GET(UnitClass*, pThis, ESI); + GET(DamageState, result, EAX); + + if (result != DamageState::PostMortem && pThis->DeathFrameCounter > 0) + R->EAX(DamageState::PostMortem); + + return 0; +}