public int checkForDex = 0;
public int lastShootTime = -1;
public int shootCounter = 0;
#region
using System;
using wServer.networking.cliPackets;
using wServer.networking.svrPackets;
using wServer.realm;
using wServer.realm.entities;
using wServer.realm.entities.player;
#endregion
namespace wServer.networking.handlers
{
internal class PlayerShootPacketHandler : PacketHandlerBase<PlayerShootPacket>
{
public override PacketID ID
{
get { return PacketID.PLAYERSHOOT; }
}
protected override void HandlePacket(Client client, PlayerShootPacket packet)
{
client.Manager.Logic.AddPendingAction(t =>
{
StatsManager statsMgr = new StatsManager(client.Player, 0);
if (client.Player.Owner == null) return;
client.Player.UpdateCount++;
Random rnd = new Random();
Item item = client.Player.Manager.GameData.Items[(ushort)packe*****ntainerType];
Player playeEr = client.Player;
int stype = 0;
for (int i = 0; i < 4; i++)
{
if (client.Player.Inventory[i]?.ObjectType == packe*****ntainerType)
{
stype = i;
break;
client.Player.UpdateCount++;
}
}
if (client.Player.SlotTypes[stype] != item.SlotType && client.Account.Rank< 2)
{
log.FatalFormat("{0} is trying to cheat (Weapon doesnt match the slot type)", client.Player.Name);
client.Player.SendError("This cheating attempt has beed logged and a message was send to all online admins.");
client.Player.SaveToAccount();
client.Player.SaveToCharacter();
client.Disconnect();
foreach (Player player in client.Player.Owner.Players.Values)
if (player.Client.Account.Rank >= 2)
player.SendInfo(String.Format("Player {0} is shooting with a weapon that doesnt match the class slot type.", client.Player.Name));
return;
}
ProjectileDesc prjDesc = item.Projectiles[0]; //Assume only one
Projectile prj = client.Player.PlayerShootProjectile(
packet.BulletId, prjDesc, item.ObjectType,
packet.Time, packet.Position, packet.Angle);
client.Player.Owner.EnterWorld(prj);
CheckShootSpeed(playeEr, item);
client.Player.BroadcastSync(new AllyShootPacket
{
OwnerId = client.Player.Id,
Angle = packet.Angle,
ContainerType = packe*****ntainerType,
BulletId = packet.BulletId,
}, p => p != client.Player && client.Player.Dist(p) < 25);
client.Player.FameCounter.Shoot(prj);
}, PendingPriority.Networking);
}
public void CheckShootSpeed(Player player, Item item)
{
StatsManager statsMgr = new StatsManager(player, 0);
player.shootCounter++;
if (player.lastShootTime == -1)
{
player.lastShootTime = Environment.TickCount;
}
int tolerance = 60;
float diff = (Environment.TickCount - player.lastShootTime) + tolerance;
float APS = statsMgr.GetDex();
if (diff < 670f / APS)
{
if (player.shootCounter > (item.NumProjectiles * item.RateOfFire))
{
player.shootCounter = 0;
player.checkForDex++;
player.Owner.Timers.Add(new WorldTimer(23500, (world, t) =>
{
player.checkForDex--;
return;
}));
}
if (player.checkForDex >= 9)
{
Client.Player.SaveToCharacter();
Client.Disconnect();
Console.WriteLine("{0} seems to be speedhacking, kicking the user. Dexterity Hack", player.Name);
}
if (player.checkForDex < 0)
{
player.checkForDex = 0;
}
}
else
{
player.shootCounter = 0;
player.lastShootTime = Environment.TickCount;
}
}
}
}
public int lastMoveTime = -1;
public int outOfBoundsCount = 0;
public int goodCount = 0;
#region
using System;
using wServer.networking.cliPackets;
using wServer.realm;
using wServer.realm.entities.player;
using wServer.networking.svrPackets;
using wServer.realm.entities;
#endregion
namespace wServer.networking.handlers
{
internal class MoveHandler : PacketHandlerBase<MovePacket>
{
public override PacketID ID
{
get { return PacketID.MOVE; }
}
protected override void HandlePacket(Client client, MovePacket packet)
{
client.Manager.Logic.AddPendingAction(t =>
{
StatsManager statsMgr = new StatsManager(client.Player, 0);
if (client.Player?.Owner == null) return;
CheckPosition(client.Player, packet.Position.X, packet.Position.Y);
client.Player.Flush();
if (client.Player.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;
if (packet.Position.X == -1 || packet.Position.Y == -1) return;
double newX = client.Player.X;
double newY = client.Player.Y;
if (newX != packet.Position.X)
{
newX = packet.Position.X;
client.Player.UpdateCount++;
}
if (newY != packet.Position.Y)
{
newY = packet.Position.Y;
client.Player.UpdateCount++;
}
CheckLabConditions(client.Player, packet);
client.Player.Move((float)newX, (float)newY);
client.Player.ClientTick(t, packet);
}, PendingPriority.Networking);
}
public void CheckPosition(Player player, double newX, double newY)
{
StatsManager statsMgr = new StatsManager(player, 0);
float curDex = statsMgr.GetStats(7); //test
float TPS = statsMgr.GetSpeed();
TileDesc tile = player.Owner.getCurrentTile(player);
float amplifier = tile.Speed;
if (amplifier != 0)
TPS *= amplifier;
if (player.lastMoveTime == -1)
{
player.lastMoveTime = Environment.TickCount;
}
//float tolerance = 0.5f;
float diff = (Environment.TickCount - player.lastMoveTime);
float actualTPS = (float)Math.Sqrt(Math.Abs(Math.Pow(newX - player.X, 2) + Math.Pow(newY - player.Y, 2)));
actualTPS *= 670f / diff;
float threshold = TPS * 1.35f;
if (actualTPS > threshold)
{
player.Owner.Timers.Add(new WorldTimer(20000, (world, t) =>
{
player.outOfBoundsCount--;
return;
}));
player.outOfBoundsCount++;
player.goodCount = 0;
if (player.outOfBoundsCount >= 9)
{
Client.Player.SaveToCharacter();
Client.Disconnect();
Console.WriteLine("{0} seems to be speedhacking, kicking user. Speed Hack", player.Name);
}
}
else
{
if (player.outOfBoundsCount > 0)
{
player.goodCount++;
if (player.goodCount >= 3)
{
player.outOfBoundsCount = 0;
player.goodCount = 0;
}
}
else
{
player.goodCount = 0;
}
}
player.lastMoveTime = Environment.TickCount;
}
private static void CheckLabConditions(Entity player, MovePacket packet)
{
var tile = player.Owner.Map[(int) packet.Position.X, (int) packet.Position.Y];
switch (tile.TileId)
{
//Green water
case 0xa9:
case 0x82:
if(tile.ObjId != 0) return;
if (!player.HasConditionEffect(ConditionEffectIndex.Hexed) ||
!player.HasConditionEffect(ConditionEffectIndex.Stunned) ||
!player.HasConditionEffect(ConditionEffectIndex.Speedy))
{
player.ApplyConditionEffect(ConditionEffectIndex.Hexed);
player.ApplyConditionEffect(ConditionEffectIndex.Stunned);
player.ApplyConditionEffect(ConditionEffectIndex.Speedy);
}
break;
//Blue water
case 0xa7:
case 0x83:
if (tile.ObjId != 0) return;
if (player.HasConditionEffect(ConditionEffectIndex.Hexed) ||
player.HasConditionEffect(ConditionEffectIndex.Stunned) ||
player.HasConditionEffect(ConditionEffectIndex.Speedy))
{
player.ApplyConditionEffect(ConditionEffectIndex.Hexed, 0);
player.ApplyConditionEffect(ConditionEffectIndex.Stunned, 0);
player.ApplyConditionEffect(ConditionEffectIndex.Speedy, 0);
}
break;
}
}
}
}
#region
using System;
using wServer.networking.cliPackets;
using wServer.networking.svrPackets;
using wServer.realm;
using wServer.realm.entities;
using wServer.realm.entities.player;
#endregion
namespace wServer.networking.handlers
{
internal class PlayerShootPacketHandler : PacketHandlerBase<PlayerShootPacket>
{
public override PacketID ID
{
get { return PacketID.PLAYERSHOOT; }
}
protected override void HandlePacket(Client client, PlayerShootPacket packet)
{
client.Manager.Logic.AddPendingAction(t =>
{
StatsManager statsMgr = new StatsManager(client.Player, 0);
if (client.Player.Owner == null) return;
client.Player.UpdateCount++;
Random rnd = new Random();
Player plr = client.Player;
Item item = client.Player.Manager.GameData.Items[(ushort)packe*****ntainerType];
int stype = 0;
for (int i = 0; i < 4; i++)
{
if (client.Player.Inventory[i]?.ObjectType == packe*****ntainerType)
{
stype = i;
break;
}
}
if (client.Player.SlotTypes[stype] != item.SlotType && client.Account.Rank < 2)
{
log.FatalFormat("{0} is trying to cheat (Weapon doesnt match the slot type)", client.Player.Name);
client.Player.SendError("This cheating attempt has beed logged and a message was send to all online admins.");
client.Disconnect();
foreach (Player player in client.Player.Owner.Players.Values)
if (player.Client.Account.Rank >= 0)
player.SendInfo(String.Format("Player {0} is shooting with a weapon that doesnt match the class slot type.", client.Player.Name));
return;
}
ProjectileDesc prjDesc = item.Projectiles[0]; //Assume only one
Projectile prj = client.Player.PlayerShootProjectile(
packet.BulletId, prjDesc, item.ObjectType,
packet.Time, packet.Position, packet.Angle);
client.Player.Owner.EnterWorld(prj);
CheckShootSpeed(plr, item);
client.Player.BroadcastSync(new AllyShootPacket
{
OwnerId = client.Player.Id,
Angle = packet.Angle,
ContainerType = packe*****ntainerType,
BulletId = packet.BulletId,
}, p => p != client.Player && client.Player.Dist(p) < 25);
client.Player.FameCounter.Shoot(prj);
}, PendingPriority.Networking);
}
public void CheckShootSpeed(Player player, Item item)
{
StatsManager statsMgr = new StatsManager(player, 0);
player.shootCounter++;
if (player.lastShootTime == -1)
{
player.lastShootTime = Environment.TickCount;
}
int tolerance = 60;
float diff = (Environment.TickCount - player.lastShootTime) + tolerance;
float APS = statsMgr.GetDex();
if (diff < 670f / APS)
{
if (player.shootCounter > (item.NumProjectiles * item.RateOfFire))
{
player.shootCounter = 0;
player.checkForDex++;
player.Owner.Timers.Add(new WorldTimer(23500, (world, t) =>
{
player.checkForDex--;
return;
}));
}
if (player.checkForDex >= 9)
{
Client.Player.SaveToCharacter();
Client.Disconnect();
Console.WriteLine("{0} seems to be speedhacking, kicking the user. Dexterity Hack", player.Name);
}
if (player.checkForDex < 0)
{
player.checkForDex = 0;
}
}
else
{
player.shootCounter = 0;
player.lastShootTime = Environment.TickCount;
}
}
}
}
public int lastMoveTime = -1;
public int outOfBoundsCount = 0;
public int goodCount = 0;
#region
using System;
using wServer.networking.cliPackets;
using wServer.realm;
using wServer.realm.entities.player;
using wServer.networking.svrPackets;
using wServer.realm.entities;
#endregion
namespace wServer.networking.handlers
{
internal class MoveHandler : PacketHandlerBase<MovePacket>
{
public override PacketID ID
{
get { return PacketID.MOVE; }
}
protected override void HandlePacket(Client client, MovePacket packet)
{
client.Manager.Logic.AddPendingAction(t =>
{
StatsManager statsMgr = new StatsManager(client.Player, 0);
if (client.Player?.Owner == null) return;
CheckPosition(client.Player, packet.Position.X, packet.Position.Y);
client.Player.Flush();
if (client.Player.HasConditionEffect(ConditionEffectIndex.Paralyzed)) return;
if (packet.Position.X == -1 || packet.Position.Y == -1) return;
double newX = client.Player.X;
double newY = client.Player.Y;
if (newX != packet.Position.X)
{
newX = packet.Position.X;
client.Player.UpdateCount++;
}
if (newY != packet.Position.Y)
{
newY = packet.Position.Y;
client.Player.UpdateCount++;
}
CheckLabConditions(client.Player, packet);
client.Player.Move((float)newX, (float)newY);
client.Player.ClientTick(t, packet);
}, PendingPriority.Networking);
}
public void CheckPosition(Player player, double newX, double newY)
{
StatsManager statsMgr = new StatsManager(player, 0);
float curDex = statsMgr.GetStats(7); //test
float TPS = statsMgr.GetSpeed();
TileDesc tile = player.Owner.getCurrentTile(player);
float amplifier = tile.Speed;
if (amplifier != 0)
TPS *= amplifier;
if (player.lastMoveTime == -1)
{
player.lastMoveTime = Environment.TickCount;
}
//float tolerance = 0.5f;
float diff = (Environment.TickCount - player.lastMoveTime);
float actualTPS = (float)Math.Sqrt(Math.Abs(Math.Pow(newX - player.X, 2) + Math.Pow(newY - player.Y, 2)));
actualTPS *= 670f / diff;
float threshold = TPS * 1.35f;
if (actualTPS > threshold)
{
player.Owner.Timers.Add(new WorldTimer(20000, (world, t) =>
{
player.outOfBoundsCount--;
return;
}));
player.outOfBoundsCount++;
player.goodCount = 0;
if (player.outOfBoundsCount >= 9)
{
Client.Player.SaveToCharacter();
Client.Disconnect();
Console.WriteLine("{0} seems to be speedhacking, kicking user. Speed Hack", player.Name);
}
}
else
{
if (player.outOfBoundsCount > 0)
{
player.goodCount++;
if (player.goodCount >= 3)
{
player.outOfBoundsCount = 0;
player.goodCount = 0;
}
}
else
{
player.goodCount = 0;
}
}
player.lastMoveTime = Environment.TickCount;
}
private static void CheckLabConditions(Entity player, MovePacket packet)
{
var tile = player.Owner.Map[(int) packet.Position.X, (int) packet.Position.Y];
switch (tile.TileId)
{
//Green water
case 0xa9:
case 0x82:
if(tile.ObjId != 0) return;
if (!player.HasConditionEffect(ConditionEffectIndex.Hexed) ||
!player.HasConditionEffect(ConditionEffectIndex.Stunned) ||
!player.HasConditionEffect(ConditionEffectIndex.Speedy))
{
player.ApplyConditionEffect(ConditionEffectIndex.Hexed);
player.ApplyConditionEffect(ConditionEffectIndex.Stunned);
player.ApplyConditionEffect(ConditionEffectIndex.Speedy);
}
break;
//Blue water
case 0xa7:
case 0x83:
if (tile.ObjId != 0) return;
if (player.HasConditionEffect(ConditionEffectIndex.Hexed) ||
player.HasConditionEffect(ConditionEffectIndex.Stunned) ||
player.HasConditionEffect(ConditionEffectIndex.Speedy))
{
player.ApplyConditionEffect(ConditionEffectIndex.Hexed, 0);
player.ApplyConditionEffect(ConditionEffectIndex.Stunned, 0);
player.ApplyConditionEffect(ConditionEffectIndex.Speedy, 0);
}
break;
}
}
}
}