Esempio n. 1
0
        public static bool hasValidTarget(Bot owner)
        {
            if (!owner.CurrentTarget.HasValue) return false;
            else if (!owner.CurrentTarget.Value.Exists() || owner.CurrentTarget.Value.id_acd.ToString("X") == "FFFFFFFF")
            {
                if (owner.isAttacking)
                {
                    Log.write("target dead");
                }

                owner.CurrentTarget = null;
                return false;
            }
            else
            {
                if (owner.CurrentTarget.Value.distanceFromMe >= 50 || Math.Abs(owner.CurrentTarget.Value.Pos1.z - Data.GetCurrentPos().z) > 5)
                {
                    Log.write("LOST TARGET");
                    owner.CurrentTarget = null;
                    return false;
                }
            }

            return true;
        }
Esempio n. 2
0
        public Sequence this[Bot owner]
        {
            get
            {
                var seq = new Sequence(
                    
                    //first we must have a valid target
                    new Decorator(ret => Helpers.hasValidTarget(owner), new TreeSharp.Action(ret => RunStatus.Success)),

                    //if we are already busy, don't continue.
                    new Decorator(ret => !Helpers.isInAction(owner), new TreeSharp.Action(ret => RunStatus.Success)),

                    //send the attack action.
                    new TreeSharp.Action(ret =>
                    {
                        owner.Attack(owner.CurrentTarget.Value);
                    }),

                    //wait for the action to complete (or we time out).
                    new Wait(1, ret => Helpers.isInAction(owner) , new TreeSharp.Action(ret => RunStatus.Success))
            );

            return seq;

            }
        
        }            
Esempio n. 3
0
        static void Main(string[] args)
        {
            if (!Log.init())
            {   //Abort..
                Console.WriteLine("Logger initialization failed, exiting..");
                Thread.Sleep(10000);
                return;
            }

            DdMonitor.bNoSync        = false;
            DdMonitor.bEnabled       = false;
            DdMonitor.DefaultTimeout = -1;

            //Register our catch-all exception handler
            Thread.GetDomain().UnhandledException += onException;

            //Create a logging client for the main loader thread
            LogClient handlerLogger = Log.createClient("LoaderHandler");

            Log.assume(handlerLogger);

            //Is Diablo 3 available?
            IntPtr pHandle = PT.GetProcessHandle(exeName);

            if (pHandle == IntPtr.Zero)
            {
                Log.write("Failed to find game process, Is Diablo 3 running?");
                Thread.Sleep(8000);
                return;
            }

            Globals.mem.Attach();


            //Initilize the bot!
            Game.Bot bot = new Game.Bot();
            if (!bot.init())
            {
                Log.write("Failed to initialize D3BLoader, exiting...");
                Thread.Sleep(8000);
                return;
            }

            //Begin!
            bot.begin();

            Log.write("D3BLoader running...");

            while (true)
            {
                Console.Read();
            }
        }
Esempio n. 4
0
        public static bool isInAction(Bot owner)
        {
            if (!owner.isMoving && !hasValidTarget(owner))
            {
                owner.isAttacking = false;
                return false;
            }

            if (owner.isMoving)
            {
                Vec3 pos = Data.GetCurrentPos();

            //                 float xd = _vMovingTo.x - pos.x;
            //                 float yd = _vMovingTo.y - pos.y;
            //                 float zd = _vMovingTo.z - pos.z;
            //                 double distance = Math.Sqrt(pos.x * pos.x + pos.y * pos.y + pos.z * pos.z);
            //
            //                 if (distance < 2)
            //                 {
            //                     _bMoving = false;
            //                     return false;
            //                 }

                return true;
            }
            else if (owner.isAttacking)
            {
                if (!Helpers.hasValidTarget(owner))
                {
                    owner.isAttacking = false;
                    return false;
                }

                Vec3 pos = Data.GetCurrentPos();
                double distance = Math.Sqrt(pos.x * pos.x + pos.y * pos.y + pos.z * pos.z);
                if (distance < 2 || Globals.mem.ReadMemoryAsFloat(Offsets.clickToMoveToggle) == 0)
                {
                    owner.isAttacking = false;
                    return false;
                }

                return true;
            }

            return false;
        }
Esempio n. 5
0
        public Sequence this[Bot owner]
        {
            get
            {
                var seq = new Sequence(

                //first we must not already have a target.
                new Decorator(ret => !Helpers.hasValidTarget(owner), new TreeSharp.Action(ret => RunStatus.Success)),

                //go grab a target
                new TreeSharp.Action(ret =>
                {
                    owner.CurrentTarget = Helpers.getNearestEnemy();
                })

            );

            return seq;

            }
        
        }        
Esempio n. 6
0
 ///////////////////////////////////////////////////
 // Member Functions
 ///////////////////////////////////////////////////
 /// <summary>
 /// Performs script initialization
 /// </summary>
 public bool init(IEventObject invoker)
 {
     _bot = invoker as Bot;
     Log.write(TLog.Normal, "SimpleBot by HellSpawn");
     return true;
 }
Esempio n. 7
0
        private string _scriptType; //The type of scripts we're instancing

        #endregion Fields

        #region Constructors

        ///////////////////////////////////////////////////
        // Member Functions
        ///////////////////////////////////////////////////
        /// <summary>
        /// Generic constructor
        /// </summary>
        public ScriptBot(Bot bot, string scriptType)
            : base()
        {
            _scriptType = scriptType;
        }