aboutsummaryrefslogtreecommitdiffstats
path: root/Malmstone/Addons
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2024-09-08 18:36:11 -0700
committerPinapelz <yukais@pinapelz.com>2024-09-08 18:36:11 -0700
commit4b5dd85a1fdcb1039c78261cab72047eb5a3933d (patch)
tree94f8f4d1dabeceddd0558c3a5990eb401bd1b970 /Malmstone/Addons
parent728d9ff38a19f0a8b72bcb004d56edabec138af8 (diff)
parentc434ed7e5b557ff82882d7ac74068169eb83de7c (diff)
Merge branch 'fl-bonus'
Diffstat (limited to 'Malmstone/Addons')
-rw-r--r--Malmstone/Addons/PvPMatchAddon.cs65
1 files changed, 64 insertions, 1 deletions
diff --git a/Malmstone/Addons/PvPMatchAddon.cs b/Malmstone/Addons/PvPMatchAddon.cs
index 78e0e38..896001a 100644
--- a/Malmstone/Addons/PvPMatchAddon.cs
+++ b/Malmstone/Addons/PvPMatchAddon.cs
@@ -5,12 +5,16 @@ using Malmstone.Utils;
using Dalamud.Game.Text.SeStringHandling;
using System.Collections.Generic;
using Dalamud.Game.Text.SeStringHandling.Payloads;
+using FFXIVClientStructs.FFXIV.Component.GUI;
+using Dalamud.Memory;
+using static Malmstone.Services.PvPService;
namespace Malmstone.Addons
{
internal class PvPMatchAddon
{
private Plugin Plugin;
+ public bool FrontlineRecordPostSetupEnabled = false;
private enum PvPContentType
{
CrystallineConflict = 1,
@@ -49,11 +53,15 @@ namespace Malmstone.Addons
public void EnableFrontlinePostMatch()
{
Plugin.AddonLifeCycle.RegisterListener(AddonEvent.PostSetup, "FrontlineRecord", OnFrontlineRecordTrigger);
+ Plugin.PvPService.CurrentFrontlineLosingBonus = Plugin.Configuration.SavedFrontlineRewardBonus;
+ Plugin.Configuration.OutdatedFrontlineRewardBonus = true;
+ FrontlineRecordPostSetupEnabled = true;
}
public void DisableFrontlinePostMatch()
{
Plugin.AddonLifeCycle.UnregisterListener(AddonEvent.PostSetup, "FrontlineRecord", OnFrontlineRecordTrigger);
+ FrontlineRecordPostSetupEnabled = false;
}
public void EnableRivalWingsPostMatch()
@@ -64,12 +72,13 @@ namespace Malmstone.Addons
{
Plugin.AddonLifeCycle.UnregisterListener(AddonEvent.PostSetup, "ManeuversRecord", OnRivalWingsRecordTrigger);
}
-
+
// Runs on the result screen of the respective game mode
private void OnCrystallineConflictRecordTrigger(AddonEvent eventType, AddonArgs addonInfo)
{
PvPSeriesInfo? seriesInfo = Plugin.PvPService.GetPvPSeriesInfo();
+ CheckFrontlineBonus(eventType, addonInfo);
if (seriesInfo == null) return;
if (Plugin.Configuration.ShowProgressionChatPostCC)
ShowSeriesProgressionMessage(seriesInfo, PvPContentType.CrystallineConflict);
@@ -77,6 +86,8 @@ namespace Malmstone.Addons
private void OnFrontlineRecordTrigger(AddonEvent eventType, AddonArgs addonInfo)
{
+ if (Plugin.Configuration.TrackFrontlineBonus)
+ CheckFrontlineBonus(eventType, addonInfo);
PvPSeriesInfo? seriesInfo = Plugin.PvPService.GetPvPSeriesInfo();
if (seriesInfo == null) return;
if (Plugin.Configuration.ShowProgressionChatPostFL)
@@ -91,6 +102,58 @@ namespace Malmstone.Addons
ShowSeriesProgressionMessage(seriesInfo, PvPContentType.RivalWings);
}
+ private void CheckFrontlineBonus(AddonEvent eventType, AddonArgs addonInfo)
+ {
+ PVPProfileFrontlineResults CurrentFrontlineResults = Plugin.PvPService.GetPVPProfileFrontlineResults();
+ if (CurrentFrontlineResults.FirstPlace == 0 &&
+ CurrentFrontlineResults.SecondPlace == 0 &&
+ CurrentFrontlineResults.ThirdPlace == 0) return;
+ // Check placement of current Frontline match
+ FrontlinePlacement FrontlineMatchResult = FrontlinePlacement.Unknown;
+ if (CurrentFrontlineResults.FirstPlace > Plugin.PvPService.CachedFrontlineResults.FirstPlace)
+ {
+ FrontlineMatchResult = FrontlinePlacement.FirstPlace;
+ }
+ else if (CurrentFrontlineResults.SecondPlace > Plugin.PvPService.CachedFrontlineResults.SecondPlace)
+ {
+ FrontlineMatchResult = FrontlinePlacement.SecondPlace;
+ }
+ else if (CurrentFrontlineResults.ThirdPlace > Plugin.PvPService.CachedFrontlineResults.ThirdPlace)
+ {
+ FrontlineMatchResult = FrontlinePlacement.ThirdPlace;
+ }
+ Plugin.Logger.Debug("Frontline Match Result: " + FrontlineMatchResult.ToString());
+ if (FrontlineMatchResult != FrontlinePlacement.Unknown)
+ {
+ unsafe
+ {
+ var FrontlineResultUnit = (AtkUnitBase*)addonInfo.Addon;
+ if (FrontlineResultUnit == null) return;
+ var SeriesExpComponent = FrontlineResultUnit->GetComponentByNodeId(35);
+ var SeriesExpTextNode = (AtkTextNode*)SeriesExpComponent->GetTextNodeById(2);
+ byte* SeriesExpTextBytePointer = SeriesExpTextNode->GetText();
+ nint SeriesExpTextAddr = (nint)SeriesExpTextBytePointer;
+ string SeriesExpText = MemoryHelper.ReadStringNullTerminated(SeriesExpTextAddr);
+ if (int.TryParse(SeriesExpText, out int SeriesExpEarned))
+ {
+ int CurrentLossBonus = Plugin.PvPService.GenerateFrontlineBonus(FrontlineMatchResult, SeriesExpEarned);
+ Plugin.Logger.Debug("Series EXP Earned: " + SeriesExpEarned.ToString());
+ Plugin.Configuration.SavedFrontlineRewardBonus = CurrentLossBonus;
+ Plugin.Configuration.OutdatedFrontlineRewardBonus = false;
+ }
+ else
+ {
+ Plugin.Chat.PrintError("[Malmstone Calculator] Unable to get earned Series EXP: " + SeriesExpText);
+ }
+ }
+ }
+ else
+ {
+ Plugin.Chat.PrintError("[Malmstone Calculator] Unable to get current Frontline match results");
+ }
+ Plugin.PvPService.UpdateFrontlineResultCache();
+ }
+
private void ShowSeriesProgressionToast(AddonEvent eventType, AddonArgs addonInfo)
{
PvPSeriesInfo? seriesInfo = Plugin.PvPService.GetPvPSeriesInfo();
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage