Code:
namespace Kibou.Connections.Packets
{
using System;
public unsafe class HoldingHands
{
public byte[] Buffer;
public HoldingHands(byte direction, byte speed)
{
Buffer = new byte[32];
fixed (byte* ptr = Buffer)
{
*((ushort*)(ptr)) = 24;
*((ushort*)(ptr + 2)) = 1114;
*((ushort*)(ptr + 4)) = 1;
*(ptr + 6) = direction;
*(ptr + 7) = speed;
*(ptr + 12) = 2;
}
}
public HoldingHands(ushort x, ushort y)
{
Buffer = new byte[32];
fixed (byte* ptr = Buffer)
{
*((ushort*)(ptr)) = 24;
*((ushort*)(ptr + 2)) = 1114;
*((ushort*)(ptr + 4)) = 2;
*((ushort*)(ptr + 6)) = x;
*((ushort*)(ptr + 8)) = y;
*(ptr + 12) = 2;
}
}
public HoldingHands(byte direction)
{
Buffer = new byte[32];
fixed (byte* ptr = Buffer)
{
*((ushort*)(ptr)) = 24;
*((ushort*)(ptr + 2)) = 1114;
*((ushort*)(ptr + 6)) = direction;
*(ptr + 12) = 2;
}
}
public uint Identity
{
get { return BitConverter.ToUInt32(Buffer, 16); }
set { fixed (byte* ptr = Buffer) *((uint*)(ptr + 16)) = value; }
}
public uint Target
{
get { return BitConverter.ToUInt32(Buffer, 20); }
set { fixed (byte* ptr = Buffer) *((uint*)(ptr + 20)) = value; }
}
}
}
Code:
namespace Kibou.Connections.Packets
{
using System;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
[StructLayout(LayoutKind.Explicit)]
public struct Interaction
{
/// <summary> Offset 8</summary>
[FieldOffset(8)]
public uint Identity;
/// <summary> Offset 12</summary>
[FieldOffset(12)]
public uint Target;
/// <summary> Offset 16</summary>
[FieldOffset(16)]
public ushort X;
/// <summary> Offset 18</summary>
[FieldOffset(18)]
public ushort Y;
/// <summary> Offset 20</summary>
[FieldOffset(20)]
public uint Action;
/// <summary> Offset 24</summary>
[FieldOffset(24)]
public uint Effect;
/// <summary> Offset 28</summary>
[FieldOffset(28)]
public uint Parameter;
public Interaction(byte[] buffer)
{
Identity = BitConverter.ToUInt32(buffer, 8);
Target = BitConverter.ToUInt32(buffer, 12);
X = BitConverter.ToUInt16(buffer, 16);
Y = BitConverter.ToUInt16(buffer, 18);
Action = BitConverter.ToUInt32(buffer, 20);
Effect = BitConverter.ToUInt32(buffer, 24);
Parameter = BitConverter.ToUInt32(buffer, 28);
}
public Interaction(uint identity, uint target)
{
Identity = identity;
Target = target;
X = 0;
Y = 0;
Action = 0;
Effect = 0;
Parameter = 0;
}
public unsafe byte[] ToArray()
{
byte[] buffer = new byte[48];
fixed (byte* ptr = buffer)
{
*(Interaction*)ptr = this;
*((ushort*)(ptr)) = 40;
*((ushort*)(ptr + 2)) = 1022;
}
return buffer;
}
}
}
Code:
namespace Kibou.Connections.Handlers
{
using System;
public static class MovementHandler
{
private static sbyte[] _walkXCoords = new sbyte[8] { 0, -1, -1, -1, 0, 1, 1, 1 };
private static sbyte[] _walkYCoords = new sbyte[8] { 1, 1, 0, -1, -1, -1, 0, 1 };
private static sbyte[] _rideXCoords = new sbyte[24] { 0, -2, -2, -2, 0, 2, 2, 2, -1, -2, -2, -1, 1, 2, 2, 1, -1, -2, -2, -1, 1, 2, 2, 1 };
private static sbyte[] _rideYCoords = new sbyte[24] { 2, 2, 0, -2, -2, -2, 0, 2, 2, 1, -1, -2, -2, -1, 1, 2, 2, 1, -1, -2, -2, -1, 1, 2 };
public static void Walk(Packets.Movement movement, World.Client client)
{
client.Character.Direction = (byte)(movement.Direction % 8);
client.Character.Action = 0;
ushort _x = client.Character.X;
ushort _y = client.Character.Y;
_x += (ushort)(_walkXCoords[movement.Direction % 8]);
_y += (ushort)(_walkYCoords[movement.Direction % 8]);
if (client.Map.Floor[_x, _y] < Enums.Tile.Available)
{
client.Character.Teleport(client.Character.MapId, client.Character.X, client.Character.Y);
return;
}
client.Character.X = _x;
client.Character.Y = _y;
if (client.Interaction != null)
{
client.Interaction.Target.Character.Direction = (byte)(movement.Direction % 8);
client.Interaction.Target.Character.Action = 0;
client.Interaction.Target.Character.X = _x;
client.Interaction.Target.Character.Y = _y;
client.Interaction.Packet.Parameter = movement.Direction % 8;
client.Interaction.Packet.X = _x;
client.Interaction.Packet.Y = _y;
client.Interaction.Target.Interaction.Packet.Parameter = movement.Direction % 8;
client.Interaction.Target.Interaction.Packet.X = _x;
client.Interaction.Target.Interaction.Packet.Y = _y;
}
#region Screen Checks
Packets.HoldingHands hands = new Packets.HoldingHands((byte)movement.Direction, (byte)movement.Speed);
if (client.Interaction != null)
{
hands.Identity = client.Identity;
hands.Target = client.Interaction.Target.Identity;
client.Send(hands.Buffer);
}
else
client.Send(movement.ToArray());
foreach (World.Client other in client.Map.Players.Values)
if (client.Identity != other.Identity)
if (Kernel.InScreen(_x, _y, other.Character.X, other.Character.Y))
{
if (!other.Screen.InScreen.ContainsKey(client.Identity))
{
client.Character.SendSpawn(other);
other.Character.SendSpawn(client);
if (client.Interaction != null)
{
other.Character.SendSpawn(client.Interaction.Target);
client.Interaction.Target.Character.SendSpawn(other);
}
}
else
{
if (client.Interaction != null)
other.Send(hands.Buffer);
else
other.Send(movement.ToArray());
}
}
else if (client.Screen.InScreen.ContainsKey(other.Identity))
{
if (!Kernel.InScreen(_x, _y, other.Character.X, other.Character.Y))
{
if (client.Interaction != null)
other.Send(hands.Buffer);
else
other.Send(movement.ToArray());
other.Screen.Remove(client.Character, false);
client.Screen.Remove(other.Character, false);
if (client.Interaction != null)
{
client.Interaction.Target.Screen.Remove(other.Character, false);
other.Screen.Remove(client.Interaction.Target.Character, false);
}
}
}
foreach (Packets.NpcSpawn npc in client.Map.Npcs.Values)
if (Kernel.InScreen(npc.X, npc.Y, _x, _y))
{
if (client.Screen.Add(npc))
client.Send(npc.ToArray());
}
else
client.Screen.Remove(npc, false);
foreach (Interfaces.iMapObject obj in client.Map.FloorItems.Values)
if (Kernel.InScreen(obj.X, obj.Y, _x, _y))
{
if (client.Screen.Add(obj))
client.Send(obj.ToArray());
}
else if (Kernel.ObjOutScreen(obj.X, obj.Y, _x, _y))
client.Screen.Remove(obj, false);
#endregion
}
public static void Ride(Packets.Movement movement, World.Client client)
{
client.Character.Direction = (byte)(movement.Direction % 8);
client.Character.Action = 0;
ushort _x = client.Character.X;
ushort _y = client.Character.Y;
_x += (ushort)(_walkXCoords[movement.Direction % 24]);
_y += (ushort)(_walkYCoords[movement.Direction % 24]);
if (client.Map.Floor[_x, _y] < Enums.Tile.Available)
{
client.Character.Teleport(client.Character.MapId, client.Character.X, client.Character.Y);
return;
}
client.Send(movement.ToArray());
#region Screen Checks
foreach (World.Client other in client.Map.Players.Values)
if (client.Identity != other.Identity)
if (Kernel.InScreen(_x, _y, other.Character.X, other.Character.Y))
{
if (!other.Screen.InScreen.ContainsKey(client.Identity))
{
client.Character.SendSpawn(other, _x, _y);
other.Character.SendSpawn(client);
}
else
other.Send(movement.ToArray());
}
else if (client.Screen.InScreen.ContainsKey(other.Identity))
{
if (!Kernel.InScreen(_x, _y, other.Character.X, other.Character.Y))
{
other.Send(movement.ToArray());
other.Screen.Remove(client.Character, false);
client.Screen.Remove(other.Character, false);
}
}
foreach (Packets.NpcSpawn npc in client.Map.Npcs.Values)
if (Kernel.InScreen(npc.X, npc.Y, _x, _y))
{
if (client.Screen.Add(npc))
client.Send(npc.ToArray());
}
else
client.Screen.Remove(npc, false);
foreach (Interfaces.iMapObject obj in client.Map.FloorItems.Values)
if (Kernel.InScreen(obj.X, obj.Y, _x, _y))
{
if (client.Screen.Add(obj))
client.Send(obj.ToArray());
}
else if (Kernel.ObjOutScreen(obj.X, obj.Y, _x, _y))
client.Screen.Remove(obj, false);
#endregion
client.Character.X = _x;
client.Character.Y = _y;
}
public static void Jump(Packets.GeneralAction action, World.Client client)
{
try
{
if (Kernel.GetDistance(action.Value1, action.Value2, action.X, action.Y) <= 18)
{
client.Character.Action = 0;
if (client.Map.Floor[action.Value1, action.Value2] < Enums.Tile.Available)
{
client.Character.Teleport(client.Character.MapId, action.X, action.Y);
return;
}
client.Send(action.ToArray());
#region Direction
double Θ = Kernel.GetAngle(action.Value1, action.Value2, action.X, action.Y);
byte direction = 0;
if (Θ >= -25 && Θ < 25)
direction = 6;
else if (Θ >= 25 && Θ < 70)
direction = 7;
else if (Θ >= 70 && Θ < 110)
direction = 0;
else if (Θ >= 110 && Θ < 160)
direction = 1;
else if (Θ >= 160 && Θ < 200)
direction = 2;
else if (Θ >= 200 && Θ < 245)
direction = 3;
else if (Θ >= 245 || Θ < -60)
direction = 4;
else
direction = 5;
client.Character.Direction = direction;
if (client.Interaction != null)
{
client.Interaction.Target.Character.Direction = direction;
client.Interaction.Packet.Parameter = direction;
client.Interaction.Target.Interaction.Packet.Parameter = direction;
}
#endregion
#region Screen Checks
Packets.HoldingHands hands = new Packets.HoldingHands(action.Value1, action.Value2);
if (client.Interaction != null)
{
hands.Identity = client.Identity;
hands.Target = client.Interaction.Target.Identity;
client.Send(hands.Buffer);
}
foreach (World.Client other in client.Map.Players.Values)
if (client.Identity != other.Identity)
if (Kernel.InScreen(action.Value1, action.Value2, other.Character.X, other.Character.Y))
{
if (!other.Screen.InScreen.ContainsKey(client.Identity))
{
Kernel.Vector v = Kernel.GetBorderCoords(client.Character.X, client.Character.Y, other.Character.X, other.Character.Y);
client.Character.SendSpawn(other, v.X, v.Y);
if (v.X != action.Value1 || v.Y != action.Value2)
if (client.Interaction == null)
other.Send(action.ToArray());
other.Character.SendSpawn(client);
if (client.Interaction != null)
{
other.Character.SendSpawn(client.Interaction.Target);
client.Interaction.Target.Character.SendSpawn(other, v.X, v.Y);
}
}
else
{
if (client.Interaction == null)
other.Send(action.ToArray());
else
other.Send(hands.Buffer);
}
}
else if (client.Screen.InScreen.ContainsKey(other.Identity))
{
if (!Kernel.InScreen(action.Value1, action.Value2, other.Character.X, other.Character.Y))
{
if (client.Interaction != null)
other.Send(hands.Buffer);
else
other.Send(action.ToArray());
client.Screen.Remove(other.Character, false);
other.Screen.Remove(client.Character, false);
if (client.Interaction != null)
{
client.Interaction.Target.Screen.Remove(other.Character, false);
other.Screen.Remove(client.Interaction.Target.Character, false);
}
}
}
foreach (Packets.NpcSpawn npc in client.Map.Npcs.Values)
if (Kernel.InScreen(npc.X, npc.Y, action.Value1, action.Value2))
{
if (client.Screen.Add(npc))
client.Send(npc.ToArray());
}
else
client.Screen.Remove(npc, false);
foreach (Interfaces.iMapObject obj in client.Map.FloorItems.Values)
if (Kernel.InScreen(obj.X, obj.Y, action.Value1, action.Value2))
{
if (client.Screen.Add(obj))
client.Send(obj.ToArray());
}
else if (Kernel.ObjOutScreen(obj.X, obj.Y, action.Value1, action.Value2))
client.Screen.Remove(obj, false);
#endregion
client.Character.X = action.Value1;
client.Character.Y = action.Value2;
if (client.Interaction != null)
{
client.Interaction.Packet.X = action.Value1;
client.Interaction.Packet.Y = action.Value2;
client.Interaction.Target.Interaction.Packet.X = action.Value1;
client.Interaction.Target.Interaction.Packet.Y = action.Value2;
client.Interaction.Target.Character.X = action.Value1;
client.Interaction.Target.Character.Y = action.Value2;
client.Interaction.Target.Character.Action = 0;
}
}
else
client.Disconnect();
}
catch (Exception e) { Program.WriteLine(e); client.Character.Teleport(client.Character.MapId, action.X, action.Y); }
}
}
}
Code:
#region 1022 - Interactions & Attacks
case 1022:
Interaction atk = new Interaction(buffer);
switch (atk.Action)
{
#region [46] Request Interaction
case 46:
foreach (Interfaces.iMapObject other in client.Screen.InScreen.Values)
if (other.Identity == atk.Target)
if (other.EntityFlag == World.Entity.FlagEnum.Player)
other.Owner.Send(buffer);
break;
#endregion
#region [47] Accept Interaction
case 47:
foreach (Interfaces.iMapObject other in client.Screen.InScreen.Values)
if (other.Identity == atk.Target)
if (other.EntityFlag == World.Entity.FlagEnum.Player)
other.Owner.Send(buffer);
client.Send(buffer);
break;
#endregion
#region [48] Reject Interaction
case 48:
foreach (Interfaces.iMapObject other in client.Screen.InScreen.Values)
if (other.Identity == atk.Target)
if (other.EntityFlag == World.Entity.FlagEnum.Player)
other.Owner.Send(buffer);
break;
#endregion
#region [49] Start Interaction
case 49:
foreach (Interfaces.iMapObject other in client.Screen.InScreen.Values)
if (other.EntityFlag == World.Entity.FlagEnum.Player)
if (other.Identity == atk.Target)
{
client.Interaction = new World.Interaction(client, other.Owner, atk.Effect, true);
atk.Identity = client.Identity;
atk.Target = other.Identity;
other.Owner.Send(buffer);
client.Send(atk.ToArray());
atk.Identity = other.Identity;
atk.Target = client.Identity;
client.Send(atk.ToArray());
other.Owner.Send(atk.ToArray());
}
else
{
other.Owner.Send(buffer);
atk.Identity = atk.Target;
atk.Target = atk.Identity;
other.Owner.Send(atk.ToArray());
}
break;
#endregion
#region [50] Stop Interaction
case 50:
client.Interaction.Dispose();
client.Interaction = null;
foreach (Interfaces.iMapObject other in client.Screen.InScreen.Values)
if (other.EntityFlag == World.Entity.FlagEnum.Player)
if (other.Identity == atk.Target)
{
atk.Identity = client.Identity;
atk.Target = other.Identity;
other.Owner.Send(buffer);
client.Send(atk.ToArray());
atk.Identity = other.Identity;
atk.Target = client.Identity;
client.Send(atk.ToArray());
other.Owner.Send(atk.ToArray());
}
else
{
other.Owner.Send(buffer);
atk.Identity = atk.Target;
atk.Target = atk.Identity;
other.Owner.Send(atk.ToArray());
}
break;
#endregion
default:
Report("1022 [Interaction]", atk.Action);
break;
}
break;
#endregion
Code:
if (client.Interaction != null)
{
client.Interaction.Packet.Action = 50;
PacketHandler.Handle(client, client.Interaction.Packet.ToArray());
}
Code:
public const uint
PureKiss = 100002,
HoldHands = 100004,
Hug = 100005;
I dare you. ._. *shot gun ready*
Sincerely,
Fang
PS: None of this will work in any source known to this community
unless you code it for your own source.






