コード例 #1
0
ファイル: DeadState.cs プロジェクト: uvbs/babbot
        protected override void DoExecute(WowPlayer entity)
        {
            if (!entity.IsGhost)
            {
                return;
            }

            CorpseLocation = entity.CorpseLocation;
            //on execute, if the distance to our corpose is more than xx yards, we need to get there
            Output.Instance.Script(string.Format("Distance from corpse: {0}", entity.DistanceFromCorpse()), this);
            if (entity.DistanceFromCorpse() > GlobalBaseBotState.MinDistanceFromCorpse)
            {
                Output.Instance.Script("We're still too far, walking to corpse");
                // so we make a new move to state that will take us to our corpose
                var mtsCorpse = new MoveToState(CorpseLocation, GlobalBaseBotState.MinDistanceFromCorpse);

                //request that we move to this location
                CallChangeStateEvent(entity, mtsCorpse, true, false);

                return;
            }

            //we should now be close to our corpse so rez!
            // TODO: we should check that there's no delay time running before trying this
            Output.Instance.Script("Trying to resurrect", this);
            entity.RetrieveCorpse();

            /// TODO: We should also check the time we spent running around trying to recover our corpse
            /// and if it's over a certain threshold we should run back to the spirit healer and repop there

            // We're done, let's finish & exit
            Finish(entity);
            Exit(entity);
        }
コード例 #2
0
        /// <summary>
        /// We are roaming through the waypoints with nothing else to do
        /// </summary>
        protected override void DoExecute(WowPlayer entity)
        {
            WayPoint wp = null;

            Output.Instance.Script("Checking if we have a last waypoint defined", this);
            if (LastWayPoint != null)
            {
                Output.Instance.Script("We have a last waypoint. Checking if we reached it", this);

                float distanceFromLast = MathFuncs.GetDistance(LastWayPoint.Location, entity.Location, false);
                if (distanceFromLast <= 3.0f)
                {
                    Output.Instance.Script("We reached the last waypoint. Let's get a new one", this);
                    wp = WayPointManager.Instance.GetNextWayPoint(WayPointType.Normal);
                }
                else
                {
                    Output.Instance.Script("We still need to reach the last waypoint. We reuse the last one.", this);
                    wp = LastWayPoint;
                }
            }
            else
            {
                Output.Instance.Script("This is the first waypoint. We try to get a new one.", this);
                wp = WayPointManager.Instance.GetNextWayPoint(WayPointType.Normal);
            }

            // Id we do have a waypoint we actually move
            if (wp != null)
            {
                LastWayPoint = wp;
                Output.Instance.Script(string.Format("Moving to waypoint. Index:{0}", WayPointManager.Instance.CurrentNormalWayPointIndex), this);
                Output.Instance.Script(string.Format("WayPoint: X:{0} Y:{1} Z:{2}", wp.Location.X, wp.Location.Y, wp.Location.Z), this);
                //MoveTo(wp.Location);
                float distance = MathFuncs.GetDistance(wp.Location, entity.Location, false);
                if (distance > 3.0f)
                {
                    var mtsTarget = new MoveToState(wp.Location, 3.0f);

                    //request that we move to this location
                    CallChangeStateEvent(entity, mtsTarget, true, false);

                    return;
                }
            }
            else
            {
                Output.Instance.Script("We are supposed to walk through waypoints but there's no waypoints defined", this);
            }
        }
コード例 #3
0
        protected override void DoExecute(WowPlayer Entity)
        {
            //if we don't have a target then get one
            if (!Entity.HasTarget)
            {
                List <WowObject> d = ProcessManager.ObjectManager.GetAllObjectsAroundLocalPlayer();

                IEnumerable <WowObject> m = from c in d
                                            where c.Type == Descriptor.eObjType.OT_UNIT && ((WowUnit)c).IsLootable
                                            select c;

                //get first unit and select it
                if (m.Count() > 0)
                {
                    Entity.SelectMob((WowUnit)m.First());
                }
            }

            //if distance to target is to far, then use a move to first
            if (Entity.DistanceFromTarget() > 0.5f)
            {
                var mtsTarget = new MoveToState(Entity.CurTarget.Location);

                //request that we move to this location
                CallChangeStateEvent(Entity, mtsTarget, true, false);

                return;
            }

            //interact with it
            Entity.CurTarget.Interact();

            while (Entity.CurTarget.Hp > 0)
            {
                Thread.Sleep(100);
            }
        }
