示例#1
0
 /// <summary>
 /// Sends the dialog text of an npc.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="text">The text.</param>
 public static void SendDialog(Entities.GameClient client, string text)
 {
     using (var reply = new NPCResponsePacket(new StringPacker(text)))
     {
         reply.Action = Enums.NPCDialogAction.Text;
         reply.Option = 255;
         client.Send(reply);
     }
 }
示例#2
0
 /// <summary>
 /// Sends a dialog option.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="text">The text of the option.</param>
 /// <param name="option">The dialog option id.</param>
 public static void SendOption(Entities.GameClient client, string text, byte option)
 {
     using (var reply = new NPCResponsePacket(new StringPacker(text)))
     {
         reply.Action = Enums.NPCDialogAction.Link;
         reply.Option = option;
         client.Send(reply);
     }
 }
示例#3
0
 public static void Handle(Entities.GameClient client, ItemPacket packet)
 {
     if (client.Booth != null)
     {
         return;
     }
     packet.Data1 = client.WarehouseMoney;
     client.Send(packet);
 }
示例#4
0
        public static void Handle(Entities.GameClient client, DataPacket packet)
        {
            using (var warehouse = new WarehousePacket(packet))
            {
                Data.Warehouse wh;
                if (client.Warehouses.TryGetValue((ushort)warehouse.WarehouseID, out wh))
                {
                    switch (warehouse.Action)
                    {
                    case Enums.WarehouseAction.Display:
                    {
                        wh.SendAll();
                        break;
                    }

                    case Enums.WarehouseAction.Add:
                    {
                        if (wh.FreeSpaces == 20)
                        {
                            return;
                        }

                        if (client.Inventory.ContainsByUID(warehouse.Identifier))
                        {
                            Data.ItemInfo item = client.Inventory.RemoveItemByUID(warehouse.Identifier);
                            if (item != null)
                            {
                                wh.AddItem(item);
                            }
                        }
                        break;
                    }

                    case Enums.WarehouseAction.Remove:
                    {
                        if (client.Inventory.FreeSpaces == 40)
                        {
                            return;
                        }

                        if (wh.ContainsByUID(warehouse.Identifier))
                        {
                            Data.ItemInfo item = wh.RemoveItemByUID(warehouse.Identifier);
                            if (item != null)
                            {
                                client.Inventory.AddItem(item);
                                //warehouse.WhType = 10;
                                client.Send(warehouse);
                            }
                        }
                        break;
                    }
                    }
                }
            }
        }
示例#5
0
 /// <summary>
 /// Sends a dialog inputbox.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="option">The dialog option id.</param>
 public static void SendInput(Entities.GameClient client, byte option)
 {
     using (var reply = new NPCResponsePacket(new StringPacker()))
     {
         reply.Action = Enums.NPCDialogAction.Edit;
         reply.Data   = 16;
         reply.Option = option;
         client.Send(reply);
     }
 }
示例#6
0
        public void SendGiveUp(Entities.GameClient Winner)
        {
            using (var action = new Packets.ArenaActionPacket())
            {
                action.DialogID = 4;
                action.OptionID = 0;

                Winner.Send(action);
            }
        }
示例#7
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);
 }
示例#8
0
        /// <summary>
        /// Adds an item to the inventory.
        /// </summary>
        /// <param name="item">The item to add.</param>
        /// <param name="pos">The position in the inventory.</param>
        /// <returns>Returns true if the item was added.</returns>
        public bool AddItem(ItemInfo item, byte pos)
        {
            if (Count >= 40)
            {
                using (var fmsg = Packets.Message.MessageCore.CreateSystem2(Owner.Name, Core.MessageConst.INVENTORY_FULL))
                    Owner.Send(fmsg);
                return(false);
            }

            if (InventoryItems.TryAdd(pos, item))
            {
                item.OwnerUID = Owner.EntityUID;
                item.Location = Enums.ItemLocation.Inventory;
                Database.CharacterDatabase.SaveInventory(Owner, item, pos);
                SendItemToClient(item);
                return(true);
            }
            return(false);
        }
示例#9
0
        public static void SendLose(Entities.GameClient Loser)
        {
            using (var action = new Packets.ArenaActionPacket())
            {
                action.DialogID = 10;
                action.OptionID = 0;

                Loser.Send(action);
            }
        }
示例#10
0
        /// <summary>
        /// Adds an item to the warehouse.
        /// </summary>
        /// <param name="item">The item to add.</param>
        /// <param name="pos">The position in the inventory.</param>
        /// <returns>Returns true if the item was added.</returns>
        public bool AddItem(ItemInfo item, byte pos)
        {
            if (Count >= 20)
            {
                using (var fmsg = Packets.Message.MessageCore.CreateSystem2(Owner.Name, Core.MessageConst.INVENTORY_FULL))
                    Owner.Send(fmsg);
                return(false);
            }

            if (WarehouseItems.TryAdd(pos, item))
            {
                item.OwnerUID = Owner.EntityUID;
                Database.CharacterDatabase.SaveWarehouse(Owner, item, pos, WhID);
                //SendAll();
                SendSingle(item);
                return(true);
            }
            return(false);
        }
示例#11
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;
 }
示例#12
0
        public static void Marriage(Entities.GameClient client)
        {
            GeneralDataPacket pack = new GeneralDataPacket();

            pack.Id        = client.EntityUID;
            pack.Data1     = 1067;
            pack.Action    = Enums.DataAction.PostCmd;          //(Enums.DataAction)116;
            pack.Data3Low  = client.X;
            pack.Data3High = client.Y;
            client.Send(pack);
        }
示例#13
0
 /// <summary>
 /// Handling the QueryEquipment & QueryFriendEquip action from GeneralDataPacket.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="General">The GeneralDataPacket.</param>
 public static void Handle(Entities.GameClient client, GeneralDataPacket General)
 {
     Entities.GameClient target;
     if (Core.Kernel.Clients.TrySelect(General.Data1, out target))
     {
         client.Send(target.CreateSpawnPacket());
         foreach (Data.ItemInfo equip in target.Equipments.Equips.Values)
         {
             equip.SendViewPacket(target.EntityUID, client);
         }
         using (var msg = Packets.Message.MessageCore.CreateSystem(
                    target.Name,
                    string.Format(Core.MessageConst.VIEW_EQUIP, client.Name)))
             target.Send(msg);
         using (var stringpacket = new Packets.StringPacket(new StringPacker(target.SpouseName)))
         {
             stringpacket.Action = Enums.StringAction.QueryMate;
             client.Send(stringpacket);
         }
     }
 }
示例#14
0
 public static void Handle(Entities.GameClient client, StringPacket strings)
 {
     Entities.GameClient reqClient;
     if (Core.Kernel.Clients.TrySelect(strings.Data, out reqClient))
     {
         using (var newstrings = new StringPacket(new StringPacker(reqClient.SpouseName)))
         {
             newstrings.Action = Enums.StringAction.QueryMate;
             client.Send(newstrings);
         }
     }
 }
示例#15
0
        /// <summary>
        /// Handling the Drop action from the ItemPacket.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="item">The item packet.</param>
        public static void Handle(Entities.GameClient client, ItemPacket packet)
        {
            if (client.Booth != null)
            {
                return;
            }
            if (!client.Alive)
            {
                return;
            }
            if (client.Map.MapType == Enums.MapType.Shared)
            {
                return;
            }

            if (client.Inventory.ContainsByUID(packet.UID))
            {
                Maps.MapPoint Location = client.Map.CreateAvailableLocation <Data.GroundItem>(client.X, client.Y, 3);

                if (Location != null)
                {
                    Data.ItemInfo dropitem = client.Inventory.GetItemByUID(packet.UID);

                    if (dropitem != null)
                    {
                        if (!dropitem.IsValidOffItem())
                        {
                            using (var fmsg = Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.NO_PERMISSION_ITEM))
                            {
                                client.Send(fmsg);
                            }
                            return;
                        }
                        client.Inventory.RemoveItemByUID(packet.UID);

                        Data.GroundItem ground = new Data.GroundItem(dropitem);
                        ground.PlayerDrop = true;
                        ground.DropType   = Enums.DropItemType.Item;
                        ground.X          = Location.X;
                        ground.Y          = Location.Y;
                        Location.Map.EnterMap(ground);
                        ground.TaskID = ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(
                            () => {
                            Location.Map.LeaveMap(ground);
                            ground.Screen.ClearScreen();
                        },
                            Core.TimeIntervals.DroppedItemRemove);
                        ground.Screen.UpdateScreen(null);
                    }
                }
            }
        }
示例#16
0
        /// <summary>
        /// Handles the AddItem subtype of the TradePacket.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="trade">The trade packet.</param>
        public static void Handle(Entities.GameClient client, TradePacket trade)
        {
            if (!client.Trade.Trading)
            {
                return;
            }
            if (!client.Trade.WindowOpen)
            {
                return;
            }

            uint itemuid = trade.TargetUID;

            if (client.Inventory.ContainsByUID(itemuid))
            {
                Data.ItemInfo item = client.Inventory[itemuid];

                if (!item.IsValidOffItem())
                {
                    using (var fmsg = Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.NO_PERMISSION_ITEM))
                    {
                        client.Send(fmsg);
                    }
                    return;
                }

                if ((client.Trade.Partner.Inventory.Count + client.Trade.Items.Count) >= 40)
                {
                    using (var fmsg = Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.TARGET_FULL_INVENTORY))
                    {
                        client.Send(fmsg);
                    }
                    return;
                }

                client.Trade.Items.Add(item);
                item.SendPacket(client.Trade.Partner, 2);
            }
        }
 public static void Handle(Entities.GameClient client, GuildPacket guild)
 {
     if (client.Guild != null)
     {
         client.SendGuild();
         using (var announce = new Packets.GuildPacket(new Packets.StringPacker(client.Guild.Bullentin)))
         {
             announce.Data   = Core.Kernel.TimeGet(Enums.TimeType.Day);
             announce.Action = Enums.GuildAction.SetAnnounce;
             client.Send(announce);
         }
     }
 }
示例#18
0
        /// <summary>
        /// Handling the GetItemSet action from GeneralDataPacket.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="General">The GeneralDataPacket.</param>
        public static void Handle(Entities.GameClient client, GeneralDataPacket General)
        {
            client.Send(General);

            client.LoginProtection = DateTime.Now;
            client.LoggedIn        = true;

            client.Inventory.SendAll();

            client.Equipments.SendItemInfos();
            client.Equipments.SendGears();

            client.Screen.UpdateScreen(null);
        }
示例#19
0
        /// <summary>
        /// Handling the Sell action from the ItemPacket.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="item">The item packet.</param>
        public static void Handle(Entities.GameClient client, ItemPacket packet)
        {
            if (client.Booth != null)
            {
                return;
            }
            if (!client.Alive)
            {
                return;
            }

            Data.Shop shop;
            if (Core.Kernel.Shops.TryGetValue(packet.UID, out shop))
            {
                if (Core.Screen.GetDistance(shop.AssociatedNPC.X, shop.AssociatedNPC.Y, client.X, client.Y) >= Core.NumericConst.MaxNPCDistance)
                {
                    using (var fmsg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.TOO_FAR_NPC))
                        client.Send(fmsg);
                    return;
                }
                Data.ItemInfo sellitem = client.Inventory.GetItemByUID(packet.Data1);
                if (!sellitem.IsValidOffItem())
                {
                    using (var fmsg = Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.NO_PERMISSION_ITEM))
                    {
                        client.Send(fmsg);
                    }
                    return;
                }

                uint giveback = (uint)(sellitem.Price / 3);
                if (client.Inventory.RemoveItemByUID(packet.Data1) != null)
                {
                    client.Money += giveback;
                }
            }
        }
示例#20
0
 public void LeaveWatcher(Entities.GameClient Watcher)
 {
     Watcher.CanAttack = true;
     if (!Watcher.LeaveDynamicMap())
     {
         Watcher.NetworkClient.Disconnect("Could not leave dynamic map...");
     }
     else
     {
         Watchers.Remove(Watcher);
         Watcher.Arena.Status = Enums.ArenaStatus.NotSignedUp;
         using (var wait = Watcher.Arena.Build())
             Watcher.Send(wait);
     }
 }
示例#21
0
        /// <summary>
        /// Sends spell info to the client.
        /// </summary>
        /// <param name="client">The client.</param>
        public void SendSpellToClient(Entities.GameClient client)
        {
            if (!client.LoggedIn)
            {
                return;
            }

            using (var spell = new Packets.SendSpellPacket())
            {
                spell.ID         = ID;
                spell.Level      = Level;
                spell.Experience = Experience;
                client.Send(spell);
            }
        }
        public static void Handle(Entities.GameClient client, DataPacket packet)
        {
            if (client.Guild == null)
            {
                return;
            }

            using (var donation = new GuildDonationPacket())
            {
                donation.DonationFlag = Enums.GuildDonationFlags.AllDonations;
                donation.Money        = client.GuildMemberInfo.MoneyDonation;
                donation.CPs          = client.GuildMemberInfo.CPDonation;
                client.Send(donation);
            }
        }
示例#23
0
        /// <summary>
        /// Handles the Close subtype of the TradePacket.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="trade">The trade packet.</param>
        public static void Handle(Entities.GameClient client, TradePacket trade)
        {
            if (client.Trade.Partner != null)
            {
                Entities.GameClient partner = client.Trade.Partner;

                partner.Trade.Reset();
                client.Trade.Reset();

                trade.TradeType = Enums.TradeType.HideTable;
                trade.TargetUID = partner.EntityUID;
                client.Send(trade);
                trade.TargetUID = client.EntityUID;
                partner.Send(trade);
            }
        }
