Skip to content

Commit

Permalink
Merge pull request #156 from DiplomacyTeam/dev
Browse files Browse the repository at this point in the history
v1.1.18 release
  • Loading branch information
artifixer authored Dec 11, 2022
2 parents 0a60d20 + d0456dc commit edee6e1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 64 deletions.
6 changes: 3 additions & 3 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<!--Module Version-->
<PropertyGroup>
<Version>1.1.17</Version>
<GameVersion>1.0.1</GameVersion>
<Version>1.1.18</Version>
<GameVersion>1.0.0</GameVersion>
</PropertyGroup>

<!-- Versions of Major Dependencies (For Package References & SubModule.xml Substitution) -->
Expand Down Expand Up @@ -78,7 +78,7 @@
<GameStableVersion>$(SecondLine)</GameStableVersion>
<GameMinimalVersion>$(LastLine)</GameMinimalVersion>
<!-- -->
<GameVersionWithPrefix>e1.1.0</GameVersionWithPrefix>
<GameVersionWithPrefix>v1.0.0</GameVersionWithPrefix>
<GameVersionWithPrefix Condition="$(IsMinimal)">$(GameMinimalVersion)</GameVersionWithPrefix>
<GameVersionWithPrefix Condition="$(IsStable)">$(GameStableVersion)</GameVersionWithPrefix>
<GameVersionWithPrefix Condition="$(IsBeta)">$(GameBetaVersion)</GameVersionWithPrefix>
Expand Down
8 changes: 7 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
---------------------------------------------------------------------------------------------------
Version: 1.1.18
Game Versions: v1.0.0,v1.0.1,v1.0.2
* Fixed a crash that occurred when sending a Messenger to a hero in the field.
* Fixed a rare crash that sometimes occurred in Kingdom Management.
* Fixed a rare crash that occurred on Encyclopedia Hero page when the hero was imprisoned by leaderless party.
---------------------------------------------------------------------------------------------------
Version: 1.1.17
Game Versions: v1.0.0,v1.0.1,v1.0.2
* Recompiled for v1.0.2.
* Fixed several issues with the Diplomacy panel in Kingdom Management.
* Fixed several issues with peace and war restrictions not applying properly.
* Fixed a crash that occurred when sending a Messenger to a factionless hero.
* Fixed a crash that occurred when trying to create a caravan using a Messenger.
* Messengers now use correct the scene for the conversation.
* Messengers now use correct scene for the conversation.
* Messengers can no longer freely access highborn locations unless you can.
* The speed of Messengers now depends on the maximum arrival time.
* Added an explanation for why some characters may not be available to send Messengers to.
Expand Down
52 changes: 28 additions & 24 deletions src/Bannerlord.Diplomacy/Messengers/MessengerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ public void StartDialogue(Hero targetHero, Messenger messenger)

PlayerEncounter.Start();
PlayerEncounter.Current.SetupFields(heroParty, targetParty ?? heroParty);

Campaign.Current.CurrentConversationContext = ConversationContext.Default;