コード例 #4
0
ファイル: PreCombatState.cs プロジェクト: uvbs/babbot
        /// <summary>
        /// This happens when we are being attacked by some mobs or when we
        /// have found something to kill
        /// </summary>
        protected override void DoExecute(WowPlayer entity)
        {
            Output.Instance.Script("OnPreCombat() Begin", this);

            DateTime start = DateTime.Now;

            if (entity.IsBeingAttacked())
            {
                Output.Instance.Script("OnPreCombat() - We are being attacked", this);
                /// We are being attacked by a Mob. That means that we should fight back
                /// by finding the mob first of all
                if (entity.SelectWhoIsAttackingUsWithCTM())
                {
                    /// We found who is attacking us and we fight back (no rebuffing now)
                    /// (If everything is correct at this point the StateManager will take care
                    /// of switching to the OnCombat state)
                    MobToAttack     = entity.CurTarget;
                    AttackTimeStart = DateTime.Now; // Reset the time check for blacklisting mobs
                }
            }
            else
            {
                Output.Instance.Script("OnPreCombat() - We are going to attack someone", this);

                // Check if we already have a valid Unit to attack from a previous state
                if (MobToAttack == null)
                {
                    Output.Instance.Script("Looking for a new enemy to attack", this);
                    // Find a new mob to attack
                    if (entity.EnemyInSight())
                    {
                        Output.Instance.Script("We have something", this);
                        MobToAttack = entity.GetClosestEnemyInSight();
                        if (MobToAttack != null)
                        {
                            Output.Instance.Script(
                                string.Format("The mob we're going to attack is a {0} with GUID {1:X}",
                                              MobToAttack.Name, MobToAttack.Guid), this);
                            AttackTimeStart = DateTime.Now; // Reset the time check for blacklisting mobs
                        }
                        else
                        {
                            Output.Instance.Script("Couldn't find the closest enemy in sight", this);
                        }
                    }
                }

                // Check if this is good
                if (MobToAttack != null)
                {
                    Output.Instance.Script("We have a mob, checking if it's dead", this);
                    if (!MobToAttack.IsDead)
                    {
                        TimeSpan attackTimeDiff = start - AttackTimeStart;
                        if (attackTimeDiff.TotalMilliseconds > 10000)
                        {
                            Output.Instance.Script("We spent more than 10 seconds trying to attack the same mob without reaching it. Moving on and blacklisting it.", this);
                            entity.MobBlackList.Add(MobToAttack);
                            MobToAttack = null;
                            return;
                        }

                        Output.Instance.Script("Checking distance", this);
                        float distance = MathFuncs.GetDistance(MobToAttack.Location, entity.Location, false);
                        if (distance > 10.0f)
                        {
                            Output.Instance.Script("We're too far to CTM it, moving closer first", this);
                            var mtsTarget = new MoveToState(MobToAttack.Location, 3.0f);

                            //request that we move to this location
                            CallChangeStateEvent(entity, mtsTarget, true, false);

                            return;
                        }

                        Output.Instance.Script("Attacking it with CTM", this);
                        TimeSpan timeDiff = start - LastCtmCheck;
                        if (timeDiff.TotalMilliseconds > 2000)
                        {
                            entity.AttackMobWithCTM(MobToAttack);
                            LastCtmCheck = DateTime.Now;
                        }
                    }
                    else
                    {
                        Output.Instance.Script("The mob we were looking for is dead :(", this);
                        MobToAttack = null;
                    }
                }

                /*
                 * if (entity.EnemyInSight())
                 * {
                 *  // Face the closest enemy
                 *  Output.Instance.Script("OnPreCombat() - Facing closest enemy (we should get a target this way)", this);
                 *  //entity.FaceClosestEnemy();
                 *  //entity.AttackClosestEnemyWithCTM();
                 *  // Get the enemy unit and save it
                 *  // Check that it's not dead or anything like that
                 *  // Move to it
                 *
                 *  entity.MoveToClosestEnemy();
                 *
                 *  // Let's check if we actually got it as our target
                 *  if ((entity.HasTarget) && (!entity.IsTargetDead()) && (entity.IsTargetInEnemyList()))
                 *  {
                 *      Output.Instance.Script("OnPreCombat() - Affirmative. We have a target", this);
                 *      /// Ok, we have the target, it's time to start attacking,
                 *      /// but first we rebuff and drink up just in case
                 *  }
                 *  else
                 *  {
                 *      // Let's try moving closer. We should already be facing our wanted target
                 *      // TODO: Change this so that we use clicktomove instead
                 *      entity.MoveForward(1000);
                 *      Output.Instance.Script("OnPreCombat() - Can't target. This should not happen :-P", this);
                 *  }
                 * }
                 * */
            }
        }