Example #1
0
        protected override void ReadEntry(JObject entry)
        {
            entry.AssertNotMissing("category", "id", "title", "itemId", "amount", "exp", "rank", "materials", "successRates", "rainBonus");

            var data = new ProductionData();

            data.Category   = (ProductionCategory)entry.ReadInt("category");
            data.Id         = entry.ReadInt("id");
            data.ItemId     = entry.ReadInt("itemId");
            data.Amount     = entry.ReadInt("amount");
            data.Exp        = entry.ReadInt("exp");
            data.Tool       = entry.ReadString("tool", null);
            data.Durability = entry.ReadInt("durability");
            data.Mana       = entry.ReadInt("mana");

            // Rank
            var difficultyRank = entry.ReadString("rank");

            if (difficultyRank == "Novice")
            {
                data.Rank = SkillRank.Novice;
            }
            else
            {
                data.Rank = (SkillRank)(16 - int.Parse(difficultyRank, NumberStyles.HexNumber));
            }

            // Materials
            foreach (var material in entry["materials"])
            {
                var materialData = new ProductionMaterialData();

                materialData.Tag    = (string)material[0];
                materialData.Amount = (int)material[1];

                data.Materials.Add(materialData);
            }

            // Success Rates
            var ratesObj = (JObject)entry["successRates"];

            ratesObj.AssertNotMissing("Novice", "F", "E", "D", "C", "B", "A", "9", "8", "7", "6", "5", "4", "3", "2", "1");
            for (SkillRank rank = SkillRank.Novice; rank <= SkillRank.R1; ++rank)
            {
                data.SuccessRates[rank] = ratesObj.ReadInt(rank.ToString().TrimStart('R'));
            }

            data.RainBonus = entry.ReadInt("rainBonus");

            data.ItemData = AuraData.ItemDb.Find(data.ItemId);
            if (data.ItemData == null)
            {
                throw new DatabaseErrorException("Item not found: " + data.ItemId);
            }

            this.Entries.Add(data);
        }
Example #2
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
        }