Added checking AP cost to ai_pick_hit_mode_ engine function

This commit is contained in:
NovaRain
2020-05-07 09:47:57 +08:00
parent b03b93d6fc
commit a9c74501df
2 changed files with 7 additions and 5 deletions
+1 -1
View File
@@ -361,7 +361,7 @@ SingleCore=1
OverrideArtCacheSize=0
;Prevents you from saving in combat except at the start of your turn to avoid a few bugs
;Note that even with this option enabled, it is still not advisable to save in combat at all.
;Note that even with this option enabled, it is still not advisable to save in combat at all (obsolete information)
;Set to 2 to block all saving in combat
SaveInCombatFix=1
+6 -4
View File
@@ -266,10 +266,12 @@ skip:
}
}
static long __fastcall CheckWeaponRangeAndDistToTarget(fo::GameObject* source, fo::GameObject* target) {
static long __fastcall CheckWeaponRangeAndApCost(fo::GameObject* source, fo::GameObject* target) {
long weaponRange = fo::func::item_w_range(source, fo::ATKTYPE_RWEAPON_SECONDARY);
long targetDist = fo::func::obj_dist(source, target);
return (weaponRange >= targetDist); // 0 - don't use secondary mode
if (targetDist > weaponRange) return 0; // don't use secondary mode
return (source->critter.movePoints >= sf_item_w_mp_cost(source, fo::ATKTYPE_RWEAPON_SECONDARY, 0)); // 1 - allow secondary mode
}
static void __declspec(naked) ai_pick_hit_mode_hook() {
@@ -281,7 +283,7 @@ static void __declspec(naked) ai_pick_hit_mode_hook() {
evaluation:
mov edx, edi;
mov ecx, esi;
jmp CheckWeaponRangeAndDistToTarget;
jmp CheckWeaponRangeAndApCost;
}
}
@@ -394,7 +396,7 @@ void AI::init() {
0x42A970, 0x42AA56, // ai_try_attack_
});
// Adds a check for the weapon range and the distance to the target when AI is choosing weapon attack modes
// Adds a check for the weapon range and the AP cost when AI is choosing weapon attack modes
HookCall(0x429F6D, ai_pick_hit_mode_hook);
/////////////////////// Combat AI behavior fixes ///////////////////////