Open phobos2077 opened 4 months ago
min_to_hit in ai.txt is used for several different things, not good:
Possible approaches to this:
try to use set_object_data
on combat_data
to force a different body part in the ctd
structure. This could be done from some hook script. But the only one I could find that happens before actual attack calculations (when we need to calculate hit chance), is TOHIT.. the problem is, it is called from many places, not just compute_attack
(ok, we can hack a new "reason" parameter, like some other hooks did). Another problem is you need to add a new opcode to calculate hit chance with given parameters, taking potential TOHIT hooks into account. Otherwise you would have to reimplement the whole calculation in SSL just for this to work, which seem too complicated.
PROs:
CONs:
Metarule to change intelligence requirements for all 3 difficulty levels. Combined with some hack for ignoring "torso" and "uncalled" from the random body part selection... Not perfect, because you'd want AI to use some kind of intelligence to choose the body part. Maybe it sees you are a melee threat and will shoot your legs, or shoot your hands if you're holding a high-dmg weapon, etc.
PROs:
CONs:
Just replace the function with a custom one with all the considerations for "smart" behavior. Basically another built-in mod similar to how "ammo mods" started back in the day.
PROs:
CONs:
Add multiple hook scripts to control key aspects of AI behavior. Complement with a bunch of metarules for certain non-opinionated/lower-level functions to keep SSL implementation of necessary logic possible and manageable.
PROs:
CONs:
Figured out how to do this using a combination of HOOK_COMBATTURN and HOOK_TOHIT with no extra hacks. Seems to work so far, so maybe no changes will be needed after all.
Conditions for aimed shot: