Esempio n. 1
0
        public static void Create(Entities.GameClient client, Packets.TeamActionPacket packet)
        {
            if (packet.EntityUID != client.EntityUID)
                return;
            if (client.Team != null)
                return;

            client.Team = new Team();
            client.Team.Leader = client.EntityUID;
            if (client.Team.Members.TryAdd(client.EntityUID, client))
            {
                using (var create = new Packets.TeamActionPacket())
                {
                    create.EntityUID = client.EntityUID;
                    create.Action = Enums.TeamAction.Leader;
                    client.Send(create);
                    create.Action = Enums.TeamAction.Create;
                    client.Send(create);
                }
                client.AddStatusEffect1(Enums.Effect1.TeamLeader, 0);
            }
            else
            {
                client.Team = null;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Handling the Court action of the interaction packet.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="interact">The interaction packet.</param>
        public static void Handle(Entities.GameClient client, InteractionPacket interact)
        {
            //uint marryUID = interact.TargetUID;

            //Entities.GameClient marrytarget;
            Maps.IMapObject obj;
            if (client.Map.MapObjects.TryGetValue(interact.TargetUID, out obj))
            {
                Entities.GameClient targ = obj as Entities.GameClient;
                if (client.SpouseDatabaseUID > 0)
                {
                    using (var fmsg = Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.MARRIAGE_SELF_SPOUSE))
                        client.Send(fmsg);
                    return;
                }
                if (targ.SpouseDatabaseUID > 0)
                {
                    using (var fmsg = Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.MARRIAGE_TARGET_SPOUSE))
                        client.Send(fmsg);
                    return;
                }

                targ.Send(interact);
            }
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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;
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Handling the EnterMap 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)
        {
            if (!Core.Kernel.Clients.Contains(client.EntityUID))
            {
                client.NetworkClient.Disconnect("Not added in clients.");
                return;
            }

            ushort SendMap = client.Map.InheritanceMap;
            GeneralDataPacket mapEnter = new GeneralDataPacket(Enums.DataAction.EnterMap)
            {
                Id = SendMap,
                Data1 = SendMap,
                Data3Low = client.X,
                Data3High = client.Y
            };
            client.Send(mapEnter);
            using (var mapinfo = new Packets.MapInfoPacket())
            {
                mapinfo.MapID = SendMap;
                mapinfo.DocID = SendMap; // not entire sure what docid is, will figure this out later!
                foreach (Enums.MapTypeFlags flag in client.Map.Flags.Values)
                    mapinfo.AddFlag(flag);

                mapinfo.Finish();
                client.Send(mapinfo);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Handling the Marry action of the interaction packet.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="interact">The interaction packet.</param>
        public static void Handle(Entities.GameClient client, InteractionPacket interact)
        {
            //uint marryUID = interact.TargetUID;

            //Entities.GameClient marrytarget;
            Maps.IMapObject obj;
            if (client.Map.MapObjects.TryGetValue(interact.TargetUID, out obj))
            {
                Entities.GameClient spouse = obj as Entities.GameClient;
                if (client.SpouseDatabaseUID > 0)
                {
                    using (var fmsg = Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.MARRIAGE_SELF_SPOUSE))
                        client.Send(fmsg);
                    return;
                }
                if (spouse.SpouseDatabaseUID > 0)
                {
                    using (var fmsg = Message.MessageCore.CreateSystem2(client.Name, Core.MessageConst.MARRIAGE_TARGET_SPOUSE))
                        client.Send(fmsg);
                    return;
                }

                client.SpouseDatabaseUID = spouse.DatabaseUID;
                spouse.SpouseDatabaseUID = client.DatabaseUID;
                //client.CharDB.AddSpouse(client.DatabaseUID, client.SpouseDatabaseUID);
                //spouse.CharDB.AddSpouse(spouse.DatabaseUID, spouse.SpouseDatabaseUID);
                Database.CharacterDatabase.AddSpouse(client, spouse);

                using (var mate = new Packets.StringPacket(new StringPacker(spouse.Name)))
                {
                    mate.Data = client.EntityUID;
                    mate.Action = Enums.StringAction.Mate;
                    client.Send(mate);
                }
                using (var mate = new Packets.StringPacket(new StringPacker(client.Name)))
                {
                    mate.Data = spouse.EntityUID;
                    mate.Action = Enums.StringAction.Mate;
                    spouse.Send(mate);
                }
                using (var fireworks = new Packets.StringPacket(new StringPacker("firework-2love")))
                {
                    fireworks.Action = Enums.StringAction.MapEffect;
                    fireworks.PositionX = client.X;
                    fireworks.PositionY = client.Y;
                    client.SendToScreen(fireworks, true);
                    fireworks.PositionX = spouse.X;
                    fireworks.PositionY = spouse.Y;
                    spouse.SendToScreen(fireworks, true);
                }

                using (var msg =Packets.Message.MessageCore.CreateSystem("ALL",
                                                                         string.Format(Core.MessageConst.MARRIAGE_CONGRATZ, client.Name, spouse.Name)))
                {
                    Packets.Message.MessageCore.SendGlobalMessage(msg);
                }
            }
        }
Esempio n. 7
0
        public static void Handle(Entities.GameClient client, ItemPacket packet)
        {
            uint uid = packet.UID;
            Data.Booth Booth = Data.Booth.FindBooth(uid);
            if (Booth != null)
            {
                if (!Booth.ShopOwner.IsInMap(client))
                    return;

                if (!Core.Screen.ValidDistance(client.X, client.Y, Booth.ShopOwner.X, Booth.ShopOwner.Y))
                    return;
                Data.BoothItem boothItem;
                if (Booth.BoothItems.TryGetValue(uid, out boothItem))
                {
                    if (boothItem.IsCP && client.CPs < boothItem.Price)
                    {
                        using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.LOW_CPS))
                            client.Send(msg);
                        return;
                    }
                    else if (client.Money < boothItem.Price)
                    {
                        using (var msg = Packets.Message.MessageCore.CreateSystem(client.Name, Core.MessageConst.LOW_MONEY2))
                            client.Send(msg);
                        return;
                    }
                    if (Booth.BoothItems.TryRemove(uid, out boothItem))
                    {
                        if (boothItem.IsCP)
                        {
                            client.CPs -= boothItem.Price;
                            Booth.ShopOwner.CPs += boothItem.Price;
                        }
                        else
                        {
                            client.Money -= boothItem.Price;
                            Booth.ShopOwner.Money += boothItem.Price;
                        }

                        client.Send(packet);

                        packet.Action = Enums.ItemAction.BoothDelete;
                        Booth.ShopOwner.Send(packet);

                        Data.ItemInfo item = Booth.ShopOwner.Inventory.RemoveItemByUID(uid);
                        client.Inventory.AddItem(item);

                        using (var msg = Packets.Message.MessageCore.CreateSystem(
                            Booth.ShopOwner.Name,
                            string.Format(Core.MessageConst.BOOTH_BUY, client.Name, item.Name)))
                            Booth.ShopOwner.Send(msg);

                        Database.CharacterDatabase.SaveInventory(client, item, client.Inventory.GetPositionFromItemUID(uid));
                    }
                }
            }
        }
Esempio n. 8
0
        public static void BeginTravel(Entities.GameClient client, ushort mapid, ushort x, ushort y, int secs = 40)
        {
            uint dynamicid;
            Core.Kernel.Maps.selectorCollection1[999].CreateDynamic(out dynamicid);
            client.TeleportDynamic(dynamicid, 70, 60);

            int travelTime = (secs * 1000);

            /*for (int i = 0; i < (travelTime / 1000); i++)
            {
                ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() =>
                                                                       {
                                                                       	using (var msg = Packets.Message.MessageCore.CreateCenter(
                                                                       		string.Format("Hitting destination in {0}", ((travelTime / 1000) - i))))
                                                                       	       {
                                                                       	       	client.Send(msg);
                                                                       	       }
                                                                       	}, 1000 * i);
            }*/

            int j = 0;
            for (int i = secs; i > 0; i--)
            {
                int waitTime = (j * 1000);
                string message = string.Format(Core.MessageConst.TRAVEL_TIME, i);
                ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() =>
                                                                       {
                                                                       	using (var msg = Packets.Message.MessageCore.CreateCenter(
                                                                       		message))
                                                                       	{
                                                                       		client.Send(msg);
                                                                       	}
                                                                       }, waitTime);
                j++;
            }

            ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() =>
                                                                   {
                                                                   	using (var msg = Packets.Message.MessageCore.CreateCenter(
                                                                   		Core.MessageConst.TRAVEL_REACH))
                                                                   	{
                                                                   		client.Send(msg);
                                                                   	}
                                                                   }, travelTime);

            ProjectX_V3_Lib.Threading.DelayedTask.StartDelayedTask(() =>
                                                                   {
                                                                   	client.Teleport(mapid, x, y);
                                                                   	using (var str = new Packets.StringPacket(new Packets.StringPacker("autorun_end")))
                                                                   	{
                                                                   		str.Action = Enums.StringAction.RoleEffect;
                                                                   		str.Data = client.EntityUID;
                                                                   		client.Send(str);
                                                                   	}
                                                                   }, travelTime);
        }
Esempio n. 9
0
        public static void Handle(Entities.GameClient client)
        {
            // Send vip, merchant, quiz points and heavenbless etc.

            client.BaseEntity.SetBaseStats();
            client.BaseEntity.CalculateBaseStats();

            client.Stamina = 50;
            client.PKPoints = client.PKPoints; // update status effect
            client.BoundCPs = client.BoundCPs; // for some reason this has to be done here ...

            using (ProjectX_V3_Lib.Sql.SqlHandler sql = Database.CharacterDatabase.OpenRead(client, "DB_Players"))
                client.StatusFlag2 = sql.ReadUInt64("PlayerStatusFlag");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(Core.MessageConst.LOGIN_MSG, client.Name, client.Account, client.EntityUID, client.DatabaseUID);
            Console.ResetColor();

            MessagePacket bc = Threads.BroadcastThread.GetLastBroadcast();
            if (bc != null)
            {
                client.Send(bc);
                bc.Dispose();
            }
            Database.CharacterDatabase.LoadMessageQuery(client);

            Data.NobilityBoard.SetNobility(client);
            client.SendNobility();

            client.SendSubClasses2();

            Packets.UpdatePacket update = Packets.UpdatePacket.Create(client.EntityUID);
            update.AddUpdate(Enums.UpdateType.VIPLevel, 6);
            update.AddUpdate(Enums.UpdateType.Merchant, 255);
            client.Send(update);

            Data.ArenaQualifier.SetArenaInfo(client);
            if (client.Arena == null)
            {
                client.Arena = new ProjectX_V3_Game.Data.ArenaInfo(client);
                client.Arena.ArenaHonorPoints = 1000;
                client.Arena.Level = (uint)client.Level;
                client.Arena.Class = (uint)client.Class;
                Database.ArenaDatabase.AddNewArenaInfo(client.Arena);
                if (!Data.ArenaQualifier.AddArenaInfo(client.Arena))
                {
                    client.NetworkClient.Disconnect("FAILED_TO_MAKE_ARENA_INFO");
                    return;
                }
            }

            client.CanSave = true;
            using (var motd = Packets.Message.MessageCore.CreateTalk(
                Core.SystemVariables.Variables["ServerName"], client.Name,
                Core.SystemVariables.ReplaceVariables(Program.Config.ReadString("MOTD"))))
                client.Send(motd);
        }
 public static void Handle(Entities.GameClient client, DataPacket packet)
 {
     using (var arenaplayers = new ArenaPlayersPacket(Data.ArenaQualifier.GetTop10()))
     {
         client.Send(arenaplayers);
     }
 }
Esempio n. 11
0
 public void SendMessage(Entities.GameClient client, string Message)
 {
     using (var msg = Packets.Message.MessageCore.CreateCenter(Message))
     {
         client.Send(msg);
     }
 }