if (targetSettlement != null)
{
_position2D = new(Hero.MainHero.GetMapPoint().Position2D);
Expand Down Expand Up @@ -311,28 +311,7 @@ public static bool IsTargetHeroAvailable(Hero targetHero, out TextObject excepti
if (!available)
{
exception = new("{=bLR91Eob}{REASON}The messenger won't be able to reach the addressee.");

TextObject reason;
if (targetHero.IsDead)
reason = new("{=vhsHDMil}{HERO_NAME} is dead. ", new() { ["HERO_NAME"] = targetHero.Name });
else if (targetHero.IsPrisoner)
reason = new("{=CusN2JMb}{HERO_NAME} is imprisoned {?IS_MOBILE}by{?}in{\\?} {DETENTION_PLACE}. ", new()
{
["HERO_NAME"] = targetHero.Name,
["IS_MOBILE"] = targetHero.PartyBelongedToAsPrisoner.IsSettlement ? 0 : 1,
["DETENTION_PLACE"] = targetHero.PartyBelongedToAsPrisoner.IsSettlement ? targetHero.PartyBelongedToAsPrisoner.Settlement.Name : targetHero.PartyBelongedToAsPrisoner.LeaderHero.Name
});
else if (targetHero.IsFugitive)
reason = new("{=1BISlFYx}{HERO_NAME} is fugitive and doesn't want to be found. ", new() { ["HERO_NAME"] = targetHero.Name });
else if (targetHero.IsReleased)
reason = new("{=ze8KJ1oL}{HERO_NAME} has just been released from custody and is not yet ready to make appointments. ", new() { ["HERO_NAME"] = targetHero.Name });
else if (targetHero.IsTraveling)
reason = new("{=N5T6IXWJ}{HERO_NAME} is traveling incognito. ", new() { ["HERO_NAME"] = targetHero.Name });
else if (targetHero.IsChild)
reason = new("{=3lknR86H}{HERO_NAME} is too inexperienced to participate in formal meetings. ", new() { ["HERO_NAME"] = targetHero.Name });
else
reason = TextObject.Empty;

var reason = GetUnavailabilityReason(targetHero);
exception.SetTextVariable("REASON", reason);
return false;
}
Expand All @@ -347,6 +326,31 @@ public static bool IsTargetHeroAvailable(Hero targetHero, out TextObject excepti
return true;
}

private static TextObject GetUnavailabilityReason(Hero targetHero)
{
TextObject reason;
if (targetHero.IsDead)
reason = new("{=vhsHDMil}{HERO_NAME} is dead. ", new() { ["HERO_NAME"] = targetHero.Name });
else if (targetHero.IsPrisoner && targetHero.PartyBelongedToAsPrisoner != null)
reason = new("{=CusN2JMb}{HERO_NAME} is imprisoned {?IS_MOBILE}by{?}in{\\?} {DETENTION_PLACE}. ", new()
{
["HERO_NAME"] = targetHero.Name,
["IS_MOBILE"] = targetHero.PartyBelongedToAsPrisoner.IsSettlement ? 0 : 1,
["DETENTION_PLACE"] = targetHero.PartyBelongedToAsPrisoner.IsSettlement ? targetHero.PartyBelongedToAsPrisoner.Settlement.Name : ((targetHero.PartyBelongedToAsPrisoner.LeaderHero?.Name ?? targetHero.PartyBelongedToAsPrisoner.Name) ?? TextObject.Empty)
});
else if (targetHero.IsFugitive)
reason = new("{=1BISlFYx}{HERO_NAME} is fugitive and doesn't want to be found. ", new() { ["HERO_NAME"] = targetHero.Name });
else if (targetHero.IsReleased)
reason = new("{=ze8KJ1oL}{HERO_NAME} has just been released from custody and is not yet ready to make appointments. ", new() { ["HERO_NAME"] = targetHero.Name });
else if (targetHero.IsTraveling)
reason = new("{=N5T6IXWJ}{HERO_NAME} is traveling incognito. ", new() { ["HERO_NAME"] = targetHero.Name });
else if (targetHero.IsChild)
reason = new("{=3lknR86H}{HERO_NAME} is too inexperienced to participate in formal meetings. ", new() { ["HERO_NAME"] = targetHero.Name });
else
reason = TextObject.Empty;
return reason;
}

public static bool IsTargetHeroAvailableNow(Hero targetHero)
{
return IsTargetHeroAvailable(targetHero) && targetHero.PartyBelongedTo?.MapEvent == null;
Expand Down Expand Up @@ -374,7 +378,7 @@ private void CleanUpSettlementEncounter(float obj)
{
PlayerEncounter.Finish();

if (_position2D != Vec2.Invalid)
if (_position2D.IsValid)
{
MobileParty.MainParty.Position2D = _position2D;
}
Expand Down
36 changes: 0 additions & 36 deletions src/Bannerlord.Diplomacy/ViewModelMixin/KingdomDiplomacyVMMixin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
using Diplomacy.Event;
using Diplomacy.Extensions;

using HarmonyLib;
using HarmonyLib.BUTR.Extensions;

using JetBrains.Annotations;

using System;
using System.Collections.Generic;
using System.Linq;

Expand All @@ -26,24 +22,6 @@ namespace Diplomacy.ViewModelMixin
[UsedImplicitly]
internal sealed class KingdomDiplomacyVMMixin : BaseViewModelMixin<KingdomDiplomacyVM>
{
static KingdomDiplomacyVMMixin()
{
var harmony = new Harmony("Diplomacy.ViewModelMixin.KingdomDiplomacyVMMixin");

harmony.Patch(
AccessTools2.Method(typeof(KingdomDiplomacyVM), "OnDiplomacyItemSelection"),
postfix: new HarmonyMethod(typeof(KingdomDiplomacyVMMixin), nameof(OnDiplomacyItemSelectionPostfix)));
}

private static void OnDiplomacyItemSelectionPostfix(KingdomDiplomacyVM __instance, KingdomDiplomacyItemVM item)
{
if (__instance.GetPropertyValue(nameof(Mixin)) is WeakReference<KingdomDiplomacyVMMixin> weakReference && weakReference.TryGetTarget(out var mixin))
{
mixin.OnDiplomacyItemSelection(item);
}
}


private static readonly TextObject _TAlliances = new("{=zpNalMeA}Alliances");
private static readonly TextObject _TStats = new("{=1occw3EF}Stats");
private static readonly TextObject _TOverview = new("{=OvbY5qxL}Overview");
Expand All @@ -57,9 +35,6 @@ private static void OnDiplomacyItemSelectionPostfix(KingdomDiplomacyVM __instanc
private bool _showOverview;
private bool _showStats;

[DataSourceProperty]
public WeakReference<KingdomDiplomacyVMMixin> Mixin => new(this);

[DataSourceProperty]
public bool ShowOverview { get => _showOverview; set => SetField(ref _showOverview, value, nameof(ShowOverview)); }

Expand Down Expand Up @@ -126,17 +101,6 @@ public void ExecuteShowOverview()
ShowStats = false;
}

public void ExecuteShowStatComparison()
{
ViewModel!.IsDisplayingStatComparisons = true;
ViewModel!.IsDisplayingWarLogs = false;
}

private void OnDiplomacyItemSelection(KingdomDiplomacyItemVM item)
{
ExecuteShowStatComparison();
}

public override void OnRefresh()
{
ExecuteShowOverview();
Expand Down

0 comments on commit edee6e1

Please sign in to comment.