Esempio n. 1
0
        //---------------------------------------------------------------------------------------------

        public void AddTree()
        {
            DataTable dt = Cal.Engine.GetOtSetDataTable(new UOPosition().DbViewNameForLoad);

            if (dt.Rows.Count > 0)
            {
                Game.PrintMessage("Tree count: " + dt.Select("IsTree=1").Length);
            }

            StaticTarget tree = UIManager.Target();

            UO.Print(tree.Graphic);

            if (tree.Graphic != 0)
            {
                UOPosition pos = new UOPosition(tree.X, tree.Y, (ushort)tree.Z);
                pos.EnsureLoadByPosition();
                pos.IsTree      = true;
                pos.TypeChecked = true;
                pos.Stepable    = false;
                if (pos.Save())
                {
                    Game.PrintMessage("Tree add: " + pos.ToString());
                }
            }
        }
Esempio n. 2
0
        //int segmentSize = 1;
        //int direction = -1;
        //int currentRadius = 0;
        //int x = World.Player.X;
        //int y = World.Player.Y;


        //List<UOPositionBase> trees = new List<UOPositionBase>();

        //while (currentRadius < radius)
        //{
        //  x = x + segmentSize * direction;

        //  UO.WaitTargetTile(x, y, z, Graphic.Invariant);
        //  //x y 1

        //  y = y + segmentSize * direction;

        //  //x y 2

        //  direction = direction * -1;
        //  segmentSize++;
        //  currentRadius = segmentSize / 2;


        //}



        //---------------------------------------------------------------------------------------------

        public void RemoveTree()
        {
            StaticTarget tree = UIManager.Target();

            UO.Print(tree.Graphic);

            if (tree.Graphic != 0)
            {
                UOPosition pos = new UOPosition(tree.X, tree.Y, (ushort)tree.Z);
                if (pos.LoadByPosition())
                {
                    if (pos.Remove())
                    {
                        UO.Print("Strom odebran");
                    }
                    else
                    {
                        UO.Print("Strom se nepodarilo odebrat");
                    }
                }
                else
                {
                    UO.Print("Strom neni v DB");
                }
            }
        }
