Skip to content

Commit

Permalink
Implements IsCanApproachTarget for TechnoTypes.
Browse files Browse the repository at this point in the history
  • Loading branch information
CCHyper committed Oct 20, 2021
1 parent 52d4ce4 commit b9059bf
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/extensions/foot/footext_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
*
Expand Down Expand Up @@ -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);
}
2 changes: 2 additions & 0 deletions src/extensions/technotype/technotypeext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ TechnoTypeClassExtension::TechnoTypeClassExtension(TechnoTypeClass *this_ptr) :
UncloakSound(VOC_NONE),
IsShakeScreen(false),
IsImmuneToEMP(false),
IsCanApproachTarget(true),
ShakePixelYHi(0),
ShakePixelYLo(0),
ShakePixelXHi(0),
Expand Down Expand Up @@ -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;
}
6 changes: 6 additions & 0 deletions src/extensions/technotype/technotypeext.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ class TechnoTypeClassExtension final : public Extension<TechnoTypeClass>
*/
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.
*/
Expand Down

0 comments on commit b9059bf

Please sign in to comment.