/// <summary> /// The read. /// </summary> /// <param name="packet"> /// The packet. /// </param> /// <param name="client"> /// The client. /// </param> /// <param name="dynel"> /// The dynel. /// </param> public static void Read(byte[] packet, Client client, Dynel dynel) { sender = client; PacketReader packetReader = new PacketReader(packet); packetReader.PopHeader(); packetReader.PopByte(); temp1 = packetReader.PopInt(); count = packetReader.PopInt(); // Count of commands sent action = packetReader.PopInt(); temp4 = packetReader.PopInt(); user = packetReader.PopIdentity(); target = packetReader.PopIdentity(); packetReader.Finish(); bool feedback = true; switch (action) { case 1: // Get break; case 2: // Drop break; case 3: // Use OnUse(); AOCoord newcoord = client.Character.Coordinates; feedback = false; if (Statels.StatelppfonUse.ContainsKey(client.Character.PlayField)) { foreach (Statels.Statel s in Statels.StatelppfonUse[client.Character.PlayField]) { if (s.onUse(client, target)) { return; } } } bool teleport = false; int playfield = 152; switch (target.Instance) { // Need to add feedback to the character // Are the Newer Grid points in this list??? // No newer Grid points in list, will be replaced by a check against a list of statels read from rdb anyway // - Algorithman case -1073605919: // Teleport Tower(noobisland)(right) if (client.Character.Stats.Side.Value != 2) { client.SendChatText("You need to be omni to use this teleporter!"); teleport = false; } else { newcoord.x = 202; newcoord.z = 878; newcoord.y = 16; playfield = 687; } break; case -1073736991: // Teleport Tower(noobisland)(left) if (client.Character.Stats.Side.Value != 1) { client.SendChatText("You need to be clan to use this teleporter!"); teleport = false; } else { newcoord.x = 390; newcoord.z = 340; newcoord.y = 0; playfield = 545; } break; case -1073671455: // Teleport Tower(noobisland)(middle) if (client.Character.Stats.Side.Value != 0) { client.SendChatText("You need to be neutral to use this teleporter!"); teleport = false; } else { newcoord.x = 685; newcoord.z = 480; newcoord.y = 73; playfield = 800; } break; case -1073741189: // 2ho -> Stret west if (client.Character.Stats.Cash.Value < 50) { // check if you got enough credits to use the ferry client.SendChatText("You need atleast 50 credits to board this ferry!"); teleport = false; } else { client.Character.Stats.Cash.Set(client.Character.Stats.Cash.Value - 50); newcoord.x = 1143; newcoord.z = 541; newcoord.y = 8; playfield = 790; } break; case -1073478890: // Stret West -> 2ho if (client.Character.Stats.Cash.Value < 50) { // check if you got enough credits to use the ferry client.SendChatText("You need atleast 50 credits to board this ferry!"); teleport = false; } else { client.Character.Stats.Cash.Set(client.Character.Stats.Cash.Value - 50); newcoord.x = 760; newcoord.z = 1982; newcoord.y = 7; playfield = 635; } break; case -1073216841: // Harry's -> Plesant Meadows if (client.Character.Stats.Cash.Value < 50) { // check if you got enough credits to use the ferry client.SendChatText("You need atleast 50 credits to board this ferry!"); teleport = false; } else { client.Character.Stats.Cash.Set(client.Character.Stats.Cash.Value - 50); newcoord.x = 370; newcoord.z = 1564; newcoord.y = 7; playfield = 630; } break; case -1073216906: // Plesant Meadows -> Harry's if (client.Character.Stats.Cash.Value < 50) { // check if you got enough credits to use the ferry client.SendChatText("You need atleast 50 credits to board this ferry!"); teleport = false; } else { client.Character.Stats.Cash.Set(client.Character.Stats.Cash.Value - 50); newcoord.x = 3196; newcoord.z = 3172; newcoord.y = 7; playfield = 695; } break; case -1073282442: // Pleasant Meadows -> Omni-Tek outpost in Lush Fields if (client.Character.Stats.Cash.Value < 50) { // check if you got enough credits to use the ferry client.SendChatText("You need atleast 50 credits to board this ferry!"); teleport = false; } else { client.Character.Stats.Cash.Set(client.Character.Stats.Cash.Value - 50); newcoord.x = 3389; newcoord.z = 800; newcoord.y = 8; playfield = 695; } break; case -1073413449: // Omni-Tek outpost in Lush Fields -> Pleasant Meadows if (client.Character.Stats.Cash.Value < 50) { // check if you got enough credits to use the ferry client.SendChatText("You need atleast 50 credits to board this ferry!"); teleport = false; } else { client.Character.Stats.Cash.Set(client.Character.Stats.Cash.Value - 50); newcoord.x = 370; newcoord.z = 1562; newcoord.y = 7; playfield = 630; } break; case -1073347913: // Harry's trading outpost -> Omni-1 Trade (free) newcoord.x = 3569; newcoord.z = 912; newcoord.y = 9; playfield = 695; break; case -1073282377: // Omni-1 Trade -> Harry's trading outpost (free) newcoord.x = 3290; newcoord.z = 2922; newcoord.y = 7; playfield = 695; break; default: feedback = true; teleport = false; break; } if (teleport) { client.Teleport(newcoord, client.Character.Heading, playfield); } // Use item in inventory if (target.Type == 104) { InventoryEntries ie = client.Character.GetInventoryAt(target.Instance); AOItem mi = ItemHandler.GetItemTemplate(ie.Item.LowID); // TODO mi.applyon(client.Character, ItemHandler.eventtype_onuse, true, false, ie.Placement); TemplateAction.Send(client.Character, ie); if (mi.isConsumable()) { ie.Item.MultipleCount--; if (ie.Item.MultipleCount <= 0) { client.Character.Inventory.Remove(ie); DeleteItem.Send(client.Character, ie.Container, ie.Placement); // Packets.Stat.Set(client, 0, client.Character.Stats.GetStat(0),false); } } foreach (AOEvents aoe in mi.Events) { if (aoe.EventType == Constants.EventtypeOnUse) { sender.Character.ExecuteEvent( sender.Character, sender.Character, aoe, true, false, 0, CheckReqs.doCheckReqs); SkillUpdate.SendStat(client, 0x209, client.Character.Stats.SocialStatus.Value, false); // Social Status return; } } int le = packet[7] + packet[6] * 256; byte[] reply = new byte[le]; Array.Copy(packet, reply, le); reply[0] = 0xdf; reply[1] = 0xdf; reply[8] = 0x00; reply[9] = 0x00; reply[10] = 0x0C; reply[11] = 0x0E; reply[12] = (byte)(client.Character.Id >> 24); reply[13] = (byte)(client.Character.Id >> 16); reply[14] = (byte)(client.Character.Id >> 8); reply[15] = (byte)client.Character.Id; reply[0x1c] = 0; reply[32] = 1; reply[36] = 3; PacketWriter pw = new PacketWriter(); pw.PushBytes(reply); byte[] rep = pw.Finish(); client.SendCompressed(rep); SkillUpdate.SendStat(client, 0x209, client.Character.Stats.SocialStatus.Value, false); // Social Status return; } else if (target.Type == 51035) { // Shops VendingMachine vm = VendorHandler.GetVendorById(target.Instance); ShopInventory.Send(client, vm); Trade.Send(client, client.Character, vm); Trade.Send(client, vm, client.Character); Trade.Send(client, vm, client.Character); int le = packet[7] + packet[6] * 256; byte[] reply = new byte[le]; Array.Copy(packet, reply, le); reply[0] = 0xdf; reply[1] = 0xdf; reply[8] = 0x00; reply[9] = 0x00; reply[10] = 0x0C; reply[11] = 0x0E; reply[12] = (byte)(client.Character.Id >> 24); reply[13] = (byte)(client.Character.Id >> 16); reply[14] = (byte)(client.Character.Id >> 8); reply[15] = (byte)client.Character.Id; reply[0x1c] = 0; reply[0x20] = 1; client.Character.LastTrade = target; PacketWriter pw = new PacketWriter(); pw.PushBytes(reply); byte[] rep = pw.Finish(); client.SendCompressed(rep); } else if (target.Type == 51050) { // Open corpse } break; case 4: // Repair break; case 5: // UseItemOnItem #if DEBUG Console.WriteLine("Use Item on Item not defined yet"); Console.WriteLine("Packet data:"); string line = string.Empty; int count2 = 0; foreach (byte packbyte in packet) { if ((count2 % 16) == 0) { Console.WriteLine(line); line = string.Empty; } line = line + packbyte.ToString("X2") + " "; count2++; } if (line != string.Empty) { Console.WriteLine(); } Console.WriteLine(line); #endif break; default: break; } if (feedback) { #if DEBUG string Feedback1 = string.Format("T1 {0}, Count {1}, Action {2}, T4 {3}", temp1, count, action, temp4); string Feedback2 = string.Format( "User {0}:{1}, Target {2}:{3} ({4}:{5})", user.Type, user.Instance, target.Type, (uint)target.Instance, target.Type.ToString("X4"), ((uint)target.Instance).ToString("X8")); Statels.Statel b = null; if (Statels.Statelppf.ContainsKey(client.Character.PlayField)) { foreach (Statels.Statel z in Statels.Statelppf[client.Character.PlayField]) { if ((z.Type == target.Type) && ((Int32)z.Instance == target.Instance)) { b = z; break; } } } if (b != null) { foreach (Statels.StatelEvent e in b.Events) { Console.WriteLine("DebugOutput: \r\n" + e); } Console.WriteLine(b.Coordinates.ToString()); } else { Console.WriteLine( "No Statel defined in database for #" + target.Type + ":" + (UInt32)target.Instance + " (" + target.Type.ToString("X4") + ":" + target.Instance.ToString("X8") + ")"); } client.SendChatText(Feedback1); client.SendChatText(Feedback2); #endif } }
/// <summary> /// /// </summary> /// <param name="client"></param> /// <param name="packet"></param> /// <param name="messageNumber"></param> public void Parse(Client client, ref byte[] packet, int messageNumber) { // Some of these messages are never sent from // client to server, but I left them in just // in case I'm wrong about some packet. And to // allow server to log/disconnect clients that // send unexpected messages. *Suiv* int _type = ((int)((packet[20] << 24) + (packet[21] << 16) + (packet[22] << 8) + packet[23])); int _dynID = ((int)((packet[24] << 24) + (packet[25] << 16) + (packet[26] << 8) + packet[27])); Dynel dyn = Misc.FindDynel.FindDynelByID(_type, _dynID); switch (messageNumber) { case 0x000a0c5a: //KnubotNPCDescription break; case 0x052e2f0c: //AddTemplate break; case 0x0639474d: //GridDestinationSelect break; case 0x0C5a5d6d: //WeatherControl break; case 0x0d381f02: //PetToMaster break; case 0x1078735a: //FlushRDBCaches break; case 0x1330734f: //ShopSearchResult break; case 0x145a4f66: //ShopSearchRequest break; case 0x166a435e: //AcceptBSInvite break; case 0x194e4f76: //AddPet break; case 0x195e496e: //SetPos break; case 0x1c3a4f77: //ReflectAttack break; case 0x1d3c0f1c: //SpecialAttackWeapon break; case 0x2001377e: //MentorInvite break; case 0x2049527c: //Action break; case 0x204f4871: //Script break; case 0x206b4b73: //FormatFeedback break; case 0x2103247d: //KnubotAnswer break; case 0x212c487a: //Quest break; case 0x215b5678: //MineFullUpdate break; case 0x2252445f: //LookAt if (dyn != null) { ((Character)dyn).setTarget(ref packet); } break; case 0x25192476: //ShieldAttack break; case 0x25314d6d: //CastNanoSpell break; case 0x253d024c: //ResearchUpdate break; case 0x260f3671: //FollowTarget FollowTarget.Read(ref packet, client, dyn); break; case 0x264b514b: //RelocateDynels break; case 0x264e5f61: //Absorb break; case 0x26515e61: //Reload break; case 0x270a4c62: //KnubotCloseChatWindow break; case 0x271b3a6b: //SimpleCharFullUpdate break; case 0x28251f01: //StartLogout break; case 0x28494070: //Attack break; case 0x28784248: //TeamMemberInfo break; case 0x29304349: //FullCharacter break; case 0x2933154f: //LaserTargetList break; case 0x2a253f5f: //TrapDisarmed break; case 0x2a293d0f: //Fov break; case 0x2b333d6e: //Stat break; case 0x2c2f061c: //QueueUpdate break; case 0x2d212407: //KnubotRejectedItems break; case 0x2e072a78: //PlayerShopFullUpdate break; case 0x2e2a4a6b: //OrgInfoPacket break; case 0x30161355: //n3PlayfieldFullUpdate break; case 0x3115534d: //ResearchRequest break; case 0x3129233b: //AreaFormula break; case 0x3301337a: //InfromPlayer break; case 0x333b2867: //Mail break; case 0x342c1d1d: //ApplySpells break; case 0x343c287f: //Bank break; case 0x353f4f52: //ShopInventory break; case 0x35505644: //TemplateAction break; case 0x36284f6e: //Trade OnTrade.read(ref packet, client, dyn); break; case 0x365a5071: //DoorFullUpdate break; case 0x365e555b: //CityAdvantages break; case 0x3710256c: //HealthDamage break; case 0x371d0542: //FightModeUpdate break; case 0x373e3513: //SetShopName break; case 0x39343c68: //Buff break; case 0x3a1b2c0c: //KnubotTrade break; case 0x3a243f41: //DropTemplate break; case 0x3a322a4a: //GridSelected break; case 0x3b11256f: //SimpleItemFullUpdate break; case 0x3b132d64: //KnubotOpenChatWindow break; case 0x3b1d2268: //WeaponItemFullUpdate break; case 0x3b290771: //SocialActionCmd SocialActionCmd.Read(ref packet, client); break; case 0x3b3b2878: //Raid break; case 0x3c1e2803: //ShadowLevel break; case 0x3c265179: //Clone break; case 0x3d5b4544: //ShopCommission break; case 0x3d746c7c: //ServerPathPosDebugInfo break; case 0x3e205660: //Skill SkillUpdate.Read(ref packet, client); break; case 0x3f3a1914: //LeaveBattle break; case 0x405b4f27: //ShopInfo break; case 0x41624f0d: //AppearanceUpdate break; case 0x43197d22: //n3Teleport break; case 0x435f7023: //PerkUpdate break; case 0x44483b3a: //SendScore break; case 0x445f2a0b: //Resurrect break; case 0x45072a0b: //UpdateClientVisual break; case 0x45273f0a: //HouseDemolishStart break; case 0x455d2938: //PlaySound break; case 0x46002f16: //AttackInfo break; case 0x46312d2e: //TeamMember break; case 0x464d000a: //SpawnMech break; case 0x465a4061: //QuestFullUpdate break; case 0x465a5d73: //ChestItemFullUpdate break; case 0x4727213e: //NanoAttack break; case 0x47483633: //DropDynel break; case 0x47537a24: //ContainerAddItem ContainerAddItem.Do(ref packet, client); break; case 0x49222612: //Visibility break; case 0x4a41203e: //StopFight break; case 0x4b062919: //BattleOver break; case 0x4b5e7202: //InventoryUpdated break; case 0x4c7d403b: //DoorStatusUpdate break; case 0x4d2a3a38: //TeamInvite break; case 0x4d333027: //ShopStatus break; case 0x4d38242e: //InfoPacket break; case 0x4d450114: //SpellList break; case 0x4e536976: //InventoryUpdate break; case 0x4f474e05: //CorpseFullUpdate break; case 0x50544d19: //Feedback break; case 0x51492120: //CharSecSpecAttack break; case 0x52213420: //BankCorpse break; case 0x52526858: //GenericCmd GenericCmd.Read(ref packet, client, dyn); break; case 0x5266632a: //PathMoveCmd break; case 0x540e3b27: //ArriveAtBs break; case 0x54111123: //CharDCMove CharDCMove.Read(ref packet, client); break; case 0x55220726: //PlayfieldAllTowers break; case 0x55682b24: //KnubotFinishTrade break; case 0x55704d3a: //KnubotAnswerList break; case 0x56353038: //StopLogout break; case 0x570c2039: //CharInPlay CharInPlay.Read(ref packet, client); break; case 0x58362220: //ShopUpdate break; case 0x58574239: //MechInfo break; case 0x58742a0f: //RemovePet break; case 0x59210126: //PlayfieldAllCities break; case 0x59313928: //TrapItemFullUpdate break; case 0x5a585f65: //Inspect break; case 0x5b1e052c: //PlayfieldTowerUpdateClient break; case 0x5c240404: //ServerPosDebugInfo break; case 0x5c436609: //QuestAlternative break; case 0x5c4a493a: //FullAuto break; case 0x5c525a7b: ChatCmd.Read(ref packet, client); break; case 0x5c654b28: //MissedAttackInfo break; case 0x5d70532a: //KnubotAppendText break; case 0x5e477770: CharacterAction.Read(ref packet, client); break; case 0x5e5b6007: //HouseDisappeared break; case 0x5f4a4c6c: //Impulse break; case 0x5f4b1a39: //PlayfieldAnarchyF break; case 0x5f4b442a: //ChatText break; case 0x5f52412e: //GameTime break; case 0x60201d0e: //SetWantedDirection break; case 0x62741e15: //AOTransportSignal break; case 0x63333303: //PetCommand break; case 0x64582a07: //OrgServer break; case 0x6e5f566e: //SetStat break; case 0x734e5a7b: //SetName break; case 0x742e2314: //StopMovingCmd break; case 0x754f1115: //SpecialAttackInfo break; case 0x77230927: //GiveQuestToMember break; case 0x7864401d: //KnubotStartTrade break; case 0x7a222202: //GfxTrigger break; case 0x7e00312f: //ShopItemPrice break; case 0x7f405a16: //NewLevel break; case 0x7f4b3108: //OrgClient OrgClient m_OrgClient = new OrgClient(); m_OrgClient.Read(ref packet, client); break; case 0x7f544905: //VendingMachineFullUpdate break; default: client.Server.Warning(client, "Client sent unknown N3Message {0:x8}", messageNumber.ToString()); break; } }