Exemple #1
0
        public static Drop DecodeForMigration(Packet pr)
        {
            var DropID          = pr.ReadInt();
            var reward          = Game.Reward.DecodeForMigration(pr);
            var OwnerID         = pr.ReadInt();
            var OwnPartyID      = pr.ReadInt();
            var OwnType         = pr.ReadByte();
            var SourceID        = pr.ReadInt();
            var Pt1X            = pr.ReadShort();
            var Pt1Y            = pr.ReadShort();
            var Pt2X            = pr.ReadShort();
            var Pt2Y            = pr.ReadShort();
            var ByPet           = pr.ReadBool();
            var ByUser          = pr.ReadBool();
            var Pos             = pr.ReadShort();
            var DropEverlasting = pr.ReadBool();
            var ConsumeOnPickup = pr.ReadBool();

            var drop = new Drop(DropID, reward, OwnerID, OwnPartyID, (DropType)OwnType, SourceID, Pt1X, Pt1Y, Pt2X, Pt2Y, ByPet, ByUser);

            // Drop time is reset; cannot get the datetime transfer to work
            drop.CreateTime = MasterThread.CurrentTime;

            drop.Pos             = Pos;
            drop.Everlasting     = DropEverlasting;
            drop.ConsumeOnPickup = ConsumeOnPickup;
            return(drop);
        }
Exemple #2
0
 public void RemoveDrop(Drop Drop, RewardLeaveType Type = RewardLeaveType.Normal, int Option = 0)
 {
     if (Drops.Remove(Drop.DropID))
     {
         DropPacket.SendMakeLeaveFieldPacket(Drop, Type, Option);
     }
 }
Exemple #3
0
        public void DecodeForMigration(Packet pr)
        {
            _DropIdCounter.Reset(pr.ReadInt());
            int amount = pr.ReadInt();

            Drops = new Dictionary <int, Drop>(amount);

            Program.MainForm.LogAppend(Field.ID + " has " + amount + " drops...");
            for (var i = 0; i < amount; i++)
            {
                var drop = Drop.DecodeForMigration(pr);
                drop.Field = Field;
                Drops.Add(drop.DropID, drop);
            }
        }
Exemple #4
0
        public static void SendMakeLeaveFieldPacket(Drop Drop, RewardLeaveType LeaveType, int Option = 0)
        {
            Packet pw = new Packet(ServerMessages.DROP_LEAVE_FIELD);

            pw.WriteByte((byte)LeaveType);
            pw.WriteInt(Drop.DropID);

            if (LeaveType == RewardLeaveType.FreeForAll ||
                LeaveType == RewardLeaveType.Remove ||
                LeaveType == RewardLeaveType.PetPickup)
            {
                pw.WriteInt(Option);
            }
            else if (LeaveType == RewardLeaveType.Explode)
            {
                pw.WriteShort((short)Option);
            }

            Drop.Field.SendPacket(Drop, pw);
        }
Exemple #5
0
        public static void SendMakeEnterFieldPacket(Drop drop, RewardEnterType EnterType, short Delay, Character chr = null)
        {
            Packet pw = new Packet(ServerMessages.DROP_ENTER_FIELD);

            pw.WriteByte((byte)EnterType);
            pw.WriteInt(drop.DropID);
            pw.WriteBool(drop.Reward.Mesos);
            pw.WriteInt(drop.Reward.Drop);
            pw.WriteInt(drop.OwnerID);
            pw.WriteByte((byte)drop.OwnType);
            pw.WriteShort(drop.Pt2.X);
            pw.WriteShort(drop.Pt2.Y);

            if (EnterType == RewardEnterType.ShowDrop ||
                EnterType == RewardEnterType.DropAnimation ||
                EnterType == RewardEnterType.DisappearDuringDrop)
            {
                pw.WriteInt(drop.SourceID);
                pw.WriteShort(drop.Pt1.X);
                pw.WriteShort(drop.Pt1.Y);
                pw.WriteShort(Delay);
            }

            if (!drop.Reward.Mesos)
            {
                pw.WriteLong(drop.Reward.DateExpire);
            }

            pw.WriteBool(!drop.ByPet);

            if (chr != null)
            {
                chr.SendPacket(pw);
            }
            else
            {
                drop.Field.SendPacket(drop, pw);
            }
        }
