Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CoreFarms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3308,7 +3308,7 @@ void RunDeathPitBrawl(string? item = null, int quant = 1, bool isTemp = false, i
// -------------------------
// 1) Faction Rank farming
// -------------------------
while (!Bot.ShouldExit && FactionRank("Death Pit Brawl") < rank)
while (!Bot.ShouldExit && !ForStory && FactionRank("Death Pit Brawl") < rank)
{
runTimer.Start();
ExecuteOneBrawlRun();
Expand All @@ -3324,7 +3324,7 @@ void RunDeathPitBrawl(string? item = null, int quant = 1, bool isTemp = false, i
}

// -------------------------
// 2) {item} farming (only AFTER rank is done)
// 2) Item farming
// -------------------------
if (item != null)
{
Expand Down
20 changes: 8 additions & 12 deletions Other/Various/Potions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private static CoreAdvanced Adv
public List<IOption> Options = new()
{
new Option<bool>("BuyReagents", "Buy Reagents?", "Use gold to buy the reagents for the Potions [this takes ALOT of gold.].", false),
new Option<int>("PotionQuant", "Potion Quantity", "Desired stack amount [max - 300]", 0),
new Option<string>("PotionQuant", "Potion Quantity", "Desired stack amount [1-300]", "0"),
new Option<bool>("MaxAll", "Max all Potions within the script.", "as the name says", false),

CoreBots.Instance.SkipOptions,
Expand Down Expand Up @@ -75,6 +75,13 @@ public void ScriptMain(IScriptInterface bot)
// Determine if MaxAll is enabled
bool maxAll = Bot.Config!.Get<bool>("MaxAll");

int potionQuant = 300;
if (!maxAll && (!int.TryParse(Bot.Config!.Get<string>("PotionQuant"), out potionQuant) || potionQuant is < 1 or > 300))
{
Core.Logger("Enter a Potion Quantity from 1 to 300.", messageBox: true, stopBot: true);
return;
}

// Prepare Potions and PotionsFarm arrays if MaxAll is true
string[]? potions = maxAll
? new[]
Expand Down Expand Up @@ -110,17 +117,6 @@ public void ScriptMain(IScriptInterface bot)
? [.. Enumerable.Repeat(true, potions!.Length)]
: null;

string? raw = Bot.Config!.Get<string>("PotionQuant");

int potionQuant;

if (!int.TryParse(raw, out potionQuant))
{
Core.Logger($"Invalid PotionQuant '{raw}', defaulting to 300");
potionQuant = 300;
}

potionQuant = maxAll ? 300 : potionQuant;
// Call the main potion farming method
INeedYourStrongestPotions(
Potions: potions,
Expand Down
5 changes: 4 additions & 1 deletion Story/0AllStories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,10 @@ public void CompleteAll()
Core.Logger($"Story: SuperDeath - Complete");

ThirdSpell.StoryLine();
Core.Logger($"Story: Third Spell - Complete");
if (Core.CheckInventory("Sun Token VIII", toInv: false))
Core.Logger("Story: Third Spell - Complete");
else
Core.Logger("Story: Third Spell - Sun Token VIII missing");

TitanAttackStory.DoAll();
Core.Logger($"Story: Titan Attack - Complete");
Expand Down
4 changes: 2 additions & 2 deletions Story/EtherstormWastes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public void FireStorm()
if (!Story.QuestProgression(1532))
{
Core.EnsureAccept(1532);
Core.HuntMonster("firestorm", "Sulfur Imp", "Sulfuric Core", 10);
Core.HuntMonster("firestorm", "Sulfur Imp", "Sulfuric Core", 8);
Core.HuntMonster("firestorm", "Sulfur Imp", "Enchanted Lava Bucket", 1);
Core.EnsureComplete(1532);
}
Expand Down Expand Up @@ -342,7 +342,7 @@ public void WaterStorm()
{
Core.EnsureAccept(1619);
Core.GetMapItem(843, 10, "waterstorm");
Core.HuntMonster("waterstorm", "Living Water", "Aqua Vitae", 15);
Core.HuntMonster("waterstorm", "Living Water", "Aqua Vitae", 12);
Core.HuntMonster("waterstorm", "Living Water", "Water Bubble Burst", 10);
Core.EnsureComplete(1619);
}
Expand Down
2 changes: 2 additions & 0 deletions Story/ThirdSpell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ void QuestLogic()
break;

case 4491: // 4491|Mother Knows The Sun
Core.AddDrop("Heart of the Sun");
Core.HuntMonster("thirdspell", "Solar Incarnation ", "Heart of the Sun Received");
break;

Expand All @@ -173,6 +174,7 @@ void QuestLogic()
break;

case 4493: // 4493|See the Hero Run
HeartoftheSun();
Core.GetMapItem(3677, map: "thirdspell");
break;
}
Expand Down
92 changes: 88 additions & 4 deletions Tools/FindBestPing.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
/*
name: Find Best Server Ping
description: will spit out the best server ( ping wise) into the logs ( diagnostics > logs )
name: Find Top 3 Best Server Pings
description: measures AQW handshake latency and logs the three fastest servers ( diagnostics > logs )
tags: server, ping, ultra
*/

//cs_include Scripts/CoreBots.cs

using Skua.Core.Interfaces;
using Skua.Core.Models.Servers;
using System.Diagnostics;
using System.Net.Sockets;
using System.Text;

public class FindBestPing
{
Expand All @@ -19,7 +23,7 @@ public async Task ScriptMain(IScriptInterface Bot)

try
{
string result = await Core.FindBestServer();
string result = await FindTopThreeServers();
Bot.Log(result);
}
finally
Expand All @@ -28,8 +32,88 @@ public async Task ScriptMain(IScriptInterface Bot)
}
}

/// <summary>
/// Finds the three fastest game servers by measuring actual AQW handshake latency.
/// Uses three samples per server and ranks servers by their median successful latency.
/// </summary>
private async Task<string> FindTopThreeServers()
{
List<Server> servers = await Bot.Servers.GetServers(true);
byte[] versionCheck = Encoding.UTF8.GetBytes("<msg t='sys'><body action='verChk' r='0'><ver v='165' /></body></msg>\0");
List<(Server Server, long Ping)> pingResults = new();

}
foreach (Server server in servers.Where(server =>
server.Online && !string.IsNullOrWhiteSpace(server.IP) && server.Port > 0))
{
List<double> samples = new(3);

for (int sample = 0; sample < 3; sample++)
{
try
{
Stopwatch stopwatch = Stopwatch.StartNew();
using TcpClient client = new();
await client.ConnectAsync(server.IP, server.Port).WaitAsync(TimeSpan.FromMilliseconds(2500));

using NetworkStream stream = client.GetStream();
await stream.WriteAsync(versionCheck.AsMemory());
await stream.FlushAsync();

using CancellationTokenSource timeout = new(2500);
byte[] buffer = new byte[1];
StringBuilder response = new();

while (!timeout.IsCancellationRequested)
{
int bytesRead = await stream.ReadAsync(buffer.AsMemory(), timeout.Token);
if (bytesRead == 0)
break;

if (buffer[0] != 0)
{
response.Append((char)buffer[0]);
continue;
}

string message = response.ToString();
response.Clear();

if (message.Contains("action='apiOK'", StringComparison.OrdinalIgnoreCase) ||
message.Contains("action=\"apiOK\"", StringComparison.OrdinalIgnoreCase))
{
stopwatch.Stop();
samples.Add(stopwatch.Elapsed.TotalMilliseconds);
break;
}

if (message.Contains("action='apiKO'", StringComparison.OrdinalIgnoreCase) ||
message.Contains("action=\"apiKO\"", StringComparison.OrdinalIgnoreCase))
break;
}
}
catch (OperationCanceledException) { }
catch (Exception) { }
}

if (samples.Count == 0)
continue;

samples.Sort();
long medianPing = (long)Math.Round(samples[samples.Count / 2], MidpointRounding.AwayFromZero);
pingResults.Add((server, medianPing));
}

List<(Server Server, long Ping)> bestServers = pingResults
.OrderBy(result => result.Ping)
.ThenBy(result => result.Server.Name, StringComparer.OrdinalIgnoreCase)
.Take(3)
.ToList();

if (bestServers.Count == 0)
return "Could not determine an optimal server, all hosts failed their AQW handshake.";

return $"Top {bestServers.Count} servers by AQW handshake latency:{Environment.NewLine}" +
string.Join(Environment.NewLine, bestServers.Select((result, index) =>
$"{index + 1}. {result.Server.Name} ({result.Server.IP}) - {result.Ping}ms"));
}
}
2 changes: 1 addition & 1 deletion Tools/ForDevelopers/FetchGameFiles/.last_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4000r8
4000r9
28 changes: 14 additions & 14 deletions scripts.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"null"
],
"path": "CoreFarms.cs",
"size": 166230,
"sha256": "0e031b1e29a3eb75344571bca6724d09c0cf90971f8561c2e46d37e1ec395bd7",
"size": 166215,
"sha256": "f088bdc5f3526b90f71ee33472e701e66820e1b296de91c9f282fb8d4a558829",
"fileName": "CoreFarms.cs",
"downloadUrl": "https://raw.githubusercontent.com/auqw/Scripts/Skua/CoreFarms.cs"
},
Expand Down Expand Up @@ -543,8 +543,8 @@
"thirdspell"
],
"path": "Story/ThirdSpell.cs",
"size": 22641,
"sha256": "b2c9db51d6ad76d5d3b8c34fb250f5af921fc224275e1a38d2cf5e76a27a914c",
"size": 22740,
"sha256": "c1914c6c866c4c562eae9794c902bef892d08d43d4620b74d9343011ec672690",
"fileName": "ThirdSpell.cs",
"downloadUrl": "https://raw.githubusercontent.com/auqw/Scripts/Skua/Story/ThirdSpell.cs"
},
Expand Down Expand Up @@ -1553,8 +1553,8 @@
"etherstorm-wastes"
],
"path": "Story/EtherstormWastes.cs",
"size": 20377,
"sha256": "80d627138f125ce6463719e5d05587d32e8bdec0cc11517844faccdca106cceb",
"size": 20376,
"sha256": "2493e5b4e4cfb40e31118aebb7df2f71a8a365242be22950069629ec9ffcfce5",
"fileName": "EtherstormWastes.cs",
"downloadUrl": "https://raw.githubusercontent.com/auqw/Scripts/Skua/Story/EtherstormWastes.cs"
},
Expand Down Expand Up @@ -2027,8 +2027,8 @@
"all"
],
"path": "Story/0AllStories.cs",
"size": 53768,
"sha256": "6cded52f5ed37c4ef0df1fc7e0f22acbae091bea59b2412cd467739502945e01",
"size": 53921,
"sha256": "08d827da65b6fd9d459d2c35ff34f30b829c3d81650d20dfb1cc18d42a448a3f",
"fileName": "0AllStories.cs",
"downloadUrl": "https://raw.githubusercontent.com/auqw/Scripts/Skua/Story/0AllStories.cs"
},
Expand Down Expand Up @@ -2371,16 +2371,16 @@
"downloadUrl": "https://raw.githubusercontent.com/auqw/Scripts/Skua/Tools/KPHandItemCounter.cs"
},
{
"name": "Find Best Server Ping",
"description": "will spit out the best server ( ping wise) into the logs ( diagnostics > logs )",
"name": "Find Top 3 Best Server Pings",
"description": "measures AQW handshake latency and logs the three fastest servers ( diagnostics > logs )",
"tags": [
"server",
"ping",
"ultra"
],
"path": "Tools/FindBestPing.cs",
"size": 672,
"sha256": "7a9090e3aa83c3c3e374b505a47d018284497118e965419b12da36517d67ae2b",
"size": 4504,
"sha256": "acc11db3f48f1b1825ba9be7957ee4485838dac020e0cd8183178a9611c90b7b",
"fileName": "FindBestPing.cs",
"downloadUrl": "https://raw.githubusercontent.com/auqw/Scripts/Skua/Tools/FindBestPing.cs"
},
Expand Down Expand Up @@ -16607,8 +16607,8 @@
"minecraft"
],
"path": "Other/Various/Potions.cs",
"size": 21219,
"sha256": "e0e0ed1750049ad154c6a54fd879a1046c00f724806fded37e94c2e9e3346fe8",
"size": 21204,
"sha256": "8944efe8329f7e67edd5b8b03dc261d88e6508cf9a8a7fdfc18c7638bef75177",
"fileName": "Potions.cs",
"downloadUrl": "https://raw.githubusercontent.com/auqw/Scripts/Skua/Other/Various/Potions.cs"
},
Expand Down
Loading