예제 #1
0
        public void ResumePath()
        {
            GetScript().ProcessEventsFor(SmartEvents.WaypointResumed, null, mCurrentWPID, GetScript().GetPathId());
            RemoveEscortState(SmartEscortState.Paused);
            mForcedPaused = false;
            mWPReached    = false;
            mWPPauseTimer = 0;
            SetRun(mRun);

            WaypointMovementGenerator move = (WaypointMovementGenerator)me.GetMotionMaster().top();

            if (move != null)
            {
                move.GetTrackerTimer().Reset(1);
            }
        }
예제 #2
0
        public void SetEscortPaused(bool on)
        {
            if (!HasEscortState(eEscortState.Escorting))
            {
                return;
            }

            if (on)
            {
                AddEscortState(eEscortState.Paused);
                me.StopMoving();
            }
            else
            {
                RemoveEscortState(eEscortState.Paused);
                WaypointMovementGenerator move = (WaypointMovementGenerator)me.GetMotionMaster().top();
                if (move != null)
                {
                    move.GetTrackerTimer().Reset(1);
                }
            }
        }
예제 #3
0
        public override void MovementInform(MovementGeneratorType moveType, uint pointId)
        {
            // no action allowed if there is no escort
            if (!HasEscortState(eEscortState.Escorting))
            {
                return;
            }

            if (moveType == MovementGeneratorType.Point)
            {
                if (m_uiWPWaitTimer == 0)
                {
                    m_uiWPWaitTimer = 1;
                }

                //Combat start position reached, continue waypoint movement
                if (pointId == EscortPointIds.LastPoint)
                {
                    Log.outDebug(LogFilter.Scripts, "EscortAI has returned to original position before combat");

                    me.SetWalk(!m_bIsRunning);
                    RemoveEscortState(eEscortState.Returning);
                }
                else if (pointId == EscortPointIds.Home)
                {
                    Log.outDebug(LogFilter.Scripts, "EscortAI has returned to original home location and will continue from beginning of waypoint list.");

                    m_bStarted = false;
                }
            }
            else if (moveType == MovementGeneratorType.Waypoint)
            {
                //Call WP function
                WaypointReached(pointId);

                //End of the line
                if (LastWP != 0 && LastWP == pointId)
                {
                    LastWP = 0;

                    m_bStarted = false;
                    m_bEnded   = true;

                    m_uiWPWaitTimer = 50;

                    return;
                }

                Log.outDebug(LogFilter.Scripts, $"EscortAI Waypoint {pointId} reached");

                WaypointMovementGenerator move = (WaypointMovementGenerator)me.GetMotionMaster().top();
                if (move != null)
                {
                    m_uiWPWaitTimer = (uint)move.GetTrackerTimer().GetExpiry();
                }

                //Call WP start function
                if (m_uiWPWaitTimer == 0 && !HasEscortState(eEscortState.Paused) && move != null)
                {
                    WaypointStart(move.GetCurrentNode());
                }

                if (m_bIsRunning)
                {
                    me.SetWalk(false);
                }
                else
                {
                    me.SetWalk(true);
                }
            }
        }
예제 #4
0
        public override void UpdateAI(uint diff)
        {
            if (HasEscortState(eEscortState.Escorting) && !me.GetVictim() && m_uiWPWaitTimer != 0 && !HasEscortState(eEscortState.Returning))
            {
                if (m_uiWPWaitTimer <= diff)
                {
                    if (!HasEscortState(eEscortState.Paused))
                    {
                        m_uiWPWaitTimer = 0;

                        if (m_bEnded)
                        {
                            me.StopMoving();
                            me.GetMotionMaster().Clear(false);
                            me.GetMotionMaster().MoveIdle();

                            m_bEnded = false;

                            if (DespawnAtEnd)
                            {
                                Log.outDebug(LogFilter.Scripts, "EscortAI reached end of waypoints");

                                if (m_bCanReturnToStart)
                                {
                                    float fRetX, fRetY, fRetZ;
                                    me.GetRespawnPosition(out fRetX, out fRetY, out fRetZ);

                                    me.GetMotionMaster().MovePoint(EscortPointIds.Home, fRetX, fRetY, fRetZ);

                                    Log.outDebug(LogFilter.Scripts, $"EscortAI are returning home to spawn location: {EscortPointIds.Home}, {fRetX}, {fRetY}, {fRetZ}");
                                }
                                else if (m_bCanInstantRespawn)
                                {
                                    me.setDeathState(DeathState.JustDied);
                                    me.Respawn();
                                }
                                else
                                {
                                    me.DespawnOrUnsummon();
                                }
                            }
                            else
                            {
                                Log.outDebug(LogFilter.Scripts, "EscortAI reached end of waypoints with Despawn off");
                            }

                            RemoveEscortState(eEscortState.Escorting);
                            return;
                        }

                        if (!m_bStarted)
                        {
                            m_bStarted = true;
                            me.GetMotionMaster().MovePath(_path, false);
                        }
                        else
                        {
                            WaypointMovementGenerator move = (WaypointMovementGenerator)me.GetMotionMaster().top();
                            if (move != null)
                            {
                                WaypointStart(move.GetCurrentNode());
                            }
                        }
                    }
                }
                else
                {
                    m_uiWPWaitTimer -= diff;
                }
            }

            //Check if player or any member of his group is within range
            if (HasEscortState(eEscortState.Escorting) && !m_uiPlayerGUID.IsEmpty() && !me.GetVictim() && !HasEscortState(eEscortState.Returning))
            {
                m_uiPlayerCheckTimer += diff;
                if (m_uiPlayerCheckTimer > 1000)
                {
                    if (DespawnAtFar && !IsPlayerOrGroupInRange())
                    {
                        if (m_bCanInstantRespawn)
                        {
                            me.setDeathState(DeathState.JustDied);
                            me.Respawn();
                        }
                        else
                        {
                            me.DespawnOrUnsummon();
                        }

                        return;
                    }

                    m_uiPlayerCheckTimer = 0;
                }
            }

            UpdateEscortAI(diff);
        }