Esempio n. 1
0
 public void CreateBooth(Packets.GeneralDataPacket data)
 {
     foreach (Maps.IMapObject mapcarpet in ShopOwner.Screen.MapObjects.Values)
     {
         if (!(mapcarpet is Entities.NPC))
         {
             return;
         }
         Entities.NPC carpet = (mapcarpet as Entities.NPC);
         if (carpet.NPCType == Enums.NPCType.ShopFlag)
         {
             if (!carpet.IsTakenBooth)
             {
                 if (carpet.X == (ShopOwner.X - 2) && carpet.Y == ShopOwner.Y)
                 {
                     Carpet = carpet;
                     Carpet.IsTakenBooth = true;
                     break;
                 }
             }
         }
     }
     if (Carpet == null)             // could not find a carpet ...
     {
         ShopOwner.Booth = null;
         ShopOwner       = null;
         return;
     }
     Carpet.StartVending(ShopOwner.Name, this);
     Carpet.Screen.UpdateScreen(null);
     data.Data1 = Carpet.EntityUID;
     data.Id    = ShopOwner.EntityUID;
     ShopOwner.Send(data);
     ShopOwner.Screen.FullUpdate();
 }
        public static void Handle(Entities.GameClient client, DataPacket inPacket)
        {
            if (client.Trade.Trading)
                return;
            if (!client.Alive)
                return;

            using (var npcrequest = new NPCRequestPacket(inPacket))
            {
                try
                {
                    if (npcrequest.Option == 255)
                    {
                        client.CurrentNPC = null;
                        return;
                    }

                    if (Core.Kernel.Shops.ContainsKey(npcrequest.NPCID))
                    {
                        if (!Core.Kernel.Shops[npcrequest.NPCID].AssociatedNPC.IsInMap(client))
                        {
                            return;
                        }

                        Packets.GeneralDataPacket pack = new Packets.GeneralDataPacket();
                        pack.Action = Enums.DataAction.OpenUpgrade;
                        pack.Id = client.EntityUID;
                        pack.Data1 = 32;
                        pack.Data3Low = client.X;
                        pack.Data3High = client.Y;
                        pack.Timestamp = npcrequest.NPCID;
                        client.Send(pack);
                    }
                    else
                    {
                        Entities.NPC npc = Core.Kernel.NPCs[npcrequest.NPCID];
                        if (!npc.IsInMap(client))
                        {
                            return;
                        }

                        if (Core.Screen.GetDistance(client.X, client.Y, npc.X, npc.Y) >= Core.NumericConst.MaxNPCDistance && npc.NPCType != Enums.NPCType.Distance)
                        {
                            using (var fmsg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.TOO_FAR_NPC))
                                client.Send(fmsg);
                            return;
                        }
                        client.CurrentNPC = npc;

                        client.CurrentNPC.CallDialog(client, npcrequest.Option);
                    }
                }
                catch
                {
                    using (var fmsg = Packets.Message.MessageCore.CreateSystem(client.Name, string.Format("NPCID: {0}", npcrequest.NPCID)))
                        client.Send(fmsg);
                }
            }
        }
Esempio n. 3
0
 public static void OpenUpgrade(Entities.GameClient client, uint subtype)
 {
     Packets.GeneralDataPacket pack = new Packets.GeneralDataPacket();
     pack.Action    = Enums.DataAction.OpenUpgrade;
     pack.Id        = client.EntityUID;
     pack.Data1     = subtype;
     pack.Data2Low  = client.X;
     pack.Data2High = client.Y;
     client.Send(pack);
 }
Esempio n. 4
0
 //static uint NextWindow = 1;
 public static void OpenWindow(Entities.GameClient client, uint subtype)
 {
     Packets.GeneralDataPacket pack = new Packets.GeneralDataPacket();
     pack.Action    = Enums.DataAction.OpenDialog;
     pack.Id        = client.EntityUID;
     pack.Data1     = subtype;
     pack.Data2Low  = client.X;
     pack.Data2High = client.Y;
     client.Send(pack);
     //NextWindow += 1;
 }
Esempio n. 5
0
 //static uint NextWindow = 1;
 public static void OpenWindow(Entities.GameClient client, uint subtype)
 {
     Packets.GeneralDataPacket pack = new Packets.GeneralDataPacket();
     pack.Action = Enums.DataAction.OpenDialog;
     pack.Id = client.EntityUID;
     pack.Data1 = subtype;
     pack.Data2Low = client.X;
     pack.Data2High = client.Y;
     client.Send(pack);
     //NextWindow += 1;
 }
Esempio n. 6
0
 public static void OpenUpgrade(Entities.GameClient client, uint subtype)
 {
     Packets.GeneralDataPacket pack = new Packets.GeneralDataPacket();
     pack.Action = Enums.DataAction.OpenUpgrade;
     pack.Id = client.EntityUID;
     pack.Data1 = subtype;
     pack.Data2Low = client.X;
     pack.Data2High = client.Y;
     client.Send(pack);
 }
        public static void Handle(Entities.GameClient client, DataPacket inPacket)
        {
            if (client.Trade.Trading)
            {
                return;
            }
            if (!client.Alive)
            {
                return;
            }

            using (var npcrequest = new NPCRequestPacket(inPacket))
            {
                try
                {
                    if (npcrequest.Option == 255)
                    {
                        client.CurrentNPC = null;
                        return;
                    }

                    if (Core.Kernel.Shops.ContainsKey(npcrequest.NPCID))
                    {
                        if (!Core.Kernel.Shops[npcrequest.NPCID].AssociatedNPC.IsInMap(client))
                        {
                            return;
                        }

                        Packets.GeneralDataPacket pack = new Packets.GeneralDataPacket();
                        pack.Action    = Enums.DataAction.OpenUpgrade;
                        pack.Id        = client.EntityUID;
                        pack.Data1     = 32;
                        pack.Data3Low  = client.X;
                        pack.Data3High = client.Y;
                        pack.Timestamp = npcrequest.NPCID;
                        client.Send(pack);
                    }
                    else
                    {
                        Entities.NPC npc = Core.Kernel.NPCs[npcrequest.NPCID];
                        if (!npc.IsInMap(client))
                        {
                            return;
                        }

                        if (Core.Screen.GetDistance(client.X, client.Y, npc.X, npc.Y) >= Core.NumericConst.MaxNPCDistance && npc.NPCType != Enums.NPCType.Distance)
                        {
                            using (var fmsg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.TOO_FAR_NPC))
                                client.Send(fmsg);
                            return;
                        }
                        client.CurrentNPC = npc;

                        client.CurrentNPC.CallDialog(client, npcrequest.Option);
                    }
                }
                catch
                {
                    using (var fmsg = Packets.Message.MessageCore.CreateSystem(client.Name, string.Format("NPCID: {0}", npcrequest.NPCID)))
                        client.Send(fmsg);
                }
            }
        }