Skip to content

Commit

Permalink
hopefully it'll do vouchers and swindlesreturn during escherion now i…
Browse files Browse the repository at this point in the history
…sntead of waiting to get `item - quangt` before doing so.
  • Loading branch information
wtffidy committed Jan 21, 2025
1 parent e22acc0 commit 8c694bc
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 31 deletions.
86 changes: 82 additions & 4 deletions CoreBots.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4058,7 +4058,11 @@ public void HuntMonsterQuestChoose(int questId, int rewardId, string? mapName =
/// <param name="isTemp">Whether the item is temporary</param>
/// <param name="log"></param>
/// <param name="publicRoom"></param>
public void KillEscherion(string? item = null, int quant = 1, bool isTemp = false, bool log = true, bool publicRoom = false)
/// <param name="FromSupplies"></param>
/// <param name="SellVoucher"></param>
/// <param name="ReturnDuring"></param>
/// <param name="ReturnItem"></param>
public void KillEscherion(string? item = null, int quant = 1, bool isTemp = false, bool log = true, bool publicRoom = false, bool FromSupplies = false, bool SellVoucher = false, bool ReturnDuring = false, string? ReturnItem = null)
{
if (item != null && (isTemp ? Bot.TempInv.Contains(item, quant) : CheckInventory(item, quant)))
return;
Expand All @@ -4068,8 +4072,10 @@ public void KillEscherion(string? item = null, int quant = 1, bool isTemp = fals
if (Bot.Player.Cell != "Boss")
Jump("Boss", "Left");

if (item is not null && log)
FarmingLogger(item, quant);
if (!FromSupplies)
if (item is not null && log)
FarmingLogger(item, quant);

if (item is not null && !isTemp)
AddDrop(item);

Expand All @@ -4095,7 +4101,7 @@ public void KillEscherion(string? item = null, int quant = 1, bool isTemp = fals
else
{
while (!Bot.ShouldExit && isTemp ? !Bot.TempInv.Contains(item, quant) : !CheckInventory(item, quant))
_KillEscherion();
_KillEscherion(item, isTemp);

Rest();
if (!isTemp)
Expand Down Expand Up @@ -4136,6 +4142,27 @@ void _KillEscherion(string? item = null, bool isTemp = false)
Bot.Combat.Attack(target);
}
Sleep();

// Sell voucher area
if (item != "Voucher of Nulgath" && SellVoucher && CheckInventory("Voucher of Nulgath"))
{
while (!Bot.ShouldExit && (Bot.Player.HasTarget || Bot.Player.InCombat) && Bot.Player.Cell != "Enter")
{
Bot.Combat.CancelTarget();
Bot.Wait.ForCombatExit();
JumpWait();
Sleep();
}

if (Bot.Player.Gold < 100000000)
{
Bot.Wait.ForPickup("Voucher of Nulgath");
SellItem("Voucher of Nulgath", all: true);
Bot.Wait.ForItemSell();
}
}
DoSwindlesReturnArea(ReturnDuring, ReturnItem);

}

Bot.Options.AttackWithoutTarget = false;
Expand All @@ -4145,8 +4172,59 @@ void _KillEscherion(string? item = null, bool isTemp = false)
JumpWait();
Rest();
Bot.Options.HidePlayers = false;

void DoSwindlesReturnArea(bool returnPolicyActive, string? item = null)
{
// Return if the policy isn't active or required items are missing
if (!returnPolicyActive || !CheckInventory(new[] { Uni(1), Uni(6), Uni(9), Uni(16), Uni(20) }))
return;

bool retry = true;

while (!Bot.ShouldExit && retry)
{
retry = false; // Reset retry flag
ResetQuest(7551);
DarkMakaiItem("Dark Makai Rune");

// Load quest and find rewards
Quest? quest = InitializeWithRetries(() => Bot.Quests.EnsureLoad(7551));
if (quest == null)
{
Logger("Failed to load quest 7551, retrying...");
Sleep();
retry = true;
continue;
}

// Handle null `item` by skipping directly to reward selection
ItemBase? targetReward = item == null
? null
: quest.Rewards.FirstOrDefault(r => r.Name == item && r.Name != "Receipt of Swindle");

int rewardID = targetReward?.ID ??
quest.Rewards.FirstOrDefault(r => !CheckInventory(r.ID, r.MaxStack))?.ID ?? -1;

if (rewardID != -1 && Bot.Quests.CanCompleteFullCheck(7551))
{
Logger($"Completing with: {quest.Rewards.First(r => r.ID == rewardID).Name} [ID: {rewardID}]");
EnsureComplete(7551, rewardID);
}
else
{
Logger("All rewards maxed. Completing with fallback reward ID: -1 (\"Receipt of Swindle\").");
EnsureComplete(7551);
}
}
}


string Uni(int nr)
=> $"Unidentified {nr}";

}


/// <summary>
/// Kill Vath for the desired item
/// </summary>
Expand Down
62 changes: 35 additions & 27 deletions Nation/CoreNation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ public void Supplies(string? item = null, int quant = 1, bool UltraAlteon = fals
if (UltraAlteon)
Core.KillMonster("ultraalteon", "r10", "Left", "Ultra Alteon", log: false);
else
Core.KillEscherion(log: false);
Core.KillEscherion(item, quant, log: false, FromSupplies: true, SellVoucher: sellMemVoucher, ReturnDuring: returnPolicyDuringSupplies, ReturnItem: ReturnItem);
Core.Sleep();

if (item != "Voucher of Nulgath" && sellMemVoucher && Core.CheckInventory("Voucher of Nulgath"))
Expand Down Expand Up @@ -914,7 +914,7 @@ public void Supplies(string? item = null, int quant = 1, bool UltraAlteon = fals
if (UltraAlteon)
Core.KillMonster("ultraalteon", "r10", "Left", "*", log: false);
else
Core.KillEscherion(item, quant, log: false);
Core.KillEscherion(item, quant, log: false, FromSupplies: true, SellVoucher: sellMemVoucher, ReturnDuring: returnPolicyDuringSupplies, ReturnItem: ReturnItem);

// Sell voucher area
if (item != "Voucher of Nulgath" && sellMemVoucher && Core.CheckInventory("Voucher of Nulgath"))
Expand Down Expand Up @@ -950,40 +950,48 @@ public void Supplies(string? item = null, int quant = 1, bool UltraAlteon = fals
/// </summary>
/// <param name="returnPolicyActive">Indicates if the return policy is active.</param>
/// <param name="item">The name of the specific reward item to prioritize.</param>
private void DoSwindlesReturnArea(bool returnPolicyActive, string? item)
void DoSwindlesReturnArea(bool returnPolicyActive, string? item = null)
{
// Return if the policy isn't active or required items are missing
if (!returnPolicyActive || !Core.CheckInventory(new[] { Uni(1), Uni(6), Uni(9), Uni(16), Uni(20) }))
return;

Retry:
Core.ResetQuest(7551);
Core.DarkMakaiItem("Dark Makai Rune");
bool retry = true;

// Try to find the specified reward item, skipping "Receipt of Swindle"
Quest? quest = Core.InitializeWithRetries(() => Bot.Quests.EnsureLoad(7551));
ItemBase? targetReward = quest?.Rewards.FirstOrDefault(r => r.Name == item && r.Name != "Receipt of Swindle");
while (!Bot.ShouldExit && retry)
{
retry = false; // Reset retry flag
Core.ResetQuest(7551);
Core.DarkMakaiItem("Dark Makai Rune");

// Complete with targetReward if found, otherwise find a non-maxed reward or use -1 as fallback
int rewardID = targetReward?.ID ??
quest?.Rewards.FirstOrDefault(r => !Core.CheckInventory(r.ID, r.MaxStack))?.ID ?? -1;
// Load quest and find rewards
Quest? quest = Core.InitializeWithRetries(() => Bot.Quests.EnsureLoad(7551));
if (quest == null)
{
Core.Logger("Failed to load quest 7551, retrying...");
Core.Sleep();
retry = true;
continue;
}

if (rewardID != -1 && Bot.Quests.CanCompleteFullCheck(7551))
{
if (quest != null)
// Handle null `item` by skipping directly to reward selection
ItemBase? targetReward = item == null
? null
: quest.Rewards.FirstOrDefault(r => r.Name == item && r.Name != "Receipt of Swindle");

int rewardID = targetReward?.ID ??
quest.Rewards.FirstOrDefault(r => !Core.CheckInventory(r.ID, r.MaxStack))?.ID ?? -1;

if (rewardID != -1 && Bot.Quests.CanCompleteFullCheck(7551))
{
Core.Logger($"Completing with: {quest.Rewards.First(r => r.ID == rewardID).Name} [ID: {rewardID}]");
Core.EnsureComplete(7551, rewardID);
}
else if (quest == null)
{
Core.Logger("Failed to load quest 7551, retrying...");
Core.Sleep();
goto Retry;
}
else
{
Core.Logger("All rewards maxed. Completing with fallback reward ID: -1 (\"Receipt of Swindle\").");
Core.EnsureComplete(7551);
Core.EnsureComplete(7551, rewardID);
}
else
{
Core.Logger("All rewards maxed. Completing with fallback reward ID: -1 (\"Receipt of Swindle\").");
Core.EnsureComplete(7551);
}
}
}

Expand Down

0 comments on commit 8c694bc

Please sign in to comment.