예제 #1
0
 private static void RequestClose(Player player, ref MsgTrade packet)
 {
     if (packet.UniqueId == 0)
     {
         return;
     }
     if (player.Trade == null)
     {
         return;
     }
     if (player.Trade.Owner.UniqueId == player.UniqueId)
     {
         (player.Trade.Partner as Player)?.Send(Create(player.UniqueId, TradeMode.CloseTradeWindowFail));
         player.Send(Create(player.Trade.Partner.UniqueId, TradeMode.CloseTradeWindowFail));
         player.Trade.Partner.Trade = null;
         player.Trade = null;
     }
     else
     {
         (player.Trade.Owner as Player)?.Send(Create(player.UniqueId, TradeMode.CloseTradeWindowFail));
         player.Send(Create(player.Trade.Owner.UniqueId, TradeMode.CloseTradeWindowFail));
         player.Trade.Owner.Trade = null;
         player.Trade             = null;
     }
 }
예제 #2
0
        private static void RequestTrade(Player player, ref MsgTrade packet)
        {
            if (packet.UniqueId == 0)
            {
                return;
            }

            if (!GameWorld.Maps[player.MapId].Entities.TryGetValue(packet.UniqueId, out var found))
            {
                return;
            }
            if (found == null)
            {
                return;
            }
            if (!Position.CanSeeBig(player, found))
            {
                return;
            }

            var target = found;

            player.Trade = target.Trade ?? new Trade(player, target);

            if (target.Trade != null)
            {
                player.Send(Create(target.UniqueId, TradeMode.ShowTradeWindow));
                (target as Player)?.Send(Create(player.UniqueId, TradeMode.ShowTradeWindow));
            }
            else
            {
                (target as Player)?.Send(Create(player.UniqueId, TradeMode.RequestNewTrade));
            }
        }
예제 #3
0
        public static void Handle(Player player, byte[] buffer)
        {
            fixed(byte *p = buffer)
            {
                var packet = *(MsgTick *)p;

                BufferPool.RecycleBuffer(buffer);

                packet.Timestamp = packet.Timestamp ^ packet.UniqueId;

                if (player.UniqueId != packet.UniqueId)
                {
                    Output.WriteLine($"UID Mismatch! {packet.UniqueId}");
                }

                if (player.LastTick == 0)
                {
                    player.LastTick = packet.Timestamp;
                }

                if (packet.Hash != HashName(player.Name.TrimEnd('\0')))
                {
                    Output.WriteLine($"Hash Mismatch! {packet.Hash}");
                }

                player.LastTick = packet.Timestamp;
            }
        }
예제 #4
0
        public static bool Execute(Player player, List <Item> items)
        {
            _player = player;

            //Add new recipes here, You can add as many id's as you want, they all have to be in the crafting window
            //but the order is ignored.

            return(items.ContainsAll(1088001) && CraftDragonball(player, items));
        }
예제 #5
0
파일: TeamSystem.cs 프로젝트: Pircs/Yi
            public void UpdateLeaderPosition(Player player)
            {
                if (player.UniqueId != Leader.UniqueId)
                {
                    return;
                }

                foreach (var member in Teams[player.UniqueId].Members)
                {
                    (member.Value as Player)?.Send(MsgAction.Create(Environment.TickCount, Leader.UniqueId, Leader.UniqueId, Leader.Location.X, Leader.Location.Y, 0, MsgActionType.QueryTeamLeader));
                }
            }
예제 #6
0
파일: MsgTeam.cs 프로젝트: Pircs/Yi
        private static void CreateTeam(Player player, ref MsgTeam packet)
        {
            if (GameWorld.Maps.TryGetValue(player.MapId, out var map))
            {
                if (map.Flags.HasFlag(MapFlags.DisableTeams))
                {
                    player.GetMessage("SYSTEM", player.Name, "Team's are not allowed on this map.", MsgTextType.Action);
                    return;
                }
            }

            TeamSystem.Teams.AddOrUpdate(player.UniqueId, new TeamSystem.TeamData(player));
            player.Send(packet);
        }
예제 #7
0
 private static void RequestFinish(Player player, ref MsgTrade packet)
 {
     if (packet.UniqueId == 0)
     {
         return;
     }
     if (player.Trade == null)
     {
         return;
     }
     if (player.Trade.Owner.UniqueId == player.UniqueId)
     {
         player.Trade.OwnerOk = true;
         (player.Trade.Partner as Player)?.Send(Create(player.UniqueId, TradeMode.RequestCompleteTrade));
         if (player.Trade.Partner is Npc)
         {
             player.Trade.PartnerOk = true;
         }
         if (player.Trade.PartnerOk)
         {
             foreach (var item in player.Trade.PartnerItems)
             {
                 player.Inventory.AddItem(item.Value);
                 player.Trade.Partner.Inventory.RemoveItem(item.Value);
             }
             foreach (var item in player.Trade.OwnerItems)
             {
                 if (player.Trade.Partner is Npc)
                 {
                     SelfContainedSystems.BoothSystem.Add(player.Trade.Partner, item.Value, item.Value.PriceBaseline);
                 }
                 else
                 {
                     player.Inventory.RemoveItem(item.Value);
                     player.Trade.Partner.Inventory.AddItem(item.Value);
                 }
             }
             player.Money += player.Trade.PartnerMoney;
             player.Trade.Partner.Money -= player.Trade.PartnerMoney;
             //player.Cps += player.Trade.PartnerCps;
             //player.Trade.Partner.Cps -= player.Trade.PartnerCps;
             player.Send(Create(player.Trade.Partner.UniqueId, TradeMode.CloseTradeWindowSuccess));
             (player.Trade.Partner as Player)?.Send(Create(player.UniqueId, TradeMode.CloseTradeWindowSuccess));
             player.Trade.Partner.Trade = null;
             player.Trade = null;
         }
     }
     else
     {
         player.Trade.PartnerOk = true;
         (player.Trade.Owner as Player)?.Send(Create(player.UniqueId, TradeMode.RequestCompleteTrade));
         if (player.Trade.OwnerOk)
         {
             foreach (var item in player.Trade.OwnerItems)
             {
                 player.Inventory.AddItem(item.Value);
                 player.Trade.Owner.Inventory.RemoveItem(item.Value);
             }
             player.Money             += player.Trade.OwnerMoney;
             player.Trade.Owner.Money -= player.Trade.OwnerMoney;
             //player.Cps += player.Trade.OwnerCps;
             //player.Trade.Owner.Cps -= player.Trade.OwnerCps;
             player.Send(Create(player.Trade.Partner.UniqueId, TradeMode.CloseTradeWindowSuccess));
             (player.Trade.Owner as Player)?.Send(Create(player.UniqueId, TradeMode.CloseTradeWindowSuccess));
             player.Trade.Owner.Trade = null;
             player.Trade             = null;
         }
     }
 }
