Beispiel #1
2
        /// <summary>
        /// Returns a list of recipes from selected skill
        /// </summary>
        /// <param name="skillLine"></param>
        /// <returns></returns>
        public static TradeSkill GetTradeSkill(SkillLine skillLine)
        {
            if (!ObjectManager.IsInGame)
            {
                throw new InvalidOperationException("Must Be in game to call GetTradeSkill()");
            }
            if (skillLine == 0 || !SupportedSkills.Contains(skillLine))
            {
                throw new InvalidOperationException(String.Format("The tradekill {0} can not be loaded", skillLine));
            }
            // if HB is not running then we need to pulse objectmanger for item counts
            if (!TreeRoot.IsRunning)
            {
                ObjectManager.Update();
            }
            //Stopwatch sw = new Stopwatch();
            TradeSkill tradeSkill = null;

            try
            {
                //using (new FrameLock())
                //{
                WoWSkill wowSkill = ObjectManager.Me.GetSkill(skillLine);
                // sw.Start();
                tradeSkill = new TradeSkill(wowSkill);

                List <SkillLineAbilityEntry> entries = tradeSkill.GetSkillLineAbilityEntries();
                foreach (SkillLineAbilityEntry entry in entries)
                {
                    // check if the entry is a recipe
                    if (entry.NextSpellId == 0 && entry.GreySkillLevel > 0)
                    {
                        var recipe = new Recipe(tradeSkill, entry);
                        recipe.UpdateHeader();
                        tradeSkill.AddRecipe(recipe);
                    }
                    //Logging.Write(entry.ToString());
                }
                //}
            }
            catch (Exception ex)
            {
                Logging.WriteException(ex);
            }
            //Logging.Write("it took {0} ms to load {1}", sw.ElapsedMilliseconds, skillLine);
            return(tradeSkill);
        }
Beispiel #2
1
        /// <summary>
        /// Returns a list of recipes from selected skill
        /// </summary>
        /// <param name="skillLine"></param>
        /// <param name="blockFrame">prevents tradeskill frame from showing</param>
        /// <returns></returns>
        public TradeSkill GetTradeSkill(SkillLine skillLine, bool blockFrame)
        {
            if (!ObjectManager.IsInGame)
            {
                throw new InvalidOperationException("Must Be in game to call GetTradeSkill()");
            }
            if (skillLine == 0 || !SupportedSkills.Contains(skillLine))
            {
                throw new InvalidOperationException(string.Format("The tradekill {0} can not be loaded", skillLine));
            }
            // if HB is not running then we need to pulse objectmanger for item counts
            if (!TreeRoot.IsRunning)
            {
                ObjectManager.Update();
            }
            WoWSkill wowSkill = ObjectManager.Me.GetSkill(skillLine);

            TradeSkill tradeSkill = new TradeSkill(wowSkill);

            //lets copy over to a local variable for performance
            bool   _isVisible = IsVisible;
            bool   loadSkill  = Skill != skillLine || !_isVisible;
            string lua        = string.Format("{0}{1}{2}{3}",
                                              blockFrame && loadSkill ? "if not TradeSkillFrame then LoadAddOn('Blizzard_TradeSkillUI') end local fs = {} local f = EnumerateFrames() while f do if f:IsEventRegistered('TRADE_SKILL_SHOW') == 1 and f:GetName() ~= 'UIParent' then f:UnregisterEvent('TRADE_SKILL_SHOW') table.insert (fs,f) end f = EnumerateFrames(f) end " : "",
                                              // have to hard code in mining since I need to cast 'Smelting' not 'Mining' XD
                                              // also using lua over SpellManager.Cast since its grabing name from DBC. one word, localization.
                                              loadSkill ? (skillLine == SkillLine.Mining ? "CastSpellByID(2656) " : string.Format("CastSpellByName('{0}') ", wowSkill.Name)) : "",
                                              // force cache load
                                              "for i=1, GetNumTradeSkills() do GetTradeSkillItemLink(i) for n=1,GetTradeSkillNumReagents(i) do GetTradeSkillReagentInfo(i,n) end end ",
                                              blockFrame && loadSkill ? "for k,v in pairs(fs) do v:RegisterEvent('TRADE_SKILL_SHOW') end CloseTradeSkill() " : ""
                                              );

            using (new FrameLock())
            {
                if (!string.IsNullOrEmpty(lua))
                {
                    Lua.DoString(lua);
                }

                int _recipeCount = RecipeCount;
                if (Skill != skillLine || _recipeCount <= 0)
                {// we failed to load tradeskill
                    throw new Exception(string.Format("Unable to load {0}", skillLine));
                }
                // array of pointers that point to each recipe structure.
                uint[] recipePtrArray = ObjectManager.Wow.ReadStructArray <uint>(RecipeOffset, RecipeCount);
                for (int index = 0; index < _recipeCount; index++)
                {
                    uint[] recipeData = ObjectManager.Wow.ReadStructArray <uint>(recipePtrArray[index], 9);
                    uint   id         = recipeData[(int)Recipe.RecipeIndex.RecipeID];
                    // check if its a header
                    if (id == uint.MaxValue)
                    {
                        continue; // no further info to get for header
                    }
                    tradeSkill.Recipes.Add(id, new Recipe(recipeData, tradeSkill, skillLine));
                }
                tradeSkill.InitIngredientList();
                tradeSkill.InitToolList();
            }
            return(tradeSkill);
        }
Beispiel #3
0
        private static void TeacherFound(int value, SkillRank skillRank, SkillLine skillLine, Npc teacher)
        {
            if (TeacherFoundNoSpam.Contains(teacher))
            {
                return;
            }
            TeacherFoundNoSpam.Add(teacher);
            SkillRank nextRank;

            if (skillRank == SkillRank.ZenMaster)
            {
                nextRank = skillRank + 100;
            }
            else
            {
                nextRank = skillRank + 75;
            }
            string current = "You don't know this skill yet";

            if (skillRank > SkillRank.None)
            {
                current = "You are currently " + skillRank + " of " + skillLine.ToString() + ". Level " + value + "/" + (int)skillRank;
            }
            Logging.Write("Teacher of " + skillLine.ToString() + " found. " + current + ". You will become " + nextRank + " of " + skillLine.ToString() + ".");
            Logging.Write("Informations about the teacher of " + skillLine.ToString() + ". Id: " + teacher.Entry + ", Name: " + teacher.Name + ", Distance: " +
                          teacher.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) + ", Coords: " + teacher.Position);
        }
 // Returns wether the profession is known
 public static bool KnowsProfession(SkillLine skill)
 {
     if (Skill.GetValue(skill) > 0)
     {
         return(true);
     }
     return(false);
 }
 public BehaviorCraftingProfession(SkillLine skill, int skillid)
 {
     Skill       = skill;
     SkillId     = skillid;
     SkillBookId = PlayerProfessions.DraenorProfessionSpellIds[Skill];
     Currency    = PlayerProfessions.GetWorkOrderItemAndQuanityRequired(skillid);
     Criteria   += () => (BaseSettings.CurrentSettings.BehaviorProfessions &&
                          BaseSettings.CurrentSettings.ProfessionSpellIds.Contains(SkillId) &&
                          PlayerProfessions.HasRequiredCurrency(Currency) &&
                          !Spell.Cooldown);
 }
    protected Profession(SkillLine professionName)
    {
        CurrentStep  = null;
        Name         = professionName;
        ItemToDelete = null;
        ItemToSplit  = null;

        // Reset save if prof level is 0
        if (ToolBox.GetProfessionLevel(Name) == 0)
        {
            ToolBox.ClearProfessionFromSavedList(Name.ToString());
        }
    }
Beispiel #7
0
 /// Opens TradeSkill Frame for the specific skill
 /// </summary>
 /// <param name="skillLine"></param>
 public void Show(SkillLine skillLine)
 {
     if (skillLine != 0 && ObjectManager.IsInGame && !IsVisible)
     {
         WoWSkill wowSkill  = ObjectManager.Me.GetSkill(skillLine);
         bool     loadSkill = Skill != skillLine || !IsVisible;
         // have to hard code in mining since I need to cast 'Smelting' not 'Mining' XD
         // also using lua over SpellManager.Cast since its grabing name from DBC. one word, localization.
         string lua = loadSkill ? (skillLine == SkillLine.Mining ? "CastSpellByID(2656);" : string.Format("CastSpellByName('{0}');", wowSkill.Name)) : null;
         if (lua != null)
         {
             Lua.DoString(lua);
         }
     }
 }
            public ProfessionSkill(SkillLine skill, WoWSkill spell)
            {
                Skill                 = skill;
                MaxValue              = spell.MaxValue;
                CurrentValue          = spell.CurrentValue;
                DailyCooldownSpellIds = null;

                if (MaxValue >= 700 && ProfessionDailyCooldownSpellIds.ContainsKey(Skill))
                {
                    DailyCooldownSpellIds = ProfessionDailyCooldownSpellIds[Skill];
                }

                if (DraenorProfessionSpellIds.ContainsKey(Skill))
                {
                    SpellbookId = DraenorProfessionSpellIds[Skill];
                }
            }
Beispiel #9
0
        public static bool AddSkill(this Player p, ushort skillId)
        {
            if (!p.Skills.ContainsKey(skillId) && DBC.SkillLine.ContainsKey(skillId))
            {
                SkillLine cbi        = DBC.SkillLine[skillId];
                ushort    startValue = 1;

                if (cbi.m_categoryID == (int)SkillTypes.MAX_SKILL)
                {
                    startValue = (ushort)cbi.m_maxRank;
                }

                p.Skills.Add((ushort)cbi.m_ID, new MirrorSkillInfo((ushort)cbi.m_ID, startValue, (ushort)cbi.m_maxRank, cbi.m_displayName_lang));
                return(true);
            }

            return(false);
        }
Beispiel #10
0
 public static void LoadProfessionEditorFiles()
 {
     try
     {
         DbcStores.InitFiles();
         Spell.LoadData();
         SkillLine.LoadData();
         SkillLineAbility.LoadData();
         SkillRaceClassInfo.LoadData();
         SpellFocusObject.LoadData();
         ChrRaces.LoadData();
         ChrClasses.LoadData();
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #11
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                SkillId   id        = trigger.Text.NextEnum <SkillId>(SkillId.None);
                SkillLine skillLine = SkillHandler.Get(id);

                if (skillLine != null)
                {
                    Character   target       = (Character)trigger.Args.Target;
                    int         num          = trigger.Text.NextInt(1);
                    SkillTierId tierForLevel = skillLine.GetTierForLevel(num);
                    target.Skills.GetOrCreate(id, true).CurrentValue = (ushort)num;
                    Spell spellForTier = skillLine.GetSpellForTier(tierForLevel);
                    if (spellForTier != null)
                    {
                        target.Spells.AddSpell(spellForTier);
                    }
                    trigger.Reply(RealmLangKey.CmdSkillSetResponse, (object)skillLine, (object)num,
                                  (object)tierForLevel);
                }
                else
                {
                    trigger.Reply(RealmLangKey.CmdSkillSetError, (object)id);
                }
            }
Beispiel #12
0
        private static ushort GetMaxRank(Player p, MirrorSkillInfo skill)
        {
            //TODO secondary prof spell check

            SkillLine cbi = DBC.SkillLine[skill.m_skillLineID];

            switch (cbi.m_skillType)
            {
            case 0:     //Weapon, Defense, Spell
                return((ushort)(p.Level * 5));

            case 4:     //Language, Riding, Secondary Profs
                if (cbi.m_categoryID == 1)
                {
                    return((ushort)cbi.m_maxRank);    //Language, Riding
                }
                else
                {
                    return((ushort)((p.Level * 5) + 25));    //Secondary Profs
                }
            }

            return(0);
        }
Beispiel #13
0
        internal void InitializeTemplate()
        {
            if (this.Names == null)
            {
                this.Names = new string[8];
            }
            if (this.Descriptions == null)
            {
                this.Descriptions = new string[8];
            }
            if (this.DefaultDescription == null)
            {
                this.DefaultDescription = "";
            }
            if (string.IsNullOrEmpty(this.DefaultName) || this.Id == 0U)
            {
                return;
            }
            this.ItemId             = (Asda2ItemId)this.Id;
            this.RequiredSkill      = SkillHandler.Get(this.RequiredSkillId);
            this.Set                = ItemMgr.GetSet(this.SetId);
            this.Lock               = LockEntry.Entries.Get <LockEntry>(this.LockId);
            this.RequiredFaction    = FactionMgr.Get(this.RequiredFactionId);
            this.RequiredProfession = SpellHandler.Get(this.RequiredProfessionId);
            this.SubClassMask       =
                (ItemSubClassMask)(1 << (int)(this.SubClass & (ItemSubClass.WeaponDagger | ItemSubClass.WeaponThrown))
                                   );
            this.EquipmentSlots    = ItemMgr.EquipmentSlotsByInvSlot.Get <EquipmentSlot[]>((uint)this.InventorySlotType);
            this.InventorySlotMask =
                (InventorySlotTypeMask)(1 << (int)(this.InventorySlotType &
                                                   (InventorySlotType.WeaponRanged | InventorySlotType.Cloak)));
            this.IsAmmo          = this.InventorySlotType == InventorySlotType.Ammo;
            this.IsKey           = this.Class == ItemClass.Key;
            this.IsBag           = this.InventorySlotType == InventorySlotType.Bag;
            this.IsContainer     = this.Class == ItemClass.Container || this.Class == ItemClass.Quiver;
            this.IsStackable     = this.MaxAmount > 1 && this.RandomSuffixId == 0U && this.RandomPropertiesId == 0U;
            this.IsTwoHandWeapon = this.InventorySlotType == InventorySlotType.TwoHandWeapon;
            this.SetIsWeapon();
            if (this.ToolCategory != ToolCategory.None)
            {
                ItemMgr.FirstTotemsPerCat[(uint)this.ToolCategory] = this;
            }
            if (this.GemPropertiesId != 0U)
            {
                this.GemProperties = EnchantMgr.GetGemproperties(this.GemPropertiesId);
                if (this.GemProperties != null)
                {
                    this.GemProperties.Enchantment.GemTemplate = this;
                }
            }

            if (this.Sockets == null)
            {
                this.Sockets = new SocketInfo[3];
            }
            else if (((IEnumerable <SocketInfo>) this.Sockets).Contains <SocketInfo>(
                         (Func <SocketInfo, bool>)(sock => sock.Color != SocketColor.None)))
            {
                this.HasSockets = true;
            }
            if (this.Damages == null)
            {
                this.Damages = DamageInfo.EmptyArray;
            }
            if (this.Resistances == null)
            {
                this.Resistances = new int[7];
            }
            if (this.SocketBonusEnchantId != 0U)
            {
                this.SocketBonusEnchant = EnchantMgr.GetEnchantmentEntry(this.SocketBonusEnchantId);
            }
            switch (this.Class)
            {
            case ItemClass.Weapon:
                this.ItemProfession = ItemProfessions.WeaponSubClassProfessions.Get <SkillId>((uint)this.SubClass);
                break;

            case ItemClass.Armor:
                this.ItemProfession = ItemProfessions.ArmorSubClassProfessions.Get <SkillId>((uint)this.SubClass);
                break;
            }

            int sheathType = (int)this.SheathType;

            if (this.Spells != null)
            {
                ArrayUtil.Prune <ItemSpell>(ref this.Spells);
                for (int index = 0; index < 5; ++index)
                {
                    this.Spells[index].Index = (uint)index;
                    this.Spells[index].FinalizeAfterLoad();
                }
            }
            else
            {
                this.Spells = ItemSpell.EmptyArray;
            }

            this.UseSpell = ((IEnumerable <ItemSpell>) this.Spells).Where <ItemSpell>(
                (Func <ItemSpell, bool>)(itemSpell =>
            {
                if (itemSpell.Trigger == ItemSpellTrigger.Use)
                {
                    return(itemSpell.Spell != null);
                }
                return(false);
            })).FirstOrDefault <ItemSpell>();
            if (this.UseSpell != null)
            {
                this.UseSpell.Spell.RequiredTargetType = this.RequiredTargetType;
                this.UseSpell.Spell.RequiredTargetId   = this.RequiredTargetId;
            }

            this.EquipSpells = ((IEnumerable <ItemSpell>) this.Spells).Where <ItemSpell>((Func <ItemSpell, bool>)(spell =>
            {
                if (spell.Trigger == ItemSpellTrigger.Equip)
                {
                    return(spell.Spell != null);
                }
                return(false);
            })).Select <ItemSpell, Spell>((Func <ItemSpell, Spell>)(itemSpell => itemSpell.Spell)).ToArray <Spell>();
            this.SoulstoneSpell = ((IEnumerable <ItemSpell>) this.Spells).Where <ItemSpell>(
                (Func <ItemSpell, bool>)(spell =>
            {
                if (spell.Trigger == ItemSpellTrigger.Soulstone)
                {
                    return(spell.Spell != null);
                }
                return(false);
            })).Select <ItemSpell, Spell>((Func <ItemSpell, Spell>)(itemSpell => itemSpell.Spell))
                                  .FirstOrDefault <Spell>();
            this.HitSpells = ((IEnumerable <ItemSpell>) this.Spells).Where <ItemSpell>((Func <ItemSpell, bool>)(spell =>
            {
                if (spell.Trigger == ItemSpellTrigger.ChanceOnHit)
                {
                    return(spell.Spell != null);
                }
                return(false);
            })).Select <ItemSpell, Spell>((Func <ItemSpell, Spell>)(itemSpell => itemSpell.Spell)).ToArray <Spell>();
            this.ConsumesAmount =
                (this.Class == ItemClass.Consumable ||
                 ((IEnumerable <ItemSpell>) this.Spells).Contains <ItemSpell>(
                     (Func <ItemSpell, bool>)(spell => spell.Trigger == ItemSpellTrigger.Consume))) &&
                (this.UseSpell == null || !this.UseSpell.HasCharges);
            this.IsHearthStone = this.UseSpell != null && this.UseSpell.Spell.IsHearthStoneSpell;
            this.IsInventory   = this.InventorySlotType != InventorySlotType.None &&
                                 this.InventorySlotType != InventorySlotType.Bag &&
                                 this.InventorySlotType != InventorySlotType.Quiver &&
                                 this.InventorySlotType != InventorySlotType.Relic;
            if (this.SetId != ItemSetId.None)
            {
                ItemSet itemSet = ItemMgr.Sets.Get <ItemSet>((uint)this.SetId);
                if (itemSet != null)
                {
                    int num = (int)ArrayUtil.Add <ItemTemplate>(ref itemSet.Templates, this);
                }
            }

            if (this.Mods != null)
            {
                ArrayUtil.TruncVals <StatModifier>(ref this.Mods);
            }
            else
            {
                this.Mods = StatModifier.EmptyArray;
            }
            this.IsCharter          = this.Flags.HasFlag((Enum)ItemFlags.Charter);
            this.RandomSuffixFactor = EnchantMgr.GetRandomSuffixFactor(this);
            if (this.IsCharter)
            {
                this.Creator = (Func <Item>)(() => (Item) new PetitionCharter());
            }
            else if (this.IsContainer)
            {
                this.Creator = (Func <Item>)(() => (Item) new Container());
            }
            else
            {
                this.Creator = (Func <Item>)(() => new Item());
            }
        }
Beispiel #14
0
        public static void SendTalentList(this Player p)
        {
            HashSet <int>           nextTalent = new HashSet <int>();
            HashSet <SpellListItem> talents    = new HashSet <SpellListItem>();

            foreach (SkillLineAbility ability in DBC.SkillLineAbility.Values)
            {
                TrainerServices status    = TrainerServices.TRAINER_SERVICE_AVAILABLE;
                SkillLine       skillline = DBC.SkillLine[ability.m_skillLine];
                if (skillline.m_skillType != TALENT_SKILL_ID)
                {
                    continue;
                }

                Spell spell = null;
                if (!DBC.Spell.TryGetValue((uint)ability.m_spell, out spell)) //Only use those with spells
                {
                    continue;
                }

                if (p.Talents.Contains(ability.m_ID)) //Already have ability
                {
                    if (ability.m_supercededBySpell > 0)
                    {
                        nextTalent.Add(ability.m_supercededBySpell); //Store next as possibly available
                    }
                    status = TrainerServices.TRAINER_SERVICE_USED;
                }
                else
                {
                    if (nextTalent.Contains(ability.m_spell))
                    {
                        status = TrainerServices.TRAINER_SERVICE_AVAILABLE; //Definitely available as in superceed list
                    }
                    else if (spell.iRank == 1)
                    {
                        status = TrainerServices.TRAINER_SERVICE_AVAILABLE; //Definitely available as Rank 1
                    }
                    else
                    {
                        status = TrainerServices.TRAINER_SERVICE_UNAVAILABLE; //Probably not available as fallen through
                    }
                }

                SpellListItem ti = new SpellListItem();
                ti.SpellId           = (uint)ability.m_spell;
                ti.Status            = (byte)status;
                ti.TalentPoints      = 10;
                ti.RequiredLevel     = (byte)spell.baseLevel;
                ti.RequiredSkillLine = 0;
                ti.RequiredSkillRank = 0;
                ti.RequiredSkillStep = 0;
                ti.RequiredAbility   = new uint[] { 0, 0, 0 };
                talents.Add(ti);
            }

            PacketWriter pk = new PacketWriter(Opcodes.SMSG_TRAINER_LIST);

            pk.WriteUInt64(p.Guid);
            pk.WriteUInt32((uint)TrainerTypes.TRAINER_TYPE_TALENTS); //Type
            pk.WriteUInt32((uint)talents.Count);                     //Spell count
            foreach (SpellListItem spell in talents)
            {
                spell.BuildPacket(ref pk);
            }

            p.Client.Send(pk);
        }
Beispiel #15
0
 public TradeskillHelper(SkillLine skillLine)
 {
     _skillLine = skillLine;
     _wowSkill  = StyxWoW.Me.GetSkill(skillLine);
 }
Beispiel #16
0
        private static bool IsNewSkillAvailable(int value, SkillRank maxValue, SkillLine skillLine, bool hardCheck = false)
        {
            uint price    = 0;
            uint minLevel = 0;
            int  maxLevelLeftBeforeLearn = 15;

            if (hardCheck)
            {
                maxLevelLeftBeforeLearn = 5;
            }
            bool primarySkillToLearn = false;

            // Note: Price and Levels of skills are hard-coded. But verified ingame with Friendly reputation to Orgrimmar.

            switch (maxValue)
            {
            case SkillRank.None:     // To Learn Apprentice
                switch (skillLine)
                {
                case SkillLine.Herbalism:
                case SkillLine.Mining:
                case SkillLine.Skinning:
                    if (!nManagerSetting.CurrentSetting.BecomeApprenticeIfNeededByProduct || PrimarySkillSlotAvailable() == 0)
                    {
                        return(false);
                    }
                    if ((skillLine == SkillLine.Mining &&
                         (!nManagerSetting.CurrentSetting.ActivateVeinsHarvesting &&
                          (Products.Products.ProductName != "Quester" || Products.Products.ProductName != "Gatherer" || Products.Products.ProductName == "Grinder"))) ||
                        (skillLine == SkillLine.Herbalism &&
                         (!nManagerSetting.CurrentSetting.ActivateHerbsHarvesting &&
                          (Products.Products.ProductName == "Quester" || Products.Products.ProductName == "Gatherer" || Products.Products.ProductName == "Grinder"))) ||
                        (skillLine == SkillLine.Skinning &&
                         (!nManagerSetting.CurrentSetting.ActivateBeastSkinning &&
                          (Products.Products.ProductName == "Quester" || Products.Products.ProductName == "Grinder"))))
                    {
                        return(false);
                    }
                    primarySkillToLearn = true;
                    price    = 10;
                    minLevel = 1;
                    break;

                case SkillLine.Leatherworking:
                case SkillLine.Alchemy:
                case SkillLine.Tailoring:
                case SkillLine.Enchanting:
                case SkillLine.Engineering:
                case SkillLine.Inscription:
                case SkillLine.Blacksmithing:
                case SkillLine.Jewelcrafting:
                    if (Products.Products.ProductName != "ProfessionsManager" || PrimarySkillSlotAvailable() == 0)
                    {
                        return(false);
                    }
                    const string professionToLevelup = "Profession";         // Example
                    if (professionToLevelup != skillLine.ToString())
                    {
                        return(false);
                    }
                    primarySkillToLearn = true;
                    price    = 10;
                    minLevel = 5;
                    break;

                case SkillLine.Archaeology:
                    if (!nManagerSetting.CurrentSetting.BecomeApprenticeOfSecondarySkillsWhileQuesting || Products.Products.ProductName != "Quester")
                    {
                        if (!nManagerSetting.CurrentSetting.BecomeApprenticeIfNeededByProduct || Products.Products.ProductName != "Archaeologist")
                        {
                            return(false);
                        }
                    }
                    price    = 1000;
                    minLevel = 20;
                    break;

                case SkillLine.Cooking:
                case SkillLine.FirstAid:
                    if (!nManagerSetting.CurrentSetting.BecomeApprenticeOfSecondarySkillsWhileQuesting || Products.Products.ProductName != "Quester")
                    {
                        return(false);
                    }
                    price    = 95;
                    minLevel = 1;
                    break;

                case SkillLine.Fishing:
                    if (!nManagerSetting.CurrentSetting.BecomeApprenticeOfSecondarySkillsWhileQuesting || Products.Products.ProductName != "Quester")
                    {
                        if (!nManagerSetting.CurrentSetting.BecomeApprenticeIfNeededByProduct || Products.Products.ProductName != "Fisherbot")
                        {
                            return(false);
                        }
                    }
                    price    = 95;
                    minLevel = 5;
                    break;

                case SkillLine.Riding:
                    price    = 38000;
                    minLevel = 20;
                    break;
                }
                break;

            case SkillRank.Apprentice:     // To Learn Journeyman
                switch (skillLine)
                {
                case SkillLine.Herbalism:
                case SkillLine.Mining:
                case SkillLine.Skinning:
                    price    = 475;
                    minLevel = 1;
                    break;

                case SkillLine.Leatherworking:
                case SkillLine.Alchemy:
                case SkillLine.Tailoring:
                case SkillLine.Enchanting:
                case SkillLine.Engineering:
                case SkillLine.Inscription:
                case SkillLine.Blacksmithing:
                case SkillLine.Jewelcrafting:
                    price    = 475;
                    minLevel = 10;
                    break;

                case SkillLine.Archaeology:
                    price    = 1000;
                    minLevel = 20;
                    break;

                case SkillLine.Cooking:
                case SkillLine.FirstAid:
                case SkillLine.Fishing:
                    price    = 475;
                    minLevel = 1;
                    break;

                case SkillLine.Riding:
                    price    = 475000;
                    minLevel = 40;
                    break;
                }
                break;

            case SkillRank.Journeyman:     // To Learn Expert
                switch (skillLine)
                {
                case SkillLine.Herbalism:
                case SkillLine.Mining:
                case SkillLine.Skinning:
                    price    = 4750;
                    minLevel = 10;
                    break;

                case SkillLine.Leatherworking:
                case SkillLine.Alchemy:
                case SkillLine.Tailoring:
                case SkillLine.Enchanting:
                case SkillLine.Engineering:
                case SkillLine.Inscription:
                case SkillLine.Blacksmithing:
                case SkillLine.Jewelcrafting:
                    price    = 4750;
                    minLevel = 20;
                    break;

                case SkillLine.Archaeology:
                    price    = 1000;
                    minLevel = 20;
                    break;

                case SkillLine.Cooking:
                case SkillLine.FirstAid:
                case SkillLine.Fishing:
                    price    = 9500;
                    minLevel = 1;
                    break;

                case SkillLine.Riding:
                    price    = 2375000;
                    minLevel = 60;
                    break;
                }
                break;

            case SkillRank.Expert:     // To Learn Artisan
                switch (skillLine)
                {
                case SkillLine.Herbalism:
                case SkillLine.Mining:
                case SkillLine.Skinning:
                    price    = 47500;
                    minLevel = 25;
                    break;

                case SkillLine.Leatherworking:
                case SkillLine.Alchemy:
                case SkillLine.Tailoring:
                case SkillLine.Enchanting:
                case SkillLine.Engineering:
                case SkillLine.Inscription:
                case SkillLine.Blacksmithing:
                case SkillLine.Jewelcrafting:
                    price    = 47500;
                    minLevel = 35;
                    break;

                case SkillLine.Archaeology:
                    price    = 25000;
                    minLevel = 35;
                    break;

                case SkillLine.Cooking:
                case SkillLine.Fishing:
                    price    = 23750;
                    minLevel = 1;
                    break;

                case SkillLine.FirstAid:
                    price    = 23750;
                    minLevel = 35;
                    break;

                case SkillLine.Riding:
                    // Todo: Check additionals Riding spells.
                    return(false);

                    /*case SkillLine.Riding:
                     * // Todo: Check additionals Riding spells.
                     * price = 47500000;
                     * minLevel = 70;
                     * break;*/
                }
                break;

            case SkillRank.Artisan:     // To Learn Master
                switch (skillLine)
                {
                case SkillLine.Herbalism:
                case SkillLine.Mining:
                case SkillLine.Skinning:
                    price    = 95000;
                    minLevel = 40;
                    break;

                case SkillLine.Leatherworking:
                case SkillLine.Alchemy:
                case SkillLine.Tailoring:
                case SkillLine.Enchanting:
                case SkillLine.Engineering:
                case SkillLine.Inscription:
                case SkillLine.Blacksmithing:
                case SkillLine.Jewelcrafting:
                    price    = 95000;
                    minLevel = 50;
                    break;

                case SkillLine.Archaeology:
                    price    = 100000;
                    minLevel = 50;
                    break;

                case SkillLine.Cooking:
                case SkillLine.Fishing:
                    price    = 95000;
                    minLevel = 1;
                    break;

                case SkillLine.FirstAid:
                    price    = 95000;
                    minLevel = 50;
                    break;

                case SkillLine.Riding:
                    // Todo: Check additionals Riding spells.
                    return(false);

                    /*case SkillLine.Riding:
                     * // Todo: Check additionals Riding spells.
                     * price = 47500000;
                     * minLevel = 80;
                     * break;*/
                }
                break;

            case SkillRank.Master:     // To Learn Grand Master
                switch (skillLine)
                {
                case SkillLine.Herbalism:
                case SkillLine.Mining:
                case SkillLine.Skinning:
                    price    = 332500;
                    minLevel = 55;
                    break;

                case SkillLine.Leatherworking:
                case SkillLine.Alchemy:
                case SkillLine.Tailoring:
                case SkillLine.Enchanting:
                case SkillLine.Engineering:
                case SkillLine.Inscription:
                case SkillLine.Blacksmithing:
                case SkillLine.Jewelcrafting:
                    price    = 332500;
                    minLevel = 65;
                    break;

                case SkillLine.Archaeology:
                    price    = 150000;
                    minLevel = 65;
                    break;

                case SkillLine.Cooking:
                case SkillLine.Fishing:
                    price    = 332500;
                    minLevel = 1;
                    break;

                case SkillLine.FirstAid:
                    price    = 142500;
                    minLevel = 65;
                    break;

                case SkillLine.Riding:
                    // Todo: Check additionals Riding spells.
                    return(false);
                }
                break;

            case SkillRank.GrandMaster:     // To Learn Illustrious Grand Master
                switch (skillLine)
                {
                case SkillLine.Herbalism:
                case SkillLine.Mining:
                case SkillLine.Skinning:
                case SkillLine.Leatherworking:
                case SkillLine.Alchemy:
                case SkillLine.Tailoring:
                case SkillLine.Enchanting:
                case SkillLine.Engineering:
                case SkillLine.Inscription:
                case SkillLine.Blacksmithing:
                case SkillLine.Jewelcrafting:
                    price    = 475000;
                    minLevel = 75;
                    break;

                case SkillLine.Archaeology:
                    price    = 250000;
                    minLevel = 75;
                    break;

                case SkillLine.Cooking:
                    price    = 475000;
                    minLevel = 1;
                    break;

                case SkillLine.FirstAid:
                    price    = 237500;
                    minLevel = 75;
                    break;

                case SkillLine.Fishing:
                    return(false);
                }
                break;

            case SkillRank.IllustriousGrandMaster:     // To Learn Zen Master
                switch (skillLine)
                {
                case SkillLine.Herbalism:
                case SkillLine.Mining:
                case SkillLine.Skinning:
                case SkillLine.Leatherworking:
                case SkillLine.Alchemy:
                case SkillLine.Tailoring:
                case SkillLine.Enchanting:
                case SkillLine.Engineering:
                case SkillLine.Inscription:
                case SkillLine.Blacksmithing:
                case SkillLine.Jewelcrafting:
                    price    = 570000;
                    minLevel = 80;
                    break;

                case SkillLine.Archaeology:
                    price    = 600000;
                    minLevel = 80;
                    break;

                case SkillLine.Cooking:
                    price    = 570000;
                    minLevel = 1;
                    break;

                case SkillLine.FirstAid:
                    price    = 285000;
                    minLevel = 80;
                    break;
                }
                break;

            case SkillRank.ZenMaster:     // To Learn DraenorMaster. Complex.
            case SkillRank.DraenorMaster: // To Learn Legion. Complex.
            case SkillRank.Legion:        // Nothing to learn anymore.
                return(false);
                // Secondary skills should be easier to learn for Zen to Draenor to Legion (Fishing, Archaeology, etc)
            }
            if (nManagerSetting.CurrentSetting.OnlyTrainIfWeHave2TimesMoreMoneyThanOurWishListSum)
            {
                price = price * 2;
            }
            if (skillLine == SkillLine.Riding && ObjectManager.ObjectManager.Me.Level >= minLevel && (Usefuls.GetMoneyCopper - _whishListSum) >= price)
            {
                _whishListSum = _whishListSum + price;
                _lastPriceAddedToWhishList = price;
                return(true);
            }
            if ((int)maxValue - maxLevelLeftBeforeLearn <= value && ObjectManager.ObjectManager.Me.Level >= minLevel && (Usefuls.GetMoneyCopper - _whishListSum) >= price)
            {
                if (primarySkillToLearn && PrimarySkillSlotAvailable() - _primarySkillsSlotOnWhishList >= 1)
                {
                    _primarySkillsSlotOnWhishList = _primarySkillsSlotOnWhishList + 1;
                    _lastPrimarySkillsWhishList   = 1;
                }
                else if (primarySkillToLearn)
                {
                    return(false);
                }
                _whishListSum = _whishListSum + price;
                _lastPriceAddedToWhishList = price;
                return(true);
            }
            return(false);
        }
Beispiel #17
0
 public TradeSkill GetTradeSkill(SkillLine skillLine)
 {
     return(GetTradeSkill(skillLine, false));
 }
 internal Recipe(uint[] data, TradeSkill parent, SkillLine skill)
 {
     _recipeData = data;
     Skill       = skill;
     Parent      = parent;
 }
Beispiel #19
0
        public static ObservableCollection<SkillLine> LoadAllSkillLine()
        {
            ObservableCollection<SkillLine> list = new ObservableCollection<SkillLine>();

            using (FileStream stream = File.OpenRead(DATA_PATH + "DBC/SkillLine.dbc"))
            {
                BinaryReader r = new BinaryReader(stream);
                stream.Position = 4;
                int records = r.ReadInt32();
                int rowCount = r.ReadInt32();
                int rowSize = r.ReadInt32();
                int stringBlockSize = r.ReadInt32();
                int dataSize = 20 + records * rowSize;
                for (int i = 0; i != records; ++i)
                {
                    SkillLine skill = new SkillLine();
                    skill.ID = r.ReadInt32();
                    skill.Category = r.ReadInt32();
                    skill.Cost = r.ReadInt32();
                    stream.Position += 16;
                    skill.Name = DBC.ReadString(r, dataSize);
                    stream.Position += 44;
                    skill.NameFlag = r.ReadInt32();
                    stream.Position += 16;
                    skill.Description = DBC.ReadString(r, dataSize);
                    stream.Position += 44;
                    skill.DescFlag = r.ReadInt32();
                    skill.Icon = r.ReadInt32();
                    stream.Position += 16;
                    skill.Verb = DBC.ReadString(r, dataSize);
                    stream.Position += 44;
                    skill.VerbFlag = r.ReadInt32();
                    skill.CanLink = r.ReadInt32();
                    list.Add(skill);
                }

                r.Close();
                return list;
            }
        }
Beispiel #20
0
 public TradeskillHelper(SkillLine skillLine)
 {
     _skillLine = skillLine;
     _wowSkill = StyxWoW.Me.GetSkill(skillLine);
 }
Beispiel #21
0
        public static int GetSkillBonus(SkillLine skill)
        {
            int bonus = 0;

            // Guide if we want to complete: http://www.elsanglin.com/equipment.html

            // Racials bonuses
            switch (ObjectManager.ObjectManager.Me.WowRace)
            {
            case WoWRace.Gnome:
                if (skill == SkillLine.Engineering)
                {
                    bonus += 15;
                }
                break;

            case WoWRace.Tauren:
                if (skill == SkillLine.Herbalism)
                {
                    bonus += 15;
                }
                break;

            case WoWRace.Draenei:
                if (skill == SkillLine.Jewelcrafting)
                {
                    bonus += 5;
                }
                break;

            case WoWRace.BloodElf:
                if (skill == SkillLine.Enchanting)
                {
                    bonus += 10;
                }
                break;

            case WoWRace.Worgen:
                if (skill == SkillLine.Skinning)
                {
                    bonus += 15;
                }
                break;

            case WoWRace.Goblin:
                if (skill == SkillLine.Alchemy)
                {
                    bonus += 15;
                }
                break;
            }

            // Buffs bonuses
            if (skill == SkillLine.Fishing && ObjectManager.ObjectManager.Me.HaveBuff(45694))
            {
                bonus += 10;
            }

            // Enchantments bonuses, seems they wont stack with the basic tools

            // Items bonuses
            switch (skill)
            {
            case SkillLine.Mining:
                if (ItemsManager.GetItemCount(40772) > 0 || ItemsManager.GetItemCount(2901) > 0)
                {
                    bonus += 10;
                }
                break;

            case SkillLine.Herbalism:
                if (ItemsManager.GetItemCount(40772) > 0 || ItemsManager.GetItemCount(85663) > 0)
                {
                    bonus += 10;
                }
                break;

            case SkillLine.Skinning:
                if (ItemsManager.GetItemCount(40772) > 0 || ItemsManager.GetItemCount(7005) > 0)
                {
                    bonus += 10;
                }
                break;

            case SkillLine.Fishing:
                // There is just too much things in Fishing to take in count, and it's not "that" useful for a bot...
                // But I will need to add them later to display the skill increases correctly. See guide above.
                break;
            }

            return(bonus);
        }
Beispiel #22
0
        internal void InitializeTemplate()
        {
            if (Names == null)
            {
                Names = new string[(int)ClientLocale.End];
            }

            if (Descriptions == null)
            {
                Descriptions = new string[(int)ClientLocale.End];
            }

            if (DefaultDescription == null)
            {
                DefaultDescription = "";
            }

            if (string.IsNullOrEmpty(DefaultName) || Id == 0)
            {
                // something's off with these entries
                return;
            }

            ItemId = (ItemId)Id;
            //Faction = (FactionId)Faction; // faction, 3.2.2
            RequiredSkill      = SkillHandler.Get(RequiredSkillId);
            Set                = ItemMgr.GetSet(SetId);
            Lock               = LockEntry.Entries.Get(LockId);
            RequiredFaction    = FactionMgr.Get(RequiredFactionId);
            RequiredProfession = SpellHandler.Get(RequiredProfessionId);
            SubClassMask       = (ItemSubClassMask)(1 << (int)SubClass);
            EquipmentSlots     = ItemMgr.EquipmentSlotsByInvSlot.Get((uint)InventorySlotType);
            InventorySlotMask  = (InventorySlotTypeMask)(1 << (int)InventorySlotType);
            IsAmmo             = InventorySlotType == InventorySlotType.Ammo;
            IsKey              = Class == ItemClass.Key;
            IsBag              = InventorySlotType == InventorySlotType.Bag;
            IsContainer        = Class == ItemClass.Container || Class == ItemClass.Quiver;

            // enchantables can't be stacked
            IsStackable     = MaxAmount > 1 && RandomSuffixId == 0 && RandomPropertiesId == 0;
            IsTwoHandWeapon = InventorySlotType == InventorySlotType.TwoHandWeapon;
            SetIsWeapon();

            if (ToolCategory != 0)            // && TotemCategory != TotemCategory.SkinningKnife)
            {
                ItemMgr.FirstTotemsPerCat[(uint)ToolCategory] = this;
            }

            if (GemPropertiesId != 0)
            {
                GemProperties = EnchantMgr.GetGemproperties(GemPropertiesId);
                if (GemProperties != null)
                {
                    GemProperties.Enchantment.GemTemplate = this;
                }
            }

            if (Sockets == null)
            {
                Sockets = new SocketInfo[ItemConstants.MaxSocketCount];
            }
            else if (Sockets.Contains(sock => sock.Color != 0))
            {
                HasSockets = true;
            }

            if (Damages == null)
            {
                Damages = DamageInfo.EmptyArray;
            }

            if (Resistances == null)
            {
                Resistances = new int[(int)DamageSchool.Count];
            }

            if (SocketBonusEnchantId != 0)
            {
                SocketBonusEnchant = EnchantMgr.GetEnchantmentEntry(SocketBonusEnchantId);
            }

            switch (Class)
            {
            case ItemClass.Weapon:
                ItemProfession = ItemProfessions.WeaponSubClassProfessions.Get((uint)SubClass);
                break;

            case ItemClass.Armor:
                ItemProfession = ItemProfessions.ArmorSubClassProfessions.Get((uint)SubClass);
                break;
            }

            if (SheathType == SheathType.Undetermined)
            {
                // TODO: Read sheath-id from Item.dbc
            }

            // spells
            if (Spells != null)
            {
                ArrayUtil.Prune(ref Spells);
                for (int i = 0; i < 5; i++)
                {
                    Spells[i].Index = (uint)i;
                    Spells[i].FinalizeAfterLoad();
                }
            }
            else
            {
                Spells = ItemSpell.EmptyArray;
            }

            UseSpell = Spells.Where(itemSpell => itemSpell.Trigger == ItemSpellTrigger.Use && itemSpell.Spell != null).FirstOrDefault();
            if (UseSpell != null)
            {
                UseSpell.Spell.RequiredTargetType = RequiredTargetType;
                UseSpell.Spell.RequiredTargetId   = RequiredTargetId;
            }

            EquipSpells = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.Equip && spell.Spell != null).Select(itemSpell =>
                                                                                                                       itemSpell.Spell).ToArray();

            SoulstoneSpell = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.Soulstone && spell.Spell != null).Select(itemSpell =>
                                                                                                                              itemSpell.Spell).FirstOrDefault();

            HitSpells = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.ChanceOnHit && spell.Spell != null).Select(itemSpell =>
                                                                                                                           itemSpell.Spell).ToArray();

            if (UseSpell != null && (UseSpell.Id == SpellId.Learning || UseSpell.Id == SpellId.Learning_2))
            {
                // Teaching
                TeachSpell = Spells.Where(spell => spell.Trigger == ItemSpellTrigger.Consume).FirstOrDefault();
            }

            ConsumesAmount =
                (Class == ItemClass.Consumable ||
                 Spells.Contains(spell => spell.Trigger == ItemSpellTrigger.Consume)) &&
                (UseSpell == null || !UseSpell.HasCharges);

            IsHearthStone = UseSpell != null && UseSpell.Spell.IsHearthStoneSpell;

            IsInventory = InventorySlotType != InventorySlotType.None &&
                          InventorySlotType != InventorySlotType.Bag &&
                          InventorySlotType != InventorySlotType.Quiver &&
                          InventorySlotType != InventorySlotType.Relic;

            // find set
            if (SetId != 0)
            {
                var set = ItemMgr.Sets.Get((uint)SetId);
                if (set != null)
                {
                    ArrayUtil.Add(ref set.Templates, this);
                }
            }

            // truncate arrays
            if (Mods != null)
            {
                ArrayUtil.TruncVals(ref Mods);
            }
            else
            {
                Mods = StatModifier.EmptyArray;
            }

            IsCharter = Flags.HasFlag(ItemFlags.Charter);

            RandomSuffixFactor = EnchantMgr.GetRandomSuffixFactor(this);

            if (IsCharter)
            {
                Creator = () => new PetitionCharter();
            }
            else if (IsContainer)
            {
                Creator = () => new Container();
            }
            else
            {
                Creator = () => new Item();
            }
        }
