Adds numerous selection & sorting hotkeys to massively ease the transfer of troops between selected formations, and makes sure empty formations are shown so hotkeys can be used to their full ability. Troop sorting can be used with modifier keys to take into account shields, throwables, ammunition, mounts, troop tiers & more.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
File credits
This author has not credited anyone else in this file
Donation Points system
Please log in to find out whether this mod is receiving Donation Points
Changelogs
Version v3.3.0
Integrated backwards compatibility up to v1.0.0
Version v3.2.1
Minor refactoring
Ref swaps & updates
Removed initialization message
Version v3.2.0
Minor refactoring
Minor optimizations
Numerous fixes related to captaincy assignment
Player agent now yells out selections
Shield sorting now puts unshielded units in Heavy Infantry instead of Skirmishers
Version v3.1.1
Fixed number of agents sorted display
Version v3.1.0
Minor refactoring
Fixed selection hotkeys not adding troop item VMs
Formation captains are now utilized and assigned properly by sorting
Mission validity check now uses more vanilla methods
Order gesture will no longer play if nothing is sorted
Troop VM filters are now updated when sorted
Version v3.0.0
Major refactoring
Ref updates
Consolidated & updated patches
Improved performance
Fixed MCM version display
Fixed troop gestures playing when not enabled
Added support for multiple formations of the same formation class
Added a warning for bad mod settings during sorting
Fixed multiple issues mostly related to empty formations
Version v2.2.4
Minor refactoring
Ref updates
Version v2.2.2
Removed debug
Fixed NRE
Code reformatting
Ref updates
Version v2.2.1
Code cleanup
Ref updates
Version v2.2.0
MCM ref update
Tier sort key will now use formation indexes instead of classes
Added an option for sorting companions into a specific formation
Version v2.1.3
Reverted to .NET Framework v4.7.2
Fixed GameKey exceptions
Version v2.1.2
Recompile for v1.0.1
Property change for v1.0.1
Version v2.1.1
Improved VM cleanup for invalid missions
Enabled mod for hideouts
Version v2.1.0
Added user-defined formation classes
Version v2.0.0
MCM update
MCM converted to a soft dependency
Version v1.9.9
MCM update
Recompile for v1.0.0
Version v1.9.8
Updated to e1.8.1
Fixed rare crashes from Harmony's transpiler
Version v1.9.7
Updated refs
Improved exception output
Version v1.9.6
Fixed minor game key exception
Version v1.9.5
Fixed a division by zero transpiler patch broken from game updates
Fixed bound key message suppressions
Version v1.9.4
Refactor, recompile & XML update for e1.8.0
Version v1.9.3
Very minor refactoring
Fixed a harmony patching exception from a minor constructor change
Version v1.9.2
Very minor refactoring
Updated to e1.7.2.314157
Updated MCM to 4.6.0
Version v1.9.1
Minor code refactoring
Tier Sort key is now counted as a bound key (for the InformationManager)
Version v1.9.0
Added tier sorting
Version v1.8.0
Fixed a minor but annoying hotkey issue
Added a modifier for shield sorting
Properly fixed formation class determination for the latest versions of the game (e1.7.*)
Version v1.7.0
Updated Bannerlord & MCM refs
Code refactoring
Version v1.6.6
Functions now work on mission end, since vanilla now allows it
Version v1.6.5
Fixed exceptions from the latest versions of MCM
Version v1.6.4
Recompile for e1.7.0 and harmony lib update
Version v1.6.3
Recompile and cleanup for e1.6.5 & e1.7.0
Version v1.6.1
Minor patch fixes
Version v1.6.0
Recompile for 1.6.4
Updated reflection utilities from my local Debugger mod
Fixed CanPlayerInteract exception
Version v1.5.9
The mod will no longer run during missions other than strictly battles (conversations, cutscenes, deployment, duels, tournaments, etc.)
Fixed a harmless PatchInformationManager exception
Added checks to all patches to make sure they only run when the mission is valid
Version v1.5.8
Large code refactor
Hotkeys no longer collide with interaction
Hotkeys now stop functioning during mission ends
Added more exception handling
Attempted to fix an "ArgumentOutOfRange" exception from settings
Fixed a bug where formation sorting would use the primary class instead of initial class for empty formations
Formations should now always have their initial class set to their index, making it easier to use selection hotkeys
The mod will no longer make agents yell if the current mission doesn't allow it
Sorting now prioritizes formations with the correct initial class over formations with the correct primary class
Version v1.5.7
Minor bug fixes
Message suppressions now update properly when settings are changed mid-mission
The mission order button now refreshes properly mid-mission
Version v1.5.6
Code refactoring and caching
Attempted fix of an ArgumentOutOfRangeException in SelectFormationsOfClasses
Suppressed "Can't access" messages for bound keys
Suppressed "Everybody!!" message when the mod's selection hotkeys are pressed
Changed selection message colors from Cyan to White so they're less distracting
Version v1.5.5
Rebuild for 1.6.3
Fixed harmless hotkey exception
Minor code refactoring
Version v1.5.4
Minor code refactoring
Minor optimization to hotkey handling
Unselectable formations now don't get added and also get removed if they exist
Added more patches to make sure formation VMs are always up-to-date
Formations with no troops now have their VMs set to their initial class
Made sure IsSelected is always set
Changed all "unit" strings to "troop" for consistency
Version v1.5.3
Changed all selection strings to make them more clear
Added the ability to completely unbind a key by setting it to Invalid
Added temporary spacers for the dropdown menus in MCM
Version v1.5.2
Fixed incorrect hotkey settings for the order key
Version v1.5.1
Fixed MCM saving error
Version v1.5.0
Integrated MCM to allow for changeable hotkeys
Version v1.4.0
Troops can now be sorted equally amongst selected formations with the LeftAlt modifier key
Fixed harmless pre-battle error
Made sure special formations can't be selected nor sorted
Made sure the player agent can't be sorted
Fixed a bug where the team leader agent would yell the order instead of the player agent
Fixed a bug with formation markers when no units were in a formation
Version v1.3.0
Re-enabled the sort order during sieges
Troops now get detached from siege engines when sorted to help prevent related issues
Patched a detachment weight error that could happen when the sorting order was used during sieges
Fixed a harmless exception that could sometimes (very rarely) be thrown in the IsCurrentMissionReady method
The sorting order will now output a relevant message if all selected formations are controlled by AI (delegated)
The player hero will now only yell the order when there are troops to be sorted
Version v1.2.2
More code refactoring
Improved the conditions for determining if a mission is a siege mission, so now the sorting-related functions can be used during Sally Out field battles
Troops now yell out the proper formation that they change to when sorted
Version v1.2.1
Added error handling to everything the mod touches
Removed the sorting function from sieges (at least for now), as it seems to cause rogue crashes when used
Version v1.2.0
Made sure the empty formations get their proper formation class
Made sure all empty formations are always visible and able to be selected
Added message feedback to the selection hotkeys
Improved message feedback for the sort order
The formation VMs at the top of the screen are now always in the correct order
The empty formations can now be actively ordered
Version v1.1.3
Improved formation class selection conditions
Added hotkey to select Infantry & Cavalry
Added hotkey to select Archers & Horse Archers
Left Control + X now moves Skirmishers into the Skirmisher formation instead of the Ranged formation
Version v1.1.2
Fixed all formations being selected when the user attempted to select only empty formations
Made empty formations selectable so you can sort between them
Fixed modifer key (LeftCtrl) formation selection
Version v1.1.1
Fixed formations not being selected if their formation class was different from the initial formation class
Fixed incorrect formation selection under certain circumstances
Stabilized modifier key selection
Removed defunct modifier conditions from formation selection
Version v1.1.0
Massive code refactoring
Changed order hotkey from F10 to X
Removed selection clearing after order hotkey press
Added multiple hotkeys related to more convenient formation selection
Version v1.0.0
Initial release
User-defined formation classes The mod utilizes user-defined formation classes by default, in place of the normally dynamic formation classes. This can be turned off or configured via Mod Configuration Menu if installed. Note that these are only referenced by the mod's own methods; you must utilize the order hotkeys below to set them up as you define (such as by quickly pressing F and then X).
When user-defined formation classes are enabled, you can also specify a formation class for all companions to be sorted as. By default these are defined as so (they follow the original beta formations from long ago):
Formation #1: Infantry
Formation #2: Archers
Formation #3: Cavalry
Formation #4: Horse Archers
Formation #5: Skirmishers
Formation #6: Heavy Infantry
Formation #7: Light Cavalry
Formation #8: Heavy Cavalry
Order hotkeys
X: Formation Sort order menu key; troops in selected formations will be sorted equally into their best formation(s) if any of its kind is among the selected formations.
Left Alt + X: When combined with the Order Key troops will be sorted equally amongst ALL selected formations instead of being put in only their best formations.
Left Ctrl + X: When combined with the Order Key javelineers, rock throwers, etc. get put into the Skirmisher formation instead of Infantry.
Left Ctrl + Left Alt + X: Same as Left Alt + X, but with the behavior of Left Ctrl + X; it will take into account that Skirmishers would be in their own formation and distribute them equally as such.
Left Shift + X: When combined with the Order Key shielded infantry get put into the Infantry formation while unshielded infantry get put into the Heavy Infantry formation.
Left Shift + Left Alt + X: Same as Left Alt + X, but with the behavior of Left Shift + X; it will take into account shielded infantry and skirmishers and distribute them equally as such.
Left Ctrl + Left Shift + X: Same as Left Ctrl + X and Left Shift + X.
L: Tier sorting key; all infantry and cavalry troops will be sorted into separate formations by their tiers. Troops go into formations like so:
Formation #1: Tier 0-2 Infantry
Formation #2: Tier 3-4 Infantry
Formation #3: Tier 5-7 Infantry
Formation #4: Ranged w/ Ammo
Formation #5: Tier 0-2 Cavalry
Formation #6: Tier 3-4 Cavalry
Formation #7: Tier 5-7 Cavalry
Formation #8: Horse Archers w/ Ammo
Selection hotkeys
Left Ctrl + #: When combined with any of the selection keys below, the formations it encompasses will be inverted from their current state, being added or removed from the current selection.
F: This key will select all formations.
C: This key will select all melee cavalry formations: Cavalry, Light Cavalry, Heavy Cavalry.
V: This key will select all ranged cavalry formations: Horse Archers.
H: This key will select all ground melee formations: Infantry, Heavy Infantry.
J: This key will select all ground ranged formations: Archers, Skirmishers.
Y: This key will select all melee formations: Infantry, Heavy Infantry, Cavalry.
U: This key will select all ranged formations: Archers, Skirmishers, Horse Archers.
N: This key will select all ground formations: Infantry, Heavy Infantry, Archers, Skirmishers.
M: This key will select all cavalry formations: Cavalry, Light Cavalry, Heavy Cavalry, Horse Archers.
NOTE: The hotkeys are all configurable and unbindable via Mod Configuration Menu if installed! How the sorting order works When the hotkeyis pressed, the mod will iterate through currently selected formations and sort units between them based on whether the units: are currently mounted on a horse, have access to their horse, have ranged weapons with any ammo left, have throwables, have shields, etc.
Troops will also yell out the formation that they change to, because why not? Technics
The mod is implemented in a very compatibility-friendly way using Harmony.
Any patches and additions my mods make always implement error handling to allow the game to keep running properly when exceptions arise.
As far as I know, it should be completely safe to add to or remove from existing saves, as it does not add or change any save-related data.
I personally use all the mods I create and thus have heavily tested them, so the mod should be very stable.