コード例 #1
0
ファイル: WizardBotThread.cs プロジェクト: f0ubar/ETDA-master
        public void ThreadLoop()
        {
            int i = 0;

            Targeting.Info TargetInfo = null;
            while (true)
            {
                if (!Paused &&
                    Client != null &&
                    Client.ClientReady &&
                    Client.IsInGame() &&
                    Client.Attributes != null &&
                    Client.ObjectSearcher != null &&
                    Client.MapLoaded)
                {
                    WalkingPath.CheckCurrentPath();
                    #region Auto Pickup
                    if (AutoPickUp)
                    {
                        MapObject pickupItem =
                            Target.FloorObjects.Where(o =>
                                                      o != null &&
                                                      !o.PickedUp &&
                                                      Client.Attributes.ServerPosition.DistanceFrom(o.ServerPosition) > 0 &&
                                                      (WalkingPath.CurrentPath == null || WalkingPath.CurrentPathLocation == null || WalkingPath.CurrentPathLocation.FirstNodeBackwardsWhere(node => node.Position.DistanceFrom(o.ServerPosition) == 0) == null) &&
                                                      Position.WithinSquare(o.ServerPosition, 2)).FirstOrDefault();
                        if (pickupItem != null)
                        {
                            pickupItem.PickedUp = true;
                            Console.WriteLine($"Picking up {pickupItem.ServerPosition}");
                            GameActions.Pickup(Client, pickupItem.ServerPosition);
                            continue;
                        }
                    }
                    #endregion
                    #region Targeting
                    if (Target.CheckTarget())
                    {
                        if (TargetInfo == null || TargetInfo.BadTargetInfo)
                        {
                            TargetInfo = Target.CurrentTargetInfo;
                        }
                        TargetInfo.CheckPathToTarget();
                        if (!TargetInfo.BadTargetInfo)
                        {
                            string[] spells = new string[]
                            {
                                //"beag srad",
                                "beag sal",
                                //"beag athar"
                            };
                            string spell = spells[i = (++i % spells.Length)];
                            Console.WriteLine($"Casting on sprite {TargetInfo.Value.Sprite}");
                            Client.Utilities.CastSpell(spells[i], TargetInfo.Value);
                            //    System.Threading.Thread.Sleep(100);
                        }
                    }
                    #endregion
                    #region Auto Walk
                    else if (WalkingPath.CurrentPath != null && HPPercent > 50 && MPPercent > 50)
                    {
                        Direction    pathDirection = WalkingPath.CurrentPathLocation.Direction;
                        SonarV2.Node nextNode      = WalkingPath.CurrentPathLocation.NextNode;
                        bool         Walkable      = !Client.FieldMap.IsWall(nextNode.Position.X, nextNode.Position.Y);
                        if (!Walkable)
                        {
                            WalkingPath.CurrentPath = WalkingPath.CurrentPathLocation = null;
                            continue;
                        }
                        if (pathDirection == Direction.None || nextNode.Attempts > 4)
                        {
                            WalkingPath.CurrentPath = WalkingPath.CurrentPathLocation = null;
                            continue;
                        }
                        nextNode.Attempts++;
                        GameActions.Walk(Client, pathDirection);
                        System.Threading.Thread.Sleep(375);
                    }
                    #endregion
                }
                System.Threading.Thread.Sleep(100);
            }
        }