Beispiel #23
0
        internal void InitializeTemplate()
        {
            if (Names == null)
            {
                Names = new string[8];
            }
            if (Descriptions == null)
            {
                Descriptions = new string[8];
            }
            if (DefaultDescription == null)
            {
                DefaultDescription = "";
            }
            if (string.IsNullOrEmpty(DefaultName) || Id == 0U)
            {
                return;
            }
            ItemId             = (Asda2ItemId)Id;
            RequiredSkill      = SkillHandler.Get(RequiredSkillId);
            Set                = ItemMgr.GetSet(SetId);
            Lock               = LockEntry.Entries.Get(LockId);
            RequiredFaction    = FactionMgr.Get(RequiredFactionId);
            RequiredProfession = SpellHandler.Get(RequiredProfessionId);
            SubClassMask       =
                (ItemSubClassMask)(1 << (int)(SubClass & (ItemSubClass.WeaponDagger | ItemSubClass.WeaponThrown))
                                   );
            EquipmentSlots    = ItemMgr.EquipmentSlotsByInvSlot.Get((uint)InventorySlotType);
            InventorySlotMask =
                (InventorySlotTypeMask)(1 << (int)(InventorySlotType &
                                                   (InventorySlotType.WeaponRanged | InventorySlotType.Cloak)));
            IsAmmo          = InventorySlotType == InventorySlotType.Ammo;
            IsKey           = Class == ItemClass.Key;
            IsBag           = InventorySlotType == InventorySlotType.Bag;
            IsContainer     = Class == ItemClass.Container || Class == ItemClass.Quiver;
            IsStackable     = MaxAmount > 1 && RandomSuffixId == 0U && RandomPropertiesId == 0U;
            IsTwoHandWeapon = InventorySlotType == InventorySlotType.TwoHandWeapon;
            SetIsWeapon();
            if (ToolCategory != ToolCategory.None)
            {
                ItemMgr.FirstTotemsPerCat[(uint)ToolCategory] = this;
            }
            if (GemPropertiesId != 0U)
            {
                GemProperties = EnchantMgr.GetGemproperties(GemPropertiesId);
                if (GemProperties != null)
                {
                    GemProperties.Enchantment.GemTemplate = this;
                }
            }

            if (Sockets == null)
            {
                Sockets = new SocketInfo[3];
            }
            else if (Sockets.Contains(
                         sock => sock.Color != SocketColor.None))
            {
                HasSockets = true;
            }
            if (Damages == null)
            {
                Damages = DamageInfo.EmptyArray;
            }
            if (Resistances == null)
            {
                Resistances = new int[7];
            }
            if (SocketBonusEnchantId != 0U)
            {
                SocketBonusEnchant = EnchantMgr.GetEnchantmentEntry(SocketBonusEnchantId);
            }
            switch (Class)
            {
            case ItemClass.Weapon:
                ItemProfession = ItemProfessions.WeaponSubClassProfessions.Get((uint)SubClass);
                break;

            case ItemClass.Armor:
                ItemProfession = ItemProfessions.ArmorSubClassProfessions.Get((uint)SubClass);
                break;
            }

            int sheathType = (int)SheathType;

            if (Spells != null)
            {
                ArrayUtil.Prune(ref Spells);
                for (int index = 0; index < 5; ++index)
                {
                    Spells[index].Index = (uint)index;
                    Spells[index].FinalizeAfterLoad();
                }
            }
            else
            {
                Spells = ItemSpell.EmptyArray;
            }

            UseSpell = Spells.Where(
                itemSpell =>
            {
                if (itemSpell.Trigger == ItemSpellTrigger.Use)
                {
                    return(itemSpell.Spell != null);
                }
                return(false);
            }).FirstOrDefault();
            if (UseSpell != null)
            {
                UseSpell.Spell.RequiredTargetType = RequiredTargetType;
                UseSpell.Spell.RequiredTargetId   = RequiredTargetId;
            }

            EquipSpells = Spells.Where(spell =>
            {
                if (spell.Trigger == ItemSpellTrigger.Equip)
                {
                    return(spell.Spell != null);
                }
                return(false);
            }).Select(itemSpell => itemSpell.Spell).ToArray();
            SoulstoneSpell = Spells.Where(
                spell =>
            {
                if (spell.Trigger == ItemSpellTrigger.Soulstone)
                {
                    return(spell.Spell != null);
                }
                return(false);
            }).Select(itemSpell => itemSpell.Spell)
                             .FirstOrDefault();
            HitSpells = Spells.Where(spell =>
            {
                if (spell.Trigger == ItemSpellTrigger.ChanceOnHit)
                {
                    return(spell.Spell != null);
                }
                return(false);
            }).Select(itemSpell => itemSpell.Spell).ToArray();
            ConsumesAmount =
                (Class == ItemClass.Consumable ||
                 Spells.Contains(
                     spell => spell.Trigger == ItemSpellTrigger.Consume)) &&
                (UseSpell == null || !UseSpell.HasCharges);
            IsHearthStone = UseSpell != null && UseSpell.Spell.IsHearthStoneSpell;
            IsInventory   = InventorySlotType != InventorySlotType.None &&
                            InventorySlotType != InventorySlotType.Bag &&
                            InventorySlotType != InventorySlotType.Quiver &&
                            InventorySlotType != InventorySlotType.Relic;
            if (SetId != ItemSetId.None)
            {
                ItemSet itemSet = ItemMgr.Sets.Get((uint)SetId);
                if (itemSet != null)
                {
                    int num = (int)ArrayUtil.Add(ref itemSet.Templates, this);
                }
            }

            if (Mods != null)
            {
                ArrayUtil.TruncVals(ref Mods);
            }
            else
            {
                Mods = StatModifier.EmptyArray;
            }
            IsCharter          = Flags.HasFlag(ItemFlags.Charter);
            RandomSuffixFactor = EnchantMgr.GetRandomSuffixFactor(this);
            if (IsCharter)
            {
                Creator = () => (Item) new PetitionCharter();
            }
            else if (IsContainer)
            {
                Creator = () => (Item) new Container();
            }
            else
            {
                Creator = () => new Item();
            }
        }
