/// <summary> /// Handling the ChangeDirection action from GeneralDataPacket. /// </summary> /// <param name="client">The client.</param> /// <param name="General">The GeneralDataPacket.</param> public static void Handle(Entities.GameClient client, GeneralDataPacket General) { client.Direction = (byte)General.Direction; client.AttackPacket = null; client.SendToScreen(General, false); }
/// <summary> /// Handling the Marry action of the interaction packet. /// </summary> /// <param name="client">The client.</param> /// <param name="interact">The interaction packet.</param> public static void Handle(Entities.GameClient client, InteractionPacket interact) { //uint marryUID = interact.TargetUID; //Entities.GameClient marrytarget; Maps.IMapObject obj; if (client.Map.MapObjects.TryGetValue(interact.TargetUID, out obj)) { Entities.GameClient spouse = obj as Entities.GameClient; if (client.SpouseDatabaseUID > 0) { using (var fmsg = Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.MARRIAGE_SELF_SPOUSE)) client.Send(fmsg); return; } if (spouse.SpouseDatabaseUID > 0) { using (var fmsg = Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.MARRIAGE_TARGET_SPOUSE)) client.Send(fmsg); return; } client.SpouseDatabaseUID = spouse.DatabaseUID; spouse.SpouseDatabaseUID = client.DatabaseUID; //client.CharDB.AddSpouse(client.DatabaseUID, client.SpouseDatabaseUID); //spouse.CharDB.AddSpouse(spouse.DatabaseUID, spouse.SpouseDatabaseUID); Database.CharacterDatabase.AddSpouse(client, spouse); using (var mate = new Packets.StringPacket(new StringPacker(spouse.Name))) { mate.Data = client.EntityUID; mate.Action = Enums.StringAction.Mate; client.Send(mate); } using (var mate = new Packets.StringPacket(new StringPacker(client.Name))) { mate.Data = spouse.EntityUID; mate.Action = Enums.StringAction.Mate; spouse.Send(mate); } using (var fireworks = new Packets.StringPacket(new StringPacker("firework-2love"))) { fireworks.Action = Enums.StringAction.MapEffect; fireworks.PositionX = client.X; fireworks.PositionY = client.Y; client.SendToScreen(fireworks, true); fireworks.PositionX = spouse.X; fireworks.PositionY = spouse.Y; spouse.SendToScreen(fireworks, true); } using (var msg =Packets.Message.MessageCore.CreateSystem("ALL", string.Format(Core.MessageConst.MARRIAGE_CONGRATZ, client.Name, spouse.Name))) { Packets.Message.MessageCore.SendGlobalMessage(msg); } } }
/// <summary> /// Handling the ChangeAction action from GeneralDataPacket. /// </summary> /// <param name="client">The client.</param> /// <param name="General">The GeneralDataPacket.</param> public static void Handle(Entities.GameClient client, GeneralDataPacket General) { Enums.ActionType actiontype = (Enums.ActionType)General.Data1Low; client.AttackPacket = null; if (client.Action != Enums.ActionType.Sit && client.Action != Enums.ActionType.Lie) { if (actiontype == Enums.ActionType.Sit || actiontype == Enums.ActionType.Lie) { client.SitTime = DateTime.Now; client.UpdateStamina(true); } } client.Action = actiontype; client.SendToScreen(General, false); }
/// <summary> /// Handling the Jump action from GeneralDataPacket. /// </summary> /// <param name="client">The client.</param> /// <param name="General">The GeneralDataPacket.</param> public static void Handle(Entities.GameClient client, GeneralDataPacket General) { if (!client.Alive) return; if (client.ContainsFlag1(Enums.Effect1.IceBlock)) return; if (client.Booth != null) { client.Booth.CancelBooth(); client.Pullback(); } client.Action = Enums.ActionType.None; client.AttackPacket = null; ushort JumpX = General.Data1Low; ushort JumpY = General.Data1High; if (Core.Screen.GetDistance(client.X, client.Y, JumpX, JumpY) > 28) { client.Pullback(); return; } if (!client.Map.ValidCoord(JumpX, JumpY)) { client.Pullback(); return; } /*DateTime time = new ProjectX_V3_Lib.Time.SystemTime(General.Timestamp); if (client.LastMovement > time) { client.Pullback(); // speedhack return; }*/ if (!(DateTime.Now >= client.LastMovement.AddMilliseconds(400)) && client.LastMoveJump) { client.Pullback(); // speedhack return; } if (client.Battle != null) { if (!client.Battle.EnterArea(client)) { client.Pullback(); return; } else if (!client.Battle.LeaveArea(client)) { client.Pullback(); return; } } if (Calculations.BasicCalculations.ChanceSuccess(50)) client.Stamina += 7; client.LastMoveJump = true; client.LastMovement = DateTime.Now; client.LastX = client.X; client.LastY = client.Y; client.X = JumpX; client.Y = JumpY; client.SendToScreen(General, true); Data.AdvancedSkill.SkillInArea(client, client.X, client.Y); }
/// <summary> /// Handles the message packet. /// </summary> /// <param name="client">The client.</param> /// <param name="packet">The packet.</param> public static void Handle(Entities.GameClient client, DataPacket packet) { using (var message = new MessagePacket(packet)) { if (message.Message.StartsWith("/") && !message.Message.StartsWith("//") || message.Message.StartsWith("@") && !message.Message.StartsWith("@@")) { Packets.Message.Commands.Handle(client, message.Message, message.Message.Split(' ')); } else { if (message.ChatType != Enums.ChatType.Team && !client.Alive && message.ChatType != Enums.ChatType.Ghost) return; if (message.From != client.Name) { client.NetworkClient.Disconnect("INVALID_CHAT_NAME"); return; } switch (message.ChatType) { #region Whisper case Enums.ChatType.Whisper: { if (message.To == client.Name) return; Entities.GameClient toclient; if (Core.Kernel.Clients.TrySelect(message.To, out toclient)) { message.FromMesh = client.Mesh; message.ToMesh = toclient.Mesh; toclient.Send(message); } else { if (Database.CharacterDatabase.CharacterExists(message.To))//(System.IO.File.Exists(Database.ServerDatabase.DatabaseLocation + "\\UsedNames\\" + message.To + ".nm")) { using (var fmsg = Packets.Message.MessageCore.CreateSystem( client.Name, string.Format(Core.MessageConst.PLAYER_OFFLINE_WHISPER, message.To))) client.Send(fmsg); ProjectX_V3_Lib.IO.IniFile whisper = new ProjectX_V3_Lib.IO.IniFile( Database.ServerDatabase.DatabaseLocation + "\\MessageQuery\\" + message.To + ".ini", "Whisper"); int count = whisper.ReadInt32("Count", 0); count++; whisper.Write<int>("Count", count); whisper.SetSection(count.ToString()); whisper.WriteString("From", client.Name); whisper.WriteString("Message", message.Message); whisper.Write<uint>("Mesh", client.Mesh); } else { using (var fmsg = Packets.Message.MessageCore.CreateSystem( client.Name, string.Format(Core.MessageConst.PLAYER_OFFLINE_WHISPER2, message.To))) client.Send(fmsg); } } break; } #endregion #region Talk + Ghost case Enums.ChatType.Talk: case Enums.ChatType.Ghost: { client.SendToScreen(message, false, message.ChatType == Enums.ChatType.Ghost); break; } #endregion #region World case Enums.ChatType.World: { if (client.Level < 70) { using (var fmsg = Packets.Message.MessageCore.CreateSystem( client.Name, Core.MessageConst.WORLD_CHAT_NO_PERMISSION)) client.Send(fmsg); return; } int required = 60000; if (client.Level >= 100) required = 45000; if (client.Level >= 110) required = 30000; if (client.Level >= 120) required = 15000; if (DateTime.Now >= client.WorldChatSend.AddMilliseconds(required)) { client.WorldChatSend = DateTime.Now; foreach (Entities.GameClient sclient in Core.Kernel.Clients.selectorCollection1.Values) { if (sclient.EntityUID != client.EntityUID) sclient.Send(message); } } else { using (var fmsg = Packets.Message.MessageCore.CreateSystem( client.Name, string.Format(Core.MessageConst.WORLD_CHAT_WAIT, required))) client.Send(fmsg); } break; } #endregion #region Guild case Enums.ChatType.Guild: { if (client.Guild != null) { client.Guild.BroadcastMessage(message); } break; } #endregion #region Hawk case Enums.ChatType.HawkMessage: { if (client.Booth == null) return; client.Booth.HawkMessage = message.Message; break; } #endregion #region Team case Enums.ChatType.Team: { if (client.TournamentTeam != null) { foreach (Entities.GameClient teamMember in client.TournamentTeam.TeamMembers.ToDictionary().Values) { teamMember.Send(message); } } else if (client.Team != null) { foreach (Entities.GameClient teamMember in client.Team.Members.Values) { teamMember.Send(message); } } break; } #endregion } } } }
public static void SetUpdate(Entities.GameClient client, Enums.UpdateType type, ulong data, Enums.SynchroType synchro, ulong data2 = 0) { var packet = UpdatePacket.Create(client.EntityUID); if (!packet.AddUpdate(type, data)) return; if (synchro != Enums.SynchroType.False) { switch (synchro) { case Enums.SynchroType.True: { client.Send(packet); break; } case Enums.SynchroType.Broadcast: { client.SendToScreen(packet, true); break; } } } }
/// <summary> /// Handles the movement packet. /// </summary> /// <param name="client">The client.</param> /// <param name="packet">The packet.</param> public static void Handle(Entities.GameClient client, DataPacket packet) { if (client.ContainsFlag1(Enums.Effect1.IceBlock)) return; client.Action = Enums.ActionType.None; client.AttackPacket = null; client.LastMoveJump = false; using (var move = new MovementPacket(packet)) { if (move.EntityUID != client.EntityUID) return; int NewX = 0, NewY = 0; int NewDir = 0; switch (move.WalkMode) { case Enums.WalkMode.Run: case Enums.WalkMode.Walk: { NewDir = (int)move.Direction % 8; NewX = client.X + DeltaX[NewDir]; NewY = client.Y + DeltaY[NewDir]; break; } case Enums.WalkMode.Mount: { NewDir = (int)move.Direction % 24; NewX = client.X + DeltaMountX[NewDir]; NewY = client.Y + DeltaMountY[NewDir]; break; } } if (client.Map.ValidCoord(NewX, NewY)) { client.LastX = client.X; client.LastY = client.LastY; client.LastMovement = DateTime.Now; client.X = (ushort)NewX; client.Y = (ushort)NewY; client.Direction = (byte)NewDir; client.SendToScreen(move, true); if (client.Battle != null) { if (!client.Battle.EnterArea(client)) { client.X = client.LastX; client.Y = client.LastY; client.Pullback(); return; } else if (!client.Battle.LeaveArea(client)) { client.X = client.LastX; client.Y = client.LastY; client.Pullback(); return; } } Data.AdvancedSkill.SkillInArea(client, client.X, client.Y); } } }