From cd2a1d8e5f5e9c5c8ff9c7e747739ed893725a9e Mon Sep 17 00:00:00 2001 From: Uranusian Date: Thu, 9 Dec 2021 13:26:27 +0800 Subject: [PATCH] WALL-GATE Links --- README.md | 2 +- docs/Fixed-or-Improved-Logics.md | 1 + docs/Whats-New.md | 1 + src/Misc/Hooks.BugFixes.cpp | 46 ++++++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cf3cb6c602..7ca803ca5f 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Credits - **SMxReaver** - help with docs, extensive and thorough testing - **4SG** - help with docs - **wiktorderelf** - overhauled Unicode font -- **Uranusian (Thrifinesma)** - Mind Control enhancement, custom warhead splash list, harvesters counter, promoted spawns, shields, death after dead fix, customizeable missing cameo, cameo sorting priority, placement mode responding of tab hotkeys fix, producing progress, custom ore gathering anim, NoManualMove, weapon target house filtering, DeathWeapon fix, re-enable obsolete `JumpjetControls`, AITrigger Building Upgrades recognition, overhauled Unicode font, docs maintenance, CN docs translation +- **Uranusian (Thrifinesma)** - Mind Control enhancement, custom warhead splash list, harvesters counter, promoted spawns, shields, death after dead fix, customizeable missing cameo, cameo sorting priority, placement mode responding of tab hotkeys fix, producing progress, custom ore gathering anim, NoManualMove, weapon target house filtering, DeathWeapon fix, re-enable obsolete `JumpjetControls`, AITrigger Building Upgrades recognition, Wall-Gate links, overhauled Unicode font, docs maintenance, CN docs translation - **secsome (SEC-SOME)** - 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, AnimList.PickRandom, MoveToCell fix, unlimited waypoints, Build At trigger action buildup anim fix, Undeploy building into a unit plays `EVA_NewRallyPointEstablished` fix, custom ore gathering anim, TemporaryClass related crash, Retry dialog on mission failure, Default disguise for individual InfantryTypes, PowerPlant Enhancer, SaveGame Trigger Action, QuickSave command, Numeric variables, Custom gravity for projectiles, Retint map actions bugfix - **Otamaa (Fahroni, BoredEXE)** - help with CellSpread, ported and fixed custom RadType code, togglable ElectricBolt bolts, customizable Chrono Locomotor properties per TechnoClass, DebrisMaximums fixes, Anim-to-Unit, NotHuman anim sequences improvements, Customizable OpenTopped Properties, hooks for ScriptType Actions 92 & 93, ore stage threshold for `HideIfNoOre` - **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 9ced255c13..c84588203b 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -41,6 +41,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho - Animations can now be offset on the X axis with `XDrawOffset`. - `IsSimpleDeployer` units now only play `DeploySound` and `UndeploySound` once, when done with (un)deploying instead of repeating it over duration of turning and/or `DeployingAnim`. - AITrigger can now recognize Building Upgrades as legal condition. +- `EWGates` and `NSGates` now will link walls like `xxGateOne` and `xxGateTwo` do. ## Animations diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 028ebb79fd..d99b64e3ba 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -254,6 +254,7 @@ New: - Jumpjet unit layer deviation customization (by Starkku) - IsSimpleDeployer deploy direction & animation customizations (by Starkku) - Customizable projectile gravity (by secsome) +- Gates can now link with walls correctly via `NSGates` or `EWGates` (by Uranusian) Vanilla fixes: - Fixed laser drawing code to allow for thicker lasers in house color draw mode (by Kerbiter, ChrisLv_CN) diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index db674334e8..56436f187b 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -314,4 +315,49 @@ DEFINE_HOOK(0x41EB43, AITriggerTypeClass_Condition_SupportPowersup, 0x7) //AITr R->EAX(count); return R->Origin() + 0xC; +} + +// Dehardcode the stupid Wall-Gate relationships +// Author: Uranusian +DEFINE_HOOK(0x441053, BuildingClass_Unlimbo_EWGate, 0x6) +{ + GET(BuildingTypeClass*, pThis, ECX); + + return RulesClass::Instance->EWGates.FindItemIndex(pThis) == -1 ? 0 : 0x441065; +} + +DEFINE_HOOK(0x4410E1, BuildingClass_Unlimbo_NSGate, 0x6) +{ + GET(BuildingTypeClass*, pThis, ECX); + + return RulesClass::Instance->NSGates.FindItemIndex(pThis) == -1 ? 0 : 0x4410F3; +} + +DEFINE_HOOK(0x480552, CellClass_AttachesToNeighbourOverlay_Gate, 0x7) +{ + GET(CellClass*, pThis, EBP); + GET(int, idxOverlay, EBX); + GET_STACK(int, state, STACK_OFFS(0x10, -0x8)); + bool isWall = idxOverlay != -1 && OverlayTypeClass::Array->GetItem(idxOverlay)->Wall; + enum { Attachable = 0x480549 }; + + if (isWall) + { + for (auto pObject = pThis->FirstObject; pObject; pObject = pObject->NextObject) + { + if (pObject->Health > 0) + { + if (auto pBuilding = abstract_cast(pObject)) + { + auto pBType = pBuilding->Type; + if ((RulesClass::Instance->EWGates.FindItemIndex(pBType) != -1) && (state == 2 || state == 6)) + return Attachable; + else if ((RulesClass::Instance->NSGates.FindItemIndex(pBType) != -1) && (state == 0 || state == 4)) + return Attachable; + } + } + } + } + + return 0; } \ No newline at end of file