private void ReceiveMobileIncoming(IRecvPacket packet) { MobileIncomingPacket p = (MobileIncomingPacket)packet; Mobile mobile = EntityManager.GetObject <Mobile>(p.Serial, true); mobile.BodyID = p.BodyID; mobile.Hue = (int)p.Hue; mobile.Move_Instant(p.X, p.Y, p.Z, p.Direction); mobile.Flags = p.Flags; mobile.Notoriety = p.Notoriety; mobile.Notoriety = p.Notoriety; for (int i = 0; i < p.Equipment.Length; i++) { Item item = add_Item(p.Equipment[i].Serial, p.Equipment[i].GumpId, p.Equipment[i].Hue, p.Serial, 0); mobile.WearItem(item, p.Equipment[i].Layer); if (item.PropertyList.Hash == 0) { World.Engine.Client.Send(new QueryPropertiesPacket(item.Serial)); } } if (mobile.Name == string.Empty) { mobile.Name = "Unknown"; World.Engine.Client.Send(new RequestNamePacket(p.Serial)); } }
private void ReceiveAddSingleItemToContainer(IRecvPacket packet) { ContainerContentUpdatePacket p = (ContainerContentUpdatePacket)packet; // Add the item... Item item = add_Item(p.Serial, p.ItemId, p.Hue, p.ContainerSerial, p.Amount); item.InContainerPosition = new Point(p.X, p.Y); // ... and add it the container contents of the container. Container iContainerObject = EntityManager.GetObject <Container>(p.ContainerSerial, true); if (iContainerObject != null) { iContainerObject.AddItem(item); } else { // Special case for game boards... the server will sometimes send us game pieces for a game board before it sends // the game board! Right now, I am discarding these messages, it might be better to queue them up for when the game // board actually exists. // Let's throw an exception if anything other than a gameboard is ever sent to us. // if (iObject.ItemData.Name != "game piece") throw new Exception("Item {" + item.ToString() + "} received before containing object received."); } }
private void ReceiveObjectPropertyList(IRecvPacket packet) { ObjectPropertyListPacket p = (ObjectPropertyListPacket)packet; AEntity entity = EntityManager.GetObject <AEntity>(p.Serial, false); if (entity == null) { return; // received property list for entity that does not exist. } entity.PropertyList.Hash = p.Hash; entity.PropertyList.Clear(); for (int i = 0; i < p.CliLocs.Count; i++) { string iCliLoc = UltimaData.StringData.Entry(p.CliLocs[i]); if (p.Arguements[i] == string.Empty) { entity.PropertyList.AddProperty(iCliLoc); } else { entity.PropertyList.AddProperty(constructCliLoc(iCliLoc, p.Arguements[i])); } } }
private void ReceiveRejectMoveItemRequest(IRecvPacket packet) { LiftRejectionPacket p = (LiftRejectionPacket)packet; World.Interaction.ChatMessage("Could not pick up item: " + p.ErrorMessage); World.Interaction.ClearHolding(); }
private void ReceivePlayMusic(IRecvPacket packet) { PlayMusicPacket p = (PlayMusicPacket)packet; // System.Console.WriteLine ( "Play music, id={0}", p.MusicID ); UltimaData.MusicData.PlayMusic(p.MusicID); }
private void ReceiveLoginRejection(IRecvPacket packet) { Disconnect(); LoginRejectionPacket p = (LoginRejectionPacket)packet; switch (p.Reason) { case LoginRejectionReasons.InvalidAccountPassword: Status = LoginClientStatus.Error_InvalidUsernamePassword; break; case LoginRejectionReasons.AccountInUse: Status = LoginClientStatus.Error_InUse; break; case LoginRejectionReasons.AccountBlocked: Status = LoginClientStatus.Error_Blocked; break; case LoginRejectionReasons.BadPassword: Status = LoginClientStatus.Error_BadPassword; break; case LoginRejectionReasons.IdleExceeded: Status = LoginClientStatus.Error_Idle; break; case LoginRejectionReasons.BadCommuncation: Status = LoginClientStatus.Error_BadCommunication; break; } }
private void ReceiveMoveRej(IRecvPacket packet) { MovementRejectPacket p = (MovementRejectPacket)packet; Mobile player = (Mobile)EntityManager.GetPlayerObject(); player.PlayerMobile_MoveEventRej(p.Sequence, p.X, p.Y, p.Z, p.Direction); }
private void ReceivePopupMessage(IRecvPacket packet) { PopupMessagePacket p = (PopupMessagePacket)packet; MsgBox g = World.Engine.UserInterface.MsgBox(p.Message, MsgBoxTypes.OkOnly); g.OnClose = ReceivePopupMessage_OnClose; }
private void ReceiveMoveAck(IRecvPacket packet) { MoveAcknowledgePacket p = (MoveAcknowledgePacket)packet; Mobile player = (Mobile)EntityManager.GetPlayerObject(); player.PlayerMobile_MoveEventAck(p.Sequence); player.Notoriety = p.Notoriety; }
private void ReceiveSeasonalInformation(IRecvPacket packet) { // Only partially handled !!! If iSeason2 = 1, then this is a season change. // If season change, then iSeason1 = (0=spring, 1=summer, 2=fall, 3=winter, 4 = desolation) SeasonChangePacket p = (SeasonChangePacket)packet; UltimaVars.EngineVars.Season = p.Season; }
private void ReceiveCharacterList(IRecvPacket packet) { CharacterCityListPacket p = (CharacterCityListPacket)packet; Characters.SetCharacterList(p.Characters); Characters.SetStartingLocations(p.Locations); Status = LoginClientStatus.GameServer_CharList; }
// ====================================================================== // Chat / messaging handling // ====================================================================== private void ReceiveCLILOCMessage(IRecvPacket packet) { MessageLocalizedPacket p = (MessageLocalizedPacket)packet; string iCliLoc = constructCliLoc(UltimaData.StringData.Entry(p.CliLocNumber), p.Arguements); ReceiveTextMessage(p.MessageType, iCliLoc, p.Hue, p.Font, p.Serial, p.SpeakerName); }
// ====================================================================== // Gump & Menu handling // ====================================================================== private void ReceiveResurrectionMenu(IRecvPacket packet) { // int iAction = reader.ReadByte(); // 0: Server sent // 1: Resurrect // 2: Ghost // The only use on OSI for this packet is now sending "2C02" for the "You Are Dead" screen upon character death. announce_UnhandledPacket(packet); }
// // Other packets // private void ReceiveMessageLocalizedAffix(IRecvPacket packet) { MessageLocalizedAffixPacket p = (MessageLocalizedAffixPacket)packet; string localizedString = string.Format(p.Flag_IsPrefix ? "{1}{0}" : "{0}{1}", constructCliLoc(UltimaData.StringData.Entry(p.CliLocNumber), p.Arguements), p.Affix); ReceiveTextMessage(p.MessageType, localizedString, p.Hue, p.Font, p.Serial, p.SpeakerName); }
// ====================================================================== // Combat handling // ====================================================================== private void ReceiveChangeCombatant(IRecvPacket packet) { ChangeCombatantPacket p = (ChangeCombatantPacket)packet; if (p.Serial > 0x00000000) { World.Interaction.LastTarget = p.Serial; } }
private void ReceiveOnSwing(IRecvPacket packet) { SwingPacket p = (SwingPacket)packet; // this changes our last target - does this behavior match legacy? if (p.Attacker == UltimaVars.EngineVars.PlayerSerial) { World.Interaction.LastTarget = p.Defender; } }
private void ReceiveServerRelay(IRecvPacket packet) { ServerRelayPacket p = (ServerRelayPacket)packet; m_ServerRelayKey = p.AccountId; // On OSI, upon receiving this packet, the client would disconnect and // log in to the specified server. Since emulated servers use the same // server for both shard selection and world, we don't need to disconnect. m_Network.IsDecompressionEnabled = true; Status = LoginClientStatus.LoginServer_WaitingForRelay; }
// ====================================================================== // Corpse handling // ====================================================================== private void ReceiveCorpseClothing(IRecvPacket packet) { CorpseClothingPacket p = (CorpseClothingPacket)packet; Corpse corpse = EntityManager.GetObject <Corpse>(p.CorpseSerial, false); if (corpse == null) { return; } corpse.LoadCorpseClothing(p.Items); }
private void ReceiveRequestNameResponse(IRecvPacket packet) { RequestNameResponsePacket p = (RequestNameResponsePacket)packet; Mobile mobile = EntityManager.GetObject <Mobile>(p.Serial, false); if (mobile == null) { return; } mobile.Name = p.MobileName; }
private void ReceiveCompressedGump(IRecvPacket packet) { CompressedGumpPacket p = (CompressedGumpPacket)packet; if (p.HasData) { string[] gumpPieces = interpretGumpPieces(p.GumpData); Gump g = (Gump)World.Engine.UserInterface.AddControl(new Gump(p.Serial, p.GumpID, gumpPieces, p.TextLines), p.X, p.Y); g.IsMovable = true; } }
private void ReceiveUpdateHealth(IRecvPacket packet) { UpdateHealthPacket p = (UpdateHealthPacket)packet; Mobile entity = EntityManager.GetObject <Mobile>(p.Serial, false); if (entity == null) { return; } entity.Health.Update(p.Current, p.Max); }
private void ReceiveDamage(IRecvPacket packet) { DamagePacket p = (DamagePacket)packet; Mobile entity = EntityManager.GetObject <Mobile>(p.Serial, false); if (entity == null) { return; } World.Interaction.ChatMessage(string.Format("{0} takes {1} damage!", entity.Name, p.Damage)); }
private void ReceiveWornItem(IRecvPacket packet) { WornItemPacket p = (WornItemPacket)packet; Item item = add_Item(p.Serial, p.ItemId, p.Hue, p.ParentSerial, 0); Mobile m = EntityManager.GetObject <Mobile>(p.ParentSerial, false); m.WearItem(item, p.Layer); if (item.PropertyList.Hash == 0) { World.Engine.Client.Send(new QueryPropertiesPacket(item.Serial)); } }
private void ReceiveOpenBuyWindow(IRecvPacket packet) { VendorBuyListPacket p = (VendorBuyListPacket)packet; Item entity = EntityManager.GetObject <Item>(p.VendorPackSerial, false); if (entity == null) { return; } // UserInterface.Merchant_Open(iObject, 0); // !!! }
private void ReceiveMobileAnimation(IRecvPacket packet) { MobileAnimationPacket p = (MobileAnimationPacket)packet; Mobile mobile = EntityManager.GetObject <Mobile>(p.Serial, false); if (mobile == null) { return; } mobile.Animate(p.Action, p.FrameCount, p.RepeatCount, p.Reverse, p.Repeat, p.Delay); }
private void ReceiveOverallLightLevel(IRecvPacket packet) { // byte iLightLevel = reader.ReadByte(); // 0x00 - day // 0x09 - OSI night // 0x1F - Black // Max normal val = 0x1F OverallLightLevelPacket p = (OverallLightLevelPacket)packet; ((WorldView)World.GetView()).Isometric.OverallLightning = p.LightLevel; }
private void ReceivePersonalLightLevel(IRecvPacket packet) { // int iCreatureID = reader.ReadInt(); // byte iLightLevel = reader.ReadByte(); // 0x00 - day // 0x09 - OSI night // 0x1F - Black // Max normal val = 0x1F PersonalLightLevelPacket p = (PersonalLightLevelPacket)packet; ((WorldView)World.GetView()).Isometric.PersonalLightning = p.LightLevel; }
private void ReceiveLoginConfirmPacket(IRecvPacket packet) { m_QueuedLoginConfirmPacket = (LoginConfirmPacket)packet; // set the player serial var and create the player entity. Don't need to do anything with it yet. UltimaVars.EngineVars.PlayerSerial = m_QueuedLoginConfirmPacket.Serial; PlayerMobile player = EntityManager.GetObject <PlayerMobile>(m_QueuedLoginConfirmPacket.Serial, true); if (player == null) { Logger.Fatal("Could not create player object."); } CheckIfOkayToLogin(); }
private void ReceiveLoginConfirmPacket(IRecvPacket packet) { m_QueuedLoginConfirmPacket = (LoginConfirmPacket)packet; // set the player serial and create the player entity. Don't need to do anything with it yet. WorldModel.PlayerSerial = m_QueuedLoginConfirmPacket.Serial; Mobile player = WorldModel.Entities.GetObject <Mobile>(m_QueuedLoginConfirmPacket.Serial, true); if (player == null) { Tracer.Critical("Could not create player object."); } CheckIfOkayToLogin(); }
private void ReceiveSkillsList(IRecvPacket packet) { foreach (SendSkillsPacket_SkillEntry skill in ((SendSkillsPacket)packet).Skills) { UltimaVars.SkillEntry entry = UltimaVars.Skills.SkillEntry(skill.SkillID); if (entry != null) { entry.Value = skill.SkillValue; entry.ValueUnmodified = skill.SkillValueUnmodified; entry.LockType = skill.SkillLock; entry.Cap = skill.SkillCap; } } }
private static void receive_SkillsList(IRecvPacket packet) { foreach (SendSkillsPacket_SkillEntry skill in ((SendSkillsPacket)packet).Skills) { if (skill.SkillID > 55) continue; ClientVars.SkillEntry entry = ClientVars.Skills.SkillEntry(skill.SkillID); entry.Value = skill.SkillValue; entry.ValueUnmodified = skill.SkillValueUnmodified; entry.LockType = skill.SkillLock; entry.Cap = skill.SkillCap; } }
private static void receive_ObjectHelpResponse(IRecvPacket packet) { announce_UnhandledPacket(packet); }
private static void receive_MoveRej(IRecvPacket packet) { MovementRejectPacket p = (MovementRejectPacket)packet; Mobile player = (Mobile)EntitiesCollection.GetPlayerObject(); player.PlayerMobile_MoveEventRej(p.Sequence, p.X, p.Y, p.Z, p.Direction); }
private static void receive_OpenBuyWindow(IRecvPacket packet) { VendorBuyListPacket p = (VendorBuyListPacket)packet; Item iObject = EntitiesCollection.GetObject<Item>(p.VendorPackSerial, false); if (iObject == null) return; // UserInterface.Merchant_Open(iObject, 0); // !!! }
private static void receive_OnParticleEffect(IRecvPacket packet) { announce_UnhandledPacket(packet); }
private static void receive_PersonalLightLevel(IRecvPacket packet) { // int iCreatureID = reader.ReadInt(); // byte iLightLevel = reader.ReadByte(); // 0x00 - day // 0x09 - OSI night // 0x1F - Black // Max normal val = 0x1F PersonalLightLevelPacket p = (PersonalLightLevelPacket)packet; // Console.WriteLine("PersonalLight: {0}", p.LightLevel); _worldService.PersonalLightning = p.LightLevel; }
private static void receive_OpenWebBrowser(IRecvPacket packet) { OpenWebBrowserPacket p = (OpenWebBrowserPacket)packet; System.Diagnostics.Process.Start("iexplore.exe", p.WebsiteUrl); }
private static void receive_SellList(IRecvPacket packet) { announce_UnhandledPacket(packet); }
private static void receive_SeasonalInformation(IRecvPacket packet) { // Only partially handled !!! If iSeason2 = 1, then this is a season change. // If season change, then iSeason1 = (0=spring, 1=summer, 2=fall, 3=winter, 4 = desolation) SeasonChangePacket p = (SeasonChangePacket)packet; ClientVars.EngineVars.Season = p.Season; }
private static void receive_ServerList(IRecvPacket packet) { ClientVars.Servers.List = ((ServerListPacket)packet).Servers; Status = UltimaClientStatus.LoginServer_HasServerList; }
private static void receive_SendCustomHouse(IRecvPacket packet) { CustomHousePacket p = (CustomHousePacket)packet; Data.CustomHousing.UpdateCustomHouseData(p.HouseSerial, p.RevisionHash, p.PlaneCount, p.Planes); Multi e = EntitiesCollection.GetObject<Multi>(p.HouseSerial, false); if (e.CustomHouseRevision != p.RevisionHash) { Data.CustomHouse house = Data.CustomHousing.GetCustomHouseData(p.HouseSerial); e.AddCustomHousingTiles(house); } }
private static void receive_TargetCursorMulti(IRecvPacket packet) { TargetCursorMultiPacket p = (TargetCursorMultiPacket)packet; GameState.MouseTargeting(TargetTypes.MultiPlacement, 0); _LegacyUI.Cursor.TargetingMulti = p.MultiModel; }
private static void receive_TargetCursor(IRecvPacket packet) { TargetCursorPacket p = (TargetCursorPacket)packet; GameState.MouseTargeting((TargetTypes)p.CommandType, p.CursorID); }
private static void receive_StatusInfo(IRecvPacket packet) { MobileStatusCompactPacket p = (MobileStatusCompactPacket)packet; if (p.StatusType >= 6) { throw (new Exception("KR Status not handled.")); } Mobile u = EntitiesCollection.GetObject<Mobile>(p.Serial, false); u.Name = p.PlayerName; u.Strength = p.Strength; u.Dexterity = p.Dexterity; u.Intelligence = p.Intelligence; u.Health.Update(p.CurrentHealth, p.MaxHealth); u.Stamina.Update(p.CurrentStamina, p.MaxStamina); u.Mana.Update(p.CurrentMana, p.MaxMana); u.Followers.Update(p.FollowersCurrent, p.FollowersMax); u.Weight.Update(p.Weight, p.WeightMax); u.StatCap = p.StatCap; u.Luck = p.Luck; u.Gold = p.GoldInInventory; u.ArmorRating = p.ArmorRating; u.ResistFire = p.ResistFire; u.ResistCold = p.ResistCold; u.ResistPoison = p.ResistPoison; u.ResistEnergy = p.ResistEnergy; u.DamageMin = p.DamageMin; u.DamageMax = p.DamageMax; // other stuff unhandled !!! }
private static void receive_PlayerMove(IRecvPacket packet) { PlayerMovePacket p = (PlayerMovePacket)packet; announce_UnhandledPacket(packet); }
private static void receive_ResurrectionMenu(IRecvPacket packet) { // int iAction = reader.ReadByte(); // 0: Server sent // 1: Resurrect // 2: Ghost // The only use on OSI for this packet is now sending "2C02" for the "You Are Dead" screen upon character death. announce_UnhandledPacket(packet); }
private static void receive_PlayerLocaleAndBody(IRecvPacket packet) { LoginConfirmPacket p = (LoginConfirmPacket)packet; // When loading the player object, we must load the serial before the object. EntitiesCollection.MySerial = p.Serial; PlayerMobile iPlayer = EntitiesCollection.GetObject<PlayerMobile>(p.Serial, true); iPlayer.Move_Instant(p.X, p.Y, p.Z, p.Direction); // iPlayer.SetFacing(p.Direction); // We want to make sure we have the client object before we load the world... if (Status == UltimaClientStatus.WorldServer_LoginComplete) Status = UltimaClientStatus.WorldServer_InWorld; }
private static void receive_RequestNameResponse(IRecvPacket packet) { RequestNameResponsePacket p = (RequestNameResponsePacket)packet; Mobile u = EntitiesCollection.GetObject<Mobile>(p.Serial, false); u.Name = p.MobileName; }
private static void receive_OverallLightLevel(IRecvPacket packet) { // byte iLightLevel = reader.ReadByte(); // 0x00 - day // 0x09 - OSI night // 0x1F - Black // Max normal val = 0x1F OverallLightLevelPacket p = (OverallLightLevelPacket)packet; // Console.WriteLine("OverallLight: {0}", p.LightLevel); _worldService.OverallLightning = p.LightLevel; }
private static void receive_RejectMoveItemRequest(IRecvPacket packet) { LiftRejectionPacket p = (LiftRejectionPacket)packet; _LegacyUI.AddMessage_Chat("Could not pick up item: " + p.ErrorMessage); _LegacyUI.Cursor.ClearHolding(); }
private static void receive_OpenPaperdoll(IRecvPacket packet) { announce_UnhandledPacket(packet); }
private static void receive_QuestArrow(IRecvPacket packet) { announce_UnhandledPacket(packet); }
private static void receive_OnSwing(IRecvPacket packet) { SwingPacket p = (SwingPacket)packet; if (p.Attacker == EntitiesCollection.MySerial) { ClientVars.EngineVars.LastTarget = p.Defender; } }
private static void receive_PopupMessage(IRecvPacket packet) { PopupMessagePacket p = (PopupMessagePacket)packet; _LegacyUI.MsgBox(p.Message, MsgBoxTypes.OkOnly); }
private static void receive_ObjectPropertyList(IRecvPacket packet) { ObjectPropertyListPacket p = (ObjectPropertyListPacket)packet; Entity iObject = EntitiesCollection.GetObject<Entity>(p.Serial, false); iObject.PropertyList.Hash = p.Hash; iObject.PropertyList.Clear(); for (int i = 0; i < p.CliLocs.Count; i++) { string iCliLoc = Data.StringList.Entry(p.CliLocs[i]); if (p.Arguements[i] == string.Empty) { iObject.PropertyList.AddProperty(iCliLoc); } else { iObject.PropertyList.AddProperty(constructCliLoc(iCliLoc, p.Arguements[i])); } } }
private static void receive_PlaySoundEffect(IRecvPacket packet) { PlaySoundEffectPacket p = (PlaySoundEffectPacket)packet; Data.Sounds.PlaySound(p.SoundModel); }
private static void receive_NewSubserver(IRecvPacket packet) { SubServerPacket p = (SubServerPacket)packet; announce_UnhandledPacket(packet); }
private static void receive_PlayMusic(IRecvPacket packet) { PlayMusicPacket p = (PlayMusicPacket)packet; // System.Console.WriteLine ( "Play music, id={0}", p.MusicID ); Data.Music.PlayMusic(p.MusicID); }
private static void receive_SetWeather(IRecvPacket packet) { announce_UnhandledPacket(packet); }
private static void receive_ServerRelay(IRecvPacket packet) { ServerRelayPacket p = (ServerRelayPacket)packet; // Normally, upon receiving this packet you would disconnect and // log in to the specified server. Since we are using RunUO, we don't // actually need to do this. _ClientNetwork.IsDecompressionEnabled = true; Send(new GameLoginPacket(p.AccountId, _account, _password)); }