Exemple #1
0
        public static async Task AttackAcdAsync(ActorCommonData acd)
        {
            var minHitsReached = acd.x188_Hitpoints;
            var dtHitReached   = DateTime.Now;

            DateTime dtTimeout = DateTime.Now;

            while (acd.x188_Hitpoints > 00000.1)
            {
                if (DateTime.Now > dtTimeout.AddSeconds(30) || DateTime.Now > dtHitReached.AddSeconds(5))
                {
                    return;
                }

                var acdVector3 = new SharpDX.Vector3()
                {
                    X = acd.x0D0_WorldPosX, Y = acd.x0D4_WorldPosY, Z = acd.x0D8_WorldPosZ
                };
                await MoveTo.MoveToPosAsync(acdVector3);

                var screenPos = D3ToScreen.FromD3toScreenCoords(acdVector3);

                MouseEvents.LeftClick(screenPos.X, screenPos.Y);
                await Task.Delay(new Random().Next(100, 250));

                if (acd.x188_Hitpoints < minHitsReached)
                {
                    minHitsReached = acd.x188_Hitpoints;
                    dtHitReached   = DateTime.Now;
                }
            }
        }
Exemple #2
0
        public static async Task <bool> MoveToPosAsync(SharpDX.Vector3 vecDest, int NearDistance = 50)
        {
            var localAcd = ActorCommonDataHelper.GetLocalAcd();
            var distance = (Math.Pow(localAcd.x0D0_WorldPosX - vecDest.X, 2) + Math.Pow(localAcd.x0D4_WorldPosY - vecDest.Y, 2));

            var minDistanceReached = distance;
            var dtDistanceReached  = DateTime.Now;

            DateTime dtTimeout = DateTime.Now;

            while (distance > NearDistance)
            {
                if (DateTime.Now > dtTimeout.AddSeconds(30) || DateTime.Now > dtDistanceReached.AddSeconds(10))
                {
                    return(false);
                }

                SharpDX.Vector2 curVector  = new SharpDX.Vector2(localAcd.x0D0_WorldPosX, localAcd.x0D4_WorldPosY);
                SharpDX.Vector2 destVector = new SharpDX.Vector2(vecDest.X, vecDest.Y);

                distance = (Math.Pow(localAcd.x0D0_WorldPosX - vecDest.X, 2) + Math.Pow(localAcd.x0D4_WorldPosY - vecDest.Y, 2));
                var minExtendValue = Math.Min(10f, float.Parse(distance.ToString(), CultureInfo.InvariantCulture.NumberFormat));

                var vecNormalized = curVector.Extend(destVector, minExtendValue).To3D();

                System.Drawing.Point screenPoint = D3ToScreen.FromD3toScreenCoords(vecNormalized);

                MouseEvents.RightClick(screenPoint.X, screenPoint.Y);
                await Task.Delay(new Random().Next(100, 250));

                if (distance < minDistanceReached)
                {
                    minDistanceReached = distance;
                    dtDistanceReached  = DateTime.Now;
                }
            }

            return(true);
        }