AI battles going on around the map now have the defending leader consider surrender depending on their valor and their troop count against the attacker's troop count. If the defender does not surrender then all nobles involved in the battle are evaluated to see if they are KIA. Siege surrender works fine. It has been tested.
Other user's assetsAll the assets in this file belong to the author, or are from free-to-use modder's resources
Upload permissionYou are not allowed to upload this file to other sites under any circumstances
Modification permissionYou must get permission from me before you are allowed to modify my files to improve it
Conversion permissionYou are not allowed to convert this file to work on other games under any circumstances
Asset use permissionYou must get permission from me before you are allowed to use any of the assets in this file
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 are not allowed to earn Donation Points for your mods if they use my assets
Author notes
Be fair!
File credits
@bockyx Your Beta Jesus! (has forsaken us lately) @Gyular Localization Support, if you can understand the mod you have him to thank!
Donation Points system
Please log in to find out whether this mod is receiving Donation Points
When NPC leading siege a player joined or in visible range of the player (lol this game) now they will wait in the settlement for 10 hours like they are supposed to after sieges (in tw code they do this but in this stupid situation, AI Values Life has to complete the siege)..
Version 1.16.3
Fixed a bug when checking if a siege defender would consider surrender when the 'Restrict' setting is enabled. Used the wrong value for defending heroes with valor less than 0. Siege defenders would be the first lord party it find or the governor.
Changed setting for which messages to show to include messages for the player clan or kingdom if enabled.
Added a setting for siege surrenders to be considered daily. Previous versions considered surrender daily but i thought it led to too many surrenders so now this is disabled by default and surrender will be considered every other day.
Fixed surrender still being considered for sieges after the player's ultimatum was refused. This is when the player is leading the besieging army.
Ultimatums now add a bonus to the surrender probability based on the attacker leader's cruelty trait level (negative mercy). Set in the MCM. Default is 2.5% per cruel level. (0.025).
Version 1.16.2
Fixed NPC besiegers not completing capture of a surrendered settlement when it was in visible range of the player. For example, when the player joined an allied lord's siege after it already started or if you just happened to be passing by. Before, once the settlement surrendered, the siege army would end the siege and wander off. Strange enough sieges outside of the player's view, the besiegers captured the settlement properly once all defenders surrendered/became wounded. I gave up trying to understand this game a long time ago so in this situation the mod will complete the siege for the game.
Version 1.16.1
Fixed a bunch of bugs with siege surrenders for NPCs and NPC death.
Added a setting to the MCM for messages to show for the clan only or show all messages like before.
Version 1.16.0
Updated code for 1.2.2
If notifications are enabled, they will only display surrenders for player clan parties and deaths will only display for player clan heroes.
Siege surrender notifications disabled by default now.
Version 1.15.16
Added two new settings to influence siege surrender probability. Wall status, food level, and number of siege engines active (attacker or defender) will all slightly adjust surrender probability for the settlement. The other setting is for the siege defender's valor influencing the surrender probability. This usually defaults to the governor if a hero led party has not garrisoned the settlement to help the defense.
Version 1.15.15
Added tooltip for Issuing Ultimatums when siege camap preparations are not complete.
Updated default battle surrender and siege surrender multipliers in the MCM to 0.5. I thought surrenders were happening way too often, just increase if you prefer something else.
Version 1.15.14
Player character blocked from death being evaluated just in case the patch from this mod was being called in player battles.
Version 1.15.13
You can toggle using vanilla death system or the one from this mod, described on the front page.
Updated localization.
Version 1.15.12
MCM reorganized.
You can toggle using vanilla death system or the one from this mod, described on the front page.
Version 1.15.11
Fixed some random bugs and improved some code.
Version 1.15.10
Fixed declining siege surrender.
Added code to ensure the player siege index is ALWAYS correct to prevent out of range crashes... usually happened in older versions because the menu options would not load and after accepting a surrender you would be forced to leave the siege as you did not have the option to capture. This was something I never accounted for and the siege index would end up being inaccurate.
Can no longer save scum to exploit issuing ultimatums in ironman mode. Once it fails and you save your game, it will remember if you had issued an ultimatum to the settlement during the siege.
Version 1.15.9
Fixed heroes in npc parties, not leading, from not getting wounded when a party surrenders.
Fixed loading menu options for siege surrenders.
Fixed some things with dialogues.
Fixed mistakes I made when I was a sweet summer child.
Version 1.15.8
Finally fixed the localization bug thanks to hsun770916 and he taught me something! The true MVP!
Version 1.15.7
Significantly reduced the probability the caravan in the escort quest would surrender since they would be relying on the player to show up.
Version 1.15.6
Caravan in the Caravan Ambush quest will not consider surrender anymore.
Possible fix for a crash that occurs when evaluating if a hero should die in battle, and the hero has a null party, which I didn't think was possible, but I saw the crash report and nothing else makes sense so I hope adding the null check to the party fixes it. hsun770916 please confirm the result of the debug version and/or this version.
Version 1.15.5
Fixed partners in crime perk.
Version 1.15.4
Added ability to toggle surrender messages for battles and sieges separately since sieges happen less often and you might want to know sometimes.
Updated the text for settings and their descriptions. Tried to make things clearer and not use military lingo such as KIA.
Version 1.15.3
Fixed a bug when defenders surrendered while the siege assault was occurring that prevented the siege event from ending. If you noticed an army was sieging a settlement with all wounded defenders and the siege never ending then this update will fix it.
Version 1.15.2
Fixed a crash when a clan is destroyed in a simulation battle between NPCs.
Version 1.15.1
Added dialogue when player requests a parley with attacker of settlement. Now player can surrender the settlement.
Version 1.15.0
Updated for Bannerlord v1.1.3
Fixed some issues with settlement surrenders.
Version 1.14.6
Surrender messages disabled by default now in the MCM.
Fixed Restrict setting so now it works for sieges. Before it was only being considered in battles.
Fief considers food stocks when considering surrender in a siege. Siege surrender is checked daily. So once a town runs out of food it will give a 1% bonus to the probability they surrender.
Version 1.14.2
Cheat Death perk now applied to NPC hero death calculation.
Updated how Surgeon Skill and Doctor's Oath perk affects probability. Updated MCM description.
Version 1.12.4
Fixed a crash when a siege surrendered with no troops. These sieges will no longer be evaluated for surrender.
Version 1.12.3
Added a setting to MCM so you can set whether or not to have influence shared between all attacker parties or just the leader only when the attacker leader accepts a surrender.
Version 1.12.2
Added influence gain to attacker when accepting surrender. Same calculation battle victories use but only leader of attackers gains the influence.
Added relationship gains between the leader of the party responsible for a KIA and the slain hero's enemies. Configurable in MCM.
Updated settings descriptions and relationship modifier default values.
Version 1.12.0
Updated for 1.7.0... this mod is still a WIP. Siege surrenders might be broken (worked in the one situation I tested way back when but users reported crashin.) If you get to a siege and this mod starts crashing when you try to initiate the siege then just do the siege with the mod unchecked in the launcher or imaybe there is an option to disable siege surrenders in the MCM but I forget if i added that back then or not.
Version 1.11.4
Fixed crash in UltimatumOnCondition
Version 1.11.3
Fixed siege surrenders. Forgot to finish some things in 1.11.2.
Fixed siege menu when a settlement surrenders. "Lead Assault" and "Send Troops" no longer visible and "Capture Settlement" displayed instead.
Version 1.11.2
Siege surrenders are done through a parley now when the player is leading.
You can issue an ultimatum from the siege menu if you are leading the attackers..
Besieged settlements will consider surrender once per day now but only once the initial siege camp is constructed.
Version 1.11.1
Fixed crash during tournament.
Version 1.11.0
Hero simulation deaths now follow the logic from this mod.
Version 1.10.8
Bug fixes and improvements to death handling code.
Version 1.10.7
Minor update to improve stability when heroes die.
Version 1.10.6
Updated MCM setting description for "Non-Hero Surrender"
Version 1.10.5
Villagers, caravans and bandits now surrender to the player through the dialogue using the mod's logic. You will see these parties surrender based on your settings now.
Version 1.10.4
Added a patch to fix crashes with WarComponent.OnFinalize.
Version 1.10.3
Fixed bandits/caravans still surrendering to the player through this mod.
Version 1.10.2
Added MCM setting to enable or prevent hero deaths from bandits or villagers. They can still be killed by these groups regardless of this new setting if they are severely outnumbered. (3 to 1 at least)
Version 1.10.1
Attempted to fix a crash when heroes die.
Version 1.10.0
Compiled for 1.6.1
Player attacking caravans and looters no longer handled by this mod since game does it.
Added surrender to another lord dialog.
Version 1.9.2
Fixed MCM settings not loading and now you can edit the settings from default again.
Version 1.9.1
Changed how relationship penalties get applied for dishonorable victims.
Fixed default relation penalty for faction members to -35.
Changed default relation penalty for friends to -60.
Version 1.9.0
1.5.9 stable + mcm 4.2.0+
Version 1.8.0
Updated name changes in code and recompiled for 1.5.5
Version 1.7.10
Companions will be removed from player clan on death now to fix them from staying on the clan screen.
Version 1.7.9
Fixed some bugs related to the surrender through dialog feature added in 1.7.8.
Version 1.7.8
When enemy lords consider surrender to the player, it will now go through the dialog.
Added setting to disable surrendering restriction for party sizes.
Version 1.7.7
Fixed relationship penalty for faction members being applied to clan members.
Version 1.7.6
Fixed a bug that prevented companion parties from considering surrender.
Added responsible hero or party to encyclopedia text when a hero is killed in battle.
Version 1.7.5
Fixed defenders surrendering to player in a field battle. Before only the leader party surrendered.
Version 1.7.4
Attempted to fix null object crash on line 674. Normally fixing this stuff is easy but with Bannerlord I have no idea if it is indeed fixed. Just have to wait for someone to get an army to surrender to them and see what happens.
Version 1.7.3
Fixed a bug introduced in the 1.7.2 update. Forgot to set the MapEventSide as surrendered in 1.7.2.
Version 1.7.2
Fixed army surrenders only making leader party surrender. Now all parties will be told to surrender individually.
Version 1.7.1
Fixed main toggle for hero protection category in the MCM menu.
Fixed some settings requiring restart. None of the settings actually require a restart but I forgot to set it up. :3
Version 1.7.0
Updated to MCM 4.0.7, remove previous MCM then install this one.
Version 1.6.1
Compiled on Stable Branch 1.5.1
Version 1.6.0
Fixed relation modifiers only applying to clan leaders and not the actual clan members when these members were not part of the neutral faction. So basically all clans part of kingdoms were broken.
Version 1.5.9
Fixed the fix :3 for exploiting surrender by repeatedly leaving encounter and engaging again until they surrender.
Version 1.5.8
Added setting to allow you to tweak who gets chosen to roll the dice for KIA RNG. Read about how it works on the front page.
Version 1.5.7
Prevented neutral faction from considering surrender or any party whose troop count is 0.
Added seperate multiplier setting to tweak sieges. FYI, sieges have the same probability calculation as field battles but are reduced by being multiplied by 0.1. So if you have 150 attackers against 100 defenders, the probability for a field battle would be (150 - 100) / 150 = 33% but for a siege, the probability is 3.3%. Siege surrenders should be rare.
Prevented exploit by intitiating battle and leaving to keep re rolling the surrender probability. Now once the party declines to surrender, it will not be evaluated again.
Version 1.5.6
Prevented hostile action from being applied against the neutral faction.
Version 1.5.5
Prevented companion party from considering surrender if the game got mixed up and started a battle against your companion.
Version 1.5.4
Fixed a couple misspellings in surrender messages.
Fixed a bug in death evaluation that made it easier for heroes on the defeated to die and harder for heroes on the winning side. Mostly affected losing side though.
Added two new settings to settings menu to toggle messages on or off. Now you won't know the mod is running.
Changed KIA probability settings max value to 1.0.
Version 1.5.3
Fixed error in settings menu category localization.
Completed localization.
Fixed troop strength not calculating properly for battles.
Version 1.5.2
Fixed crash with AIEvaluateSiegeSurrender code.
Added localization support to the settings menu only for now. Next update I will finish the localization but I wanted to get the bug fix out and finishing the localization will take me a bit longer.
Version 1.5.1
Fixed crash because I using wrong index.
See changelog for 1.5.0 and 1.4.9 for all changes.
Version 1.5.0
Fixed a bug that would have made siege probability 100% if defender strength reached limit for surrender.
Make sure to view the changelog for 1.4.9!
Version 1.4.9
Changed how surrender probability works. Now the probability is calculated based on the percent difference between attacker and defenders total strength. The surrender probability setting has been replaced with a multiple setting so you can adjust the calculated probability. This should pretty much force small parties to surrender to the attackers with a small chance they actually fight. No more tough guy villagers taking on entire armies. Using strength will also prevent smaller parties of top tier troops surrendering to trash when they could easily have won.
Forgot to fix the same bug that prevented surrenders but now I fixed it because it was only allowing KIAs if the two parties were at war.
Added siege surrenders. The game doesn't handle settlements surrendering so in order for this to work for the AI, data needs to persist so I am syncing data onto your save file. I think after playing with this installed you aren't going to want to uninstall and play boring vanilla xD So you can install this mid game, no need for a new game but just know it is syncing data so don't try to uninstall the mod in that case or you might have to use Save Module Missing Fix to save you save file. You might be able to uninstall in that case but it shouldn't be something you worry about. Vanilla is boring anyways.
Version 1.4.6
Fixed bug that only let parties at war surrender.
Now checking if the encounter menu or siege menu is showing if the player is attacking in order to fix the bug where allies could surrender or be killed during non hostile map events. TaleWorlds considers every MapEvent to be a field battle pretty much so kinda hard to know when you are talking to someone only. So yeah now I am checking to see what menu is showing to know. Hopefully this prevents any deaths or surrenders when they should not happen.
Tweaked divisor for low valor party leaders when doing the troop count comparison. Now for low valor defending party leaders, if their troop count < attackerTroopCount / 1.2, they will consider surrender. Before I only used 1. Which meant they considered surrender even if outnumbered by only one soldier.
Made villagers consider surrender more often. villagerTroopCount < attackerTroopCount / 0.75. They will only want to fight if outnumbering the attacker by 25% or more.
Using TW code for hostile actions which handles relations modifiers, declaring war, and consequences if at peace when you force a surrender.
Version 1.4.4
Attempting to fix a null object crash when a map event starts. Let me know if it helps since I have not been able to test.
Version 1.4.2
Attempting to fix a crash when accepting a siege surrender. Let me know if it helps since I have not been able to test.
Version 1.4.0
Wasn't giving you the honor and mercy penalty while at war and declining surrender. Now it will give you honor and mercy penalty anytime you decline a surrender.
Version 1.3.9
Changed honor penalty to use what the game does when caravans surrender natively.
I had never seen an AI party surrender to the player and literally after I uploaded the last update a caravan surrendered to me but I was only able to get loot or prisoners. I added toggle in options to disable caravan surrender in my mod since the game does it natively. If you let them surrender through my mod, then you can take prisoners and their loot. ;D
Version 1.3.8
Compiled for Beta Branch.
Version 1.3.7
Added honor penalty if player declines AI surrender.
Version 1.3.6
Compiled for Beta branch.
Version 1.3.5
Added dialog pop up to allow the player to accept or decline surrenders.
Added menu option to toggle non hero led parties being able to surrender.
Version 1.3.4
AWSFFSGFgSDGSDG
Version 1.3.3
Fixed a typo in submodule.xml that caused crash on game start.
Version 1.3.2
Code edited and compiled by @bockyx, all beta users owe him a big thanks!
Version 1.3.1
Added more condition checks to MapEvent events in order to prevent surrenders and deaths when no battle is taking place (talking to allies/neutral parties).
Removed list to track map events. Was completely unnecessary. Should increase performance and now this mod no longer syncs data with your save file. Makes it safe to uninstall.
Now non hero led parties (looters, patrols, etc) can surrender if the conditions are correct.
Version 1.3.0
Added character pictures to the notification messages.
Version 1.2.10
Code edited and compiled for 1.4.1 beta branch by @bockyx! Thanks!
Version 1.2.9
Compiled on 1.4.0
Version 1.2.8
Downgraded MCM v2.0.10 … I am not updating this piece of shit lib anymore.
Fixed null object crash by not applying relation penalties when the responsible hero is null.
Version 1.2.7
Reorganized some code. Made it easier to read and flow better.
Possibly eliminated relations penalties getting applied to the same clan members.
Version 1.2.6
Updated MCM to v2.0.11.
Version 1.2.5
Had to edit one last thing to fix bug introduced in v1.2.3. KIAs should go back to normal.
Version 1.2.4
Fixed bug introduced in v1.2.3 that was killing heroes who qualified for survival.
Version 1.2.3
Made small change to ensure probabilities were accurate.
Version 1.2.2
mboption 2.0.10
Version 1.2.1
mboption 2.0.8
Version 1.2.0
Removed code checking the native module's minor version in an attempt to avoid missing method exceptions for people who were on 1.1.1 stable. It never worked as jus referencing the missing method in the code was enough to cause crashes. This is what people told me as I never experienced these crashes.
Version 1.1.9
Compiled with 1.3.0 beta branch. Stable is no longer supported :(
Compiled with MBOption v2.0.6 and I am now including the dependency in the upload
Version 1.1.8
mboption updated so i had to update to accomodate name changes
Version 1.1.7
Restricted MapEvent types to field battles and sieges. Hopefully this avoids weird bugs where people were surrendering and dying in odd situations. EventTypes no longer considered are... sallying out, raids, ambush, alley fights, siege outside (??), hideout, forcing supplies and forcing volunteers. These seem to be the only event types even though talking to someone in your army is a mapevent and gets assigned one of these types.
Removing the need to save a list of my custom class on the file since I now realize the game engine's class MapEventSide exposes who surrendered. Now the script will no longer need to save as much data. Still will need to save a list of mapevents. This however will cause you to not be able to load your save if updating from a previous version. Dx I apologize for this but it is better I make this change now and get it over with. Sorry!!
Now I am making sure the two opposing sides of a mapevent are at war with each other. this should help avoid stuff where you talk to someone in your own army and they get killed or surrender.
Version 1.1.6
Blocked player party from being evaluated for KIAs
Version 1.1.5
Crash when applying relation penalties fix. https://i.imgur.com/nTqqnVE.png
Version 1.1.4
Crash fix when applying relation penalty to the slain's clan's leader. https://i.imgur.com/F7T0Rc2.png
Version 1.1.3
Fixed a null object crash when applying relationship changes to a killed clan leader's heir apparents. https://imgur.com/JZFoKy0
Version 1.1.2
Fixed misspelled heres so they can be properly protected and fixed their names in the menu.
Added a setting to change the notifications to less intrusive messages that display in the lower left part of the screen.
Version 1.1.1
Fixed a major bug that just appeared as I was playing, heroes were only being wounded because TaleWorld's code is sneaky and says it is killing someone but really if you look at the code inside it isn't killing them, it sometimes wounds them. Anyways this confusion is fixed now if you noticed people were not dead
Added a bunch of morale penalty settings for when a defender in battle is killed. The leader of the attacking army will suffer relation penalties with the slain's kin. See mod options menu.
Fixed misspelled names so the proper people are protected. (Might still be misspelled in menu... just remembered i forgot to do that Dx
Version 1.1.0
Added 6 more Neretzes Quest characters to the hero protection.
Now wounding heroes who surrender. I have only tested letting the map run and I was witnessing the AI surrender no problem. If someone can now test 1.1.0 by attacking a party and receiving the surrender message. You might get loaded into a battle scene but the hope is for every enemy to already be wounded and then you just exit the battle. Will work on avoiding that if that is the case but this feature is untested by me. I am only guessing what might happen now.
Version 1.0.9
Fixed bug causing player party to be considered a non player party and to be evaluated for surrender which could cause the player to auto surrender.
Version 1.0.8
Fixed a crash if starting to play before accessing the settings menu. I'm just learning MBOptionScreen :3
Version 1.0.7
Added MBOptionScreen Standalone to submodule.xml dependencies.
Added ability to protect some important NPCs related to the Neretzes Quest. You can turn on and off for individual heroes at will.
Reduced the Max Value for KIA Probability in the settings menu to make it easier to select options. At 0.25 max you will have lot's of people die quickly regardless and you don't really need to go higher to wipe out every noble on the map in a relatively short time... keep this setting LOW unless you just want to see death left and right!
Version 1.0.6
Added ModLib Settings for Probability for KIA and Surrender
Version 1.0.5
AI was getting killed too much, reduced probability from 10% to 2%, if it is still too high let me know.
Version 1.0.4
Changed method I was using to kill characters. Now it is being done properly and may solve crashing issues. Please confirm on a new game in case saves are already corrupted.
Fixed error in calculation, accidently was compaing attacker troops to attackertroops for the attacker so they would never be penalized if they were outnumbered.
I noticed not many people were ever qualifying to be killed and this was because my logic was too lenient. See font page for clear explanation on how I decide to kill in battle...
Version 1.0.3
Added error checks against null objects being used in the AIEvaluateDeathInBattle and AIEvaluateSurrender methods.
Version 1.0.2
Fixed a null object crash when the map event would end and the party list had not been loaded yet.
Version 1.0.1
Made the notifications more informative. You will know who surrendered to who and who died in battle against whose party.
Created a more unique save base id to ensure less conflict with other mods that save data.
Supporters on Patreon will be invited to my discord where I can help you with modding or you can have a place to discuss Bannerlord and modding. Additionally, you can click the donate button on my mod pages or profile to show support by donating to my paypal!
AI Values Life handles death for NPCs in simulated battles around the map. If you want to handle deaths in the player mission battles, that is my other mod, Heroes Must Die! You should use both together!!
INTRO:
The one thing that annoyed me in Warband was how jails had revolving doors on them... war was not dangerous for anyone... it was just a big silly game, I hated it in Warband and I hate it now. Nobody valued their own life. Now people can die, the way war should be. I have yet to see an AI die by the game natively so maybe they do but I have yet to see it happen even when I enable death, which I think is just for the battle the player is involved in. This is what made me write this and I have been using it for a few days now and it seems to work well. Use this in conjunction with my edit for EvilNobleman's Executioner mod. This mod and my executioner edit can be loaded together without any conflict and together offer the best experience. There are multiple executioner mods too and you can pick the one you think is best.
HOW IT WORKS: Whenever a "map event" or battle goes on around the map, this script will check the defending lord's troop count against the attacker and it will consider his valor to decide if he should surrender or not. Then if the defender qualifies for surrender, there is still some random chance they might not surrender. This mechanic will reward nobles with larger armies that can trap a smaller army. They don't have to lose troops. I feel like this is balanced because smaller armies have speed on their side. If a defender chooses not to surrender then the battles proceeds and all nobles involved in the battle are evaluated to see if they die. This has rng involved but nobles with higher valor have a higher chance of dying since being brave in a battle can get you killed easier. So high valor will help the AI to not surrender but then it works against them in battle. The script also considers the number of troops for a noble's army in this death evaluation. Outnumbering the enemy helps keep the noble alive. Which is why surrendering is a valid choice to make now.
Note: It seems surrender to the player has been confirmed by a user and it caused every troop in the defender army to become wounded and he had to fight a battle with his entire army against the AI hero. Now in version 1.1.0, I will be wounding the AI heroes that surrender to see if this avoids the battle and leads straight to a surrender. I have a feeling the game might load the scene and it will be instantly over. This feature is untested by me and will need you guys to test and report to me in detail how the game reacts or if any crashes then I need screen shots of the error. Thanks to @Xentatic for providing this info. I still want to eventually override the game's default behavior to show the cutscene, I would need to change that cutscene to become a negotiation for surrender or something.
The goal is for nothing to out of control with people dying and a kingdom getting snowballed. You shouldn't see the message often but it will happen. Tweaks can always be made based on your feedback. I do read all comments and respond to them.
Who dies? Basically in order to qualify for the 2% (v1.0.5) probability RNG test... a hero needs to have 1 or less points in my algorithm. Attackers start with 1 point and defenders start with 0 points. People with positive valor, lose a point and people with negative valor gain a point. If a heroe's army has < 2/3 the enemy's army they lose a point. If their enemy has < 2/3 their own army, they gain a point. So attackers have the advantage to start but then valor and troop count could drop their points to 0 or less and then it is possible with a 2% probability for them to die.
During Debug I was Displaying The Points On The Left: