Exemple #1
0
        //---------------------------------------------------------------------------------------------

        public bool GetMixureReagent(UOItem container, Potion potion, PotionQuality quality)
        {
            if (!potion.Reagent.IsValid)
            {
                Game.PrintMessage("!potion.Reagent.IsValid :", MessageType.Error);
                return(false);
            }
            int    amount   = potion.GetAmountOrDefault(quality);
            UOItem resource = Reagent.FindReagent(container.Serial, potion.Reagent.Graphic, potion.Reagent.Color);

            if (resource.Exist && amount > 0)
            {
                //UOItem invetoryRg = new UOItem(Serial.Invalid);
                //if ((invetoryRg = Reagent.FindReagent(UO.Backpack.Serial, potion.Reagent.Graphic, potion.Reagent.Color)).Exist)
                //{
                //  invetoryRg.Move(invetoryRg.Amount, container);
                //  Game.Wait(Settings.SmallestWait);
                //}
                resource.Move((ushort)amount, UO.Backpack.Serial, 20, 20);
                Game.Wait(Game.SmallestWait);
                return(true);
            }
            else
            {
                Game.PrintMessage("Ve zdrojovem kontaineru nejsou regy.", MessageType.Error);
            }

            return(false);
        }
Exemple #2
0
        //---------------------------------------------------------------------------------------------

        public int GetAmountOrDefault(PotionQuality pq)
        {
            if (this.Qualities.ContainsKey(pq))
            {
                return(this.Qualities[pq].Amount);
            }

            return(0);
        }
Exemple #3
0
        //---------------------------------------------------------------------------------------------

        public PotionQualityDefinition GetQualityDefinition(PotionQuality quality)
        {
            if (this.Qualities.ContainsKey(quality))
            {
                return(this.Qualities[quality]);
            }

            return(TopQualityDefinition);
        }
Exemple #4
0
        public bool MixurePotion(Potion potion, PotionQuality quality, bool findInAll)
        {
            int    amount     = potion.GetAmountOrDefault(quality);
            UOItem invetoryRg = Reagent.FindReagentAll(UO.Backpack.Serial, potion.Reagent.Graphic, potion.Reagent.Color, amount);

            if (!invetoryRg.Exist)
            {
                Game.PrintMessage("Nejsou regy.", MessageType.Error);
                return(false);
            }

            if (!Mortar.Exist)
            {
                Game.PrintMessage("Neni mortar.", MessageType.Error);
                return(false);
            }
            Game.RunScript(amount * 6000);

            Game.PrintMessage("Micham:" + potion.Name + " - " + quality.ToString());
            Journal.Clear();

            Targeting.ResetTarget();
            UO.WaitMenu("Vyber typ potionu", potion.GetQualityDefinition(quality).MenuName);
            Mortar.Use();
            JournalEventWaiter jew = new JournalEventWaiter(true, "*You toss", "You can't make another potion now", "You completed the mixture in the mortar", "Musis mit v batuzku prazdnou lahev.");
            DateTime           dt1 = DateTime.Now;

            if (jew.Wait(60000))
            {
                if (Journal.Contains(true, "You can't make another potion now"))
                {
                    Game.Wait(4000);
                    return(true);
                }
                else if (Journal.Contains(true, "You toss"))
                {
                    return(true);
                }
                else if (Journal.Contains(true, "Musis mit v batuzku prazdnou lahev."))
                {
                    UIManager.Reset();
                    return(false);
                }
                else
                {
                    Mortar.Use();
                    if (Journal.WaitForText(false, 500, "You pour the completed"))
                    {
                        return(true);
                    }
                }
            }

            return(true);
        }
Exemple #5
0
        //---------------------------------------------------------------------------------------------

        public static PotionQuality ParsePQOrDefault(string name, PotionQuality df, Potion potion)
        {
            PotionQuality result = df;

            try { result = (PotionQuality)Enum.Parse(typeof(PotionQuality), name, true); }
            catch { }
            if (potion != null && !potion.Qualities.ContainsKey(result))
            {
                result = potion.Qualities.GetEnumerator().Current.Key;
            }

            return(result);
        }
