public static void HandleStateMoveTo(SimpleClient client, StateMoveToMessage message) { if (client.GetHashCode() == message.objId) //Check if objId == -1, if it's that means that's the player is moving by clicking somewhere else, it means that is targeting something and it send the id of the object { Console.WriteLine("It's an attack !"); } if (!client.Character.Position.IsInRange(new ObjectPosition(message.param1 / 1000f, message.param2 / 1000f, message.param3 / 1000f), (int)DefineEnum.MAXDISTANCE)) { // client.Disconnect(); return; } client.Character.Position.X = message.param1 / 1000f; client.Character.Position.Y = message.param2 / 1000f; client.Character.Position.Z = message.param3 / 1000f; client.Character.Map.SendMouvementMessageToNearestClients(client.Character); }
public static void HandleJoinMessage(SimpleClient client, JoinMessage message) { Character character = client.Account.Characters.FirstOrDefault(x => x.Id == message.characterId); if (character == null) { client.Disconnect(); return; } client.Character = character; client.Character.Client = client; Map map = WorldManager.Instance.GetMapById(character.Record.SceneId); if (map == null) { client.Disconnect(); return; } client.Character.Position = new ObjectPosition(character.Record.X, character.Record.Y, character.Record.Z); map.Enter(client.Character); SendJoinRightMessage(client, message.characterId, character.Position.Map.SceneId, character.Position.X, character.Position.Y, character.Position.Z, false, 0);//Send all players in the map var stats = StatsFields.LoadInertieData(); SendSnapshotMessage(client, new Snapshot[] { new SetStateVerSnapshot(1), new UpdateServerTimeSnapshot(DateTime.UtcNow.GetUnixTimeStamp()), new AddObjectSnapshot(client.Character.GetObjectType(true)), new AddObjectSnapshot(new MonsterObjectType(ObjectTypeEnum.OT_MOB, (uint)client.GetHashCode(), 20, 0xFFFFFFFF, 609, 300, 600, 0, 0, 100, "Nuan", stats.Count, stats.Keys.Select(x => (ushort)x).ToArray(), stats.Values.Select(x => x.Total).ToArray(), 0, new byte[0], new int[0], new int[0], 1, false, 255, 0, 0, 0, 0, new uint[0], 0, true, true, false, 0, 0, 2, -1, 0)) }); foreach (var attribute in client.Character.Stats.Fields) { SendSnapshotMessage(client, new [] { new SetValueObjectSnapshot((uint)client.Character.GetHashCode(), (short)attribute.Key, attribute.Value.Total), }); } List <Snapshot> spawnOtherObjects = new List <Snapshot>(); foreach (var @object in map.Objects.Where(x => x != character)) { spawnOtherObjects.Add(new AddObjectSnapshot(@object.GetObjectType())); } SendSnapshotMessage(client, spawnOtherObjects.ToArray()); //foreach (var stats in client.Character.Stats.Fields) //{ // SendSnapshotMessage(client, new Snapshot[] { new SetValueObjectSnapshot((uint)client.Character.GetHashCode(), (short)stats.Key, (int)stats.Value.Total) }); //} }