A problem with
critical hits and the
CombatDamage hook.
As you well know critical hits are integral part of damage calculations. So if you want to change the calculations you will have to deal with criticals too.
There is 2 ways to deal with this. One is to re-roll the whole critical phase, and the second is keep and use the roll created by game engine. It would be advantageous if we could re-roll the whole critical phase and recalculate as it would give more freedom of modding. However a few problems arise.
When combat_damage hook gets triggered the critical roll has already been made using default game engine calculations for critical chance, and the crit level, effects, and likely combat message, have all been decided. You then have access to change the effects, and the damage. However if you do this, you then need to update the combat message too but there is no way to do that with CombatDamage hook. If you don't update the message then there will be a mismatch between
what happened and what the message says happened, and that's not good. For example:
If a hit was not originally a critical hit, and it becomes critical through your re-roll then the message will say "critter was hit for [large number of] hit points." Where as it should say: "critter was critically hit for [large number of] hit points, and had his insides blown out." Or it might say "critter was critically hit for 3 points of damage and died an agonizing death with his spine sticking out" while the critter still stands and is fine. So there would be a mismatch between the previously calculated message and the re-calculated event.
A solution is to keep the original game engine critical results, but then you are not able to alter critical chances nor the critical level.
Now I have a situation where I need to know the crit level. I could live with keeping the default engine generated crit results, however the crit level is not exposed, and I need it for some calculations that affect damage. The only solution I can think of is to reverse engineer the crit level based on "critical multiplier", "body part", and "target" arguments of combat damage hook. However this solution is not perfect and can not reverse engineer the exact crit level in many cases.
So my questions are, do any of you guys know or can think of:
1. how the combat message can be replaced for new event.
2. how to "get" the crit level calculated by game engine.
Another issue is the problem of altering critical chances. (example: to give extra critical chance for a weapon)
Crit chance calculations I think happen during the Attack Complex phase. So when you encounter "AfterHitRoll" or "CombatDamage" hooks its already too late. As far as I know there is no "hook" to alter it.
The only way I can think of is to alter the critter's native critical chance stat before its sent anywhere, and that's a
problematic solution. I have thought of a way to do it, however its a dirty and cumbersome hack and I don't want to do it that way. (edit critter's stat during its turn, and then revert it back at end of turn, updated with weapon change during turn. Its cumbersome and might lead to problems.)
So,
3. I'm wondering if anyone knows a solution to alter critical chance calculations in attack complex or elsewhere. I'm not at all familiar with attack complex.