示例#1
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));
                    }
                }
            }
        }
示例#2
0
        public static void StartLumber(Serial container, Serial innerContainer, string containerPosition, string ressPosition, string deny, string trees, int maxForesnicSkill, int nastrojLoad, bool enableVisitor, string ESWN)
        {
            Lumberjacking2 lumber = new Lumberjacking2();

            lumber.StartPosition = new UOPositionBase(World.Player.X, World.Player.Y, 0);

            if (!String.IsNullOrEmpty(ESWN))
            {
                string[] esvnSplit = ESWN.Split(new char[] { ',' });

                if (esvnSplit.Length > 0)
                {
                    lumber.MaxE = Int32.Parse(esvnSplit[0]);
                }
                if (esvnSplit.Length > 1)
                {
                    lumber.MaxS = Int32.Parse(esvnSplit[1]);
                }
                if (esvnSplit.Length > 2)
                {
                    lumber.MaxW = Int32.Parse(esvnSplit[2]);
                }
                if (esvnSplit.Length > 3)
                {
                    lumber.MaxN = Int32.Parse(esvnSplit[3]);
                }
            }


            if (String.IsNullOrEmpty(trees))
            {
                int currentX = lumber.StartPosition.X.GetValueOrDefault();
                int currentY = lumber.StartPosition.Y.GetValueOrDefault();
                int minX     = 0;
                int minY     = 0;
                int maxX     = 0;
                int maxY     = 0;

                minX = (currentX - lumber.SearchSuqareSize < 0 ? 0 : currentX - lumber.SearchSuqareSize);
                maxX = (currentX + lumber.SearchSuqareSize > 6000 ? 6000 : currentX + lumber.SearchSuqareSize);
                minY = (currentY - lumber.SearchSuqareSize < 0 ? 0 : currentY - lumber.SearchSuqareSize);
                maxY = (currentY + lumber.SearchSuqareSize > 6000 ? 6000 : currentY + lumber.SearchSuqareSize);

                if (lumber.MaxE > 0)
                {
                    maxX = Math.Min(maxX, lumber.MaxE);
                }
                if (lumber.MaxS > 0)
                {
                    maxY = Math.Min(maxY, lumber.MaxS);
                }
                if (lumber.MaxW > 0)
                {
                    minX = Math.Max(minX, lumber.MaxW);
                }
                if (lumber.MaxN > 0)
                {
                    minY = Math.Max(minY, lumber.MaxN);
                }

                UOPositionCollection allTrees = new UOPositionCollection();
                allTrees.Load(String.Format("IsTree=1 AND X>={0} AND X<={1} AND Y>={2} AND Y<={3}", minX, maxX, minY, maxY));
                allTrees = allTrees.SortByOptimalTrack(new Robot().ActualPosition);

                lumber.Trees.AddRange(allTrees.ToArray());
            }
            else
            {
                lumber.Trees.AddRange(UOPositionBase.ParseList(trees));
            }

            lumber.Container         = container;
            lumber.InnerContainer    = innerContainer;
            lumber.ContainerPosition = UOPositionBase.ParseList(containerPosition);
            lumber.RessPositionPath  = UOPositionBase.ParseList(ressPosition);
            lumber.MaxForensicSkill  = maxForesnicSkill;
            lumber.NastrojLoad       = nastrojLoad;
            lumber.EnableVisitorInfo = enableVisitor;

            foreach (string s in deny.Split(new char[] { ',' }))
            {
                lumber.dennyLogList.Add(s);
            }

            UO.Print(0x0035, "StartLumber s nasledujicimi parametry:");
            UO.Print(0x0035, "Container:" + lumber.Container);
            UO.Print(0x0035, "InnerContainer:" + lumber.InnerContainer);
            UO.Print(0x0035, "ContainerPosition:" + UOPositionBase.ListToString(lumber.ContainerPosition));
            UO.Print(0x0035, "RessPositionPath:" + UOPositionBase.ListToString(lumber.RessPositionPath));
            UO.Print(0x0035, "StartPosition:" + lumber.StartPosition);
            UO.Print(0x0035, "Trees:" + lumber.Trees.Count);
            UO.Print(0x0035, "MaxForensicSkill:" + lumber.MaxForensicSkill);
            UO.Print(0x0035, "KumpLoad:" + lumber.NastrojLoad);
            UO.Print(0x0035, "EnableVisitorInfo:" + lumber.EnableVisitorInfo);
            UO.Print(0x0191, "DenyOres:" + String.Join(",", lumber.dennyLogList.ToArray()));



            lumber.Lumber();
        }