Exemple #6
0
        //---------------------------------------------------------------------------------------------

        public void TrainAlchemy(string name, string quality)
        {
            Potion        potion = null;
            PotionQuality pq     = Potion.ParsePQOrDefault(quality, PotionQuality.Lesser);

            if ((potion = PotionCollection.Potions.GetItemByName(name)) != null)
            {
                TrainAlchemy(potion, pq);
            }
            else
            {
                Game.PrintMessage("Potion s nazvem " + name + " neexistuje", MessageType.Error);
            }
        }
Exemple #7
0
        //---------------------------------------------------------------------------------------------


        public void TrainAlchemyMag(Potion potion, PotionQuality quality)
        {
            //WatchDogHelper.Watch();
            Game.CurrentGame.Mode = GameMode.Working;
            Game.PrintMessage("Vyber zdrojovy konterjner s regy:");
            UOItem container = new UOItem(UIManager.TargetObject());

            ItemHelper.EnsureContainer(container);
            while (GetMixureReagent(container, potion, quality))
            {
                FillKadRecursive(potion, quality);
                if (!MixurePotion(potion, quality))
                {
                    break;
                }
            }
            Game.PrintMessage("Trenovani dokonceno.");
        }
Exemple #8
0
    public void Randomize()
    {
        int   bonus;
        Array values;

        System.Random random = new System.Random();
        //randomize all info
        switch (potionQuality)
        {
        case PotionQuality.COMMON:
            bonus      = 50;
            healAmount = bonus;
            break;

        case PotionQuality.RARE:
            bonus      = 500;
            healAmount = bonus;
            break;

        case PotionQuality.LEGENDARY:
            bonus      = 1000;
            healAmount = bonus;
            break;
        }

        //Generate random item stats
        values = Enum.GetValues(typeof(PotionQuality));
        var randomQuality = (PotionQuality)values.GetValue(random.Next(values.Length));

        potionQuality = randomQuality;

        values = Enum.GetValues(typeof(PotionBuff));
        var randomBuff = (PotionBuff)values.GetValue(random.Next(values.Length));

        potionBuff = randomBuff;

        ItemID      = string.Format("ID{0}POT{1}", potionBuff, random.Next(0, 100));
        Name        = string.Format("{0} potion of {1} restoration.", potionQuality.ToString().ToLower(), potionBuff.ToString().ToLower());
        Description = string.Format("Heals your {0} for {1} points.", potionBuff.ToString().ToLower(), healAmount);
        Prefab      = RandomizePrefab();
        Material    = RandomizeMaterial(Prefab);
    }
Exemple #9
0
        //---------------------------------------------------------------------------------------------

        public void TrainAlchemy(Potion potion, PotionQuality quality)
        {
            //WatchDogHelper.Watch();
            Game.CurrentGame.Mode = GameMode.Working;
            Game.PrintMessage("Vyber zdrojovy konterjner s regy:");
            UOItem container = new UOItem(UIManager.TargetObject());

            ItemHelper.EnsureContainer(container);

            decimal okCount = 0;
            decimal count   = 0;

            while (GetMixureReagent(container, potion, quality))
            {
                FillKadRecursive(potion, quality);
                if (!MixurePotion(potion, quality))
                {
                    //break;
                }
                else
                {
                    count++;
                    if (Journal.Contains(true, "You pour"))
                    {
                        okCount++;
                    }

                    decimal okDivide  = (okCount / count);
                    decimal okPerc    = okDivide * 100;
                    int     regAmount = potion.GetAmountOrDefault(quality);


                    decimal pricePerPcs = (1 / (okDivide > 0 ? (okCount / count) : 1)) * (decimal)regAmount * 5.0m;//

                    Game.PrintMessage("Ks: " + okCount + " / " + count + " : " + String.Format("{0:n} %", okPerc));
                }
            }
            Game.PrintMessage("Trenovani dokonceno.");
        }
Exemple #10
0
        //---------------------------------------------------------------------------------------------

        public void FillKadRecursive(Potion potion, PotionQuality quality)
        {
            UOItem p = UO.Backpack.Items.FindType(potion.DefaultGraphic, potion.DefaultColor);

            PotionQualityDefinition pqDef = potion.GetQualityDefinition(quality);
            UOColor kadColor    = pqDef != null ? pqDef.KadColor : potion.TopKadColor;
            UOColor potionColor = pqDef != null ? pqDef.Color : potion.DefaultColor;

            UOItem kad = FindKadAround(Potion.KadGraphic, kadColor);

            if (p.Exist && kad.Exist)
            {
                Journal.Clear();
                //Game.Wait(250);
                kad.Use();
                UO.WaitTargetObject(p);
                JournalEventWaiter jew = new JournalEventWaiter(true, "Tohle nejde");
                jew.Wait(250);
                if (UO.Backpack.Items.FindType(potion.DefaultGraphic, potionColor).Exist)
                {
                    FillKadRecursive(potion, quality);
                }
            }
        }