Esempio n. 12
0
 public static void Handle(Entities.GameClient client, ItemPacket packet)
 {
     if (client.Booth != null)
         return;
     packet.Data1 = client.WarehouseMoney;
     client.Send(packet);
 }
        public static void Handle(Entities.GameClient client, StringPacket strings)
        {
            string Name = strings.Strings[0];
            Entities.GameClient reqClient;
            if (Core.Kernel.Clients.TrySelect(Name, out reqClient))
            {
                string toAdd = reqClient.EntityUID + " ";
                toAdd += reqClient.Level + " ";
                toAdd += reqClient.Level + " ";//battle power
                toAdd += "# ";//unknown
                toAdd += "# ";//unknown
                toAdd += reqClient.SpouseName + " ";
                toAdd += 0 + " ";//unknown
                if (reqClient.Mesh % 10 < 3)
                    toAdd += "1 ";
                else
                    toAdd += "0 ";

                using (var newstrings = new StringPacket(new StringPacker(Name, toAdd)))
                {
                    newstrings.Action = Enums.StringAction.WhisperWindowInfo;
                    client.Send(newstrings);
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Handling the Use 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)
        {
            uint uid = packet.UID;
            if (client.Inventory.ContainsByUID(uid))
            {
                Data.ItemInfo useitem = client.Inventory[uid];
                if (useitem.IsMisc())
                {
                    if (!Core.Kernel.ItemScriptEngine.Invoke(useitem.ItemID, new object[] { client, useitem }))
                    {
                        using (var fmsg = Packets.Message.MessageCore.CreateSystem(client.Name, string.Format(Core.MessageConst.INVALD_ITEM_USE, useitem.Name, useitem.ItemID)))
                            client.Send(fmsg);
                    }
                }
                else
                {
                    if (!client.Alive)
                        return;

                    Enums.ItemLocation loc = (Enums.ItemLocation)packet.Data1;
                    client.Equipments.Equip(useitem, loc, true);
                }
            }
            //	else (Reason this is commented out is because it disconnected the client if switching equips too fast lmao.
            //		client.NetworkClient.Disconnect("Using invalid item.");
        }
Esempio n. 15
0
        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. 16
0
        public static void SendLose(Entities.GameClient Loser)
        {
            using (var action = new Packets.ArenaActionPacket())
            {
                action.DialogID = 10;
                action.OptionID = 0;

                Loser.Send(action);
            }
        }
Esempio n. 17
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);
         }
     }
 }
Esempio n. 18
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);
         }
     }
 }
 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);
         }
     }
 }
        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);
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Handling the QueryPlayer 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)
        {
            uint uid = General.Data1;
            if (client.Map.MapObjects.ContainsKey(uid))
            {
                Maps.IMapObject target = client.Map.MapObjects[uid];

                if (target is Entities.GameClient)
                    (target as Entities.GameClient).Send(client.CreateSpawnPacket());

                if ((target is Entities.GameClient)) // or mob etc.
                    client.Send(target.CreateSpawnPacket());
            }
        }
Esempio n. 23
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);
        }
Esempio n. 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);
            }
        }
Esempio n. 25
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);
                }
            }
        }
Esempio n. 26
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);
            }
        }
Esempio n. 27
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);
         }
     }
 }
 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);
             }
         }
     }
 }
Esempio n. 29
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);
                    }
                }
            }
        }
        public static void Handle(Entities.GameClient client, DataPacket packet)
        {
            if (client.Guild == null)
                return;

            using (var info = new GuildMemberListPacket(packet))
            {
                Data.GuildMember[] members = client.Guild.SelectFromIndex(info.StartIndex);
                using (var sinfo = new GuildMemberListPacket(members.Length))
                {
                    foreach (Data.GuildMember member in members)
                        sinfo.AddInfo(GuildMemberInfo.Create(member));
                    int offset = 16;
                    foreach (GuildMemberInfo minfo in sinfo.MemberList)
                    {
                        minfo.Append(sinfo, offset, out offset);
                    }
                    client.Send(sinfo);
                }
            }
        }