public static List <Vendor_items> GetVendorItems(ushort id)
        {
            if (!_newVendors.ContainsKey(id))
            {
                Log.Debug("WorldMgr", "Loading Vendors of " + id + " ...");

                IList <Vendor_items> IVendors = Database.SelectObjects <Vendor_items>("VendorId=" + id);
                List <Vendor_items>  Vendors  = new List <Vendor_items>();
                Vendors.AddRange(IVendors);

                _newVendors.Add(id, Vendors);
                // commenting out this next line as it does not seem to be used...
                //  Item_Info Req;
                foreach (Vendor_items Info in Vendors.ToArray())
                {
                    if ((Info.Info = ItemService.GetItem_Info(Info.ItemId)) == null)
                    {
                        Vendors.Remove(Info);
                        continue;
                    }
                }

                Log.Debug("LoadCreatureVendors", "Loaded " + Vendors.Count + " Vendors of " + id);
            }

            return(_newVendors[id]);
        }
        public static LootContainer GenerateScavenge(byte unitLevel, byte unitRank, byte skillLv)
        {
            uint itemId;

            if (skillLv > Program.Config.RankCap * 5)
            {
                skillLv = (byte)(Program.Config.RankCap * 5);
            }

            if (StaticRandom.Instance.Next(100) <= 40)
            {
                // Gold dust.
                if (StaticRandom.Instance.Next(100) >= 60)
                {
                    itemId = (uint)(907638 + skillLv / 25);
                }
                // Curios.
                else
                {
                    itemId = (uint)(907501 + skillLv / 25 * 4);
                }
            }

            // Fragments.
            else
            {
                itemId = (uint)(_fragmentIDs[StaticRandom.Instance.Next(_fragmentIDs.Length)] + skillLv / 25 * 4);

                int rand = StaticRandom.Instance.Next(100);

                if (rand < 1 + unitRank * 7)
                {
                    itemId += 3;
                }
                else if (rand < 2 + unitRank * 21)
                {
                    itemId += 2;
                }
                else if (rand > 65 - (unitLevel / 2) - (unitRank * 10))
                {
                    itemId += 1;
                }
            }

            return(new LootContainer {
                LootInfo = new List <LootInfo> {
                    new LootInfo(ItemService.GetItem_Info(itemId))
                }
            });
        }
Exemple #3
0
        private static void LoadGameObjectLoots(uint entry)
        {
            if (!GameObjectLoots.ContainsKey(entry))
            {
                Log.Debug("WorldMgr", "Loading GameObject Loots of " + entry + " ...");

                List <GameObject_loot>  Loots  = new List <GameObject_loot>();
                IList <GameObject_loot> ILoots = Database.SelectObjects <GameObject_loot>("Entry=" + entry);
                foreach (GameObject_loot Loot in ILoots)
                {
                    Loots.Add(Loot);
                }

                GameObjectLoots.Add(entry, Loots);

                long MissingGameObject = 0;
                long MissingItemProto  = 0;

                if (GetGameObjectProto(entry) == null)
                {
                    Log.Debug("LoadLoots", "[" + entry + "] Invalid GameObject Proto");
                    ++MissingGameObject;
                }

                foreach (GameObject_loot Loot in GameObjectLoots[entry].ToArray())
                {
                    Loot.Info = ItemService.GetItem_Info(Loot.ItemId);

                    if (Loot.Info == null)
                    {
                        Log.Debug("LoadLoots", "[" + Loot.ItemId + "] Invalid Item Info");
                        GameObjectLoots[entry].Remove(Loot);
                        ++MissingItemProto;
                    }
                }

                if (MissingItemProto > 0)
                {
                    Log.Error("LoadLoots", "[" + MissingItemProto + "] Missing Item Info");
                }

                if (MissingGameObject > 0)
                {
                    Log.Error("LoadLoots", "[" + MissingGameObject + "] Misssing GameObject proto");
                }
            }
        }
        public static LootContainer GenerateButchery(byte creatureSubType, byte skillLv)
        {
            if (!ButcheryEntries.ContainsKey(creatureSubType))
            {
                return(null);
            }

            if (skillLv > Program.Config.RankCap * 5)
            {
                skillLv = (byte)(Program.Config.RankCap * 5);
            }

            uint itemId = ButcheryEntries[creatureSubType][StaticRandom.Instance.Next(ButcheryEntries[creatureSubType].Count)] + (uint)Math.Min(8, skillLv / 25);

            return(new LootContainer {
                LootInfo = new List <LootInfo> {
                    new LootInfo(ItemService.GetItem_Info(itemId))
                }
            });
        }
Exemple #5
0
        public static void GeneratePQuestObjective(PQuest_Objective Obj, PQuest_Info Q)
        {
            switch ((Objective_Type)Obj.Type)
            {
            case Objective_Type.QUEST_KILL_PLAYERS:
            {
                if (Obj.Description.Length < 1)
                {
                    Obj.Description = "Enemy Players";
                }
            }
            break;

            case Objective_Type.QUEST_SPEAK_TO:
                goto case Objective_Type.QUEST_KILL_MOB;

            case Objective_Type.QUEST_PROTECT_UNIT:
                goto case Objective_Type.QUEST_KILL_MOB;

            case Objective_Type.QUEST_KILL_MOB:
            {
                uint ObjID = 0;
                uint.TryParse(Obj.ObjectId, out ObjID);

                if (ObjID != 0)
                {
                    Obj.Creature = CreatureService.GetCreatureProto(ObjID);
                }

                if (Obj.Description.Length < 1 && Obj.Creature != null)
                {
                    Obj.Description = Obj.Creature.Name;
                }
            }
            break;

            case Objective_Type.QUEST_KILL_GO:
            {
                uint ObjID = 0;
                uint.TryParse(Obj.ObjectId, out ObjID);

                if (ObjID != 0)
                {
                    Obj.GameObject = GameObjectService.GetGameObjectProto(ObjID);
                }

                if (Obj.Description.Length < 1 && Obj.GameObject != null)
                {
                    Obj.Description = "Destroy " + Obj.Creature.Name;
                }
            }
            break;

            case Objective_Type.QUEST_USE_GO:
            {
                uint ObjID = 0;
                uint.TryParse(Obj.ObjectId, out ObjID);

                if (ObjID != 0)
                {
                    Obj.GameObject = GameObjectService.GetGameObjectProto(ObjID);
                }

                if (Obj.Description.Length < 1 && Obj.GameObject != null)
                {
                    Obj.Description = "Use " + Obj.GameObject.Name;
                }
            }
            break;

            case Objective_Type.QUEST_GET_ITEM:
            {
                uint ObjID = 0;
                uint.TryParse(Obj.ObjectId, out ObjID);

                if (ObjID != 0)
                {
                    Obj.Item = ItemService.GetItem_Info(ObjID);
                }
            }
            break;
            }
        }