Skip to content

Commit

Permalink
Allow configurable race route
Browse files Browse the repository at this point in the history
  • Loading branch information
NostraThomas99 committed Oct 7, 2024
1 parent 4955f52 commit 57f7bab
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
29 changes: 29 additions & 0 deletions RebornToolbox/Features/ChocoboRacing/ChocoboRacing.Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,33 @@ public class ChocoboRacing_Config
public bool AlwaysRun { get; set; } = true;
public bool AutoRun { get; set; } = true;
public bool StopAtMaxRank { get; set; } = false;
public RaceRoute RaceRoute { get; set; } = RaceRoute.Random;
}

public enum RaceRoute : byte
{
Random = 21,
Sagolii = 18,
Costa = 19,
Tranquil = 20
}

public static class RaceRouteExtensions
{
public static string ToFriendlyString(this RaceRoute raceRoute)
{
switch (raceRoute)
{
case RaceRoute.Random:
return "Random";
case RaceRoute.Sagolii:
return "Sagolii Road";
case RaceRoute.Costa:
return "Costa del Sol";
case RaceRoute.Tranquil:
return "Tranquil Paths";
default:
return "Unknown";
}
}
}
7 changes: 7 additions & 0 deletions RebornToolbox/Features/ChocoboRacing/ChocoboRacing.UI.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Dalamud.Interface.Windowing;
using ImGuiNET;
using OtterGui;

namespace RebornToolbox.Features.ChocoboRacing;

Expand All @@ -18,6 +19,12 @@ public override void Draw()
{
_chocoboRacing.IsRunning = enabled;
}
var route = Plugin.Configuration.ChocoboRacingConfig.RaceRoute;
if (ImGuiUtil.GenericEnumCombo("Race Route", 150, route, out var newRoute, r => r.ToFriendlyString()))
{
Plugin.Configuration.ChocoboRacingConfig.RaceRoute = newRoute;
Plugin.Configuration.SaveConfig();
}
ImGui.Text($"Current Rank: {_chocoboRacing.ChocoboLevel}");
ImGui.Text($"Moving: {_chocoboRacing.IsMoving}");
}
Expand Down
10 changes: 7 additions & 3 deletions RebornToolbox/Features/ChocoboRacing/ChocoboRacing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ private unsafe void OnUpdate(IFramework framework)
IsMoving = false;
return;
}

if (Plugin.Configuration.ChocoboRacingConfig.StopAtMaxRank && ChocoboLevel == 40)
{
if (IsMoving)
Expand Down Expand Up @@ -111,19 +112,22 @@ private unsafe void OnUpdate(IFramework framework)
var cfAgent = AgentContentsFinder.Instance();
if (!GenericHelpers.TryGetAddonByName("ContentsFinder", out AddonContentsFinder* addon))
{
cfAgent->OpenRouletteDuty(21);
cfAgent->OpenRouletteDuty((byte)Plugin.Configuration.ChocoboRacingConfig.RaceRoute);

return;
}

var selectedContent = cfAgent->SelectedContent;
if (!selectedContent.Any(c => c.Id == 21 && c.ContentType == ContentsId.ContentsType.Roulette))
if (!selectedContent.Any(c =>
c.Id == (byte)Plugin.Configuration.ChocoboRacingConfig.RaceRoute &&
c.ContentType == ContentsId.ContentsType.Roulette))
{
SelectDuty(addon);
return;
}

var selectedDutyName = addon->AtkValues[18].GetValueAsString();
if (string.Equals(selectedDutyName, "Chocobo Race: Random", StringComparison.OrdinalIgnoreCase))
if (selectedDutyName.Contains(Plugin.Configuration.ChocoboRacingConfig.RaceRoute.ToFriendlyString(), StringComparison.OrdinalIgnoreCase))
{
Callback.Fire((AtkUnitBase*)addon, true, 12, 0);
}
Expand Down

0 comments on commit 57f7bab

Please sign in to comment.