diff --git a/src/extensions/foot/footext_hooks.cpp b/src/extensions/foot/footext_hooks.cpp index 6dd3d2450..43717617b 100644 --- a/src/extensions/foot/footext_hooks.cpp +++ b/src/extensions/foot/footext_hooks.cpp @@ -28,6 +28,8 @@ #include "footext_hooks.h" #include "foot.h" #include "technotype.h" +#include "technotypeext.h" +#include "house.h" #include "fatal.h" #include "asserthandler.h" #include "debughandler.h" @@ -36,6 +38,55 @@ #include "hooker_macros.h" +/** + * #issue-595 + * + * Implements IsCanApproachTarget for TechnoTypes. + * + * @author: CCHyper + */ +DECLARE_PATCH(_FootClass_Approach_Target_Can_Approach_Patch) +{ + GET_REGISTER_STATIC(FootClass *, this_ptr, ebp); + static TechnoTypeClassExtension *technotypeext; + + technotypeext = TechnoTypeClassExtensions.find(this_ptr->Techno_Type_Class()); + + /** + * Stolen bytes/code. + */ + if (this_ptr->Mission == MISSION_STICKY) { + goto assign_null_target_return; + } + + /** + * + */ + if (technotypeext && !technotypeext->IsCanApproachTarget) { + + static bool force_approach; + force_approach = false; + + if (this_ptr->Mission == MISSION_ATTACK) { + force_approach = true; + } + if (this_ptr->Mission == MISSION_GUARD_AREA && this_ptr->House->Is_Player_Control()) { + force_approach = true; + } + if ((this_ptr->Mission != MISSION_HUNT || this_ptr->House->Is_Player_Control()) && !force_approach) { + goto assign_null_target_return; + } + + } + +continue_checks: + JMP(0x004A1ED2); + +assign_null_target_return: + JMP(0x004A1EAE); +} + + /** * #issue-404 * @@ -137,4 +188,5 @@ void FootClassExtension_Hooks() { Patch_Jump(0x004A4D60, &_FootClass_Death_Announcement_IsInsignifcant_Patch); Patch_Jump(0x004A6866, &_FootClass_Is_Allowed_To_Recloak_Cloak_Stop_BugFix_Patch); + Patch_Jump(0x004A1EA8, &_FootClass_Approach_Target_Can_Approach_Patch); } diff --git a/src/extensions/technotype/technotypeext.cpp b/src/extensions/technotype/technotypeext.cpp index dcba60820..69784f810 100644 --- a/src/extensions/technotype/technotypeext.cpp +++ b/src/extensions/technotype/technotypeext.cpp @@ -51,6 +51,7 @@ TechnoTypeClassExtension::TechnoTypeClassExtension(TechnoTypeClass *this_ptr) : UncloakSound(VOC_NONE), IsShakeScreen(false), IsImmuneToEMP(false), + IsCanApproachTarget(true), ShakePixelYHi(0), ShakePixelYLo(0), ShakePixelXHi(0), @@ -234,6 +235,7 @@ bool TechnoTypeClassExtension::Read_INI(CCINIClass &ini) VoiceEnter = ini.Get_VocType_List(ini_name, "VoiceEnter", VoiceEnter); VoiceDeploy = ini.Get_VocType_List(ini_name, "VoiceDeploy", VoiceDeploy); VoiceHarvest = ini.Get_VocType_List(ini_name, "VoiceHarvest", VoiceHarvest); + IsCanApproachTarget = ini.Get_Bool(ini_name, "CanApproachTarget", IsCanApproachTarget); return true; } diff --git a/src/extensions/technotype/technotypeext.h b/src/extensions/technotype/technotypeext.h index 93a4038b0..a501260bf 100644 --- a/src/extensions/technotype/technotypeext.h +++ b/src/extensions/technotype/technotypeext.h @@ -77,6 +77,12 @@ class TechnoTypeClassExtension final : public Extension */ bool IsImmuneToEMP; + /** + * Can this unit can continually move towards its intended target with + * the intention of gaining more accuracy? + */ + bool IsCanApproachTarget; + /** * These values are used to shake the screen when the object is destroyed. */