PostMovement Framework

Posts 17 of 7 · Page 1 of 1
Movement Framework
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:

Code:
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
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:
Quote Originally Posted by 483 View Post
@tmwilliamlin168 Looks like its what you were looking for!
???
Nice tutorial, but you can tell that this sends goto packets all the time, which are messy, and can cause dcs.
I already use exactmove.
Quote Originally Posted by RigBan View Post
Why test this in the laggiest server lol
I rarely lag on ROTMG

- - - Updated - - -

Quote Originally Posted by tmwilliamlin168 View Post
???
Nice tutorial, but you can tell that this sends goto packets all the time, which are messy, and can cause dcs.
I already use exactmove.
I'm not sure what you mean by "This sends goto packets all the time, which are messy". I can send you the source and you can check yourself how often gotopackets are sent in my method.

There is a "pending" variable which is incremented when a goto packet is sent. The "pending" value is then decreased when the GOTO ACK packet is stopped. A new goto packet will not be sent unless the "pending" value is equal to zero. This is a pretty solid solution to stop you from getting d/c'd as often.

You can see this fallback had to be used in the first gif (watch the log)
Quote Originally Posted by pixelzerg View Post
I rarely lag on ROTMG

- - - Updated - - -



I'm not sure what you mean by "This sends goto packets all the time, which are messy". I can send you the source and you can check yourself how often gotopackets are sent in my method.

There is a "pending" variable which is incremented when a goto packet is sent. The "pending" value is then decreased when the GOTO ACK packet is stopped. A new goto packet will not be sent unless the "pending" value is equal to zero. This is a pretty solid solution to stop you from getting d/c'd as often.

You can see this fallback had to be used in the first gif (watch the log)
I tried to use this before but then what happened was that when i tried to walk on water or lava, the speed is supposed to be slower, but the goto packets that i sent made it move faster than it should. Also, sometimes it accidentally walks into walls and objects.
Why test this in the laggiest server lol
Quote Originally Posted by pixelzerg View Post
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:

Code:
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
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:
How can you add this to K-Relay? I've created a .dll file under notepad with the demo code, added it to the plugins but get an error saying its a "manifest." Halp pls
Posts 17 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?