예제 #1
0
        public void MonsterDrop()
        {
            try
            {
                if (GetDie || Die)
                {
                    if (Type != 16)
                    {
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        // Set Target Information
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        PlayerMgr sys = (PlayerMgr)GetTarget();
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        // If There's no target return
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        if (sys == null)
                        {
                            return;
                        }

                        sbyte Leveldiff  = (sbyte)(sys.Character.Information.Level - ObjData.Manager.ObjectBase[ID].Level);
                        int   Amountinfo = 0;

                        if (Math.Abs(Leveldiff) < 10 || Math.Abs(Leveldiff) == 0)
                        {
                            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            // Gold Drop
                            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            #region Gold
                            int Golddrop = Rnd.Next(ObjData.Manager.LevelGold[ObjData.Manager.ObjectBase[ID].Level].min, ObjData.Manager.LevelGold[ObjData.Manager.ObjectBase[ID].Level].max);
                            Amountinfo = 0;
                            if (Type == 4 && (Rnd.Next(0, 200) < 200 * Helpers.Settings.Rate.Gold))
                            {
                                Amountinfo = Convert.ToByte(Rnd.Next(1, 3));
                            }
                            if (Type == 3 && (Rnd.Next(0, 200) < 200 * Helpers.Settings.Rate.Gold))
                            {
                                Amountinfo = Convert.ToByte(Rnd.Next(4, 6));
                            }
                            if (Type == 1 && (Rnd.Next(0, 200) < 200 * Helpers.Settings.Rate.Gold))
                            {
                                Amountinfo = Convert.ToByte(Rnd.Next(1, 3));
                            }
                            if (Type == 0 && (Rnd.Next(0, 200) < 100 * Helpers.Settings.Rate.Gold))
                            {
                                Amountinfo = 1;
                            }

                            for (byte a = 1; a <= Amountinfo;)
                            {
                                WorldMgr.Items Gold_Drop = new WorldMgr.Items();

                                Gold_Drop.amount = Golddrop * Helpers.Settings.Rate.Gold;
                                Gold_Drop.Model  = 1;

                                if (Gold_Drop.amount < 1000)
                                {
                                    Gold_Drop.Model = 1;
                                }
                                else if (Gold_Drop.amount > 1000 && Gold_Drop.amount < 10000)
                                {
                                    Gold_Drop.Model = 2;
                                }
                                else if (Gold_Drop.amount > 10000)
                                {
                                    Gold_Drop.Model = 3;
                                }

                                Gold_Drop.Ids      = new GenerateUniqueID(GenerateUniqueID.IDS.World);
                                Gold_Drop.UniqueID = Gold_Drop.Ids.GetUniqueID;
                                Gold_Drop.x        = x;
                                Gold_Drop.z        = z;
                                Gold_Drop.y        = y;
                                Gold_Drop.xSec     = xSec;
                                Gold_Drop.ySec     = ySec;
                                Gold_Drop.Type     = 1;
                                Gold_Drop.downType = true;
                                Gold_Drop.fromType = 5;
                                Gold_Drop.CalculateNewPosition();

                                Helpers.Manager.WorldItem.Add(Gold_Drop);
                                Gold_Drop.Send(Client.Packet.ObjectSpawn(Gold_Drop), true);
                                a++;

                                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                // Send Info To Grabpet
                                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                if (((PlayerMgr)GetTarget()).Character.Grabpet.Active)
                                {
                                    ((PlayerMgr)GetTarget()).Pet_PickupItem(Gold_Drop);
                                }
                            }
                            #endregion
                            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            // Drop Database
                            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            #region Drop Databases
                            foreach (KeyValuePair <string, ObjData.drop_database> p in ObjData.Manager.DropBase)
                            {
                                Amountinfo = p.Value.GetAmount(ObjData.Manager.ObjectBase[ID].Type, p.Key);
                                if (Amountinfo > 0)
                                {
                                    for (byte c = 1; c <= Amountinfo; c++)
                                    {
                                        Items Dropped_Item = new Items();
                                        Dropped_Item.Model = p.Value.GetDrop(ObjData.Manager.ObjectBase[ID].Level, ID, p.Key, sys.Character.Information.Race);
                                        if (Dropped_Item.Model == -1)
                                        {
                                            continue;
                                        }
                                        Dropped_Item.Ids       = new GenerateUniqueID(GenerateUniqueID.IDS.World);
                                        Dropped_Item.UniqueID  = Dropped_Item.Ids.GetUniqueID;
                                        Dropped_Item.PlusValue = Function.Items.RandomPlusValue();
                                        Dropped_Item.MagAtt    = Function.Items.RandomStatValue();
                                        Dropped_Item.x         = x;
                                        Dropped_Item.z         = z;
                                        Dropped_Item.y         = y;
                                        Dropped_Item.xSec      = xSec;
                                        Dropped_Item.ySec      = ySec;
                                        Dropped_Item.Type      = p.Value.GetSpawnType(p.Key);
                                        Dropped_Item.fromType  = 5;
                                        Dropped_Item.downType  = true;
                                        Dropped_Item.fromOwner = UniqueID;
                                        Dropped_Item.amount    = p.Value.GetQuantity(Type, p.Key);
                                        Dropped_Item.Owner     = ((PlayerMgr)GetTarget()).Character.Account.ID;
                                        Dropped_Item.CalculateNewPosition();
                                        Helpers.Manager.WorldItem.Add(Dropped_Item);
                                        Dropped_Item.Send(Client.Packet.ObjectSpawn(Dropped_Item), true);
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Drop system error: {0}", ex);
            }
        }
        public static byte[] ObjectSpawn(WorldMgr.Items w)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(OperationCode.SERVER_SOLO_SPAWN);
            Writer.DWord(w.Model);
            switch (w.Type)
            {
            case 1:
                Writer.DWord(w.amount);
                Writer.DWord(w.UniqueID);
                Writer.Byte(w.xSec);
                Writer.Byte(w.ySec);
                Writer.Float(Formule.packetx((float)w.x, w.xSec));
                Writer.Float(w.z);
                Writer.Float(Formule.packety((float)w.y, w.ySec));
                Writer.DWord(0);
                Writer.Byte(w.fromType);
                Writer.DWord(0);
                break;

            case 2:
                //Weapon and armory drops
                Writer.Byte(w.PlusValue);
                Writer.DWord(w.UniqueID);
                Writer.Byte(w.xSec);
                Writer.Byte(w.ySec);
                Writer.Float(Formule.packetx((float)w.x, w.xSec));
                Writer.Float(w.z);
                Writer.Float(Formule.packety((float)w.y, w.ySec));
                Writer.Word(0);                         // Angle
                Writer.Bool(w.downType);
                if (w.downType)
                {
                    Writer.DWord(w.Owner);
                }
                Writer.Byte(ObjData.Manager.ItemBase[w.Model].SOX);                         // if rare 2 not 0
                Writer.Byte(w.fromType);
                Writer.DWord(w.fromOwner);
                break;

            case 3:
                //Other item types
                //TODO: Define more detailed drops (Quest items, Mall types etc).
                Writer.DWord(w.UniqueID);
                Writer.Byte(w.xSec);
                Writer.Byte(w.ySec);
                Writer.Float(Formule.packetx((float)w.x, w.xSec));
                Writer.Float(w.z);
                Writer.Float(Formule.packety((float)w.y, w.ySec));
                Writer.Word(0);
                Writer.Bool(w.downType);
                if (w.downType)
                {
                    Writer.DWord(w.Owner);
                }
                Writer.Byte(0);
                Writer.Byte(w.fromType);
                Writer.DWord(w.fromOwner);
                break;
            }
            return(Writer.GetBytes());
        }
        public void MonsterDrop()
        {
            try
            {
                if (GetDie || Die)
                {
                    if (Type != 16)
                    {
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        // Set Target Information
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        PlayerMgr sys = (PlayerMgr)GetTarget();
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        // If There's no target return
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        if (sys == null) return;

                        sbyte Leveldiff = (sbyte)(sys.Character.Information.Level - ObjData.Manager.ObjectBase[ID].Level);
                        int Amountinfo = 0;

                        if (Math.Abs(Leveldiff) < 10 || Math.Abs(Leveldiff) == 0)
                        {
                            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            // Gold Drop
                            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            #region Gold
                            int Golddrop = Rnd.Next(ObjData.Manager.LevelGold[ObjData.Manager.ObjectBase[ID].Level].min, ObjData.Manager.LevelGold[ObjData.Manager.ObjectBase[ID].Level].max);
                            Amountinfo = 0;
                            if (Type == 4 && (Rnd.Next(0, 200) < 200 * Helpers.Settings.Rate.Gold)) Amountinfo = Convert.ToByte(Rnd.Next(1, 3));
                            if (Type == 3 && (Rnd.Next(0, 200) < 200 * Helpers.Settings.Rate.Gold)) Amountinfo = Convert.ToByte(Rnd.Next(4, 6));
                            if (Type == 1 && (Rnd.Next(0, 200) < 200 * Helpers.Settings.Rate.Gold)) Amountinfo = Convert.ToByte(Rnd.Next(1, 3));
                            if (Type == 0 && (Rnd.Next(0, 200) < 100 * Helpers.Settings.Rate.Gold)) Amountinfo = 1;

                            for (byte a = 1; a <= Amountinfo;)
                            {
                                WorldMgr.Items Gold_Drop = new WorldMgr.Items();

                                Gold_Drop.amount = Golddrop * Helpers.Settings.Rate.Gold;
                                Gold_Drop.Model = 1;

                                if (Gold_Drop.amount < 1000)
                                    Gold_Drop.Model = 1;
                                else if (Gold_Drop.amount > 1000 && Gold_Drop.amount < 10000)
                                    Gold_Drop.Model = 2;
                                else if (Gold_Drop.amount > 10000)
                                    Gold_Drop.Model = 3;

                                Gold_Drop.Ids = new GenerateUniqueID(GenerateUniqueID.IDS.World);
                                Gold_Drop.UniqueID = Gold_Drop.Ids.GetUniqueID;
                                Gold_Drop.x = x;
                                Gold_Drop.z = z;
                                Gold_Drop.y = y;
                                Gold_Drop.xSec = xSec;
                                Gold_Drop.ySec = ySec;
                                Gold_Drop.Type = 1;
                                Gold_Drop.downType = true;
                                Gold_Drop.fromType = 5;
                                Gold_Drop.CalculateNewPosition();

                                Helpers.Manager.WorldItem.Add(Gold_Drop);
                                Gold_Drop.Send(Client.Packet.ObjectSpawn(Gold_Drop), true);
                                a++;

                                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                // Send Info To Grabpet
                                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                if (((PlayerMgr)GetTarget()).Character.Grabpet.Active)
                                {
                                    ((PlayerMgr)GetTarget()).Pet_PickupItem(Gold_Drop);
                                }
                            }
                            #endregion
                            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            // Drop Database
                            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            #region Drop Databases
                            foreach (KeyValuePair<string, ObjData.drop_database> p in ObjData.Manager.DropBase)
                            {
                                Amountinfo = p.Value.GetAmount(ObjData.Manager.ObjectBase[ID].Type, p.Key);
                                if (Amountinfo > 0)
                                {
                                    for (byte c = 1; c <= Amountinfo; c++)
                                    {
                                        Items Dropped_Item = new Items();
                                        Dropped_Item.Model = p.Value.GetDrop(ObjData.Manager.ObjectBase[ID].Level, ID, p.Key, sys.Character.Information.Race);
                                        if (Dropped_Item.Model == -1) continue;
                                        Dropped_Item.Ids = new GenerateUniqueID(GenerateUniqueID.IDS.World);
                                        Dropped_Item.UniqueID = Dropped_Item.Ids.GetUniqueID;
                                        Dropped_Item.PlusValue = Function.Items.RandomPlusValue();
                                        Dropped_Item.MagAtt = Function.Items.RandomStatValue();
                                        Dropped_Item.x = x;
                                        Dropped_Item.z = z;
                                        Dropped_Item.y = y;
                                        Dropped_Item.xSec = xSec;
                                        Dropped_Item.ySec = ySec;
                                        Dropped_Item.Type = p.Value.GetSpawnType(p.Key);
                                        Dropped_Item.fromType = 5;
                                        Dropped_Item.downType = true;
                                        Dropped_Item.fromOwner = UniqueID;
                                        Dropped_Item.amount = p.Value.GetQuantity(Type, p.Key);
                                        Dropped_Item.Owner = ((PlayerMgr)GetTarget()).Character.Account.ID;
                                        Dropped_Item.CalculateNewPosition();
                                        Helpers.Manager.WorldItem.Add(Dropped_Item);
                                        Dropped_Item.Send(Client.Packet.ObjectSpawn(Dropped_Item), true);
                                    }
                                }
                            }
                        }
                        #endregion

                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Drop system error: {0}", ex);
            }
        }