Skip to content

Commit bd73c2e

Browse files
[Dehardcode] Bunkerable dehardcode (#1512)
skip the hardcoded checks to static properties --------- Co-authored-by: Kerbiter <[email protected]>
1 parent f701344 commit bd73c2e

File tree

6 files changed

+52
-0
lines changed

6 files changed

+52
-0
lines changed

CREDITS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,8 @@ This page lists all the individual contributions to the project by their author.
404404
- Raise alert when technos are taking damage
405405
- Toggle waypoint for building
406406
- Parasite returning bug fix
407+
- Bunkerable checks dehardcode
408+
- Prevent the units with locomotors that cause problems from entering the tank bunker
407409
- **tyuah8** - Drive/Jumpjet/Ship/Teleport locomotor did not power on when it is un-piggybacked bugfix
408410
- **Aephiex** - initial fix for Ares academy not working on the initial payloads of vehicles built from a war factory
409411
- **Ares developers**

docs/Fixed-or-Improved-Logics.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
189189
- Aircraft will now behave as expected according to it's `MovementZone` and `SpeedType` when moving onto different surfaces. In particular, this fixes erratic behavior when vanilla aircraft is ordered to move onto water surface and instead the movement order changes to a shore nearby.
190190
- Allowed `AuxBuilding` to count building upgrades.
191191
- Fix the bug that parasite will vanish if it missed its target when its previous cell is occupied.
192+
- Prevent the units with locomotors that cause problems from entering the tank bunker.
192193

193194
## Fixes / interactions with other extensions
194195

@@ -1189,6 +1190,23 @@ MinimapColor= ; integer - Red,Green,Blue
11891190

11901191
## Vehicles
11911192

1193+
### Bunker entering check dehardcode
1194+
1195+
- In vanilla, vehicles entering tank bunkers are subject to a series of hardcoding restrictions, including having to have turrets, having to have weapons, and not having Hover speed types. Now you can skip these restrictions.
1196+
- This needs to be used with `Bunkerable=yes`.
1197+
- This flag only skips the static check, that is, the check on the unit type. The dynamic check (cannot be parasitized) remains unchanged.
1198+
1199+
In `rulesmd.ini`:
1200+
```ini
1201+
[SOMEVEHICLE] ; VehicleType
1202+
BunkerableAnyway=false ; boolean
1203+
```
1204+
1205+
```{warning}
1206+
Skipping checks with this feature doesn't mean that vehicles and tank bunkers will interact correctly. Following the simple checks performed by the provider of this feature, bunkerability is mainly determined by Locomotor. The details about locomotors' bunkerability can be found on [ModEnc](https://modenc.renegadeprojects.com/Bunkerable).
1207+
```
1208+
1209+
11921210
### Customizing crushing tilt and slowdown
11931211

11941212
- Vehicles with `Crusher=true` and `OmniCrusher=true` / `MovementZone=CrusherAll` were hardcoded to tilt when crushing vehicles / walls respectively. This now obeys `TiltsWhenCrushes` but can be customized individually for these two scenarios using `TiltsWhenCrusher.Vehicles` and `TiltsWhenCrusher.Overlays`, which both default to `TiltsWhenCrushes`.

docs/Whats-New.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,12 @@ New:
324324
- Raise alert when technos are taking damage (by TaranDahl)
325325
- Enhanced Bombard trajectory (by CrimRecya & Ollerus, based on knowledge of NaotoYuuki)
326326
- Toggle waypoint for building (by TaranDahl)
327+
- Bunkerable checks dehardcode (by TaranDahl)
327328
328329
Vanilla fixes:
329330
- Aircraft will now behave as expected according to it's `MovementZone` and `SpeedType` when moving onto different surfaces. In particular, this fixes erratic behavior when vanilla aircraft is ordered to move onto water surface and instead the movement order changes to a shore nearby (by CrimRecya)
330331
- Fix the bug that parasite will vanish if it missed its target when its previous cell is occupied (by 航味麻酱)
332+
- Prevent the units with locomotors that cause problems from entering the tank bunker (by TaranDahl)
331333

332334
Phobos fixes:
333335
- Type conversion on Warheads and Superweapons will no longer recursively convert units if applicable conversion pairs are listed, and only first applicable pair takes effect (by Starkku)

src/Ext/Techno/Hooks.Misc.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,4 +429,30 @@ DEFINE_HOOK(0x51D7E0, InfantryClass_DoAction_Water, 0x5)
429429
return Continue;
430430
}
431431

432+
bool __fastcall LocomotorCheckForBunkerable(TechnoTypeClass* pType)
433+
{
434+
auto const loco = pType->Locomotor;
435+
436+
// These locomotors either cause the game to crash or fail to enter the tank bunker properly.
437+
return loco != LocomotionClass::CLSIDs::Hover
438+
&& loco != LocomotionClass::CLSIDs::Mech
439+
&& loco != LocomotionClass::CLSIDs::Fly
440+
&& loco != LocomotionClass::CLSIDs::Droppod
441+
&& loco != LocomotionClass::CLSIDs::Rocket
442+
&& loco != LocomotionClass::CLSIDs::Ship;
443+
}
444+
445+
DEFINE_HOOK(0x70FB73, FootClass_IsBunkerableNow_Dehardcode, 0x6)
446+
{
447+
enum { CanEnter = 0x70FBAF, NoEnter = 0x70FB7D };
448+
449+
GET(TechnoTypeClass*, pType, EAX);
450+
GET(FootClass*, pThis, ESI);
451+
452+
if (!LocomotorCheckForBunkerable(pType) || pThis->ParasiteEatingMe)
453+
return NoEnter;
454+
455+
auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pType);
456+
return pTypeExt->BunkerableAnyway ? CanEnter : 0;
457+
}
432458
#pragma endregion

src/Ext/TechnoType/Body.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
464464
this->Wake.Read(exINI, pSection, "Wake");
465465
this->Wake_Grapple.Read(exINI, pSection, "Wake.Grapple");
466466
this->Wake_Sinking.Read(exINI, pSection, "Wake.Sinking");
467+
this->BunkerableAnyway.Read(exINI, pSection, "BunkerableAnyway");
467468

468469
this->KeepTargetOnMove.Read(exINI, pSection, "KeepTargetOnMove");
469470
this->KeepTargetOnMove_ExtraDistance.Read(exINI, pSection, "KeepTargetOnMove.ExtraDistance");
@@ -848,6 +849,7 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
848849
.Process(this->Wake_Grapple)
849850
.Process(this->Wake_Sinking)
850851

852+
.Process(this->BunkerableAnyway)
851853
.Process(this->KeepTargetOnMove)
852854
.Process(this->KeepTargetOnMove_ExtraDistance)
853855

src/Ext/TechnoType/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ class TechnoTypeExt
237237
Nullable<AnimTypeClass*> Wake_Grapple;
238238
Nullable<AnimTypeClass*> Wake_Sinking;
239239

240+
Valueable<bool> BunkerableAnyway;
240241
Valueable<bool> KeepTargetOnMove;
241242
Valueable<Leptons> KeepTargetOnMove_ExtraDistance;
242243

@@ -472,6 +473,7 @@ class TechnoTypeExt
472473
, Wake_Grapple { }
473474
, Wake_Sinking { }
474475

476+
, BunkerableAnyway { false }
475477
, KeepTargetOnMove { false }
476478
, KeepTargetOnMove_ExtraDistance { Leptons(0) }
477479

0 commit comments

Comments
 (0)