Skip to content

Commit 5724493

Browse files
[Minor] ElectricAssult Fix (#1696)
Infantry entering `Guard` and `Area Guard` missions with `Overpowerable=yes` to your building in its vicinity and with `ElectricAssault=yes` to the infantry's second weapon, will unconditionally attack your building. There are now some fixes for this situation. ------------- 步兵在执行`Guard`和`Area Guard`任务时如果附近存在`Overpowerable=yes`的己方建筑且步兵的副武器有`ElectricAssault=yes`,那么他会无条件的攻击这个建筑。现在对这种情况做了些修复。 --------- Co-authored-by: Netsu_Negi <[email protected]>
1 parent 52e3a48 commit 5724493

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ This page lists all the individual contributions to the project by their author.
366366
- Customize the damage taken when falling from a bridge
367367
- `600 The shield of the attached object is broken` bug fix for the triggered event
368368
- Fixed an issue where a portion of Ares's trigger event 75/77 was determined unsuccessfully
369+
- Second weapon with `ElectricAssault=yes` will not unconditionally attack your building with `Overpowerable=yes`
369370
- **NetsuNegi**:
370371
- Forbidding parallel AI queues by type
371372
- Jumpjet crash speed fix when crashing onto building

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
228228
- Dehardcoded 255 limit of `OverlayType`.
229229
- Fixed an issue where airstrike flare line drawn to target at lower elevation would clip.
230230
- Fixed the bug that uncontrolled scatter when elite techno attacked by aircraft or some unit try crush it.
231+
- Second weapon with `ElectricAssault=yes` will not unconditionally attack your building with `Overpowerable=yes`.
231232

232233
## Fixes / interactions with other extensions
233234

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ Vanilla fixes:
410410
- Fixed the bug that ships can travel on elevated bridges (by NetsuNegi)
411411
- Fixed an issue where airstrike flare line drawn to target at lower elevation would clip (by Starkku)
412412
- Fixed the bug that uncontrolled scatter when elite techno attacked by aircraft or some unit try crush it (by NetsuNegi)
413+
- Second weapon with `ElectricAssault=yes` will not unconditionally attack your building with `Overpowerable=yes` (by FlyStar)
413414
414415
Phobos fixes:
415416
- Fixed the bug that `AllowAirstrike=no` cannot completely prevent air strikes from being launched against it (by NetsuNegi)

src/Misc/Hooks.BugFixes.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,3 +2003,41 @@ DEFINE_HOOK(0x481778, CellClass_ScatterContent_Scatter, 0x6)
20032003

20042004
return NextTechno;
20052005
}
2006+
2007+
#pragma region ElectricAssultFix
2008+
2009+
namespace ElectricAssultTemp
2010+
{
2011+
WeaponTypeClass* WeaponType;
2012+
}
2013+
2014+
DEFINE_HOOK_AGAIN(0x4D5102, FootClass_ElectricAssultFix_SetWeaponType, 0x6) // Mission_Guard
2015+
DEFINE_HOOK(0x4D6F66, FootClass_ElectricAssultFix_SetWeaponType, 0x6) // Mission_AreaGuard
2016+
{
2017+
GET(WeaponTypeClass*, Secondary, ECX);
2018+
2019+
ElectricAssultTemp::WeaponType = Secondary;
2020+
return 0;
2021+
}
2022+
2023+
DEFINE_HOOK_AGAIN(0x4D5184, FootClass_ElectricAssultFix2, 0x7) // Mission_Guard
2024+
DEFINE_HOOK(0x4D6FE1, FootClass_ElectricAssultFix2, 0x7) // Mission_AreaGuard
2025+
{
2026+
GET(FootClass*, pThis, ESI);
2027+
GET(BuildingClass*, pBuilding, EDI);
2028+
enum { SkipGuard = 0x4D51AE, ContinueGuard = 0x4D5198,
2029+
SkipAreaGuard = 0x4D7001, ContinueAreaGuard = 0x4D6FF5 };
2030+
2031+
const auto pWeapon = ElectricAssultTemp::WeaponType;
2032+
bool InGuard = (R->Origin() == 0x4D5184);
2033+
2034+
if (pBuilding->Owner == pThis->Owner &&
2035+
GeneralUtils::GetWarheadVersusArmor(pWeapon->Warhead, pBuilding, pBuilding->GetTechnoType()) != 0.0)
2036+
{
2037+
return InGuard ? SkipGuard : SkipAreaGuard;
2038+
}
2039+
2040+
return InGuard ? ContinueGuard : ContinueAreaGuard;
2041+
}
2042+
2043+
#pragma endregion

0 commit comments

Comments
 (0)