예제 #8
0
        public static void Handle(Player player, byte[] buffer)
        {
            try
            {
                fixed(byte *p = buffer)
                {
                    var packet = *(MsgTrade *)p;

                    BufferPool.RecycleBuffer(buffer);

                    switch (packet.Mode)
                    {
                    case TradeMode.RequestNewTrade:
                        RequestTrade(player, ref packet);
                        break;

                    case TradeMode.RequestCloseTrade:
                        RequestClose(player, ref packet);
                        break;

                    case TradeMode.RequestAddItemToTrade:
                        AddItem(player, ref packet);
                        break;

                    case TradeMode.RequestAddMoneyToTrade:
                        AddMoney(player, ref packet);
                        break;

                    case TradeMode.RequestCompleteTrade:
                        RequestFinish(player, ref packet);
                        break;

                    case TradeMode.ShowTradeWindow:
                        break;

                    case TradeMode.CloseTradeWindowSuccess:
                        break;

                    case TradeMode.CloseTradeWindowFail:
                        break;

                    case TradeMode.DisplayMoney:
                        break;

                    case TradeMode.DisplayMoneyAdd:
                        break;

                    case TradeMode.ReturnItem:
                        break;

                    default:
                        Output.WriteLine(((byte[])packet).HexDump());
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Output.WriteLine(e);
            }
        }
예제 #9
0
파일: MsgTeam.cs 프로젝트: Pircs/Yi
        public static void Handle(Player player, byte[] buffer)
        {
            try
            {
                fixed(byte *p = buffer)
                {
                    var packet = *(MsgTeam *)p;

                    BufferPool.RecycleBuffer(buffer);

                    switch (packet.Mode)
                    {
                    case MsgTeamAction.Create:
                        CreateTeam(player, ref packet);
                        break;

                    case MsgTeamAction.RequestJoin:
                        RequestJoin(player, ref packet);
                        break;

                    case MsgTeamAction.Invite:
                        Invite(player, ref packet);
                        break;

                    case MsgTeamAction.AcceptInvite:
                        AcceptInvite(player, ref packet);
                        break;

                    case MsgTeamAction.AcceptJoin:
                        AcceptJoin(player, ref packet);
                        break;

                    case MsgTeamAction.Dismiss:
                        DismissTeam(player, ref packet);
                        break;

                    case MsgTeamAction.LeaveTeam:
                        Leave(player, ref packet);
                        break;

                    case MsgTeamAction.Kick:
                        Kick(player, ref packet);
                        break;

                    case MsgTeamAction.ForbidNewMembers:
                        if (TeamSystem.Teams[player.UniqueId].Leader.UniqueId != packet.TargetUniqueId)
                        {
                            break;
                        }
                        TeamSystem.Teams[player.UniqueId].Locked = true;
                        break;

                    case MsgTeamAction.AllowNewMembers:
                        if (TeamSystem.Teams[player.UniqueId].Leader.UniqueId != packet.TargetUniqueId)
                        {
                            break;
                        }
                        TeamSystem.Teams[player.UniqueId].Locked = false;
                        break;

                    case MsgTeamAction.ForbidMoney:
                        if (TeamSystem.Teams[player.UniqueId].Leader.UniqueId != packet.TargetUniqueId)
                        {
                            break;
                        }
                        TeamSystem.Teams[player.UniqueId].MoneyLocked = true;
                        break;

                    case MsgTeamAction.AllowMoney:
                        if (TeamSystem.Teams[player.UniqueId].Leader.UniqueId != packet.TargetUniqueId)
                        {
                            break;
                        }
                        TeamSystem.Teams[player.UniqueId].MoneyLocked = false;
                        break;

                    case MsgTeamAction.ForbidItems:
                        if (TeamSystem.Teams[player.UniqueId].Leader.UniqueId != packet.TargetUniqueId)
                        {
                            break;
                        }
                        TeamSystem.Teams[player.UniqueId].ItemsLocked = true;
                        break;

                    case MsgTeamAction.AllowItems:
                        if (TeamSystem.Teams[player.UniqueId].Leader.UniqueId != packet.TargetUniqueId)
                        {
                            break;
                        }
                        TeamSystem.Teams[player.UniqueId].ItemsLocked = false;
                        break;

                    default:
                        Output.WriteLine(((byte[])packet).HexDump());
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Output.WriteLine(e);
            }
        }