Here's a movement framework for K Relay. BTW: This post is aimed at people who write plugins for K Relay.
I did make a K Relay Movement framework before I quit ROTMG. I felt rather bored so I looked at the source code for it and I really can't believe how terrible the code was >.<
Well, after all, I was very new to making plugins and stuff.
Well, I'm back with an immensely improved K Relay Move Framework (and I coded it in a quarter of the time it took for me to make the first one).
How to use it
It uses a basic linear interpolation algorithm with the distance between the points being the projected speed (tiles per second). Since ROTMG doesn't provide us with this value, it must be calculated and thus there is a "care" variable which can be adjusted to make the calculation more cautious (i.e move slower) and thus increase the chance of not getting d/c'd. The care value's default is 1, decreasing it will make it less careful (but faster) and increasing it will make it slower but less likely to get disconnected.
To use it just reference the .dll, get the non-static client class (PZClient) for the client by enumerating through the clientlist variable of type List<PZClient> in the KRelayMove.Core class and checking if the client names match. I've already made a method for this which can be used like so:
PZClient client = KrelayMove.Core.Clientlist[KRelayMove.Core.IndexOfClient(client)];
PS: The PZClient has a NT(); method and GACK(); method which are invoked when the NEWTICK packet and GOTOACK packets are fired. You do not need to handle this, this is already handled by the plugin. To move the client just invoke the StartMove(); method on the PZClient object:
Code:
pzclient.StartMove(new Location(){ X=135; Y=140; });
In summary, if you want to move the client just run this line of code:
Code:
KrelayMove.Core.Clientlist[KRelayMove.Core.IndexOfClient(client)].StartMove(new Location(){ X=135; Y=140; });
The plugin will handle the rest!
This probably isn't worth releasing in the releases section so if you want it just let me know.
Here's it doing something that the old framework failed miserably at (moving from the top of the nexus to the middle):
UPDATE:
Here's a demo:
Demo Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Lib_K_Relay;
using Lib_K_Relay.Networking;
using Lib_K_Relay.Networking.Packets.Client;
using Lib_K_Relay.Networking.Packets.DataObjects;
using Lib_K_Relay.Networking.Packets.Server;
using Lib_K_Relay.Utilities;
using Lib_K_Relay.Networking.Packets;
namespace KRelayFollow
{
public class Core : Lib_K_Relay.Interface.IPlugin
{
#region iplugin
public string GetAuthor()
{
return "PixelZerg";
}
public string GetName()
{
return this.GetType().Namespace;
}
public string GetDescription()
{
return this.GetType().Namespace;
}
public string[] GetCommands()
{
return new string[] { "/followme" };
}
#endregion
public List<Client> clientlist = new List<Client>();
private Client target = null;
private bool enabled = false;
public void Initialize(Proxy p)
{
p.ClientConnected += ClientConnected;
p.ClientDisconnected += ClietnDisconnected;
p.HookPacket<NewTickPacket>(NT);
p.HookCommand("followme", COM);
}
private void ClietnDisconnected(Client client)
{
clientlist.Remove(client);
}
private void ClientConnected(Client client)
{
clientlist.Add(client);
}
public void COM(Client client, string com, string[] args)
{
try
{
enabled = Boolean.Parse(args[0]);
}
catch
{
target = client;
}
}
public void NT(Client client, Packet packet)
{
if (client == target)
{
foreach (var cli in clientlist)
{
if (cli != target)
{
KRelayMove.Core.clientlist[KRelayMove.Core.IndexOfClient(cli)].StartMove(target.PlayerData.Pos);
}
}
}
}
}
}
Demo:
