Esempio n. 1
0
        public static Loot GenerateLoot(Unit Corps, Unit Looter)
        {
            if (!Looter.IsPlayer())
                return null;

            if (Corps.IsCreature())
            {
                Creature Crea = Corps.GetCreature();

                List<Creature_loot> CreatureLoots = WorldMgr.GetLoots(Crea.Entry);
                if (CreatureLoots.Count <= 0)
                    return null;

                List<LootInfo> Loots = new List<LootInfo>();
                foreach (Creature_loot Loot in CreatureLoots)
                {
                    float Pct = Loot.Pct * Program.Config.GlobalLootRate;
                    if (Pct <= 0)
                        Pct = 0.01f;

                    switch ((SystemData.ItemRarity)Loot.Info.Rarity)
                    {
                        case SystemData.ItemRarity.ITEMRARITY_COMMON:
                            Pct *= Program.Config.CommonLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_UNCOMMON:
                            Pct *= Program.Config.UncommonLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_RARE:
                            Pct *= Program.Config.RareLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_VERY_RARE:
                            Pct *= Program.Config.VeryRareLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_ARTIFACT:
                            Pct *= Program.Config.ArtifactLootRate;
                            break;
                    };

                    // Je Fawk | 14 April 2014 | Declined fix
                    #region <Commented>
                    // Fixing the drop rate so that a mob can drop the same item type more than once based on drop % Pct
                    // If the drop percentage is lower than 100%
                    //if (Pct < 100.0f)
                    //{
                    //    if (RandomMgr.Next(10000) <= (Pct*100))
                    //    {
                    //        Loots.Add(new LootInfo(Loot.Info));
                    //    }
                    //}
                    //else
                    //    // If the drop percentage is between 100% and 999%
                    //    if ((Pct > 100.0f) && (Pct < 1000.0f))
                    //    {
                    //        // For each 100 percentage give the player 1 item
                    //        for (byte i = 0; i < Math.Floor((Pct / 100.0f)); i++)
                    //        {
                    //            Loots.Add(new LootInfo(Loot.Info));
                    //        }
                    //        // For the rest that's below 100 do a roll for a new item
                    //        if (RandomMgr.Next(10000) <= ((Pct % 100) * 100))
                    //        {
                    //            Loots.Add(new LootInfo(Loot.Info));
                    //        }
                    //    }
                    //    else
                    //        // For the extreme case where we want the item to drop more than 10 per mob
                    //        if (( Pct > 1000.0f) && (Pct < 10000.0f))
                    //        {
                    //            // For each 100 percentage give the player 1 item
                    //            for (int i = 0; i < Math.Floor((Pct / 100.0f)); i++)
                    //            {
                    //                Loots.Add(new LootInfo(Loot.Info));
                    //            }
                    //            // For the rest that's below 100 do a roll for a new item
                    //            if (RandomMgr.Next(10000) <= ((Pct % 1000) * 100))
                    //            {
                    //                Loots.Add(new LootInfo(Loot.Info));
                    //            }
                    //        }
                    #endregion

                    if (Pct > 100.0f || RandomMgr.Next(10000) < (Pct * 100))
                        Loots.Add(new LootInfo(Loot.Info));
                }

                UInt32 Money = (UInt32)(Corps.Level * (UInt32)7) + (Corps.Rank * (UInt32)50);

                if (Loots.Count > 0 || Money > 0)
                {
                    Log.Success("LootMgr", "Generate Loot : " + Loots.Count);
                    Loot Lt = new Loot();
                    Lt.Money = Money;
                    Lt.Loots = Loots.ToArray();
                    return Lt;
                }

            }

            return null;
        }
Esempio n. 2
0
        public void GenerateLoot(Unit Killer)
        {
            if (Killer == null)
                return;

            Loots = LootsMgr.GenerateLoot(this, Killer);
            if (Loots != null && Killer.IsPlayer())
                SetLootable(true, Killer.GetPlayer());
        }
Esempio n. 3
0
        public static Loot GenerateLoot(Unit Corps, Unit Looter)
        {
            if (!Looter.IsPlayer())
                return null;

            if (Corps.IsCreature())
            {
                Creature Crea = Corps.GetCreature();

                List<Creature_loot> CreatureLoots = WorldMgr.GetLoots(Crea.Entry);
                if (CreatureLoots.Count <= 0)
                    return null;

                List<LootInfo> Loots = new List<LootInfo>();
                foreach (Creature_loot Loot in CreatureLoots)
                {
                    float Pct = Loot.Pct * Program.Config.GlobalLootRate;
                    if (Pct <= 0)
                        Pct = 0.01f;

                    switch ((SystemData.ItemRarity)Loot.Info.Rarity)
                    {
                        case SystemData.ItemRarity.ITEMRARITY_COMMON:
                            Pct *= Program.Config.CommonLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_UNCOMMON:
                            Pct *= Program.Config.UncommonLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_RARE:
                            Pct *= Program.Config.RareLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_VERY_RARE:
                            Pct *= Program.Config.VeryRareLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_ARTIFACT:
                            Pct *= Program.Config.ArtifactLootRate;
                            break;
                    };

                    if(Pct  > 100.0f || RandomMgr.Next(10000) < (Pct*100))
                      Loots.Add(new LootInfo(Loot.Info));
                }

                UInt32 Money = (UInt32)(Corps.Level * (UInt32)7) + (Corps.Rank * (UInt32)50);

                if (Loots.Count > 0 || Money > 0)
                {
                    Log.Success("LootMgr", "Generate Loot : " + Loots.Count);
                    Loot Lt = new Loot();
                    Lt.Money = Money;
                    Lt.Loots = Loots.ToArray();
                    return Lt;
                }

            }

            return null;
        }
