Skip to content

Commit 2ce0790

Browse files
committed
让使用侵略性移动攻击的单位会在有攻击目标的情况下仍会自动重新选择威胁更高的目标进行攻击
1 parent ac4ea93 commit 2ce0790

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/Ext/Techno/Hooks.Others.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,50 @@ DEFINE_HOOK(0x4C75DA, EventClass_RespondToEvent_Stop, 0x6)
887887
return SkipGameCode;
888888
}
889889

890+
static inline bool CheckAttackMoveCanResetTarget(FootClass* pThis)
891+
{
892+
if (!pThis->Target || pThis->Target == reinterpret_cast<AbstractClass*>(pThis->unknown_5CC))
893+
return false;
894+
895+
if (pThis->TargetingTimer.InProgress())
896+
return false;
897+
898+
const auto pPrimary = pThis->GetWeapon(0);
899+
900+
if (!pPrimary)
901+
return false;
902+
903+
const auto pPrimaryWeapon = pPrimary->WeaponType;
904+
905+
if (!pPrimaryWeapon)
906+
return false;
907+
908+
const auto pSecondary = pThis->GetWeapon(1);
909+
910+
if (!pSecondary)
911+
return true;
912+
913+
const auto pSecondaryWeapon = pSecondary->WeaponType;
914+
915+
if (!pSecondaryWeapon || !pSecondaryWeapon->NeverUse)
916+
return true;
917+
918+
return pSecondaryWeapon->Range <= pPrimaryWeapon->Range;
919+
}
920+
921+
DEFINE_HOOK(0x4DF3A0, FootClass_UpdateAttackMove_SelectNewTarget, 0x6)
922+
{
923+
GET(FootClass* const, pThis, ECX);
924+
925+
if (RulesExt::Global()->AttackMove_Aggressive && CheckAttackMoveCanResetTarget(pThis))
926+
{
927+
pThis->Target = nullptr;
928+
pThis->unknown_bool_5D1 = false; // pThis->HaveAttackMoveTarget
929+
}
930+
931+
return 0;
932+
}
933+
890934
DEFINE_HOOK(0x6F85AB, TechnoClass_CanAutoTargetObject_AggressiveAttackMove, 0x6)
891935
{
892936
enum { ContinueCheck = 0x6F85BA, CanTarget = 0x6F8604 };

0 commit comments

Comments
 (0)