K Relay Move - A framework for simulating movement with K Relay
This is a release aimed at coders.
Introducing: KRelayMove!
This framework makes it much easier making your client move with K Relay.
The entire complex process is reduced down to one line:
KRelayMove.MoveClient(client, KRelayMove.Direction.up, 5)
Documentation
Moving the Client
Moving the client is simple and is done with the MoveClient method.
The required variables are:
(Client, Direction, int, float)
Client
The K Relay client object that you want to move
Direction
The K_RelayMove.KRelayMove.Direction variable; the direction that you want the client to move
int
The amount of "steps" you want the client to move.
float
The distance you want the client to move per "step" (basically speed) This variable is not necessary. If not defined, the highest possible amount will be used. If you define a value higher than the highest possible amount, the client will be disconnected.
mClient Class
This class contains all the data about every client connected.
To find the corresponding mClient object to any client:
mClient mclient = KRelayMove.clientlist[KRelayMove.IndexOfClient(client)];
Usage Tutorial
Step1:

Add a reference to your project

Click "browse" and refrence the attatched .dll file

Add the line of code "using K_RelayMove" at the top of your file
Remember you will need to put the K RelayMove.dll file in the K Relay plugin folder along with your .dll file for it to function.
Demo
Here's a quick demo that I made. It only supports 2 clients. Do /follow to proclaim yourself as the one to follow the other client.
The demo script in action:

In-Game Commands
If you place this .dll file in the plugin folder by itself, there are still a few commands you can do in game
to see how the plugin works:
/move up:down:left:right [amount]
This will move your client the specified direction the specified amount. But you probably won't find yourself using that command too often.
This file is meant to be used as a framework not as a standalone plugin :p
Credits:
jex4334
Psifour
059
for helping me figure out how to programatically make a client move.
I also used a method from Jex's code that calculates the client's speed in tiles per second.
Introducing: KRelayMove!
This framework makes it much easier making your client move with K Relay.
The entire complex process is reduced down to one line:
KRelayMove.MoveClient(client, KRelayMove.Direction.up, 5)
Documentation
Moving the Client
Moving the client is simple and is done with the MoveClient method.
The required variables are:
(Client, Direction, int, float)
Client
The K Relay client object that you want to move
Direction
The K_RelayMove.KRelayMove.Direction variable; the direction that you want the client to move
int
The amount of "steps" you want the client to move.
float
The distance you want the client to move per "step" (basically speed) This variable is not necessary. If not defined, the highest possible amount will be used. If you define a value higher than the highest possible amount, the client will be disconnected.
mClient Class
This class contains all the data about every client connected.
To find the corresponding mClient object to any client:
mClient mclient = KRelayMove.clientlist[KRelayMove.IndexOfClient(client)];
Usage Tutorial
Step1:

Add a reference to your project

Click "browse" and refrence the attatched .dll file

Add the line of code "using K_RelayMove" at the top of your file
Remember you will need to put the K RelayMove.dll file in the K Relay plugin folder along with your .dll file for it to function.
Demo
Here's a quick demo that I made. It only supports 2 clients. Do /follow to proclaim yourself as the one to follow the other client.
Code:
using K_RelayMove;
using Lib_K_Relay;
using Lib_K_Relay.Interface;
using Lib_K_Relay.Networking;
using Lib_K_Relay.Networking.Packets;
using Lib_K_Relay.Utilities;
using System;
using System.Collections.Generic;
namespace K_RelayMoveDemo
{
public class Follow : IPlugin
{
public static List<Client> clientlist = new List<Client>();
public static bool Enabled = false;
public static Client WhoFollow;
public string GetAuthor(){return "PixelZerg";}
public string[] GetCommands(){return new string[] { "/follow (proclaim yourself the follower)" };}
public string GetDescription(){return "Make yourself follow another person";}
public string GetName(){ return "Follow";}
public void Initialize(Proxy proxy)
{
proxy.HookCommand("follow", new Proxy.CommandHandler(this.OnCommand));
proxy.HookPacket(PacketType.NEWTICK, new Proxy.PacketHandler(this.NT));
proxy.ClientConnected += new Proxy.ConnectionHandler(this.proxy_ClientConnected);
proxy.ClientDisconnected += new Proxy.ConnectionHandler(this.proxy_ClientDisconnected);
}
private void NT(Client client, Packet packet)
{
foreach (Client client2 in clientlist)
{
if (client != WhoFollow)
{
if (Math.Abs((float) (client2.PlayerData.Pos.X - WhoFollow.PlayerData.Pos.X)) > KRelayMove.clientlist[KRelayMove.IndexOfClient(client2)].Step)
{
if (client2.PlayerData.Pos.X > WhoFollow.PlayerData.Pos.X)
{
KRelayMove.MoveClient(client2, KRelayMove.Direction.right, 1, 8.332474E+09f);
}
else
{
KRelayMove.MoveClient(client2, KRelayMove.Direction.left, 1, 8.332474E+09f);
}
}
if (Math.Abs((float) (client2.PlayerData.Pos.Y - WhoFollow.PlayerData.Pos.Y)) > KRelayMove.clientlist[KRelayMove.IndexOfClient(client2)].Step)
{
if (client2.PlayerData.Pos.Y > WhoFollow.PlayerData.Pos.Y)
{
KRelayMove.MoveClient(client2, KRelayMove.Direction.down, 1, 8.332474E+09f);
}
else
{
KRelayMove.MoveClient(client2, KRelayMove.Direction.up, 1, 8.332474E+09f);
}
}
}
}
}
private void OnCommand(Client client, string command, string[] args)
{
Enabled = !Enabled;
if (Enabled)
{
WhoFollow = client;
PluginUtils.CreateNotification(client.ObjectId, "Now Following " + client.PlayerData.Name);
}
else
{
PluginUtils.CreateNotification(client.ObjectId, "Follow Plugin Disabled");
}
}
private void proxy_ClientConnected(Client client)
{
clientlist.Add(client);
}
private void proxy_ClientDisconnected(Client client)
{
clientlist.Remove(client);
KRelayMove.MoveClient(client, KRelayMove.Direction.up, 5);
}
}
}

In-Game Commands
If you place this .dll file in the plugin folder by itself, there are still a few commands you can do in game
to see how the plugin works:
/move up:down:left:right [amount]
This will move your client the specified direction the specified amount. But you probably won't find yourself using that command too often.
This file is meant to be used as a framework not as a standalone plugin :p
Credits:
jex4334
Psifour
059
for helping me figure out how to programatically make a client move.
I also used a method from Jex's code that calculates the client's speed in tiles per second.



plz