Skip to content

Commit 8838439

Browse files
committed
Fishing Improvements
Added food/medicine/cordial usage configs. Defer options for repair/reduction/extraction. Patience usage adjusted based on mooch/collect/reduceable. Fish with explicit needed lures overwrite lure configs. Configs for Patience(default on), chum, and price catch added for preset generator. Thaliaks Favor enabled in all presets generated.
1 parent 7ebe694 commit 8838439

File tree

8 files changed

+533
-77
lines changed

8 files changed

+533
-77
lines changed

GatherBuddy/AutoGather/AutoGather.Actions.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ private unsafe void DoActionTasks(IEnumerable<GatherTarget> target)
138138

139139
private unsafe void DoFishingTasks(IEnumerable<GatherTarget> targets)
140140
{
141+
if (TryUseFoodAndMedicine())
142+
return;
143+
141144
if (SpiritbondMax > 0)
142145
{
146+
if (GatherBuddy.Config.AutoGatherConfig.DeferMateriaExtractionDuringFishingBuffs && (IsFishing || HasActiveFishingBuff()))
147+
return;
148+
143149
if (IsGathering || IsFishing)
144150
{
145151
if (GatherBuddy.Config.AutoGatherConfig.UseAutoHook && AutoHook.Enabled)
@@ -171,7 +177,10 @@ private unsafe void DoFishingTasks(IEnumerable<GatherTarget> targets)
171177

172178
if (FreeInventorySlots < 20 && HasReducibleItems())
173179
{
174-
if (IsFishing)
180+
if (GatherBuddy.Config.AutoGatherConfig.DeferReductionDuringFishingBuffs && (IsFishing || HasActiveFishingBuff()))
181+
return;
182+
183+
if (IsFishing || IsGathering)
175184
{
176185
QueueQuitFishingTasks();
177186
return;
@@ -186,7 +195,7 @@ private unsafe void DoFishingTasks(IEnumerable<GatherTarget> targets)
186195
});
187196
}
188197

189-
ReduceItems(false, () =>
198+
ReduceItems(true, () =>
190199
{
191200
if (GatherBuddy.Config.AutoGatherConfig.UseAutoHook && AutoHook.Enabled)
192201
{

GatherBuddy/AutoGather/AutoGather.Config.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,22 @@ public class AutoGatherConfig
101101
public bool UseHookTimers { get; set; } = false;
102102
public bool AutoCollectablesFishing { get; set; } = true;
103103
public bool DiademAutoAetherCannon { get; set; } = false;
104+
public bool DeferRepairDuringFishingBuffs { get; set; } = true;
105+
public bool DeferReductionDuringFishingBuffs { get; set; } = true;
106+
public bool DeferMateriaExtractionDuringFishingBuffs { get; set; } = true;
107+
public bool UseFood { get; set; } = false;
108+
public uint FoodItemId { get; set; } = 0;
109+
public bool UseMedicine { get; set; } = false;
110+
public uint MedicineItemId { get; set; } = 0;
111+
public bool UseCordialForFishing { get; set; } = false;
112+
public int CordialForFishingGPThreshold { get; set; } = 0;
113+
public bool UsePatience { get; set; } = true;
114+
public bool UsePrizeCatch { get; set; } = false;
115+
public int PrizeCatchGPThreshold { get; set; } = 200;
116+
public bool PrizeCatchGPAbove { get; set; } = true;
117+
public bool UseChum { get; set; } = false;
118+
public int ChumGPThreshold { get; set; } = 100;
119+
public bool ChumGPAbove { get; set; } = true;
104120

105121
public enum SortingType
106122
{
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
using System.Linq;
2+
using GatherBuddy.Helpers;
3+
4+
namespace GatherBuddy.AutoGather;
5+
6+
public partial class AutoGather
7+
{
8+
private static readonly uint[] FishingBuffIds =
9+
[
10+
850, // Angler's Fortune (Patience)
11+
1803, // Surface Slap
12+
1804, // Identical Cast
13+
2779, // Makeshift Bait
14+
2780, // Prize Catch
15+
568, // Fisher's Intuition
16+
763, // Chum
17+
762, // Fish Eyes
18+
3907, // Big Game Fishing
19+
3972, // Ambitious Lure
20+
3973 // Modest Lure
21+
];
22+
23+
private bool HasActiveFishingBuff()
24+
{
25+
var player = Dalamud.Objects.LocalPlayer;
26+
if (player == null)
27+
return false;
28+
29+
return player.StatusList.Any(status => FishingBuffIds.Contains(status.StatusId));
30+
}
31+
32+
private bool HasFoodBuff()
33+
{
34+
var player = Dalamud.Objects.LocalPlayer;
35+
if (player == null)
36+
return false;
37+
38+
return player.StatusList.Any(status => status.StatusId == 48);
39+
}
40+
41+
private bool HasMedicineBuff()
42+
{
43+
var player = Dalamud.Objects.LocalPlayer;
44+
if (player == null)
45+
return false;
46+
47+
return player.StatusList.Any(status => status.StatusId == 49);
48+
}
49+
50+
private bool TryUseFoodAndMedicine()
51+
{
52+
if (Player.Job != 18)
53+
return false;
54+
55+
var config = GatherBuddy.Config.AutoGatherConfig;
56+
var needFood = config.UseFood && config.FoodItemId > 0 && !HasFoodBuff() && GetInventoryItemCount(config.FoodItemId) > 0;
57+
var needMed = config.UseMedicine && config.MedicineItemId > 0 && !HasMedicineBuff() && GetInventoryItemCount(config.MedicineItemId) > 0;
58+
59+
if (!needFood && !needMed)
60+
return false;
61+
62+
if (HasActiveFishingBuff())
63+
return false;
64+
65+
if (IsFishing || IsGathering)
66+
{
67+
GatherBuddy.Log.Debug("[Consumables] Quitting fishing to use food/medicine");
68+
QueueQuitFishingTasks();
69+
return true;
70+
}
71+
72+
if (needFood)
73+
{
74+
var itemCount = GetInventoryItemCount(config.FoodItemId);
75+
if (itemCount > 0)
76+
{
77+
GatherBuddy.Log.Information($"[Consumables] Using food item {config.FoodItemId}");
78+
EnqueueActionWithDelay(() => UseItem(config.FoodItemId));
79+
return true;
80+
}
81+
else
82+
{
83+
GatherBuddy.Log.Warning($"[Consumables] Configured food item {config.FoodItemId} not found in inventory");
84+
}
85+
}
86+
87+
if (needMed)
88+
{
89+
GatherBuddy.Log.Information($"[Consumables] Using medicine item {config.MedicineItemId}");
90+
EnqueueActionWithDelay(() => UseItem(config.MedicineItemId));
91+
return true;
92+
}
93+
94+
return false;
95+
}
96+
}

GatherBuddy/AutoGather/AutoGather.Repair.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ private bool RepairIfNeededForFishing()
135135
return false;
136136
}
137137

138+
if (GatherBuddy.Config.AutoGatherConfig.DeferRepairDuringFishingBuffs && (IsFishing || HasActiveFishingBuff()))
139+
return false;
140+
138141
if ((DateTime.Now - _lastRepairTime).TotalSeconds < 5)
139142
return false;
140143

GatherBuddy/AutoGather/AutoGather.cs

Lines changed: 95 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,11 @@ public void DoAutoGather()
413413
{
414414
if (HasReducibleItems())
415415
{
416-
if (IsGathering)
416+
if (Player.Job == 18 /* FSH */ && GatherBuddy.Config.AutoGatherConfig.DeferReductionDuringFishingBuffs && (IsFishing || HasActiveFishingBuff()))
417+
{
418+
return;
419+
}
420+
else if (IsGathering)
417421
CloseGatheringAddons();
418422
else
419423
ReduceItems(false);
@@ -638,22 +642,39 @@ public void DoAutoGather()
638642
&& !isPathing
639643
&& !Dalamud.Conditions[ConditionFlag.Mounted])
640644
{
645+
if (TryUseFoodAndMedicine())
646+
return;
647+
641648
if (SpiritbondMax > 0)
642649
{
643-
GatherBuddy.Log.Debug($"[Materia] Triggering extraction. IsGathering={IsGathering}, SpiritbondMax={SpiritbondMax}");
644-
if (IsGathering)
650+
if (Player.Job == 18 /* FSH */ && GatherBuddy.Config.AutoGatherConfig.DeferMateriaExtractionDuringFishingBuffs && (IsFishing || HasActiveFishingBuff()))
645651
{
646-
QueueQuitFishingTasks();
652+
return;
647653
}
654+
else
655+
{
656+
GatherBuddy.Log.Debug($"[Materia] Triggering extraction. IsGathering={IsGathering}, SpiritbondMax={SpiritbondMax}");
657+
if (IsGathering)
658+
{
659+
QueueQuitFishingTasks();
660+
}
648661

649-
DoMateriaExtraction();
650-
return;
662+
DoMateriaExtraction();
663+
return;
664+
}
651665
}
652666

653667
if (FreeInventorySlots < 20 && HasReducibleItems())
654668
{
655-
ReduceItems(true);
656-
return;
669+
if (Player.Job == 18 /* FSH */ && GatherBuddy.Config.AutoGatherConfig.DeferReductionDuringFishingBuffs && (IsFishing || HasActiveFishingBuff()))
670+
{
671+
return;
672+
}
673+
else
674+
{
675+
ReduceItems(true);
676+
return;
677+
}
657678
}
658679
}
659680

@@ -783,29 +804,36 @@ public void DoAutoGather()
783804
{
784805
if (Player.Job == 18 /* FSH */)
785806
{
786-
if (IsGathering)
807+
if (GatherBuddy.Config.AutoGatherConfig.DeferReductionDuringFishingBuffs && (IsFishing || HasActiveFishingBuff()))
787808
{
788-
QueueQuitFishingTasks();
789809
return;
790810
}
811+
else
812+
{
813+
if (IsGathering)
814+
{
815+
QueueQuitFishingTasks();
816+
return;
817+
}
791818

792-
if (GatherBuddy.Config.AutoGatherConfig.UseAutoHook && AutoHook.Enabled)
793-
{
794-
TaskManager.Enqueue(() =>
795-
{
796-
AutoHook.SetPluginState?.Invoke(false);
797-
AutoHook.SetAutoStartFishing?.Invoke(false);
798-
});
799-
}
800-
801-
ReduceItems(true, () =>
802-
{
803-
if (GatherBuddy.Config.AutoGatherConfig.UseAutoHook && AutoHook.Enabled)
804-
{
805-
AutoHook.SetPluginState?.Invoke(true);
806-
AutoHook.SetAutoStartFishing?.Invoke(true);
807-
}
808-
});
819+
if (GatherBuddy.Config.AutoGatherConfig.UseAutoHook && AutoHook.Enabled)
820+
{
821+
TaskManager.Enqueue(() =>
822+
{
823+
AutoHook.SetPluginState?.Invoke(false);
824+
AutoHook.SetAutoStartFishing?.Invoke(false);
825+
});
826+
}
827+
828+
ReduceItems(true, () =>
829+
{
830+
if (GatherBuddy.Config.AutoGatherConfig.UseAutoHook && AutoHook.Enabled)
831+
{
832+
AutoHook.SetPluginState?.Invoke(true);
833+
AutoHook.SetAutoStartFishing?.Invoke(true);
834+
}
835+
});
836+
}
809837
}
810838
else
811839
{
@@ -1413,17 +1441,17 @@ private void DoFishMovement(IEnumerable<GatherTarget> next)
14131441
}
14141442
else if (!Lifestream.IsBusy())
14151443
{
1416-
if (IsFishing)
1417-
{
1418-
if (GatherBuddy.Config.AutoGatherConfig.UseAutoHook && AutoHook.Enabled)
1444+
if (IsFishing)
14191445
{
1420-
AutoHook.SetPluginState?.Invoke(false);
1421-
AutoHook.SetAutoStartFishing?.Invoke(false);
1446+
if (GatherBuddy.Config.AutoGatherConfig.UseAutoHook && AutoHook.Enabled)
1447+
{
1448+
AutoHook.SetPluginState?.Invoke(false);
1449+
AutoHook.SetAutoStartFishing?.Invoke(false);
1450+
}
1451+
AutoStatus = "Closing fishing before teleport...";
1452+
QueueQuitFishingTasks();
1453+
return;
14221454
}
1423-
AutoStatus = "Closing fishing before teleport...";
1424-
QueueQuitFishingTasks();
1425-
return;
1426-
}
14271455
AutoStatus = "Teleporting...";
14281456
StopNavigation();
14291457
string name = Dalamud.GameData.GetExcelSheet<TerritoryType>().GetRow(886).PlaceName.Value.Name.ToString()
@@ -2103,39 +2131,46 @@ private void AbortAutoGather(string? status = null)
21032131

21042132
if (HasReducibleItems())
21052133
{
2106-
GatherBuddy.Log.Debug("[AutoGather] Found reducible items during abort, reducing before shutdown");
2107-
2108-
if (Player.Job == 18)
2134+
if (Player.Job == 18 && GatherBuddy.Config.AutoGatherConfig.DeferReductionDuringFishingBuffs && (IsFishing || HasActiveFishingBuff()))
2135+
{
2136+
GatherBuddy.Log.Debug("[AutoGather] Skipping reduction during abort due to active fishing or buffs");
2137+
}
2138+
else
21092139
{
2110-
if (IsGathering)
2140+
GatherBuddy.Log.Debug("[AutoGather] Found reducible items during abort, reducing before shutdown");
2141+
2142+
if (Player.Job == 18)
21112143
{
2112-
QueueQuitFishingTasks();
2113-
return;
2114-
}
2144+
if (IsGathering)
2145+
{
2146+
QueueQuitFishingTasks();
2147+
return;
2148+
}
21152149

2116-
if (GatherBuddy.Config.AutoGatherConfig.UseAutoHook && AutoHook.Enabled)
2150+
if (GatherBuddy.Config.AutoGatherConfig.UseAutoHook && AutoHook.Enabled)
2151+
{
2152+
TaskManager.Enqueue(() =>
2153+
{
2154+
AutoHook.SetPluginState?.Invoke(false);
2155+
AutoHook.SetAutoStartFishing?.Invoke(false);
2156+
});
2157+
}
2158+
2159+
ReduceItems(true, () =>
2160+
{
2161+
AbortAutoGather(status);
2162+
});
2163+
}
2164+
else
21172165
{
2118-
TaskManager.Enqueue(() =>
2166+
ReduceItems(true, () =>
21192167
{
2120-
AutoHook.SetPluginState?.Invoke(false);
2121-
AutoHook.SetAutoStartFishing?.Invoke(false);
2168+
AbortAutoGather(status);
21222169
});
21232170
}
21242171

2125-
ReduceItems(true, () =>
2126-
{
2127-
AbortAutoGather(status);
2128-
});
2129-
}
2130-
else
2131-
{
2132-
ReduceItems(true, () =>
2133-
{
2134-
AbortAutoGather(status);
2135-
});
2172+
return;
21362173
}
2137-
2138-
return;
21392174
}
21402175

21412176
if (!string.IsNullOrEmpty(status))

0 commit comments

Comments
 (0)