Charge Attack Parry
For OpenMW 0.48.0+
-- Solthas, 20230117

(Combine with Weighty Charged Attacks!) Turn your charged attacks into parries! You'll be slowed while you're charging them up depending on weapon weight and your strength, but you'll get a different defensive buff afterward, depending on weapon weight and your charge time, and depending on whether you're moving backwards or side to side!

[RECOMMENDATIONS]
My other lua mods may seamlessly be used with this one! Weighty Charged attacks in particular is highly recommended.
Directional Attack Stat Buffs: https://www.nexusmods.com/morrowind/mods/52168
Weighty Charged Attacks: https://www.nexusmods.com/morrowind/mods/52180
Etc.

[INSTALLATION]
Note: This mod only works with 0penMW 0.48+, and is only tested on OpenMW 0.48.0.

Unzip the mod subdirectory wherever you put your mods, or on a datapath listed in openmw.cfg (default Windows location C:\Users\...\Documents\My Games\OpenMW), and check the checkbox in OpenMW Launcher > Data Files > SolWeightyChargeAttacks.omwscripts

[DESCRIPTION]
This mod uses what Lua API hooks currently exist for OpenMW 0.48 to debuff you while you're charging an attack, and buff you for a short duration once you release it, depending on whether you are moving backwards or sideways at the time of release.

As it stands, the buffs are as follows:
	While charging, lose speed and armor skills, scaling with (1+sqrt(weaponWeight)) and with (50/strength).
	On release, buff, scaling with (1+sqrt(weaponWeight)) and min(2, chargeTime*weaponSpeed). 
	If moving backwards at all, buff armor skills. If moving side to side, buff agility.
	
The logic is as follows: Charging up for a well timed parry exposes you to danger and keeps you from dodging well, if you mistime it. You can either put that focus into dodging or blocking. That's how it's supposed to feel at least.

[IMPLEMENTATION]
Every frame, the script checks whether you're using the use action. If so, then the very first frame of that, it checks if you've got the correct weapon setup. If so, it debuffs you and sets your state as "charging". Then, when you release the use key, on the first frame of that, it kills the "charging" state, removes the debuffs, and applies the buffs, triggering a timer to them remove them after buffDuration has passed.

[CONFLICTS]
I hope there aren't any. I've set this mod up so that it doesn't change any values absolutely, and so that it tracks its state internally. I suppose it'll conflict with mods that change how you charge attacks.

[CREDITS]
Me. Antsan for discussion and the idea to include agility "dodging". Phoenix Rime for the inspiration to expand my Weighty Charged Attacks mod to impact defense as well. Esker for strength equation.

[CHANGELOG]
1.6 - Reworked stat modifier / damage logic to hopefully prevent permanent incorrect stat modification from occurring. 
1.5 - Implemented fatigue drain on attack release, logic for swimming, Esker's strength scaling equation, and refactored the settings handler.
1.4 - Changed charge mod equation to fix possible div by zero for 0 strength. Now it is 2.5x at 0 str and 0.5x at 100 str.
1.3 - Added setting for debuffing speed on release to simulate followthrough / recovery.
