public override void ExecuteCommand(Client client, Identity target, string[] args) { client.SendChatText("Looking up for statel in playfield " + client.Character.PlayField.ToString()); Statels.Statel o = null; foreach (Statels.Statel s in Statels.Statelppf[client.Character.PlayField]) { if (o == null) { o = s; } else { if (AOCoord.Distance2D(client.Character.Coordinates, s.Coordinates) < AOCoord.Distance2D(client.Character.Coordinates, o.Coordinates)) { o = s; } } } if (o == null) { client.SendChatText("No statel on this playfield... Very odd, where exactly are you???"); return; } client.SendChatText(o.Type + ":" + o.Instance); foreach (Statels.StatelEvent se in o.Events) { client.SendChatText( "Event: " + se.EventNumber.ToString() + " # of Functions: " + se.Functions.Count.ToString()); foreach (Statels.Statel_Function sf in se.Functions) { string Fargs = ""; foreach (string arg in sf.Arguments) { if (Fargs.Length > 0) { Fargs = Fargs + ", "; } Fargs = Fargs + arg; } client.SendChatText( " Fn: " + sf.FunctionNumber.ToString() + ", # of Args: " + sf.Arguments.Count.ToString()); client.SendChatText(" Args: " + Fargs); foreach (Statels.Statel_Function_Requirement sfr in sf.Requirements) { string req; req = "Attr: " + sfr.AttributeNumber.ToString() + " Value: " + sfr.AttributeValue.ToString() + " Target: " + sfr.Target.ToString() + " Op: " + sfr.Operator.ToString(); client.SendChatText(" Req: " + req); } } } }
/// <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 } }