Exemple #6
0
        public bool GetDrop(int OwnerID, Reward Reward, int x, int y, out Drop Result)
        {
            Result = null;

            /*var tCur = DateTime.Now;
             *
             * if ((!Reward.Mesos && !Constants.isRechargeable(Reward.Drop)) || Reward.Mesos)
             * {
             *  Point Pos = new Point(x, y);
             *  foreach (Drop Drop in Drops.Values)
             *  {
             *      if (Drop.SourceID != 0 && Drop.MergeArea.Contains(Pos))
             *      {
             *          if (((Drop.Reward.Mesos && Reward.Mesos == Drop.Reward.Mesos) || (Reward.Drop == Drop.Reward.Drop && Drop.Reward.Amount + Reward.Amount < Reward.MaxStack))
             *            && !Drop.ToExplode && ((tCur - Drop.CreateTime).TotalMinutes > 1 || Drop.OwnerID == OwnerID))
             *          {
             *              Result = Drop;
             *              return true;
             *          }
             *      }
             *  }
             * }*/
            return(false);
        }
Exemple #7
0
 public void RemoveDrop(Drop drop)
 {
     Drops.Remove(drop.ID);
     drop = null;
 }
Exemple #8
0
        public bool Create(Reward Reward, int OwnerID, int OwnPartyID, DropType OwnType, int SourceID, Pos CurPos, int x2, short Delay, bool Admin, short Pos, bool ByPet, bool ByUser)
        {
            var Foothold = Field.GetFootholdUnderneath(x2, CurPos.Y - 100, out int y2);

            if (Foothold == null || !Field.IsPointInMBR(x2, y2, true))
            {
                Foothold = Field.GetFootholdClosest(x2, CurPos.Y, ref x2, ref y2, CurPos.X);
            }

            Drop Drop = null;

            if (_MergeDrops && !ByUser && GetDrop(OwnerID, Reward, x2, y2, out Drop))
            {
                Drop.CreateTime = MasterThread.CurrentTime;
                Drop.FFA        = true;
                bool Changed = false;

                if (Drop.Reward.Mesos)
                {
                    int Value = Reward.Drop + Drop.Reward.Drop;
                    if (Drop.Reward.Drop < 50 && Value >= 50)
                    {
                        Changed = true;
                    }
                    else if (Drop.Reward.Drop < 100 && Value >= 100)
                    {
                        Changed = true;
                    }
                    else if (Drop.Reward.Drop < 1000 && Value >= 1000)
                    {
                        Changed = true;
                    }
                    Drop.Reward.Drop = Value;
                }
                else
                {
                    Drop.Reward.GetData().Amount += Reward.Amount;
                }

                DropPacket.SendMakeEnterFieldPacket(Drop, RewardEnterType.DisappearDuringDrop, Delay);

                if (Changed)
                {
                    DropPacket.SendMakeLeaveFieldPacket(Drop, RewardLeaveType.Remove);
                    DropPacket.SendMakeEnterFieldPacket(Drop, RewardEnterType.ShowExisting, 0);
                }
                return(true);
            }
            else
            {
                Drop = new Drop(_DropIdCounter.NextValue(), Reward, OwnerID, OwnPartyID, OwnType, SourceID, CurPos.X, CurPos.Y, (short)x2, (short)y2, ByPet, ByUser)
                {
                    Field           = Field,
                    CreateTime      = MasterThread.CurrentTime,
                    Pos             = Pos,
                    Everlasting     = DropEverlasting,
                    ConsumeOnPickup = (!Reward.Mesos && false /*DataProvider.ConsumeOnPickup.Contains(Reward.ItemID)*/)
                };

                if (!Admin && ByUser && !Drop.Reward.Mesos && ((DataProvider.QuestItems.Contains(Reward.ItemID) || DataProvider.UntradeableDrops.Contains(Reward.ItemID))))
                {
                    DropPacket.SendMakeEnterFieldPacket(Drop, RewardEnterType.DisappearDuringDrop, Delay);
                }
                else
                {
                    Drops.Add(Drop.DropID, Drop);
                    DropPacket.SendMakeEnterFieldPacket(Drop, RewardEnterType.DropAnimation, Delay);
                }
                return(false);
            }
        }