forked from mipen/BannerlordTweaks
-
Notifications
You must be signed in to change notification settings - Fork 3
/
TweakedCombatXpModel.cs
49 lines (48 loc) · 2.57 KB
/
TweakedCombatXpModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.SandBox.GameComponents.Map;
using TaleWorlds.Library;
namespace BannerlordTweaks
{
public class TweakedCombatXpModel : DefaultCombatXpModel
{
// v1.4.3 - They added PartyBase param. Updated method to address build error.
// v1.5.5 - They added Captain param.
// ToDo: Update formula based on new code in DefaultCombatXpModel
public override void GetXpFromHit(CharacterObject attackerTroop, CharacterObject captain, CharacterObject attackedTroop, PartyBase party, int damage, bool isFatal, MissionTypeEnum missionType, out int xpAmount)
{
if (attackerTroop == null || attackedTroop == null || !(BannerlordTweaksSettings.Instance is { } settings))
{
xpAmount = 0;
return;
}
int num = attackerTroop.MaxHitPoints();
xpAmount = MBMath.Round(0.4f * ((attackedTroop.GetPower() + 0.5f) * (float)(Math.Min(damage, num) + (isFatal ? num : 0))));
//There are three things to do here: Tournament Experience, Arena Experience, Troop Experience.
if (attackerTroop.IsHero)
{
if (missionType == MissionTypeEnum.Tournament)
{
if (settings.TournamentHeroExperienceMultiplierEnabled)
xpAmount = (int)MathF.Round(settings.TournamentHeroExperienceMultiplier * (float)xpAmount);
else
xpAmount = MathF.Round((float)xpAmount * 0.33f);
}
else if (missionType == MissionTypeEnum.PracticeFight)
{
if (settings.ArenaHeroExperienceMultiplierEnabled)
xpAmount = (int)MathF.Round(settings.ArenaHeroExperienceMultiplier * (float)xpAmount);
else
xpAmount = MathF.Round((float)xpAmount * 0.0625f);
}
}
else if ((missionType == MissionTypeEnum.Battle || missionType == MissionTypeEnum.SimulationBattle))
{
if (settings.TroopBattleSimulationExperienceMultiplierEnabled && missionType == MissionTypeEnum.SimulationBattle)
xpAmount = (int)MathF.Round(xpAmount * settings.TroopBattleSimulationExperienceMultiplier);
else if (settings.TroopBattleExperienceMultiplierEnabled && missionType == MissionTypeEnum.Battle)
xpAmount = (int)MathF.Round(xpAmount * settings.TroopBattleExperienceMultiplier);
}
}
}
}