示例#24
0
        public static void Handle(Entities.GameClient client, GeneralDataPacket general)
        {
            if (client.Team == null)
            {
                return;
            }

            uint TargetID = general.Data1;

            Entities.GameClient TeamMember;
            if (client.Team.Members.TryGetValue(TargetID, out TeamMember))
            {
                general.Data3Low  = TeamMember.X;
                general.Data3High = TeamMember.Y;
                client.Send(general);
            }
        }
示例#25
0
        public static bool HandleSelf(Entities.IEntity attacker, Entities.IEntity target, InteractionPacket interaction, UseSpellPacket usespell, Data.Spell spell, out uint damage)
        {
            damage = 0;
            if (target != null)
            {
                if (target is Entities.NPC)
                {
                    return(false);
                }

                if (target.EntityUID != attacker.EntityUID)
                {
                    return(false);
                }
            }
            if (attacker is Entities.GameClient)
            {
                Entities.GameClient client = (attacker as Entities.GameClient);
                if (!(DateTime.Now >= client.LastSmallLongSkill.AddMilliseconds(Core.TimeIntervals.SmallLongSkillInterval)) && client.AttackPacket == null)
                {
                    using (var fmsg = Packets.Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.REST))
                        client.Send(fmsg);
                    return(false);
                }
                client.LastSmallLongSkill = DateTime.Now;
            }
            if (spell.ID == 1190 || spell.ID == 7016)
            {
                attacker.HP += spell.Power;
            }
            else
            {
                attacker.MP += spell.Power;
            }

            uint exp = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next((int)spell.Power, (int)spell.Power * 2);

            if ((attacker is Entities.GameClient))
            {
                (attacker as Entities.GameClient).AddSpellExp(spell.SpellID, exp);
            }

            usespell.AddTarget(attacker.EntityUID, spell.Power);

            return(true);
        }
示例#26
0
        public static void Handle(Entities.GameClient client, ItemPacket packet)
        {
            if (client.Booth == null)
            {
                return;
            }

            uint uid = packet.UID;

            if (client.Booth.BoothItems.ContainsKey(uid))
            {
                Data.BoothItem rItem;
                if (client.Booth.BoothItems.TryRemove(uid, out rItem))
                {
                    client.Send(packet);
                }
            }
        }
示例#27
0
        public static void Handle(Entities.GameClient client, GuildPacket guild)
        {
            uint guilduid = guild.Data;

            if (guilduid > 0)
            {
                Data.Guild realguild;
                if (Core.Kernel.Guilds.TrySelect(guilduid, out realguild))
                {
                    using (var stringpacket = new Packets.StringPacket(new StringPacker(realguild.StringInfo)))
                    {
                        stringpacket.Action = Enums.StringAction.Guild;
                        stringpacket.Data   = guilduid;
                        client.Send(stringpacket);
                    }
                }
            }
        }
示例#28
0
        public void SendCountDown(string Name, uint Level, uint Class, uint Ranking, uint EntityUID, Entities.GameClient To)
        {
            using (var action = new Packets.ArenaActionPacket())
            {
                action.DialogID = 8;
                action.OptionID = 0;

                action.Name        = Name;
                action.Level       = Level;
                action.ArenaPoints = 0;
                action.Class       = Class;
                action.Rank        = Ranking;
                action.EntityUID   = EntityUID;
                action.Unknown40   = 1;

                To.Send(action);
            }
        }
示例#29
0
        public void SendCountDown(Entities.GameClient From, Entities.GameClient To)
        {
            using (var action = new Packets.ArenaActionPacket())
            {
                action.DialogID = 8;
                action.OptionID = 0;

                action.Name        = From.Name;
                action.Level       = (uint)From.Level;
                action.ArenaPoints = From.Arena.ArenaHonorPoints;
                action.Class       = (uint)From.Class;
                action.Rank        = From.Arena.ArenaRanking;
                action.EntityUID   = From.EntityUID;
                action.Unknown40   = 1;

                To.Send(action);
            }
        }
示例#30
0
        public static void Handle(Entities.GameClient client, ItemPacket packet)
        {
            if (client.Booth == null)
            {
                return;
            }
            uint uid = packet.UID;

            if (client.Inventory.ContainsByUID(uid))
            {
                Data.BoothItem boothItem = new ProjectX_V3_Game.Data.BoothItem(true);
                boothItem.ItemUID = uid;
                boothItem.Price   = packet.Data1;
                if (client.Booth.BoothItems.TryAdd(uid, boothItem))
                {
                    client.Send(packet);
                }
            }
        }