Exemple #11
0
        //---------------------------------------------------------------------------------------------

        public bool MixurePotion(Potion potion, PotionQuality quality)
        {
            return(MixurePotion(potion, quality, true));
        }
Exemple #12
0
        public void TrainAlchemyMag(string name, string quality)
        {
            Game.PrintMessage("TrainAlchemyMag");
            Potion        potion = PotionCollection.Potions.GetItemByName(name);
            PotionQuality pq     = Potion.ParsePQOrDefault(quality, PotionQuality.Lesser);

            Game.PrintMessage("Vyber zdrojovy konterjner s regy:");
            UOItem container = new UOItem(UIManager.TargetObject());

            ItemHelper.EnsureContainer(container);


            decimal okCount = 0;
            decimal count   = 0;

            while (!UO.Dead &&
                   World.Player.Backpack.AllItems.FindType(Reagent.Nightshade.Graphic, Reagent.Nightshade.Color).Exist&&
                   World.Player.Backpack.AllItems.FindType(Reagent.BlackPearl.Graphic, Reagent.BlackPearl.Color).Exist
                   )
            {
                while (World.Player.Mana > 10)
                {
                    if (World.Player.Hits < 40)
                    {
                        while (World.Player.Hits < World.Player.Strenght)
                        {
                            UOItem banda = World.Ground.FindType(0x0E21);//bandy
                            if (!banda.Exist)
                            {
                                return;
                            }

                            UO.WaitTargetSelf();
                            banda.Use();
                            Game.Wait(2500);
                        }
                    }

                    UO.Cast(StandardSpell.MagicArrow, Aliases.Self);
                    Game.Wait(1500);
                }

                while (World.Player.Hits < World.Player.Strenght)
                {
                    UOItem banda = World.Ground.FindType(0x0E21);//bandy
                    if (!banda.Exist)
                    {
                        break;
                    }

                    UO.WaitTargetSelf();
                    banda.Use();
                    Game.Wait(2500);
                }

                //UOItem mrKad = new UOItem(World.Player.Backpack.Items.FindType(Potion.KadGraphic, Potion.ManaRefresh.TopKadColor));
                //UOItem tmrKad = new UOItem(World.Player.Backpack.Items.FindType(Potion.KadGraphic, Potion.TotalManaRefresh.TopKadColor));
                //if (mrKad.Exist || tmrKad.Exist)
                //{
                //  Game.CurrentGame.CurrentPlayer.GetSkillInstance<Alchemy>().DrinkPotion("Total Mana Refresh");
                //  Game.Wait();
                //}
                //else
                {
                    while (GetMixureReagent(container, potion, pq) && World.Player.Mana < World.Player.Intelligence)
                    {
                        FillKadRecursive(potion, pq);
                        if (!MixurePotion(potion, pq))
                        {
                            break;
                        }
                        else
                        {
                            count++;
                            if (Journal.Contains(true, "You pour"))
                            {
                                okCount++;
                            }

                            decimal okDivide  = (okCount / count);
                            decimal okPerc    = okDivide * 100;
                            int     regAmount = potion.GetAmountOrDefault(pq);


                            decimal pricePerPcs = (1 / (okDivide > 0 ? (okCount / count) : 1)) * (decimal)regAmount * 5.0m;//

                            Game.PrintMessage("Ks: " + okCount + " / " + String.Format("{0:n} %", okPerc) + " Prc: " + String.Format("{0:n} gp", pricePerPcs));
                        }
                    }
                }
            }
            Game.PrintMessage("TrainAlchemyMag END");
        }
Exemple #13
0
        //---------------------------------------------------------------------------------------------

        public static PotionQuality ParsePQOrDefault(string name, PotionQuality df)
        {
            return(ParsePQOrDefault(name, df, null));
        }
Exemple #14
0
        public void Train(string name, string quality, string drinkPotion, bool drink, int manaLimit, params string[] menus)
        {
            Game.PrintMessage("Zvol kontejner s materialem > (esc) = ground");
            UOItem containerFrom = new UOItem(UIManager.TargetObject());

            Game.CurrentGame.Mode = GameMode.Working;

            decimal okCountAlch = 0;
            decimal countAlch   = 0;

            decimal okCount = 0;
            decimal count   = 0;

            bool restart = true;

            while (!UO.Dead)
            {
                Journal.Clear();
                if (!World.Player.Backpack.AllItems.FindType(BlankScroll.Graphic, BlankScroll.Color).Exist)
                {
                    foreach (UOItem item in World.Player.Backpack.AllItems)
                    {
                        if (item.Graphic > 0x1F20 && item.Graphic < 0x1F99)
                        {
                            item.Move(10000, containerFrom);
                            Game.Wait(500);
                        }
                    }

                    UOItem sourceItem = containerFrom.Items.FindType(BlankScroll.Graphic, BlankScroll.Color);
                    if (sourceItem.Exist)
                    {
                        sourceItem.Move(100, World.Player.Backpack);
                        Game.Wait(500);
                    }
                    else
                    {
                        break;
                    }
                }

                if (World.Player.Mana > manaLimit)
                {
                    Game.PrintMessage("Write - " + String.Join(",", menus));
                    UO.UseType(BlankScroll.Graphic, BlankScroll.Color);
                    UO.WaitMenu(menus);
                    Journal.WaitForText(true, 7500, "You fail to inscribe", "You dont't know any", "You put");

                    count++;

                    if (Journal.Contains("You put"))
                    {
                        okCount++;
                    }


                    if (Journal.Contains("You dont't know any"))
                    {
                        Game.PrintMessage("Nemas suroviny");
                        break;
                    }


                    decimal okDivide = (okCount / count);
                    decimal okPerc   = okDivide * 100;
                    Game.PrintMessage("Ks: " + okCount + " / " + count + " - " + String.Format("{0:n} %", okPerc));
                }

                Potion p = PotionCollection.Potions.GetItemByName(drinkPotion);

                UOItem mrKad = null;

                if (p != null)
                {
                    mrKad = new UOItem(World.Player.Backpack.Items.FindType(Potion.KadGraphic, p.TopKadColor));
                    if (mrKad == null || !mrKad.Exist)
                    {
                        mrKad = World.Ground.FindType(Potion.KadGraphic, p.TopKadColor);
                    }
                }

//        Game.PrintMessage("" + (p != null) + " / " + (mrKad != null && mrKad.Exist));

                //new UOItem(World.Player.Backpack.Items.FindType(Potion.KadGraphic, Potion.ManaRefresh.TopKadColor));
                int manaOffset = 60;
                if (p != null && p.Name == "ManaRefresh")
                {
                    manaOffset = 25;
                }

                if (World.Player.Mana < manaLimit || (restart && World.Player.Mana < (World.Player.Intelligence - manaOffset)))
                {
                    restart = false;


                    if (drink && mrKad != null && mrKad.Exist)
                    {
                        Game.CurrentGame.CurrentPlayer.GetSkillInstance <Alchemy>().DrinkPotion(p);
                        Game.Wait(1500);
                        if (Journal.Contains("You can't drink", "You can't "))
                        {
                            Game.Wait(8000);
                            Journal.Clear();
                        }
                    }
                }

                if (World.Player.Mana < manaLimit)
                {
                    World.Player.ChangeWarmode(WarmodeChange.Peace);
                    Game.Wait(250);
                    int    counter     = 0;
                    bool   alchemyOK   = true;
                    double timeCounter = 0;
                    restart = true;
                    long   lastDrink = 0;
                    UOItem atlas     = World.Player.Backpack.AllItems.FindType(AtlasType.Graphic, AtlasType.Color);

                    //while (World.Player.Mana < World.Player.Intelligence)
                    //{
                    Journal.Clear();

                    DateTime start = DateTime.Now;
                    if (!String.IsNullOrEmpty(name) && !String.IsNullOrEmpty(quality) && alchemyOK)
                    {
                        Potion        potion = null;
                        PotionQuality pq     = Potion.ParsePQOrDefault(quality, PotionQuality.Lesser);
                        if ((potion = PotionCollection.Potions.GetItemByName(name)) != null)
                        {
                            Alchemy a = new Alchemy();

                            if (a.GetMixureReagent(containerFrom, potion, pq))
                            {
                                a.FillKadRecursive(potion, pq);
                                if (!a.MixurePotion(potion, pq, false))
                                {
                                    break;
                                }
                                else
                                {
                                    countAlch++;
                                    if (Journal.Contains(true, "You pour"))
                                    {
                                        okCountAlch++;
                                    }

                                    decimal okDivide    = (okCountAlch / countAlch);
                                    decimal okPerc      = okDivide * 100;
                                    int     regAmount   = potion.GetAmountOrDefault(pq);
                                    decimal pricePerPcs = (1 / (okDivide > 0 ? (okCountAlch / countAlch) : 1)) * (decimal)regAmount * 5.0m;//

                                    Game.PrintMessage("Ks: " + okCountAlch + " / " + String.Format("{0:n} %", okPerc) + " Prc: " + String.Format("{0:n} gp", pricePerPcs));
                                }
                            }
                            Game.PrintMessage("Trenovani dokonceno.");
                        }
                        else
                        {
                            alchemyOK = false;
                            Game.PrintMessage("Potion s nazvem " + name + " neexistuje", MessageType.Error);
                        }
                        //WatchDogHelper.Watch();
                    }
                    else if (atlas.Exist && atlas.Amount > 0)
                    {
                        //map 0x14EF

                        foreach (UOItem map in World.Player.Backpack.AllItems)
                        {
                            if (map.Graphic == 0x14EB && map.Color == 0x0000)
                            {
                                UO.WaitTargetObject(map);
                                atlas.Use();
                                Game.Wait();
                            }
                        }

                        if (!World.Player.Backpack.AllItems.FindType(0x14EB, 0x0000).Exist)
                        {
                            UO.WaitTargetSelf();
                            atlas.Use();
                            Game.Wait();
                        }

                        if (World.Player.Backpack.AllItems.FindType(0x14EB, 0x0000).Exist)
                        {
                            UO.WaitMenu("What sort of map do you want to draw ?", "Detail Map");
                            UO.UseType(0x14EB, 0x0000);
                            JournalEventWaiter jew = new JournalEventWaiter(true, "You put the map", "Thy trembling hand results in an unusable map");
                            jew.Wait(5000);
                        }
                    }
                    else if (World.Player.Backpack.AllItems.FindType(0x0E9D).Exist&& SkillsHelper.GetSkillValue("Musicianship").RealValue < 500)
                    {
                        UO.UseType(0x0E9D, 0x0000);
                        if (Journal.WaitForText(true, 2500, "You play poorly"))
                        {
                        }
                        //Game.Wait(1000);

                        if (Journal.Contains(true, " You are preoccupied with thoughts of battle"))
                        {
                            Game.CurrentGame.CurrentPlayer.SwitchWarmode();
                            Game.Wait();
                        }
                    }
                    else if (World.Player.Backpack.AllItems.FindType(0x1438).Exist&& SkillsHelper.GetSkillValue("ItemIdentification").RealValue < 1000)//war hamer
                    {
                        UO.WaitTargetType(0x1438);
                        UO.UseSkill(StandardSkill.ItemIdentification);
                        Game.Wait(1500);
                    }
                    //else if (SkillsHelper.GetSkillValue("DetectingHidden").RealValue < 150)
                    //{
                    //  UO.UseSkill(StandardSkill.DetectingHidden);
                    //  Game.Wait(1000);
                    //}

                    else
                    {
                        UO.UseSkill(StandardSkill.Meditation);
                        Game.Wait(2500);
                    }

                    Game.Wait(100);
                    counter++;



                    double elapsedTime = (DateTime.Now - start).TotalMilliseconds;
                    timeCounter += elapsedTime;

                    int longpartCount = (int)Math.Truncate(timeCounter) / 5000;
                    Game.PrintMessage("Cas:" + (longpartCount * 5000) + " / " + ((longpartCount * 5000) - lastDrink));

                    if ((longpartCount * 5000) - lastDrink > 10000)
                    {
                        lastDrink = (longpartCount * 5000);
                        if (drink && mrKad != null && mrKad.Exist && World.Player.Mana < (World.Player.Intelligence - manaOffset))//        if (World.Player.Mana < 50 || (restart && World.Player.Mana < (World.Player.Intelligence - manaLimit)))
                        {
                            Journal.Clear();
                            Game.CurrentGame.CurrentPlayer.GetSkillInstance <Alchemy>().DrinkPotion(p);
                            Game.Wait(1500);
                        }
                    }
                    //}
                }
            }
        }