private void OnGetMailList(WorldSession session, PCGetMailList packet) { var mailList = this.Mails.Where(m => m.receiver == packet.GUID).ToList(); this.RemoveExpiredMail(mailList); session.SendPacket(new PSMailListResult(mailList)); }
public static void OnLogout(WorldSession session, PacketReader reader) { if (LogoutQueue.ContainsKey(session)) LogoutQueue.Remove(session); session.SendPacket(new PSLogoutResponse()); LogoutQueue.Add(session, DateTime.Now); }
private void OnAuthSession(WorldSession session, PCAuthSession packet) { account account = new DatabaseUnitOfWork<LoginDatabase>().GetRepository<account>().SingleOrDefault((a) => a.username == packet.Username); session.Account = account; session.PacketCrypto = new VanillaCrypt(); session.PacketCrypto.init(Utils.HexToByteArray(session.Account.sessionkey)); session.SendPacket(new PSAuthResponse()); }
public void OnNameQuery(WorldSession session, PCNameQuery packet) { WorldSession target = Server.Sessions.Find(sesh => sesh.Player.ObjectGUID.RawGUID == packet.GUID); if (target != null) { session.SendPacket(new PSNameQueryResponse(target.Player.Character)); } }
public void OnAreaTrigger(WorldSession session, PCAreaTrigger packet) { areatrigger_teleport areaTrigger = Core.WorldDatabase.GetRepository<areatrigger_teleport>().SingleOrDefault(at => at.id == packet.TriggerID); if (areaTrigger != null) { session.SendMessage("[AreaTrigger] ID:" + packet.TriggerID + " " + areaTrigger.name); session.Player.Location.MapID = areaTrigger.target_map; session.Player.Location.X = areaTrigger.target_position_x; session.Player.Location.Y = areaTrigger.target_position_y; session.Player.Location.Z = areaTrigger.target_position_z; session.Player.Location.Orientation = areaTrigger.target_orientation; session.SendPacket(new PSTransferPending(areaTrigger.target_map)); session.SendPacket(new PSNewWorld(areaTrigger.target_map, areaTrigger.target_position_x, areaTrigger.target_position_y, areaTrigger.target_position_z, areaTrigger.target_orientation)); } else { session.SendMessage("[AreaTrigger] ID:" + packet.TriggerID); } }
private void OnCastSpell(WorldSession session, PCCastSpell packet) { IUnitEntity target = session.Player.Target ?? session.Player; target.SubscribedBy.ToList().ForEach(s => s.SendPacket(new PSSpellGo(session.Player, target, packet.spellID))); session.SendPacket(new PSSpellGo(session.Player, target, packet.spellID)); session.SendPacket(new PSCastFailed(packet.spellID)); SpellEntry spell = Core.DBC.GetDBC<SpellEntry>().SingleOrDefault(s => s.ID == packet.spellID); float spellSpeed = spell.Speed; /* float distance = (float)Math.Sqrt((session.Entity.X - session.Entity.Target.X) * (session.Entity.X - session.Entity.Target.X) + (session.Entity.Y - session.Entity.Target.Y) * (session.Entity.Y - session.Entity.Target.Y) + (session.Entity.Z - session.Entity.Target.Z) * (session.Entity.Z - session.Entity.Target.Z)); if (distance < 5) distance = 5; float dx = session.Entity.X - target.X; float dy = session.Entity.Y - target.Y; float dz = session.Entity.Z - target.Target.Z; float radius = 5; float distance = (float)Math.Sqrt((dx * dx) + (dy * dy) + (dz * dz)) - radius; //if (distance < 5) distance = 5; float timeToHit = (spellSpeed > 0) ? (float)Math.Floor(distance / spellSpeed * 1000f) : 0; session.sendMessage("Cast [" + spell.Name + "] Distance: " + distance + " Speed: " + spellSpeed + " Time: " + timeToHit); float radians = (float)(Math.Atan2(session.Entity.Y - session.Entity.Target.Y, session.Entity.X - session.Entity.Target.X)); if(spellSpeed > 0) { DoTimer(timeToHit, (s, e) => { WorldServer.TransmitToAll(new PSMoveKnockBack(target, (float)Math.Cos(radians), (float)Math.Sin(radians), -10, -10)); }); } */ }
public void OnWhisper(WorldSession session, PCMessageChat packet) { WorldSession remoteSession = Server.GetSessionByPlayerName(packet.To); if (remoteSession != null) { session.SendPacket(new PSMessageChat(ChatMessageType.CHAT_MSG_WHISPER_INFORM, ChatMessageLanguage.LANG_UNIVERSAL, remoteSession.Player.ObjectGUID.RawGUID, packet.Message)); remoteSession.SendPacket(new PSMessageChat(ChatMessageType.CHAT_MSG_WHISPER, ChatMessageLanguage.LANG_UNIVERSAL, session.Player.ObjectGUID.RawGUID, packet.Message)); } else { session.SendMessage("Player not found."); } }
public void OnCreatureQuery(WorldSession session, PCCreatureQuery packet) { CreatureEntity entity = Core.GetComponent<EntityComponent>().CreatureEntities.SingleOrDefault(ce => ce.Creature.guid == (long)packet.GUID); session.SendPacket(new PSCreatureQueryResponse(packet.Entry, entity)); }
private void OnCharDelete(WorldSession session, PCCharDelete packet) { Characters.Delete(Characters.SingleOrDefault(chars => chars.guid == packet.GUID)); Core.CharacterDatabase.SaveChanges(); session.SendPacket(new PSCharDelete(LoginErrorCode.CHAR_DELETE_SUCCESS)); }
private void OnJoinChannel(WorldSession session, PCJoinChannel packet) { var channel = ChatChannels.SingleOrDefault(c => c.Name == packet.ChannelName); if (channel == null) { channel = new ChatChannel(packet.ChannelName, packet.Password); ChatChannels.Add(channel); } channel.Sessions.Add(session); session.SendPacket(new PSChannelNotify(ChatChannelNotify.CHAT_YOU_JOINED_NOTICE, session.Player.ObjectGUID.RawGUID, packet.ChannelName)); }
private void OnCharCreate(WorldSession session, PCCharCreate packet) { byte[] playerBytes = { packet.Skin, packet.Face, packet.HairStyle, packet.HairColor }; byte[] playerBytes2 = { packet.Accessory }; playercreateinfo info = CreateInfo.SingleOrDefault(ci => ci.race == packet.Race && ci.@class == packet.Class); var charGuid = Characters.AsQueryable().Any() ? Characters.AsQueryable().Max(c => c.guid) + 1 : 1; character character = new character() { guid = charGuid, account = session.Account.id, name = Utils.NormalizeText(packet.Name), race = packet.Race, @class = packet.Class, gender = packet.Gender, level = 1, xp = 0, money = 100000, playerBytes = BitConverter.ToInt32(playerBytes, 0), playerBytes2 = 0, playerFlags = 0, position_x = info.position_x, position_y = info.position_y, position_z = info.position_z, map = info.map, orientation = info.orientation, taximask = "", online = 0, cinematic = 0, totaltime = 0, leveltime = 0, logout_time = 0, is_logout_resting = 0, rest_bonus = 0, resettalents_cost = 0, resettalents_time = 0, trans_x = 0, trans_y = 0, trans_z = 0, trans_o = 0, transguid = 0, extra_flags = 0, at_login = 0, zone = info.zone, death_expire_time = 0, taxi_path = "", honor_highest_rank = 0, honor_standing = 0, stored_honor_rating = 0, stored_dishonorable_kills = 0, stored_honorable_kills = 0, watchedFaction = 0, drunk = 0, health = 100, power1 = 0, power2 = 0, power3 = 0, power4 = 0, power5 = 0, exploredZones = "", equipmentCache = GetStartingEquipment(packet.Race, packet.Class, packet.Gender), ammoId = 0, actionBars = 0, deleteInfos_Account = session.Account.id, deleteInfos_Name = Utils.NormalizeText(packet.Name), deleteDate = 0 }; Characters.Add(character); Core.CharacterDatabase.SaveChanges(); session.SendPacket(new PSCharCreate(LoginErrorCode.CHAR_CREATE_SUCCESS)); }
private void OnSendMail(WorldSession session, PCSendMail packet) { character reciever = Characters.SingleOrDefault(c => c.name == packet.Reciever); var result = MailResponseResult.MAIL_OK; if (reciever == null) { result = MailResponseResult.MAIL_ERR_RECIPIENT_NOT_FOUND; } else if (reciever.name == session.Player.Name) { result = MailResponseResult.MAIL_ERR_CANNOT_SEND_TO_SELF; } else if (session.Player.Character.money < packet.Money + 30) { result = MailResponseResult.MAIL_ERR_NOT_ENOUGH_MONEY; } else if (Mails.Where(m => m.receiver == reciever.guid).ToArray().Length > 100) { result = MailResponseResult.MAIL_ERR_RECIPIENT_CAP_REACHED; } else if (GetFaction(reciever) != GetFaction(session.Player.Character)) { result = MailResponseResult.MAIL_ERR_NOT_YOUR_TEAM; } if (packet.ItemGUID > 0) { throw new NotImplementedException(); } session.SendPacket(new PSSendMailResult(0, MailResponseType.MAIL_SEND, result)); if (result == MailResponseResult.MAIL_OK) { session.Player.Character.money -= (int)(packet.Money + 30); Mails.Add( new mail() { messageType = (byte)MailMessageType.MAIL_NORMAL, deliver_time = 0, expire_time = (int)GameUnits.DAY * 30, @checked = packet.Body != "" ? (byte)MailCheckMask.MAIL_CHECK_MASK_HAS_BODY : (byte)MailCheckMask.MAIL_CHECK_MASK_COPIED, cod = (int)packet.COD, has_items = 0, itemTextId = 0, money = (int)packet.Money, sender = session.Player.Character.guid, receiver = reciever.guid, subject = packet.Subject, stationery = (sbyte)MailStationery.MAIL_STATIONERY_DEFAULT, mailTemplateId = 0 }); } }
public static void Warp(WorldSession session, string[] args) { if (Teleports == null) AddTeleports(); string locationName = args[0]; DistanceTeleportEntry location = FetchList(locationName).First(); session.Player.Location = new Location(new Vector3(location.Entry.X, location.Entry.Y, location.Entry.Z), 0, location.Entry.MapID); session.SendPacket(new PSTransferPending(location.Entry.MapID)); session.SendPacket(new PSNewWorld(location.Entry.MapID, location.Entry.X, location.Entry.Y, location.Entry.Z, 0)); }
public void SendInitialSpells(WorldSession session) { session.SendPacket(new PSInitialSpells(session.Player.SpellCollection)); }
private void OnWorldPort(WorldSession session, PacketReader reader) { session.SendPacket(session.Player.PacketBuilder.BuildOwnCharacterPacket()); }
public void OnPing(WorldSession session, PCPing packet) { session.SendMessage("Ping: " + packet.Ping + " Latancy: " + packet.Latency); session.SendPacket(new PSPong(packet.Ping)); }
public static void OnCancel(WorldSession session, PacketReader reader) { LogoutQueue.Remove(session); session.SendPacket(new PSLogoutCancelAcknowledgement()); }
public void SendInitialButtons(WorldSession session) { session.SendPacket(new PSActionButtons(session.Player.ActionButtonCollection)); }
private void OnCharEnum(WorldSession session, PacketReader reader) { session.SendPacket(new PSCharEnum(session, Characters.Where(c => c.account == session.Account.id).ToList())); }
public void OnGameObjectQuery(WorldSession session, PCGameObjectQuery packet) { gameobject_template template = Core.WorldDatabase.GetRepository<gameobject_template>().SingleOrDefault(g => g.entry == packet.EntryID); session.SendPacket(new PSGameObjectQueryResponse(template)); }
public static void Default(WorldSession session, string[] args) { if (args.Length == 1 && args[0].ToLower() == "list") { session.SendMessage("List"); } else if(args.Length == 2) { string attributeName = args[0].ToLower(); string attributeValue = args[1]; // If player isn't targeting. Target self IUnitEntity entity = session.Player.Target ?? session.Player; //TODO Fix horrible hack. UnitInfo info = entity.ObjectGUID.TypeID == TypeID.TYPEID_PLAYER ? (UnitInfo)((PlayerEntity)entity).Info : ((CreatureEntity)entity).Info; bool unknownAttribute = false; switch (attributeName) { case "faction": var val = uint.Parse(attributeValue); if (val == 0) session.SendMessage("FactionID: " + info.FactionTemplate); else { session.SendMessage("Old FactionID: " + info.FactionTemplate); info.FactionTemplate = val; session.SendMessage("New FactionID: " + info.FactionTemplate); } break; case "scale": info.Scale = float.Parse(attributeValue); break; case "health": info.Health = int.Parse(attributeValue); break; case "level": info.Level = int.Parse(attributeValue); break; case "xp": (info as PlayerInfo).XP = int.Parse(attributeValue); break; case "model": info.DisplayID = int.Parse(attributeValue); break; case "money": int moneyToAdd = int.Parse(attributeValue) < 0x7fffffff ? int.Parse(attributeValue) : 0x7fffffff; (info as PlayerInfo).Money += moneyToAdd; session.Player.Character.money += moneyToAdd; break; case "standstate": info.StandState = (byte)int.Parse(attributeValue); break; case "speed": info.WalkSpeed = float.Parse(attributeValue); session.SendPacket(new PSForceRunSpeedChange(entity.ObjectGUID, info.WalkSpeed)); break; default: unknownAttribute = true; break; } if (unknownAttribute) { session.SendMessage("Attribute '" + attributeName + "' was unknown"); } else { session.SendMessage("Applied " + attributeName + " = " + attributeValue + ""); } } }
public void Move(WorldSession session, List<Vector3> path) { session.SendPacket(new PSMonsterMove(entity, path)); }
public void OnTextEmote(WorldSession session, PCTextEmote packet) { //TODO Get the targetname from the packet.GUID String targetName = session.Player.Target != null ? session.Player.Target.Name : null; Server.TransmitToAll(new PSTextEmote((int)session.Player.Character.guid, (int)packet.EmoteID, (int)packet.TextID, targetName)); EmotesText textEmote = Core.DBC.GetDBC<EmotesText>().SingleOrDefault(e => e.textid == packet.TextID); switch ((Emote)textEmote.textid) { case Emote.EMOTE_STATE_SLEEP: case Emote.EMOTE_STATE_SIT: case Emote.EMOTE_STATE_KNEEL: case Emote.EMOTE_ONESHOT_NONE: break; default: Server.Sessions.ForEach(s => s.SendPacket(new PSEmote(textEmote.textid, session.Player.ObjectGUID.RawGUID))); session.SendPacket(new PSEmote(textEmote.textid, session.Player.ObjectGUID.RawGUID)); break; } }
private void OnLeaveChannel(WorldSession session, PCChannel packet) { var channel = ChatChannels.SingleOrDefault(c => c.Name == packet.ChannelName); channel.Sessions.Remove(session); if (channel.Sessions.Count == 0) ChatChannels.Remove(channel); session.SendPacket(new PSChannelNotify(ChatChannelNotify.CHAT_YOU_LEFT_NOTICE, session.Player.ObjectGUID.RawGUID, packet.ChannelName)); }
private void OnEmote(WorldSession session, PCEmote packet) { session.SendPacket(new PSEmote(packet.EmoteID, session.Player.ObjectGUID.RawGUID)); }
public void SendSytemMessage(WorldSession session, string message) { session.SendPacket(new PSMessageChat(ChatMessageType.CHAT_MSG_SYSTEM, ChatMessageLanguage.LANG_COMMON, 0, message)); }
public void SendWeather(WorldSession session) { session.SendPacket(new PSWeather(GetWeatherZoneForSession(session))); }