Adds passive healing while in battle. Affects player, friends, foes, and mounts (configurable). Switch between regen formulas, or define one yourself! (C# and/or VB knowledge required to define formulas.)
Other user's assetsAll the assets in this file belong to the author, or are from free-to-use modder's resources
Upload permissionYou can upload this file to other sites but you must credit me as the creator of the file
Modification permissionYou are allowed to modify my files and release bug fixes or improve on the features so long as you credit me as the original creator
Conversion permissionYou can convert this file to work with other games as long as you credit me as the creator of the file
Asset use permissionYou are allowed to use the assets in this file without permission as long as you credit me
Asset use permission in mods/files that are being soldYou are not allowed to use assets from this file in any mods/files that are being sold, for money, on Steam Workshop or other platforms
Asset use permission in mods/files that earn donation pointsYou must get permission to earn Donation Points for your mods if they use my assets
Author notes
Released under Apache License 2.0 (https://github.com/Designer225/BattleRegeneration/blob/master/LICENSE). Note: the separate code files (00_builtin.battleregen.cs and 01_vb.battleregen.vb) are released under the Unlicense (https://choosealicense.com/licenses/unlicense/). All other part of the code falls under Apache-2.0.
File credits
Aragas - Mod Configuration Manager (https://github.com/Aragas/Bannerlord.MBOptionScreen) Andreas Pardeike - Harmony Patch Library (https://github.com/pardeike/Harmony) Microsoft .NET Team - .NET Compiler Platform/Roslyn (https://github.com/dotnet/roslyn)
Healing code rewrite. Also, "Companion" has been changed to "Subordinate" since that is more accurate in battle.
Version 2.0.4.42
Updated for Bannerlord v1.0.0.
Version 2.0.2.30
Compiled against e1.8.0.
Version 2.0.1.29
Fixed mounts not regenerating. Hopefully.
Version 2.0.0.26
Parallel multithreading used in an attempt to speed up code during high load.
Code refactored; if you are a modder, update your scripts as they will not work for v2.0 anymore.
Recompiled for e1.7.2.
RegenDataInfo is now passed by reference.
Version 2.0.0.25-rc2
Recompiled for e1.7.1.
Repacked the mod file because I apparently packed it incorrectly. Whoops.
Version 2.0.0.24-rc1
Once again attempting multithreading, this time using Parallelism.
Refactored code again. All existing scripts will no longer work with 2.0 and after and will need to be updated.
RegenDataInfo is now passed by reference.
Version 1.5.1.5
Added delayed regeneration. By default disabled (0), you can change the time, in seconds, before regeneration will occur.
Version 1.5.0.2
Updated to e1.6.5.
Changed RegenDataInfo into a struct and all of its into members into camelCase fields. This is a breaking change and will break most scripts.
Version 1.4.0.4
Removed multhreading code due to stability concerns.
Version 1.4.0.3
Fixed a crash where only self-inflicted damage exists.
Version 1.4.0.2
Modified to starting a new task on tick and awaiting on it.
Some code refactoring.
Version 1.4.0.0
Reintroduced multi-threading. This time creating tasks on construction of `BattleRegenerationComponent` and ticking from `BattleRegeneration` class.
Version 1.3.1.1
(Non-MCM users only) Configs now save after start up.
Version 1.3.1.0
Update to e1.6.0.
Version 1.3.0.0
Switched to Roslyn/.NET Compiler Service (Microsoft.CodeAnalysis library set). Somehow the resulting mod file is even larger.
Added a method to Formula class enabling scripts in other languages to be compiled using Roslyn/.NET Compiler Service.
Decoupled agent type-based toggles into separate sliders.
Fixed unable to compile scripts due to obfuscated assemblies being referenced.
Version 1.2.6.1
Rewrote code to increase performance in high-unit-count situations.
Updated MCM dependencies.
Version 1.2.5.0
Updated to e1.5.7.
Version 1.2.4.4
Made MCM optional. A config file will be generated if you don't use MCM. May need further testing due to the use of alternative tricks...
Regen should no longer occur at the end of combat (and briefly after the end of a practice round), and will no longer regenerate beyond the agent's starting health.
API change: Calculate(Agent, double, double) has been deprecated; override Calculate(RegenDataInfo) instead.
Version 1.2.3
Added VB support.
Added the Sine formula (credit to WrydOh: https://forums.nexusmods.com/index.php?showtopic=8702373/#entry86794963), rewritten in VB and rebalanced.
Version 1.2.2.2
Removed ButterLib DLL. You still need to install MCM and all of its dependencies, including ButterLib.
Version 1.2.2
Migrated to MCMv4 API.
Version 1.2.1
Fixed a rare crash caused by a race condition with hero XP gains.
Increased XP gains for heroes and commanders to 5.0 and 0.5 per 100% HP healed, respectively. The range is also increased from 10.0 to 100. Localization has been updated accordingly.
Version 1.2.0-rc6f
Formulas have been added, replacing the models present in the previous versions. You can define your own models using the three *.battleregen.cs files inside the mod's ModuleData folder. Or you can define them in your own DLL mods and call Formula.AddFormula with your formula type (see documentation for details).
All formulas will be loaded (and compiled) from mods' ModuleData folder, provided the mod that has them is active. Currently only supports C#, but VB support may be added in the future.
Made the program multi-threaded to generally speed it up.
Switched to using the skeleton version of MCM. Warning: MCM is now a hard requirement.
Added exception handler to an occasional crash when the mission ended.
Version 1.2.0-rc4
Switched to using runtime compiler (and increasing the size of the mod to 19 MB), using Roslyn, and more specifically Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Since the resulting code is the same type of code the game runs on, it should run much, much faster. Note that you do need some programming knowledge to utilize this feature. Currently only supports C#, but VB support may be added in the future.
Switched to using the skeleton version of MCM. Warning: MCM is now a hard requirement.
Version 1.2.0-rc3
Formulas have been added, replacing the models present in the previous versions. You can define your own models using the three *.battleregen.xml files inside the mod's ModuleData folder.
All formulas will be loaded from mods' ModuleData folder, provided the mod that has it is active.
Made the program multi-threaded so that it can support multiple calls to that very expensive method (the Expression.calculate() method).
Version 1.2.0-rc1
Fixed a crash with cargo camels.
Version 1.1.3
Updated MCM to v3.1.9.
Updated Harmony to v2.0.2.
Version 1.1.2
Updated MCM (formerly MBOptionScreen) API to version 3.
Version 1.1.1
Restored dropdown slider after it was fixed in MCM v3.0.13. Kept the numerical slider as a backup.
Implemented experimental localization support.
Version 1.1.0
Switched "Regen Model" option to a slider since Aragas hasn't fixed dropdowns yet.
Fixed a bug where the player receives regen when s/he is not supposed to.
Version 1.0.0-release
Fixed a few typos in settings page and shortened the tooltip for Regen Model. (1.0.0)
Added three healing models: linear, quadratic, and EVE Online(-like) (RC2)
Decided to patch TaleWorlds.MountAndBlade.Agent.Health setter after all (TaleWorlds... uncool.) (RC2)
Added medicine to healing consideration and gave healers xp (RC2)
Rewrote health regeneration code (RC2)
Rewrote XP gain formula, hopefully reducing XP gain (RC3)
Added option to modify commander medicine boost (RC3)
Added options to modify XP gains for both self/rider and commander (RC3)
Version 1.0.0-rc3
Rewrote XP gain formula, hopefully reducing XP gain
Added option to modify commander medicine boost
Added options to modify XP gains for both self/rider and commander
Version 1.0.0-rc2
Initial release. Release candidate.
Donations
Both straight donations and premium membership donations accepted
v2.1.1.25 tested on Bannerlord v1.1.5. You should install MCM. Steam Workshop version pending better images than what I have :P
See first stickied post for more updates and notes.
There are two known passive battle health regeneration mods, and each have its own features and issues:
Combat Health Regen for Player and Mount adds regeneration to, as the name suggest, the player and their mount. The regen rate is affected by the player's own medicine skill. Sadly, as the name suggests, it only works for the player and their mount. It uses its own config, though that's liable to be overwritten by Vortex after every update...
J0schi Tweaks (formerly Regeneration) adds regeneration to all human agents. The settings are configurable either via its own config (again liable to overwriting by Vortex) or via ModLib. Mounts are unaffected however, and the medicine skill does not affect regen. There also seems to be an issue with units regenerating health way too quickly...
So here's my take on the dumpster fire :P
Much like Combat Health Regen, this mod adds passive healing to the player and their mount.
Much like J0schi Tweaks, this mod adds passive healing to all human agents.
Much like Combat Health Regen, healing in this mod is affected by the medicine skill of the agent in question.
Unlike both of them, it does something more (see below).
Details:
An agent (horse, camel, other mount, or human) heals a certain percentage of their maximum health every second (default 1%, configurable).
Healing is continuous (i.e. it occurs every frame).
The healing factor can be boosted by the medicine skill of the agent (or its rider if mount, if applicable), with every 50 points increasing heal rate by 50% (default, configurable). If the agent (or their rider, if applicable) is a hero, the hero gain 1 xp when they heal enough to refill the agent's health bar from 0 (configurable).
Commanders (read: anyone who is commanding troops in battle) can also boost the healing factor, but with a 25% boost (configurable). If the commander is a hero, the commander gain 0.1 xp when they heal enough to refill an agent's health bar from 0 (configurable).
This healing factor can apply to the player, their companions, their allied heroes/lords, their troops, their allied troops, enemy heroes/lords, enemy troops, and all mounts (all configurable).
You can choose between three four formulas that come with this mod. More can be defined by creating C# or Visual Basic files containing subclasses of Formulas and either putting the files inside the ModuleData folders of any module or adding them while your mods load. Quick instructions here. Documentation here.
Default Regen Formulas:
Linear: health increases at a linear rate. (Default.)
Quadratic: heal rate is greater the lower an agent's health is. Maximum heal rate is 2x the linear/average heal rate (although if you need that much healing, you are already dead :P). (Desmos)
Sine (credit: WyrdOh): heal rate is at its highest at 50% of maximum health, with the regen rate looking like a sine curve. Max heal rate is 2.5x the linear/average heal rate.
Additional formulas can be defined. See here for quick instructions and here for class documentation.
Spoiler:
Show
Settings (possibly outdated; updates will be noted in italics)
Regen Amounts (Percents) Per Seconds - What percent of total health to be regenerated every second. (Regen is applied continuously with this mod.) Default is 1%. Now only affects players since v1.3.0; all other types have their own sliders (see "Apply to X" sections updates, below).
Medicine Boost (Percents) - Regen is increased by this percentage for every 50 points in a human agent's medicine skill. Riders affect regen for their mounts at standard efficiency. Bonuses stack additively. Default is 50%.
Medicine Boost (Percents) For Commanders - Regen is increased by this percentage for every 50 points in a commander's medicine skills. Bonuses stack additively. Default is 25%.
XP Gain Per Full Health - How much XP is gained when an agent or its rider (if applicable) heals enough to refill its health bar from 0 to max health. XP gain is continuous. Default is 5.
XP Gain Per Full Health For Commanders - How much XP is gained when a commander heals an agent enough to refill its health bar from 0 to max health. XP gain is continuous. Default is 0.5.
Regeneration Model (see above): Determines the model used for regenerating health. Default is Linear.
Apply To Player - Whether the player should receive passive regen. Default is true. Removed and substituted with sliders in v1.3.0 (see Regen Amount updates, above).
Apply To Companions - Whether the player's companions should receive passive regen. Default is true. Converted to slider in v1.3.0
Apply To Allied Heroes - Whether the player's allied heroes should receive passive regen. Default is true. Converted to slider in v1.3.0
Apply To Party Troops - Whether the player's troops should receive passive regen. Default is true. Converted to slider in v1.3.0
Apply To Allied Troops - Whether the player's allied troops should receive passive regen. Default is true. Converted to slider in v1.3.0
Apply To Enemy Heroes - Whether the player's enemy heroes should receive passive regen. Default is true. Converted to slider in v1.3.0
Apply To Enemy Troops - Whether the player's enemy troops should receive passive regen. Default is true. Converted to slider in v1.3.0
Apply To MountsAnimals since v1.2.0 - Whether mounts should receive passive regen. MountsAnimals regenerate regardless of their rider's allegiance. Default is true. Converted to slider in v1.3.0
Heal to Max Health: Enable to allow healing to max health, beyond your character's starting health in battle. Disabled by default. (Added in 1.2.4)
Time Before Regeneration: The time taken, in seconds, before regeneration will occur. Default is 0 (disabled). (Added in 1.5.1.5)
Debug Mode - Whether to print debug outputs to log (in C:/ProgramData/Mount and Blade II Bannerlord/logs folder). Default is false.
Requirements:
Mod Configuration Menu: Optional, but highly recommended. (2/17/2021: only now did I notice this and change it lol)
Harmony Patches:
Transpiler to TaleWorlds.MountAndBlade.Agent.Health setter to remove the arbitrary call to a ceiling method (TaleWorlds... uncool.)