72 lines
3.1 KiB
C#
72 lines
3.1 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace Harmony.QuestEventManagerPatchesRebirth
|
|
{
|
|
internal class QuestEventManagerPatches
|
|
{
|
|
[HarmonyPatch(typeof(QuestEventManager))]
|
|
[HarmonyPatch("GetPrefabsForTrader")]
|
|
public class GetPrefabsForTraderPatch
|
|
{
|
|
private static bool Prefix(QuestEventManager __instance, ref List<PrefabInstance> __result, TraderArea traderArea, int difficulty, int index, GameRandom gameRandom)
|
|
{
|
|
if (traderArea == null)
|
|
{
|
|
__result = null;
|
|
return false;
|
|
|
|
}
|
|
if (!__instance.TraderPrefabList.ContainsKey(traderArea))
|
|
{
|
|
RebirthUtilities.SetupTraderPrefabList(traderArea, difficulty, ref __instance.TraderPrefabList);
|
|
}
|
|
QuestEventManager.PrefabListData prefabListData = __instance.TraderPrefabList[traderArea][index];
|
|
prefabListData.ShuffleDifficulty(difficulty, gameRandom);
|
|
if (prefabListData.TierData.ContainsKey(difficulty))
|
|
{
|
|
__result = prefabListData.TierData[difficulty];
|
|
return false;
|
|
}
|
|
__result = null;
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
[HarmonyPatch(typeof(QuestEventManager))]
|
|
[HarmonyPatch("HandleNewCompletedQuest")]
|
|
public class HandleNewCompletedQuest
|
|
{
|
|
|
|
private static bool Prefix(QuestEventManager __instance, global::EntityPlayer player, byte questFaction, int completedQuestTier, bool addsToTierComplete)
|
|
{
|
|
if (addsToTierComplete)
|
|
{
|
|
float numQuestCompletionTier = 0;
|
|
if (player.Buffs.HasCustomVar("$varFuriousRamsayQuestCompletionTier"))
|
|
{
|
|
numQuestCompletionTier = player.Buffs.GetCustomVar("$varFuriousRamsayQuestCompletionTier");
|
|
}
|
|
|
|
int currentFactionTier = player.QuestJournal.GetCurrentFactionTier(questFaction, 0, true);
|
|
int currentFactionTier2 = player.QuestJournal.GetCurrentFactionTier(questFaction, completedQuestTier, true);
|
|
if (currentFactionTier != currentFactionTier2)
|
|
{
|
|
for (int i = 0; i < __instance.questTierRewards.Count; i++)
|
|
{
|
|
if (__instance.questTierRewards[i].Tier == currentFactionTier2)
|
|
{
|
|
numQuestCompletionTier++;
|
|
player.Buffs.SetCustomVar("$varFuriousRamsayQuestCompletionTier", numQuestCompletionTier);
|
|
//Log.Out("QuestEventManager-HandleNewCompletedQuest $varFuriousRamsayQuestCompletionTier: " + numQuestCompletionTier);
|
|
__instance.questTierRewards[i].GiveRewards(player);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
} |