This repository has been archived by the owner on Mar 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a crash occuring in the Lord Wants Rival Captured quest (#395)
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
src/CommunityPatch/Patches/Quests/LordWantsRivalCapturedQuestPatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using TaleWorlds.CampaignSystem; | ||
using TaleWorlds.Library; | ||
using TaleWorlds.Localization; | ||
using static HarmonyLib.AccessTools; | ||
|
||
namespace CommunityPatch.Patches.Quests { | ||
|
||
[PatchNotBefore(ApplicationVersionType.EarlyAccess, 1, 4, 2)] | ||
public class LordWantsRivalCapturedQuestPatch : PatchBase<LordWantsRivalCapturedQuestPatch> { | ||
|
||
public static readonly byte[][] Hashes = { | ||
new byte[] { | ||
// e1.4.2.231952 | ||
0x2B, 0x96, 0x7F, 0xA2, 0x14, 0x52, 0x67, 0xA8, | ||
0x9C, 0xDA, 0x6E, 0x67, 0x32, 0xD7, 0x0D, 0x2D, | ||
0x77, 0x25, 0x08, 0x19, 0xAB, 0xCF, 0x09, 0x06, | ||
0xC2, 0x20, 0x8D, 0x71, 0xF2, 0x8C, 0x1F, 0x46 | ||
} | ||
}; | ||
|
||
private static readonly Type LordWantsRivalCapturedIssueBehaviorType = | ||
Type.GetType("TaleWorlds.CampaignSystem.SandBox.Issues.LordWantsRivalCapturedIssueBehavior, TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral", false); | ||
|
||
private static readonly Type LordWantsRivalCapturedIssueQuestType = | ||
Inner(LordWantsRivalCapturedIssueBehaviorType, "LordWantsRivalCapturedIssueQuest"); | ||
|
||
private static readonly MethodInfo GetWarDeclaredQuestLog = PropertyGetter(LordWantsRivalCapturedIssueQuestType, "_warDeclaredQuestLog"); | ||
|
||
public LordWantsRivalCapturedQuestPatch() { | ||
if (GetWarDeclaredQuestLog == null) | ||
return; | ||
|
||
var patchMethodInfo = typeof(LordWantsRivalCapturedQuestPatch).GetMethod(nameof(GetWarDeclaredQuestLogPrefix), all); | ||
PatchedMethodsInfo[GetWarDeclaredQuestLog] = new List<(string, MethodInfo)> { ("Prefix", patchMethodInfo) }; | ||
} | ||
|
||
private static bool GetWarDeclaredQuestLogPrefix(QuestBase __instance, ref TextObject __result) { | ||
if (__instance?.QuestGiver?.MapFaction?.Name != null) { | ||
__result = new TextObject("{=cKz1cyuM}Your clan is now at war with {QUEST_GIVER_FACTION}. Quest is cancelled."); | ||
__result.SetTextVariable("QUEST_GIVER_FACTION", __instance.QuestGiver.MapFaction.Name); | ||
return false; | ||
} | ||
|
||
if (__instance?.QuestGiver?.Clan?.Name != null) { | ||
__result = new TextObject("{=cKz1cyuM}Your clan is now at war with {QUEST_GIVER_CLAN}. Quest is cancelled."); | ||
__result.SetTextVariable("QUEST_GIVER_CLAN", __instance.QuestGiver.Clan.Name); | ||
return false; | ||
} | ||
|
||
__result = new TextObject("{=cKz1cyuM}Your clan is now at war with the quest giver. Quest is cancelled."); | ||
return false; | ||
} | ||
|
||
} | ||
|
||
} | ||
|