Skip to content
Open
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
2 changes: 1 addition & 1 deletion Apps/GetItemNames/GetItemNames.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ReleaseVersion>0.1.3</ReleaseVersion>
</PropertyGroup>

Expand Down
62 changes: 61 additions & 1 deletion Apps/GetItemNames/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,63 @@ private static void SendItemNamesRequests()
_client.Connection.SendToServer(firstPacket);
}


public class GetCreatureIdAndName : LookAtCreature
{
public GetCreatureIdAndName(Client client, uint id) : base(client)
{
Client = client;
PacketType = ClientPacketType.LookAtCreature;
CreatureId = id;

}
}


private static void SendCreatureLookRequests()
{
StringBuilder sb = new StringBuilder();

ushort from = 0;
ushort to = 1000;


_client.Connection.OnReceivedServerMessagePacket += (packet) =>
{
var creatureLookPacket = (OXGaming.TibiaAPI.Network.ServerPackets.Message)packet;

if (creatureLookPacket.MessageMode == MessageModeType.Look)
{
Console.WriteLine($"Received message: {creatureLookPacket.Text}");
}

if (!string.IsNullOrEmpty(creatureLookPacket.Text))
{
sb.AppendLine($"[{to}] {creatureLookPacket.Text}");
}

if (to != 1000)
{
from = to;
to += 1;

var nextPacket = new GetCreatureIdAndName(_client, to);
_client.Connection.SendToServer(nextPacket);
}
else
{
System.IO.File.WriteAllText(@"./creature_names.txt", sb.ToString());
Console.WriteLine("Done. Creature names have been written to ./creature_names.txt.");
}

return true;
};


var firstPacket = new GetCreatureIdAndName(_client, to);
_client.Connection.SendToServer(firstPacket);
}

public static int IndexOfSequence(byte[] buffer, byte[] pattern, int startIndex)
{
int i = Array.IndexOf<byte>(buffer, pattern[0], startIndex);
Expand Down Expand Up @@ -205,7 +262,7 @@ static void Main(string[] args)
Console.WriteLine($@"Usage:
1. Start this program (already done).
2. Login to a Tibia server that is not protected by Battleye (Zuna/Zunera) using the client at ""{tibiaApiClientPath}"".
3. Write 'send' in this terminal once your character is online.
3. Write 'send' or 'mon' in this terminal once your character is online.
");

bool exit = false;
Expand All @@ -217,6 +274,9 @@ 3. Write 'send' in this terminal once your character is online.
case "send":
SendItemNamesRequests();
break;
case "mon":
SendCreatureLookRequests();
break;
case "quit":
exit = true;
break;
Expand Down