Beispiel #24
0
        /// <summary>
        /// Returns a list of recipes from selected skill
        /// </summary>
        /// <param name="skillLine"></param>
        /// <returns></returns>
        public static TradeSkill GetTradeSkill(SkillLine skillLine)
        {
            if (!StyxWoW.IsInGame)
                throw new InvalidOperationException("Must Be in game to call GetTradeSkill()");
            if (skillLine == 0 || !SupportedSkills.Contains(skillLine))
                throw new InvalidOperationException(String.Format("The tradekill {0} can not be loaded", skillLine));
            // if HB is not running then we need to pulse objectmanger for item counts
            if (!TreeRoot.IsRunning)
                ObjectManager.Update();
            //Stopwatch sw = new Stopwatch();
            TradeSkill tradeSkill = null;
            try
            {
                using (StyxWoW.Memory.AcquireFrame())
                {
                    WoWSkill wowSkill = StyxWoW.Me.GetSkill(skillLine);
                    // sw.Start();
                    tradeSkill = new TradeSkill(wowSkill);

                    List<SkillLineAbilityEntry> entries = tradeSkill.GetSkillLineAbilityEntries();
                    foreach (SkillLineAbilityEntry entry in entries)
                    {
                        // check if the entry is a recipe
                        if (entry.NextSpellId == 0 && entry.GreySkillLevel > 0 && entry.TradeSkillCategoryIndex != 0)
                        {
                            var recipe = new Recipe(tradeSkill, entry);
                            recipe.UpdateHeader();
                            tradeSkill.AddRecipe(recipe);
                        }
                        //Logging.Write(entry.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                Logging.WriteException(ex);
            }
            //Logging.Write("it took {0} ms to load {1}", sw.ElapsedMilliseconds, skillLine);
            return tradeSkill;
        }
Beispiel #25
0
 public TradeskillHelper(SkillLine skillLine)
 {
     _skillLine = skillLine;
     _wowSkill  = ObjectManager.Me.GetSkill(skillLine);
 }
 // Gets Character's profession max level
 public static int GetProfessionMaxLevel(SkillLine skill)
 {
     return(Skill.GetMaxValue(skill));
 }
 internal Recipe(uint[] data, TradeSkill parent, SkillLine skill)
 {
     this.recipeData = data;
     this.Skill = skill;
     this.parent = parent;
 }
Beispiel #28
0
 public TradeskillHelper(SkillLine skillLine)
 {
     _skillLine = skillLine;
     _wowSkill = ObjectManager.Me.GetSkill(skillLine);
 }
Beispiel #29
0
            public override ItemSet ConvertTo(byte[] rawData, ref int id)
            {
                ItemSet itemSet = new ItemSet();

                id                = (int)(itemSet.Id = rawData.GetUInt32(0U));
                itemSet.Name      = this.GetString(rawData, 1);
                itemSet.Templates = new ItemTemplate[10];
                Spell[] spellArray = new Spell[8];
                for (uint field = 35; field < 43U; ++field)
                {
                    uint  uint32 = rawData.GetUInt32(field);
                    Spell spell;
                    if (uint32 != 0U && (spell = SpellHandler.Get(uint32)) != null)
                    {
                        uint num = field - 35U;
                        spellArray[num] = spell;
                    }
                }

                List <Spell>[] spellListArray = new List <Spell> [8];
                uint           num1           = 0;

                for (uint field = 43; field < 51U; ++field)
                {
                    uint uint32 = rawData.GetUInt32(field);
                    if (uint32 > 0U)
                    {
                        uint num2 = uint32 - 1U;
                        if (num1 < num2)
                        {
                            num1 = num2;
                        }
                        List <Spell> spellList = spellListArray[num2];
                        if (spellList == null)
                        {
                            spellListArray[num2] = spellList = new List <Spell>(3);
                        }
                        uint  num3  = field - 43U;
                        Spell spell = spellArray[num3];
                        if (spell != null)
                        {
                            spellList.Add(spell);
                        }
                    }
                }

                itemSet.Boni = new Spell[num1 + 1U][];
                for (int index = 0; (long)index <= (long)num1; ++index)
                {
                    if (spellListArray[index] != null)
                    {
                        itemSet.Boni[index] = spellListArray[index].ToArray();
                    }
                }

                SkillId uint32_1 = (SkillId)rawData.GetUInt32(51U);

                if (uint32_1 > SkillId.None)
                {
                    SkillLine skillLine = SkillHandler.Get(uint32_1);
                    if (skillLine != null)
                    {
                        itemSet.RequiredSkill      = skillLine;
                        itemSet.RequiredSkillValue = rawData.GetUInt32(52U);
                    }
                }

                return(itemSet);
            }
 public TradeSkill GetTradeSkill(SkillLine skillLine)
 {
     return GetTradeSkill(skillLine, false);
 }
Beispiel #31
0
        public override void Run()
        {
            if (_listOfTeachers.Count <= 0)
            {
                return;
            }
            Npc bestTeacher = new Npc();

            for (int i = 0; i < _listOfTeachers.Count; i++)
            {
                Npc teacher = _listOfTeachers[i];
                if (bestTeacher.Entry > 0)
                {
                    // priority checks first
                    switch (Products.Products.ProductName)
                    {
                    case "Gatherer":
                        if (bestTeacher.Type == Npc.NpcType.MiningTrainer && teacher.Type != Npc.NpcType.RidingTrainer)
                        {
                            continue;
                        }
                        if (bestTeacher.Type == Npc.NpcType.HerbalismTrainer && teacher.Type != Npc.NpcType.RidingTrainer && teacher.Type != Npc.NpcType.MiningTrainer)
                        {
                            continue;
                        }
                        if (bestTeacher.Type == Npc.NpcType.SkinningTrainer && teacher.Type != Npc.NpcType.RidingTrainer && teacher.Type != Npc.NpcType.MiningTrainer &&
                            teacher.Type != Npc.NpcType.HerbalismTrainer)
                        {
                            continue;
                        }
                        if (teacher.Type == Npc.NpcType.RidingTrainer)
                        {
                            bestTeacher = teacher;
                        }
                        else if (teacher.Type == Npc.NpcType.MiningTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer)
                        {
                            bestTeacher = teacher;
                        }
                        else if (teacher.Type == Npc.NpcType.HerbalismTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer && bestTeacher.Type != Npc.NpcType.MiningTrainer)
                        {
                            bestTeacher = teacher;
                        }
                        else if (teacher.Type == Npc.NpcType.SkinningTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer && bestTeacher.Type != Npc.NpcType.MiningTrainer &&
                                 bestTeacher.Type != Npc.NpcType.HerbalismTrainer)
                        {
                            bestTeacher = teacher;
                        }
                        break;

                    case "Quester":
                    case "Grinder":
                        if (bestTeacher.Type == Npc.NpcType.SkinningTrainer && teacher.Type != Npc.NpcType.RidingTrainer)
                        {
                            continue;
                        }
                        if (bestTeacher.Type == Npc.NpcType.MiningTrainer && teacher.Type != Npc.NpcType.RidingTrainer && teacher.Type != Npc.NpcType.SkinningTrainer)
                        {
                            continue;
                        }
                        if (bestTeacher.Type == Npc.NpcType.HerbalismTrainer && teacher.Type != Npc.NpcType.RidingTrainer && teacher.Type != Npc.NpcType.SkinningTrainer &&
                            teacher.Type != Npc.NpcType.MiningTrainer)
                        {
                            continue;
                        }
                        if (teacher.Type == Npc.NpcType.RidingTrainer)
                        {
                            bestTeacher = teacher;
                        }
                        else if (teacher.Type == Npc.NpcType.SkinningTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer)
                        {
                            bestTeacher = teacher;
                        }
                        else if (teacher.Type == Npc.NpcType.MiningTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer && bestTeacher.Type != Npc.NpcType.SkinningTrainer)
                        {
                            bestTeacher = teacher;
                        }
                        else if (teacher.Type == Npc.NpcType.HerbalismTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer && bestTeacher.Type != Npc.NpcType.SkinningTrainer &&
                                 bestTeacher.Type != Npc.NpcType.MiningTrainer)
                        {
                            bestTeacher = teacher;
                        }
                        break;
                    }
                    if (bestTeacher == teacher)
                    {
                        continue; // We just set a best from priority checks, so distance check is not important anymore
                    }
                    if (ObjectManager.ObjectManager.Me.Position.DistanceTo(teacher.Position) < ObjectManager.ObjectManager.Me.Position.DistanceTo(bestTeacher.Position))
                    {
                        bestTeacher = teacher; // We do not have priority between teacher and the actual bestTeacher, so we use distance instead
                    }
                }
                else
                {
                    bestTeacher = teacher;
                }
            }

            if (bestTeacher.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 800)
            {
                if (Quest.TravelToQuestZone(bestTeacher.Position, ref _doTravel, bestTeacher.ContinentIdInt, false, bestTeacher.Type.ToString()))
                {
                    return;
                }
            }
            uint baseAddress = MovementManager.FindTarget(ref bestTeacher);

            if (MovementManager.InMovement)
            {
                return;
            }
            if (baseAddress == 0 && bestTeacher.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) < 10)
            {
                NpcDB.DelNpc(bestTeacher);
            }
            else if (baseAddress > 0)
            {
                if (bestTeacher.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 5f)
                {
                    return;
                }
                string[] skillInfo = bestTeacher.InternalData.Split(',');
                if (skillInfo.Length == 2)
                {
                    SkillLine skillLine = (SkillLine)Others.ToInt32(skillInfo[0]);
                    SkillRank skillRank = (SkillRank)Others.ToInt32(skillInfo[1]);
                    SkillRank nextRank;
                    if (skillRank == SkillRank.ZenMaster)
                    {
                        nextRank = skillRank + 100;
                    }
                    else
                    {
                        nextRank = skillRank + 75;
                    }
                    string oldRank = "";
                    if (skillRank != SkillRank.None)
                    {
                        oldRank = " We were only " + skillRank.ToString() + " of " + skillLine.ToString() + ".";
                    }
                    Logging.Write("We have just reached the Teacher of " + skillLine.ToString() + ", " + bestTeacher.Name + ". We are now going to learn " + nextRank.ToString() +
                                  " of " + skillLine.ToString() + "." + oldRank);
                }
                Interact.InteractWith(baseAddress);
                Thread.Sleep(500 + Usefuls.Latency);
                Quest.CompleteQuest();
                Gossip.TrainAllAvailableSpells();
                TeacherFoundNoSpam.Remove(bestTeacher);
                SpellManager.UpdateSpellBook();
                _doTravel = true;
            }
            // still on the road, but not in movement for some reasons
        }
Beispiel #32
0
 internal Recipe(uint[] data, TradeSkill parent, SkillLine skill)
 {
     this.recipeData = data;
     this.Skill      = skill;
     this.parent     = parent;
 }
        /// <summary>
        /// Returns a list of recipes from selected skill
        /// </summary>
        /// <param name="skillLine"></param>
        /// <param name="blockFrame">prevents tradeskill frame from showing</param>
        /// <returns></returns>
        public TradeSkill GetTradeSkill(SkillLine skillLine, bool blockFrame)
        {
            if (!ObjectManager.IsInGame)
                throw new InvalidOperationException("Must Be in game to call GetTradeSkill()");
            if (skillLine == 0 || !SupportedSkills.Contains(skillLine))
                throw new InvalidOperationException(string.Format("The tradekill {0} can not be loaded", skillLine));
            // if HB is not running then we need to pulse objectmanger for item counts
            if (!TreeRoot.IsRunning)
                ObjectManager.Update();
            WoWSkill wowSkill = ObjectManager.Me.GetSkill(skillLine);

            TradeSkill tradeSkill = new TradeSkill(wowSkill);

            //lets copy over to a local variable for performance
            bool _isVisible = IsVisible;
            bool loadSkill = Skill != skillLine || !_isVisible;
            string lua = string.Format("{0}{1}{2}{3}",
                blockFrame && loadSkill ? "if not TradeSkillFrame then LoadAddOn('Blizzard_TradeSkillUI') end local fs = {} local f = EnumerateFrames() while f do if f:IsEventRegistered('TRADE_SKILL_SHOW') == 1 and f:GetName() ~= 'UIParent' then f:UnregisterEvent('TRADE_SKILL_SHOW') table.insert (fs,f) end f = EnumerateFrames(f) end " : "",
                // have to hard code in mining since I need to cast 'Smelting' not 'Mining' XD
                // also using lua over SpellManager.Cast since its grabing name from DBC. one word, localization.
                loadSkill ? (skillLine == SkillLine.Mining ? "CastSpellByID(2656) " : string.Format("CastSpellByName('{0}') ", wowSkill.Name)) : "",
                // force cache load
                "for i=1, GetNumTradeSkills() do GetTradeSkillItemLink(i) for n=1,GetTradeSkillNumReagents(i) do GetTradeSkillReagentInfo(i,n) end end ",
                blockFrame && loadSkill ? "for k,v in pairs(fs) do v:RegisterEvent('TRADE_SKILL_SHOW') end CloseTradeSkill() " : ""
            );
            using (new FrameLock())
            {
                if (!string.IsNullOrEmpty(lua))
                    Lua.DoString(lua);

                int _recipeCount = RecipeCount;
                if (Skill != skillLine || _recipeCount <= 0)
                {// we failed to load tradeskill
                    throw new Exception(string.Format("Unable to load {0}", skillLine));
                }
                // array of pointers that point to each recipe structure.
                uint[] recipePtrArray = ObjectManager.Wow.ReadStructArray<uint>(RecipeOffset, RecipeCount);
                for (int index = 0; index < _recipeCount; index++)
                {
                    uint[] recipeData = ObjectManager.Wow.ReadStructArray<uint>(recipePtrArray[index], 9);
                    uint id = recipeData[(int)Recipe.RecipeIndex.RecipeID];
                    // check if its a header
                    if (id == uint.MaxValue)
                    {
                        continue; // no further info to get for header
                    }
                    tradeSkill.Recipes.Add(id, new Recipe(recipeData, tradeSkill, skillLine));
                }
                tradeSkill.InitIngredientList();
                tradeSkill.InitToolList();
            }
            return tradeSkill;
        }
Beispiel #34
0
            public override ItemSet ConvertTo(byte[] rawData, ref int id)
            {
                ItemSet set = new ItemSet();

                id       = (int)(set.Id = rawData.GetUInt32(0));
                set.Name = GetString(rawData, 1);

                set.Templates = new ItemTemplate[10];

                // 17 (or less) items
                //for (uint i = ItemsOffset; i <= ItemsEnd; i++)
                //{
                //    var itemId = rawData.GetUInt32(i);
                //    if (itemId != 0)
                //    {
                //        var templ = ItemMgr.GetTemplate(itemId);
                //        if (templ != null)
                //        {
                //            items.Add(templ);
                //        }
                //    }
                //}

                var boni = new Spell[MaxBonusCount];

                for (uint i = BoniOffset; i < BoniOffset + MaxBonusCount; i++)
                {
                    var spellId = rawData.GetUInt32(i);
                    if (spellId != 0)
                    {
                        Spell spell;
                        if ((spell = SpellHandler.Get(spellId)) != null)
                        {
                            var index = i - BoniOffset;
                            boni[index] = spell;
                        }
                    }
                }

                var  orderedBoni  = new List <Spell> [MaxBonusCount];
                uint highestIndex = 0;

                for (uint i = BoniOrderOffset; i < BoniOrderOffset + MaxBonusCount; i++)
                {
                    var amount = rawData.GetUInt32(i);
                    if (amount > 0)
                    {
                        var orderedIndex = amount - 1;
                        if (highestIndex < orderedIndex)
                        {
                            highestIndex = orderedIndex;
                        }

                        var spells = orderedBoni[orderedIndex];
                        if (spells == null)
                        {
                            orderedBoni[orderedIndex] = spells = new List <Spell>(3);
                        }

                        var bonusSlot = i - BoniOrderOffset;
                        var spell     = boni[bonusSlot];
                        if (spell != null)
                        {
                            spells.Add(spell);
                        }
                    }
                }

                set.Boni = new Spell[highestIndex + 1][];
                for (int i = 0; i <= highestIndex; i++)
                {
                    if (orderedBoni[i] != null)
                    {
                        set.Boni[i] = orderedBoni[i].ToArray();
                    }
                }

                var skillId = (SkillId)rawData.GetUInt32(51);

                if (skillId > 0)
                {
                    SkillLine skill = SkillHandler.Get(skillId);
                    if (skill != null)
                    {
                        set.RequiredSkill      = skill;
                        set.RequiredSkillValue = rawData.GetUInt32(52);
                    }
                }

                return(set);
            }
 /// Opens TradeSkill Frame for the specific skill
 /// </summary>
 /// <param name="skillLine"></param>
 public void Show(SkillLine skillLine)
 {
     if (skillLine != 0 && ObjectManager.IsInGame && !IsVisible)
     {
         WoWSkill wowSkill = ObjectManager.Me.GetSkill(skillLine);
         bool loadSkill = Skill != skillLine || !IsVisible;
         // have to hard code in mining since I need to cast 'Smelting' not 'Mining' XD
         // also using lua over SpellManager.Cast since its grabing name from DBC. one word, localization.
         string lua = loadSkill ? (skillLine == SkillLine.Mining ? "CastSpellByID(2656);" : string.Format("CastSpellByName('{0}');", wowSkill.Name)) : null;
         if (lua != null)
             Lua.DoString(lua);
     }
 }