Esempio n. 4
0
        static public Loot GenerateLoot(Unit Corps, Unit Looter)
        {
            if (!Looter.IsPlayer())
                return null;

            Player Plr = Looter.GetPlayer();
            if (Corps.IsCreature())
            {
                Creature Crea = Corps.GetCreature();

                List<Creature_loot> CreatureLoots = WorldMgr.GetLoots(Crea.Entry);
                if (CreatureLoots.Count <= 0)
                    return null;

                QuestsInterface Interface = Plr.QtsInterface;

                List<LootInfo> Loots = new List<LootInfo>();
                float Pct;
                foreach (Creature_loot Loot in CreatureLoots)
                {
                    if (Loot.Info.MinRank > Corps.Level + 4 || Loot.Info.MinRenown > (Corps.Level + 4) * 2)
                        continue;

                    if (Loot.Info.Realm != 0 && Loot.Info.Realm != (byte)Plr.Realm)
                        continue;

                    Pct = Loot.Pct * Program.Config.GlobalLootRate;
                    if (Pct <= 0)
                        Pct = 0.01f;

                    switch ((SystemData.ItemRarity)Loot.Info.Rarity)
                    {
                        case SystemData.ItemRarity.ITEMRARITY_COMMON:
                            Pct *= Program.Config.CommonLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_UNCOMMON:
                            Pct *= Program.Config.UncommonLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_RARE:
                            Pct *= Program.Config.RareLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_VERY_RARE:
                            Pct *= Program.Config.VeryRareLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_ARTIFACT:
                            Pct *= Program.Config.ArtifactLootRate;
                            break;
                    };

                    if (Interface != null && Pct != 100.0f)
                    {
                        foreach (KeyValuePair<ushort, Character_quest> Kp in Interface._Quests)
                        {
                            if (!Kp.Value.Done && !Kp.Value.IsDone())
                            {
                                foreach (Character_Objectives Obj in Kp.Value._Objectives)
                                {
                                    if (!Obj.IsDone() && Obj.Objective.Item != null)
                                    {
                                        if (Obj.Objective.Item.Entry == Loot.ItemId)
                                        {
                                            Pct = 100;
                                            break;
                                        }
                                    }
                                }
                            }

                            if (Pct >= 100)
                                break;
                        }
                    }

                    if(Pct >= 100f || RandomMgr.Next(10000) < (Pct*100))
                      Loots.Add(new LootInfo(Loot.Info));
                }

                UInt32 Money = (UInt32)(Corps.Level * (UInt32)7) + (Corps.Rank * (UInt32)50);

                if (Loots.Count > 0 || Money > 0)
                {
                    Loot Lt = new Loot();
                    Lt.Money = Money;
                    Lt.Loots = Loots;
                    Corps.EvtInterface.Notify(EventName.ON_GENERATE_LOOT, Looter, Lt);
                    return Lt;
                }
              
            }
            else if (Corps.IsGameObject())
            {
                // This will generate gameobject loot. Currently this only shows loot
                // if a player needs an item it holds for a quest. If an object has
                // been looted already or has no loot this will return null.
                // Todo: Currently object loot always is 100%. Make this support
                // non quest related loot.
                GameObject GameObj = Corps.GetGameObject();
                List<GameObject_loot> GameObjectLoots = WorldMgr.GetGameObjectLoots(GameObj.Spawn.Entry);
                if (GameObjectLoots.Count <= 0 || GameObj.Looted)
                    return null;

                QuestsInterface Interface = Plr.QtsInterface;
                List<LootInfo> Loots = new List<LootInfo>();
                foreach (GameObject_loot Loot in GameObjectLoots)
                {
                    if (Interface != null)
                    {
                        foreach (KeyValuePair<ushort, Character_quest> Kp in Interface._Quests)
                        {
                            if (!Kp.Value.Done && !Kp.Value.IsDone())
                            {
                                foreach (Character_Objectives Obj in Kp.Value._Objectives)
                                {
                                    if (!Obj.IsDone() && Obj.Objective.Item != null)
                                    {
                                        if (Obj.Objective.Item.Entry == Loot.ItemId)
                                        {
                                            Loots.Add(new LootInfo(Loot.Info));
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    
                }

                Loot Lt = new Loot();
                Lt.Money = 0;
                Lt.Loots = Loots;
                return Lt;
            }

            return null;
        }