Beispiel #1
0
        public void TweakMelee(BoogieBot.Common.Object Monster)
        {
            double Distance    = Monster.GetCoordinates().DistanceTo(BoogieCore.world.getPlayerObject().GetCoordinates());
            double sensitivity = 2.5; // default melee distance is 4.8 - 2.5 = 2.3, no monster will chase us at 2.3
            double min         = 4.5 - sensitivity;

            if (min < 1.0)
            {
                min = 1.0;
            }

            if (Distance > 4.5)
            {
                // Too far
                //Spam("Tweak forwards. "+ Distance + " > " + Context.MeleeDistance);
                mover.Forwards(true);
                Thread.Sleep(100);
                mover.Forwards(false);
            }
            else if (Distance < min)
            {
                // Too close
                //Spam("Tweak backwards. "+ Distance + " < " + min);
                mover.Backwards(true);
                Thread.Sleep(200);
                mover.Backwards(false);
            }
        }
Beispiel #2
0
        public bool checkStuck()
        {
            if (firstStuckCheck)
            {
                oldLocation     = GContext.Main.Me.Location;
                predictedDX     = 0;
                predictedDY     = 0;
                firstStuckCheck = false;
                lastStuckCheck.Reset();
            }
            else
            {
                // update predicted location
                double h;
                double speed;
                h = mover.GetMoveHeading(out speed);

                float dt = (float)-lastStuckCheck.TicksLeft / 1000f;
                float dx = (float)Math.Cos(h) * (float)speed * dt;
                float dy = (float)Math.Sin(h) * (float)speed * dt;
                //PPather.WriteLine("speed: " + speed + " dt: " + dt + " dx: " + dx + " dy : " + dy);
                predictedDX += dx;
                predictedDY += dy;

                lastStuckCheck.Reset();
                if (StuckTimeout.IsReady)
                {
                    // Check stuck
                    GLocation loc    = Me.Location;
                    float     realDX = loc.X - oldLocation.X;
                    float     realDY = loc.Y - oldLocation.Y;
                    //PPather.WriteLine(" dx: " + predictedDX + " dy : " + predictedDY + " Real dx: " + realDX + " dy : " + realDY );

                    float predictDist = (float)Math.Sqrt(predictedDX * predictedDX + predictedDY * predictedDY);
                    float realDist    = (float)Math.Sqrt(realDX * realDX + realDY * realDY);

                    //PPather.WriteLine(" pd " + predictDist + " rd " + realDist);

                    int multiplier = 3;
                    if (GPlayerSelf.Me.IsStealth)
                    {
                        multiplier = 4;
                    }

                    if (predictDist > realDist * multiplier)
                    {
                        // moving a lot slower than predicted
                        // check direction
                        GLocation excpected = new GLocation(loc.X + predictedDX, loc.Y + predictedDY);

                        PPather.WriteLine("I am stuck " + stuckMove);                         //. Jumping to get free");
                        if (stuckMove == 0)
                        {
                            mover.Forwards(false);
                            mover.Forwards(true);
                            mover.StrafeLeft(true);
                            //mover.Jump();
                            //mover.StrafeRight(false);
                        }
                        else if (stuckMove == 1)
                        {
                            mover.Forwards(false);
                            mover.Forwards(true);
                            mover.StrafeLeft(true);
                            //PPather.WriteLine("  strafe left");
                            //mover.Jump();
                            //mover.StrafeLeft(false);
                        }
                        else if (stuckMove == 2)
                        {
                            mover.Forwards(false);
                            mover.Forwards(true);
                            mover.StrafeRight(true);
                            //PPather.WriteLine("  strafe left");
                            //mover.StrafeLeft(true);
                        }
                        else if (stuckMove == 2)
                        {
                            mover.Forwards(false);
                            mover.Forwards(true);
                            mover.StrafeRight(true);
                            //PPather.WriteLine("  strafe left");
                            //mover.StrafeLeft(true);
                        }
                        stuckMove++;
                        if (stuckMove >= abortSensitivity)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        stuckMove = 0;
                    }
                    predictedDX = 0;
                    predictedDY = 0;
                    oldLocation = loc;
                    StuckTimeout.Reset();
                }
            }
            return(false);
        }