Code:
using System.Linq;
using Lib_K_Relay;
using Lib_K_Relay.GameData;
using Lib_K_Relay.Utilities;
using System;
using System****;
using System.Collections.Generic;
using Lib_K_Relay.Networking;
using Lib_K_Relay.Networking.Packets;
using Lib_K_Relay.Networking.Packets.Server;
using System.Text;
using Lib_K_Relay.Networking.Packets.Client;
using Lib_K_Relay.Networking.Packets.DataObjects;
using System.Net;
namespace ConsoleKRelay
{
/*PlayerShootPacket psp = (PlayerShootPacket)Packet.Create(PacketType.PLAYERSHOOT);
Console.WriteLine("Playershoot packet created!");
Console.WriteLine("Angle in radians: (floating point: ',')");
float rad = 0;
try
{
rad = float.Parse(Console.ReadLine());
if ((rad > (float)Math.PI * 2) || (rad < 0))
throw new OverflowException();
}
catch
{
Console.WriteLine("Invalid radians value. Max: " + Math.PI * 2 + " Min: 0");
return;
}
psp.Angle = rad;
psp.Position = curClient.PlayerData.Pos;
psp.BulletId = 1;
curClient.SendToServer(psp);
Console.WriteLine("Playershoot packet send!");*/
class Program
{
public static Boolean _enabled = true;
public static Boolean b;
public static int health = 6969;
public static Dictionary<int, List<Bullet>> bulletMap = new Dictionary<int, List<Bullet>>();
public static Dictionary<int, int> objectTypeMap = new Dictionary<int, int>();
public static readonly Dictionary<int, List<int>> armorPiercingBullets = new Dictionary<int, List<int>>(){
{1617, new List<int>(){0}},
{28958, new List<int>(){2}},
{28956, new List<int>(){2}},
{29339, new List<int>(){2}},
{29340, new List<int>(){2}},
{29021, new List<int>(){2,3}},
{29039, new List<int>(){1}},
{5952, new List<int>(){2}},
{3472, new List<int>(){0}},
{29070, new List<int>(){6}},
{29084, new List<int>(){0}},
{2354, new List<int>(){6}}
};
public static Client curClient;
public static Proxy _proxy = new Proxy();
static string PATH = Directory.GetCurrentDirectory() + "/settings.txt";
static string server;
static string filterdbg = "";
static ConsoleColor oldcolor;
public static List<string> name = new List<string>();
public static List<string> accountID = new List<string>();
public static List<string> blocklist = new List<string>();
static void Main(string[] args)
{
Console.WindowWidth += 30;
oldcolor = ConsoleColor.White;
Console.Title = "ConsoleKRelay";
LoadSettings();
Console.Clear();
Console.WriteLine("Welcome to ConsoleKRelay, a modified KRelay version by PKTINOS");
Console.WriteLine("Credits to KRelay team, and especially KrazyShank");
Console.WriteLine("--------------------------------------------------------------------------------------------------------------");
CustomCommands.LoadCommandsC();
Console.Write("[");Console.ForegroundColor = ConsoleColor.Yellow;Console.Write("ConsoleKRelay"); Console.ForegroundColor = oldcolor;Console.Write("]");
Console.WriteLine(" Loaded custom commands!");
Console.ForegroundColor = ConsoleColor.Cyan;
try
{
GameData.Load();
}catch(Exception ex)
{
Console.WriteLine(ex.InnerException.ToString());
}
Console.ForegroundColor = oldcolor;
Console.ForegroundColor = ConsoleColor.Gray;
try
{
}
catch { Console.WriteLine("No arguments found. Loading normally..");
}
Console.ForegroundColor = oldcolor;
_proxy = new Proxy();
Console.ForegroundColor = ConsoleColor.Green;
_proxy.Start();
Console.ForegroundColor = oldcolor;
_proxy.HookPacket(Lib_K_Relay.Networking.Packets.PacketType.MAPINFO, onMapInfo);
Console.WriteLine("Hooked client receiving magic.");
foreach (PacketType ptype in Enum.GetValues(typeof(PacketType)))
{
try
{
_proxy.HookPacket(ptype, onDebugMode);
}
catch { }
}
Console.WriteLine("Hooked every packet to debug state. Debugging: OFF");
_proxy.HookPacket(PacketType.PLAYERHIT, OnPlayerHit);
_proxy.HookPacket(PacketType.ENEMYSHOOT, OnShoot);
_proxy.HookPacket(PacketType.SERVERPLAYERSHOOT, OnShoot2);
_proxy.HookPacket(PacketType.AOE, OnAOE);
_proxy.HookPacket(PacketType.NEWTICK, OnNT);
_proxy.HookPacket(PacketType.UPDATE, OnUpdate);
_proxy.HookPacket(PacketType.MOVE, FreecamManager);
_proxy.HookPacket(PacketType.MAPINFO, onMapInfo);
_proxy.HookPacket(PacketType.ENEMYSHOOT, CustomCommands.onEnemyShoot);
_proxy.ClientDisconnected += OnDisconnect;
Console.WriteLine("## Loaded OpAutonexus - made by Tmwilliamlin168, updated by crazyjani. \n## Type command 'opautonexus' to enable/disable");
Console.WriteLine("## Currently: Enabled");
_enabled = true;
try { server = File.ReadAllText(PATH).Split('|')[1]; } catch { Console.WriteLine("settings.txt not found, or problem occurred. Setting server as EUNorth2"); server = "EUNorth2"; }
try { Proxy.DefaultServer = GameData.Servers.ByName(server).Address; }catch { Console.WriteLine("Server not found in settings.. Using EUNorth2"); server = "EUNorth2"; Proxy.DefaultServer = GameData.Servers.ByName(server).Address; }
Console.Write("["); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("ConsoleKRelay"); Console.ForegroundColor = oldcolor; Console.Write("]");
Console.WriteLine("ConsoleKRelay was loaded - Proxy started - Server:" + server);
Console.Write("["); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("ConsoleKRelay"); Console.ForegroundColor = oldcolor; Console.Write("]");
Console.WriteLine("You can run commands in the console. Type help for a list of commands.");
do
{
string[] com = Console.ReadLine().Split(' ')
;
List<string> args1 = new List<string>();
int i = 1;
do
{
try
{
args1.Add(com[i]);
i++;
}
catch
{
continue;
}
} while (i < com.Length);
if (isCommand(com[0].ToLower()))
{
Console.ForegroundColor = oldcolor;
runCommand(com[0].ToLower(), args1.ToArray());
}else
{
Console.Write("["); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("ConsoleKRelay"); Console.ForegroundColor = oldcolor; Console.Write("]");
Console.WriteLine(com[0] + " is not a command. Think it should it be added? Let me know.");
}
} while (true);
}
static bool FreecamActive = false;
static Location freezer;
private static void FreecamManager(Client client, Packet packet)
{
if (FreecamActive)
{
MovePacket move = (MovePacket)packet;
move.NewPosition = freezer;
move.Records = new LocationRecord[] { };
}
}
static string returnFixed(Packet packet,string s2)
{
if (s2 == "TEXT")
{
TextPacket t = (TextPacket)packet;
s2 += " | " + t.Text.Replace(" ", "") + " | By " + t.Name + " | (*" + t.NumStars.ToString() + ")";
}else if (s2 == "LOAD")
{
LoadPacket l = (LoadPacket)packet;
s2 += " | " + l.CharacterId;
}else if (s2 == "MAPINFO")
{
MapInfoPacket map = (MapInfoPacket)packet;
s2 += " | Name:" + map.DisplayName + " | Max x: " + map.Width + " | Max y: " + map.Height;
} else if (s2 == "RECONNECT")
{
ReconnectPacket r = (ReconnectPacket)packet;
s2 += " | Going to: " + r.Name + " | " + r.Host.ToString();
}
else if (s2 == "PLAYERSHOOT")
{
PlayerShootPacket ps = (PlayerShootPacket)packet;
s2 += " | Radians: " + ConvertDECAtoRadians(ps.Angle) + " | Deca angle measurement:" + ps.Angle +"| X:" + ps.Position.X + " Y: " + ps.Position.Y + " | BID: " + ps.BulletId.ToString() + " | WeaponID: " + ps.ContainerType.ToString();
}
else if (s2 == "MOVE")
{
MovePacket m = (MovePacket)packet;
s2 += " | Position of player: (" + m.NewPosition.X + " | " + m.NewPosition.Y + ")" + " | TICKID: " + m.TickId + " | Time:" + m.Time + " | ClientTime:" + curClient.Time + " | PrevTime:" + curClient.PreviousTime;
}
else if (s2 == "ENEMYSHOOT")
{
EnemyShootPacket e = (EnemyShootPacket)packet;
s2 += " | Radians: " + ConvertDECAtoRadians(e.Angle) + " | BulletAmount: " + e.NumShots.ToString() + " | Damage: " + e.Damage;
}else if (s2 == "NEWTICK")
{
NewTickPacket n = (NewTickPacket)packet;
s2 += " | TickID: " + n.TickId + " | TickTime:" + n.TickTime + " | Statuses length: " + n.Statuses.Count();
}
else if (s2 == "ESCAPE")
{
s2 += " | Health at nexus: " + curClient.PlayerData.Health;
}else if(s2 == "ALLYSHOOT")
{
AllyShootPacket a = (AllyShootPacket)packet;
s2 += " | Radians: " + ConvertDECAtoRadians(a.Angle) + " | WeaponID: " + *****ntainerType.ToString() + " | Send by:" + a.OwnerId;
}else if(s2 == "DAMAGE")
{
DamagePacket d = (DamagePacket)packet;
s2 += " | Damage: " + d.Damage + " | Effect: " + d.Effects + " | Target: " + d.TargetId + " | Killed: " + d.Killed.ToString();
}else if (s2 == "PLAYSOUND")
{
PlaySoundPacket ps = (PlaySoundPacket)packet;
s2 += " | SoundID: " + ps.SoundId;
}else if (s2 == "PLAYERHIT")
{
PlayerHitPacket ph = (PlayerHitPacket)packet;
s2 += " | Hit by BID: " + ph.BulletId + " | PlayerhitOID:" + ph.ObjectId + " | Your objectID:" + curClient.ObjectId;
}else if (s2 == "HELLO")
{
HelloPacket h = (HelloPacket)packet;
s2 += " | GUID:" + h.GUID + " | Pass:" + h.Password + " | Random1:" + h.Random1 +" | " + h.Random2;
}else if(s2 == "SHOWEFFECT")
{
ShowEffectPacket s = (ShowEffectPacket)packet;
s2 += " | Color:" + s.Color.R + "," + s.Color.G + "," + s.Color.B + " | EffectType:" + (int)s.EffectType + " | TargetID:" + s.TargetId + " | Your ID:" + curClient.ObjectId;
;
}else if (s2 == "INVSWAP")
{
InvSwapPacket isp = (InvSwapPacket)packet;
s2 += " | Loc:" + isp.Position.X + "|" + isp.Position.Y + " | SlotIDS { SlotObject1:" + isp.SlotObject1.SlotId + " SlotObject2:" + isp.SlotObject2.SlotId + " } | ObjectID1:" + isp.SlotObject1.ObjectId + " | " + isp.SlotObject2.ObjectId;
}
return s2;
}
public static byte lastid;
private static void onDebugMode(Client client, Packet packet)
{
string s2 = (packet.ToString().Split('(')[0]);
if (s2 == "NAMERESULT")
{
NameResultPacket cn = (NameResultPacket)packet;
cn.ErrorText = "";
cn.Success = true;
}
if (s2 == "PLAYERSHOOT")
{
PlayerShootPacket ps = (PlayerShootPacket)packet;
lastid = ps.BulletId;
}
if (blocklis*****ntains(s2.ToLower()))
{
packet.Send = false;
}
if (debugging)
{
if (filterdbg == "")
{
s2 = returnFixed(packet, s2);
Console.WriteLine(s2);
}
else
{
if(s2 == filterdbg)
{
s2 = returnFixed(packet, s2);
Console.WriteLine(s2);
}
}
}
}
public static float ConvertDECAtoRadians(float Decadians)
{
if (Decadians < 0)
{
return Decadians * -1f;
}
else
{
return 2 * float.Parse(Math.PI.ToString()) - Decadians;
//x = xCenter + r * cos(theta)
//y = yCenter + r * sin(theta)
}
}
public static float RadiansToDecadians(float Radians)
{
if (Radians < Math.PI)
{
return Radians * -1f;
}
else
{
return 2 * (float)Math.PI - Radians;
}
}
private static void onMapInfo(Client client, Packet packet)
{
try
{
name.Clear();
accountID.Clear();
curClient = client;
}
catch
{
}
}
static bool isCommand(string s)
{
if (CustomCommands.customs.ToArray().Contains(s)){
CustomCommands.RunCustom(s, curClient);
return true;
}
else {
if (s == ("help") || s == ("customize") || s == ("send") || s == ("changeserv") || s == ("debugmode") || s == "block" || s == "unblock" || s=="clearblock" || s =="opautonexus" || s == "freecam")
{
return true;
} }
return false;
}
static bool debugging = false;
static void runCommand(string s, string[] args)
{
if (s == "debugmode")
{
if (!debugging)
{
Console.Title = "ConsoleKRelay - type debugmode and press enter to stop";
debugging = true;
Console.WriteLine("Debugging mode activated! \n");
try {
if (args[0] !="")
{
filterdbg = args[0].ToUpper();
}else
{
Console.WriteLine("No filter found, will debug each packet");
filterdbg = "";
}
}
catch
{
Console.WriteLine("No filter found, will debug each packet");
filterdbg = "";
}
}
else { Console.Title = "ConsoleKRelay"; debugging = false; Console.WriteLine("Debugging mode deactivated!");filterdbg = ""; }
}
if (s == "help")
{
if (args.Length < 1)
{
string sss = "";
foreach (string a in CustomCommands.customs)
{
sss += Environment.NewLine + a;
}
Console.WriteLine(@"ConsoleKRelay commands:
help - Displays this message.
help <COMMAND> - Gives extra details about a command.
freecam - Initiates freecam
customize - Lists themes.
customize <THEME> <SERVER> - Sets theme and default server. (Servers are case sensitive)
send - Initializes packet sender
block <PACKET> - Blocks certain packet (EG: block allyshoot (prevents lag)) (Not case sensitive)
unblock <PACKET> - Unblock certain packet
clearblock - Unblock each packet
debugmode - Toggle between debug mode. Debug mode prints each packet you get.
opautonexus - Activates op autonexus. Made by tmwilliamlin168, updated by CrazyJani
(ConsoleKRelay allows you to change your name to whatever you want, visit the golden statue)
(no gold wasted for that ^, but also only you see it. Great for streamers)
Custom commands ###########################################
" + sss + Environment.NewLine);
return;
}
else
{
if (args[0] == "help") Console.WriteLine("Woah, that's like MetaHelp");
if (args[0] == "debugmode") Console.WriteLine("Displays the name of each packet you receive");
if (args[0] == "customize") Console.WriteLine("Change default server and theme.");
if (args[0] == "send") Console.WriteLine("Initializes packet sender. Follow the instructions from there to create and send a packet.");
if (args[0] == "block") Console.WriteLine("Blocks a packet. Packet names are the same as in the packettype enum, but not case sensitive.");
if (args[0] == "unblock") Console.WriteLine("Unblocks a packet.");
if (args[0] == "opautonexus") Console.WriteLine("Loads OPAutonexus which is built-in consolekrelay.");
if (args[0] == "freecam") Console.WriteLine("Freecam mode. Move around without others seeing your position update");
}
}
else if (s == "send")
{
try
{
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine(@"Packet sender initialized!
Select packet to send: (not case sensitive)
PLAYERTEXT
ESCAPE
PLAYERSHOOT
GOTO (to client) (auto ignore gotoack)");
string packetsend = Console.ReadLine();
if (packetsend.ToLower() == "playertext")
{
PlayerTextPacket ptp = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
Console.WriteLine("Playertext packet created!");
Console.WriteLine("Insert text to send:");
ptp.Text = Console.ReadLine();
curClient.SendToServer(ptp);
Console.WriteLine("Packet send successfully!");
return;
}
else if (packetsend.ToLower() == "escape")
{
EscapePacket esc = (EscapePacket)Packet.Create(PacketType.ESCAPE);
Console.WriteLine("Escape packet created! Press enter to escape to the nexus.");
Console.ReadLine();
curClient.SendToServer(esc);
return;
}
else if (packetsend.ToLower() == "playershoot")
{
PlayerShootPacket ps = (PlayerShootPacket)Packet.Create(PacketType.PLAYERSHOOT)
;
Console.WriteLine("Angle in radians: (floating point: ',')")
;
float rad = float.Parse(Console.ReadLine());
if (rad > Math.PI * 2 || rad < 0)
{
Console.WriteLine("Your angle must be in radians. Min: 0 - Max: pi * 2 (" + (Math.PI * 2).ToString() + ")");
Console.ForegroundColor = oldcolor;
return;
}
else
{
ps.Angle = RadiansToDecadians( rad);
ps.ContainerType = (short)curClient.PlayerData.Slot[0];
Console.WriteLine(curClient.PlayerData.Slot[0].ToString());
lastid++;
ps.BulletId = lastid;
ps.Position = curClient.PlayerData.Pos;
ps.Time = curClient.Time;
curClient.SendToServer(ps);
Console.WriteLine("Playershoot packet send!");
}
}else if (packetsend.ToLower() == "goto")
{
GotoPacket gotox = (GotoPacket)Packet.Create(PacketType.GOTO);
Console.WriteLine("Goto packet created!");
Console.WriteLine("Current position: " + curClient.PlayerData.Pos.X + "," + curClient.PlayerData.Pos.Y);
Console.WriteLine("New X,Y (format like current position):");
string temp = Console.ReadLine();
gotox.ObjectId = curClient.ObjectId;
gotox.Location = new Location(float.Parse(temp.Split(',')[0]), float.Parse(temp.Split(',')[1]));
runCommand("block", new string[] { "gotoack" });
curClient.SendToClient(gotox);
System.Threading.Thread.Sleep(200);
runCommand("unblock", new string[] { "gotoack" });
Console.WriteLine("Goto send successfully!");
}
else
{
Console.WriteLine("Invalid packet");
}
Console.ForegroundColor = oldcolor;
} catch (Exception ex)
{
Console.WriteLine("\n\nException occurred: \n\n\n\n " + ex.ToString());
}
return;
}
else if (s == "customize")
{
if (args.Length < 2)
{
Console.WriteLine("Themes: \n Default \n Blue \n Pink \n Mustard");
}
else
{
string sssss = args[0] + "|" + args[1];
File.WriteAllText(PATH, sssss);
Console.WriteLine("New settings saved!");
}
}else if (s == "freecam")
{
if (!FreecamActive)
{
freezer = curClient.PlayerData.Pos;
FreecamActive = true;
Console.WriteLine(" <O> Freecam activated!");
}else
{
GotoPacket gotox = (GotoPacket)Packet.Create(PacketType.GOTO);
gotox.ObjectId = curClient.ObjectId;
gotox.Location = freezer;
runCommand("block", new string[] { "gotoack" });
curClient.SendToClient(gotox);
System.Threading.Thread.Sleep(500);
runCommand("unblock", new string[] { "gotoack" });
FreecamActive = false;
Console.WriteLine(" <O> Freecam deactivated!");
}
}
else if (s == "opautonexus")
{
if (_enabled)
{
_enabled = false;
Console.WriteLine("## Opautonexus disabled");
return;
}
else _enabled = true; Console.WriteLine("## Opautonexus enabled");
}
else if (s == "block")
{
blocklist.Add(args[0].ToLower());
Console.WriteLine("Now blocking " + args[0]);
}
else if (s == "unblock")
{
if (blocklis*****ntains(args[0].ToLower()))
{
blocklist.Remove(args[0].ToLower());
Console.WriteLine("Removed from blocking: " + args[0]);
}
}
else if (s == "clearblock")
{
blocklist.Clear();
Console.WriteLine("Cleared block list! Now not blocking any packets!");
}
}
static void LoadSettings()
{
try
{
string[] s = File.ReadAllText(PATH).Split('|');
if (s[0] == "default") return;
if (s[0] == "blue") { Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.Blue; }
if (s[0] == "pink") { Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.DarkMagenta; }
if (s[0] == "mustard") { Console.ForegroundColor = ConsoleColor.DarkYellow; Console.BackgroundColor = ConsoleColor.Black; }
server = s[1];
oldcolor = Console.ForegroundColor;
} catch(Exception ex)
{
Console.Write("["); Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("ConsoleKRelay"); Console.ForegroundColor = oldcolor; Console.Write("]");
Console.WriteLine("Exception occured while trying to load your settings! \n\n\n" + ex.ToString());
}
}
static void OnUpdate(Client client, Packet packet)
{
UpdatePacket up = (UpdatePacket)packet;
foreach (Entity entity in up.NewObjs)
if (armorPiercingBullets.ContainsKey(entity.ObjectType) && !objectTypeMap.ContainsKey(entity.Status.ObjectId))
objectTypeMap.Add(entity.Status.ObjectId, entity.ObjectType);
}
static void OnDisconnect(Client client)
{
bulletMap.Clear();
objectTypeMap.Clear();
}
static void OnNT(Client client, Packet packet)
{
//Update health vitality
health += (int)(0.2 + client.PlayerData.Vitality * 0.024);
NewTickPacket ntPacket = packet as NewTickPacket;
foreach (Status status in ntPacket.Statuses)
if (status.ObjectId == client.ObjectId && !b)
foreach (StatData stat in status.Data)
if (stat.Id == StatsType.HP)
health = stat.IntValue;
b = false;
}
static void OnPlayerHit(Client client, Packet packet)
{
b = true;
PlayerHitPacket phPacket = packet as PlayerHitPacket;
int originalDamage = 0;
int bulletType = -1;
foreach (Bullet bullet in bulletMap[phPacket.ObjectId])
{
if (bullet.id == phPacket.BulletId)
{
originalDamage = bullet.damage;
bulletType = bullet.type;
}
}
int damageEstimate = getDamageEstimate(originalDamage, client.PlayerData.Defense);
//See if armor piercing or not
if (objectTypeMap.ContainsKey(phPacket.ObjectId))
if (armorPiercingBullets[objectTypeMap[phPacket.ObjectId]].Contains(bulletType))
damageEstimate = originalDamage;
health -= damageEstimate;
if (health < 0.1 * client.PlayerData.MaxHealth && _enabled)
{
packet.Send = false;
client.SendToServer(Packet.Create(PacketType.ESCAPE));
Console.WriteLine("## OPAutoNexus saved you at " + health + " health");
}
}
static void OnShoot(Client client, Packet packet)
{
EnemyShootPacket sPacket = (EnemyShootPacket)packet;
for (int i = 0; i < sPacket.NumShots; i++)
if (bulletMap.ContainsKey(sPacket.OwnerId))
bulletMap[sPacket.OwnerId].Add(new Bullet { id = sPacket.BulletId + i, type = sPacket.BulletType, damage = sPacket.Damage });
else
bulletMap[sPacket.OwnerId] = new List<Bullet> { new Bullet { id = sPacket.BulletId + i, type = sPacket.BulletType, damage = sPacket.Damage } };
}
static void OnShoot2(Client client, Packet packet)
{
ServerPlayerShootPacket sPacket = (ServerPlayerShootPacket)packet;
if (bulletMap.ContainsKey(sPacket.OwnerId))
bulletMap[sPacket.OwnerId].Add(new Bullet { id = sPacket.BulletId, type = -1, damage = sPacket.Damage });
else
bulletMap[sPacket.OwnerId] = new List<Bullet> { new Bullet { id = sPacket.BulletId, type = -1, damage = sPacket.Damage } };
}
static void OnAOE(Client client, Packet packet)
{
AoEPacket aoePacket = (AoEPacket)packet;
if (client.PlayerData.Pos.DistanceSquaredTo(aoePacket.Location) <= aoePacket.Radius * aoePacket.Radius)
{
b = true;
health -= getDamageEstimate(aoePacket.Damage, client.PlayerData.Defense);
if (health < 0.1f * client.PlayerData.MaxHealth && _enabled)
{
aoePacket.Send = false;
client.SendToServer(Packet.Create(PacketType.ESCAPE));
Console.WriteLine("AutoNexus saved you at " + health + " health");
}
}
}
static public int getDamageEstimate(int baseDamage, int defense)
{
int damage = baseDamage - defense;
if (damage < 0.15 * baseDamage)
damage = (int)(0.15 * baseDamage);
return damage;
}
}
public class Bullet
{
// Token: 0x04000001 RID: 1
public int id;
// Token: 0x04000002 RID: 2
public int type;
// Token: 0x04000003 RID: 3
public int damage;
}
}
Code:
using Lib_K_Relay.GameData;
using Lib_K_Relay.Networking;
using Lib_K_Relay.Networking.Packets;
using Lib_K_Relay.Networking.Packets.Client;
using Lib_K_Relay.Networking.Packets.Server;
using Lib_K_Relay.Utilities;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System****;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Security.Cryptography;
namespace ConsoleKRelay
{
class CustomCommands
{
static bool showESP = false;
static bool allah;
private static TcpClient _serverconnection;
public static List<string> customs = new List<string>();
public static void LoadCommandsC()
{
customs.Add("logoprint");
customs.Add("anhero");
customs.Add("clear");
customs.Add("restart");
customs.Add("allah");
customs.Add("bulletesp");
}
public static void RunCustom(string command,Client client)
{
try {
if (command == "anhero")
{
DeathPacket death = (DeathPacket)Packet.Create(PacketType.DEATH);
death.KilledBy = " god.";
death.AccountId = client.PlayerData.AccountId;
death.CharId = (int)Classes****gue;
death.ZombieId = -1;
death.ZombieType = -1;
client.SendToClient(death);
Console.WriteLine("He was an hero :(");
Console.WriteLine("You are not dead. Restart client.");
}
else if (command == "logoprint")
{
logoprint(client);
}
else if (command == "clear") { clear(); }
else if (command == "restart")
{
try { Process.Start(Directory.GetCurrentDirectory() + "/ConsoleKRelay.exe"); System.Threading.Thread.Sleep(200); Environment.Exit(0); } catch { Console.WriteLine("Rename of consoleKRelay detected! How dare you! We can't restart like this.."); return; }
}
else if (command == "allah")
{
if (!allah)
{
allah = true;
Console.WriteLine("Weapon id to shoot with: (blank for own weapon)");
string temp = Console.ReadLine();
short container = 3074;
if (temp == "")
{
container = (short)client.PlayerData.Slot[0];
}
else
{
try
{
container = short.Parse(temp);
}
catch
{
Console.WriteLine("Invalid input.. If you did hexadecimal, try decimal format. \nWill use doom bow.");
container = 3074;
}
}
i = 0; int j = 0;
float ang = 0.1f;
(new Thread(() =>
{
Random rand = new Random();
do
{
AllyShootPacket ally = (AllyShootPacket)Packet.Create(PacketType.ALLYSHOOT);
TextPacket tp = (TextPacket)Packet.Create(PacketType.TEXT);
ally.Angle = Program.RadiansToDecadians(ang);
ang += 0.1f;
if (ang > 6.27f)
{
ang = 0.1f;
}
ally.BulletId = (byte)j;
i++;
j++;
if (j == byte.MaxValue)
{
j = 0;
}
ShowEffectPacket show = (ShowEffectPacket)Packet.Create(PacketType.SHOWEFFECT);
show.PosA = new Lib_K_Relay.Networking.Packets.DataObjects.Location((float)(client.PlayerData.Pos.X + 5 * Math.Cos(ang)), (float)(client.PlayerData.Pos.Y + 5 * Math.Sin(ang)));
show.PosB = client.PlayerData.Pos;
show.EffectType = EffectType.Throw;
show.Color = new ARGB(255, 255, 0, 157);
show.TargetId = client.ObjectId;
ally.ContainerType = container;
ally.OwnerId = client.ObjectId;
client.SendToClient(ally);
client.SendToClient(show);
System.Threading.Thread.Sleep(15);
} while (allah && Program.curClien*****nnected);
Console.WriteLine(i.ToString() + " shots sent.");
})).Start();
}
else
{
allah = false;
Console.WriteLine("Deactivated :(");
}
} else if (command == "bulletesp")
{
onESPCOM(Program.curClient, "", new string[] { });
}
//Add more commands here with following the pattern (add it in loadcommandsc as well)
}
catch (Exception ex) { Console.WriteLine("###########" + Environment.NewLine + ex.ToString() + "###########"); }
}
static uint i;
private static void clear()
{
Console.Clear();
}
static void logoprint(Client client)
{
Console.WriteLine("Hooray for ConsoleKRelay");
ascii(client);
}
static async void ascii(Client client)
{
PlayerTextPacket ptp = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
ptp.Text = "__________[_][=][X]";
client.SendToServer(ptp);
await Task.Delay(650);
PlayerTextPacket ptp1 = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
ptp1.Text = "|Console------------|";
client.SendToServer(ptp1);
await Task.Delay(650);
PlayerTextPacket ptp2 = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
ptp2.Text = "|----------KRelay---|";
client.SendToServer(ptp2);
await Task.Delay(650);
PlayerTextPacket ptp3 = (PlayerTextPacket)Packet.Create(PacketType.PLAYERTEXT);
ptp3.Text = "|_______________|";
client.SendToServer(ptp3);
await Task.Delay(650);
}
private static void onESPCOM(Client client, string command, string[] args)
{
if (!showESP)
{
showESP = true;
Console.WriteLine("\n\n\nESP activated. Please activate particles on client\n\n\n");
}
else
{
showESP = false;
Console.WriteLine("ESP de-activated.");
}
}
public static void onEnemyShoot(Client client, Packet packet)
{
if (showESP)
{
EnemyShootPacket es = (EnemyShootPacket)packet;
double distance = Math.Sqrt(Math.Pow((Math****und(es.Location.X - client.PlayerData.Pos.X)), 2) + Math.Pow((Math****und(es.Location.Y - client.PlayerData.Pos.Y)), 2));
if (distance >= 10)
{
return;
}
if (es.NumShots > 1)
{
int i = 0;
do
{
ShowEffectPacket sep = (ShowEffectPacket)Packet.Create(PacketType.SHOWEFFECT);
sep.Color = randomColor(es.Damage);
sep.EffectType = EffectType.Stream;
sep.PosA = es.Location;
float newX = es.Location.X + 35f * (float)Math.Cos(RadiansToDecadians(es.Angle + es.AngleInc * i));
float newY = es.Location.Y - 35f * (float)Math.Sin(RadiansToDecadians(es.Angle + es.AngleInc * i));
sep.PosB = new Lib_K_Relay.Networking.Packets.DataObjects.Location(newX, newY);
sep.TargetId = es.OwnerId;
client.SendToClient(sep);
i++;
} while (i < es.NumShots);
}
else
{
ShowEffectPacket sep = (ShowEffectPacket)Packet.Create(PacketType.SHOWEFFECT);
sep.Color = randomColor(es.Damage);
sep.EffectType = EffectType.Stream;
sep.PosA = es.Location;
float newX = es.Location.X + 35f * (float)Math.Cos(RadiansToDecadians(es.Angle));
float newY = es.Location.Y - 35f * (float)Math.Sin(RadiansToDecadians(es.Angle));
sep.PosB = new Lib_K_Relay.Networking.Packets.DataObjects.Location(newX, newY);
sep.TargetId = es.OwnerId;
client.SendToClient(sep);
}
}
}
public static float RadiansToDecadians(float Radians)
{
if (Radians < Math.PI)
{
return Radians * -1f;
}
else
{
return 2 * (float)Math.PI - Radians;
}
}
public static ARGB randomColor(int damage)
{
return new ARGB(255, 0, 0, 255);
}
}
}
You can add more console commands to the customcommands class.