Esempio n. 3
0
        public static void StayAndFight(int distance, int hpMin, bool boost, bool reversePath, string path, string summonName, int summonCount)
        {
            ManualLastTarget.SwitchShowStatusBar();
            int initGold = World.Player.Gold;
            int initFD   = World.Player.Backpack.AllItems.FindType(0x103D, 0x0B52).Amount;
            //Serial: 0x4023CD57  Name: "Fairy Dust"  Position: 136.144.0  Flags: 0x0020  Color: 0x0B52  Graphic: 0x103D  Amount: 4  Layer: None  Container: 0x4019287E

            PlayerClass pclass = Game.CurrentGame.CurrentPlayer.PlayerClass;

            UOPosition zero = new UOPosition(World.Player.X, World.Player.Y, (ushort)World.Player.Z);

            CalebConfig.AutoHeal = true;
            World.Player.ChangeWarmode(WarmodeChange.War);
            Game.Wait();

            short         maxHitsBase   = World.Player.MaxHits;
            DateTime?     lastBoostTime = null;
            List <Serial> deny          = new List <Serial>();
            UOCharacter   current       = null;
            Robot         r             = new Robot();
            Robot         r2            = new Robot();
            Robot         r3            = new Robot();
            Loot          l             = new Loot();
            DateTime      startTime     = DateTime.Now;

            Hashtable htKilled = new Hashtable();

            int walkCounter = 0;

            GotoEventHandler beforeMoveHandler = (sender, e) =>
            {
                ushort x = e.Destination.X.GetValueOrDefault();
                ushort y = e.Destination.Y.GetValueOrDefault();
                walkCounter++;

                if (Game.CurrentGame.Mobs.Count > 0 && (walkCounter % 15) == 0)
                {
                    new Thread(new ThreadStart(MobMaster.Current.MobCome)).Start();
                }

                foreach (UOItem item in World.Ground)
                {
                    if (item.Graphic == 0x0DDA && item.X == x && item.Y == y)
                    {
                        e.IvalidDestination = true;
                    }
                }
            };

            GotoEventHandler beforeMoveHandler2 = (sender, e) =>
            {
                walkCounter++;
                if (current != null && e.Tries > 5)
                {
                    List <UOCharacter> chars = new List <UOCharacter>();
                    chars.AddRange(World.Characters.Where(ch => (ch.Notoriety == Notoriety.Enemy || ch.Notoriety == Notoriety.Murderer) && ch.Distance <= distance && !deny.Contains(ch.Serial) && !Characters.IsSummon(ch) && ch.Serial != World.Player.Serial).OrderBy(ch => ch.Distance).ThenBy(ch => ch.MaxHits).ToArray());


                    if (Game.CurrentGame.Mobs.Count > 0 && (walkCounter % 15) == 0)
                    {
                        new Thread(new ThreadStart(MobMaster.Current.MobCome)).Start();
                    }

                    foreach (UOCharacter ch in chars)
                    {
                        if (ch.Distance < current.Distance)
                        {
                            e.Abort = true;
                            break;
                        }
                    }
                }
            };

            GotoEventHandler beforeMoveHandler3 = (sender, e) =>
            {
                walkCounter++;
                List <UOCharacter> chars = new List <UOCharacter>();
                chars.AddRange(World.Characters.Where(ch => (ch.Notoriety == Notoriety.Enemy || ch.Notoriety == Notoriety.Murderer) && ch.Distance <= distance && !deny.Contains(ch.Serial) && !Characters.IsSummon(ch) && ch.Serial != World.Player.Serial).OrderBy(ch => ch.Distance).ThenBy(ch => ch.MaxHits).ToArray());

                if (Game.CurrentGame.Mobs.Count > 0 && (walkCounter % 15) == 0)
                {
                    new Thread(new ThreadStart(MobMaster.Current.MobCome)).Start();
                }


                foreach (UOCharacter ch in chars)
                {
                    if (current == null || ch.Distance < current.Distance)
                    {
                        e.Abort = true;
                        break;
                    }
                }
            };

            List <IUOPosition> posPath = new List <IUOPosition>();

            posPath.Add(new UOPositionBase(World.Player.X, World.Player.Y, (ushort)World.Player.Z));

            if (!String.IsNullOrEmpty(path))
            {
                posPath.AddRange(UOPositionBase.ParseList(path));
            }

            r2.BeforeMove += beforeMoveHandler;
            r2.BeforeMove += beforeMoveHandler2;
            r.BeforeMove  += beforeMoveHandler;

            r3.BeforeMove += beforeMoveHandler;
            r3.BeforeMove += beforeMoveHandler3;

            int pathIndex = 0;

            Poisoning p = new Poisoning();

            while (!UO.Dead)
            {
                if (boost)
                {
                    if (lastBoostTime == null || (DateTime.Now - lastBoostTime).Value.TotalMilliseconds > 180000)
                    {
                        Game.RunScript(8000);
                        lastBoostTime = DateTime.Now;
                        Game.PrintMessage("Try booost...");
                        UO.Cast(StandardSpell.ReactiveArmor, Aliases.Self);
                        Game.Wait(2500);
                        Game.RunScript(4000);
                        UO.Cast(StandardSpell.Strength, Aliases.Self);
                        Game.Wait(3500);
                        Game.RunScript(4000);
                        UO.Cast(StandardSpell.Protection, Aliases.Self);
                        Game.Wait(3500);
                    }
                }

                List <UOCharacter> chars = new List <UOCharacter>();
                chars.AddRange(World.Characters.Where(ch => (ch.Notoriety == Notoriety.Enemy || ch.Notoriety == Notoriety.Murderer) && ch.Distance <= distance && !Characters.IsSummon(ch) && ch.Serial != World.Player.Serial).OrderBy(ch => ch.Distance).ThenBy(ch => ch.MaxHits).ToArray());

                foreach (UOCharacter ch in chars)
                {
                    bool isVladimirSkorp = ch.Model == 0x0030 && ch.Color == 0x0B78;

                    if (deny.Contains(ch.Serial) && ch.Distance > 2)
                    {
                        continue;
                    }

                    ch.RequestStatus(500);
                    ch.Click();
                    Game.Wait();

                    if (World.Player.Hits <= hpMin)
                    {
                        while (World.Player.Hits < hpMin)
                        {
                            Game.Wait(500);
                        }
                    }

                    ch.Print(Game.Val_GreenBlue, "[killing...]");

                    current = ch;

                    if (!String.IsNullOrEmpty(summonName) && World.Player.Layers[Layer.Hat].Graphic == 0x1451 && Game.CurrentGame.Mobs.Count < summonCount && World.Player.Mana > 20)
                    {
                        Magery.ExecCastSummonCreature(summonName, "Self");
                        Game.Wait(4000);
                        MobMaster.Current.MobStop();
                    }

                    for (int i = 0; i < Game.CurrentGame.Mobs.Count; i++)
                    {
                        MobMaster.Current.MobKill();
                        Game.Wait(250);
                    }

                    if (ch.Exist && ch.Hits > 0 && ch.Distance < 50 && r2.GoTo(ch.X, ch.Y, 1, 25))
                    {
                        UOItem trainKit = World.Player.Backpack.AllItems.FindType(Poisoning.TrainKit.Graphic, Poisoning.TrainKit.Color);

                        if (trainKit.Exist)
                        {
                            p.TrainPoisEngage();
                        }



                        while (ch.Exist && ch.Hits > 0)
                        {
                            if (!Game.CurrentGame.WorldSave())
                            {
                                //Serial: 0x401E33B3  Position: 0.0.0  Flags: 0x0000  Color: 0x0000  Graphic: 0x1451  Amount: 0  Layer: Hat Container: 0x0037EAF7

                                if (!String.IsNullOrEmpty(summonName) && World.Player.Layers[Layer.Hat].Graphic == 0x1451 && Game.CurrentGame.Mobs.Count < summonCount && World.Player.Mana > 20)
                                {
                                    Magery.ExecCastSummonCreature(summonName, "Self");
                                    Game.Wait(4000);
                                    MobMaster.Current.MobStop();
                                }



                                if (ch.Exist && ch.Hits > 0 && ch.Distance > 1 && ch.Distance < 30)
                                {
                                    Game.PrintMessage("HUNT... " + new UOPositionBase(ch.X, ch.Y, 0));
                                    Game.RunScript(500);
                                    Game.Wait(500);
                                    UO.Attack(ch.Serial);



                                    if (!r.GoTo(ch.X, ch.Y, 1, 5))
                                    {
                                        break;
                                    }
                                }

                                htKilled[ch.Serial] = ch;

                                UO.Attack(ch.Serial);
                                Game.RunScript(1500);
                                Game.Wait(1000);


                                for (int i = 0; i < Game.CurrentGame.Mobs.Count; i++)
                                {
                                    MobMaster.Current.MobKill();
                                    Game.Wait(250);
                                }

                                if (World.Player.Hits <= hpMin)
                                {
                                    while (World.Player.Hits < hpMin)
                                    {
                                        if (pclass == PlayerClass.Vampire)
                                        {
                                            if (Game.CurrentGame.CanDrink)
                                            {
                                                Alchemy.ExecDrinkPotion("Blood");
                                                Game.Wait(500);
                                            }

                                            if (World.Player.Hits < 45)
                                            {
                                                Vampire.SnezBandu();
                                                Game.Wait(500);
                                            }
                                        }
                                        else
                                        {
                                            if (Game.CurrentGame.CanDrink && Potion.Heal.ContainsTopKad(World.Player.Backpack))
                                            {
                                                Alchemy.ExecDrinkPotion("Heal");
                                                Game.Wait(150);
                                            }
                                        }

                                        if (World.Player.Hits < hpMin)
                                        {
                                            Game.RunScript(5);
                                            //  Game.CurrentGame.SwitchWarRunOff();

                                            Game.Wait(2500);
                                        }


                                        if (Game.CurrentGame.Mobs.Count > 0)
                                        {
                                            if (!ch.Exist)
                                            {
                                                MobMaster.Current.MobStop();
                                                Game.Wait(150);
                                            }
                                            else
                                            {
                                                MobMaster.Current.MobKill();
                                                Game.Wait(150);
                                            }
                                        }
                                    }
                                }

                                if (ch.Exist && ch.Hits > 0 && ch.Distance > 1 && ch.Distance < 30)
                                {
                                    Game.PrintMessage("HUNT... " + new UOPositionBase(ch.X, ch.Y, 0));

                                    if (!r.GoTo(ch.X, ch.Y, 1, 5))
                                    {
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                Game.Wait(2500);
                            }
                        }

                        if (!ch.Exist)
                        {
                            if (isVladimirSkorp && World.Player.Backpack.Items.FindType(0x227B, 0x0697).Exist)
                            {
                                Game.UseTypeCust(0x227B, 0x0697, "nearestcorpse", "[Target]", "[Ladislav]");
                            }

                            if (Game.CurrentGame.Mobs.Count > 0)
                            {
                                MobMaster.Current.MobCome();
                            }

                            Game.PrintMessage("KILLED...");
                            Game.Wait(1500);
                            current = null;
                            break;
                        }
                    }
                    else
                    {
                        Game.PrintMessage("Deny ADD " + ch.Name);
                        deny.Add(ch.Serial);
                        break;
                    }
                }

                l.LootGround(Loot.LootType.QuickCut);

                if (chars.Count == 0 || chars.Count - deny.Count <= 0)
                {
                    pathIndex++;
                    if (pathIndex > posPath.Count - 1)
                    {
                        if (reversePath)
                        {
                            posPath.Reverse();
                        }
                        pathIndex = 0;
                    }

                    Game.PrintMessage("Goto Next " + posPath[pathIndex]);
                    deny.Clear();
                    Game.Wait(500);

                    if (!r3.GoTo(posPath[pathIndex], 0, 500))
                    {
                        Game.PrintMessage("Cant go to NEXT " + posPath[pathIndex]);
                        continue;
                    }
                    else
                    {
                        Game.PrintMessage(posPath[pathIndex].ToString() + " - Com:" + posPath[pathIndex].CommandName);


                        if (!String.IsNullOrEmpty(posPath[pathIndex].CommandName))
                        {
                            if (posPath[pathIndex].CommandName.ToLower() == "opendoor")
                            {
                                ItemHelper.OpenDoorAll();
                                Game.Wait();
                            }
                        }

                        //,exec stayandfight 5 110 false true "5125.1152|5122.1163|5124.1178|5124.1185|5124.1185.0.OpenDoor|5124.1187.0.OpenDoor|5125.1188|5125.1198|5125.1209|5137.1208|5143.1207|5156.1208|5167.1209|5181.1209|5182.1212|5188.1211|5188.1201|5188.1193|5180.1193"

                        Game.PrintMessage(String.Format("Zabito {0} za {1:N0} min. Gold: {2}, FD: {3}", htKilled.Values.Count, (DateTime.Now - startTime).TotalMinutes, World.Player.Gold - initGold, World.Player.Backpack.AllItems.FindType(0x103D, 0x0B52).Amount - initFD));
                    }
                }
            }
        }