示例#1
0
 void WaypointReached(uint32 uiPointId)
 {
     switch (uiPointId)
     {
         case 0:
             JustStartedEscort();
             for (std::list<Creature*>::iterator itr = m_lResearchersList.begin(); itr != m_lResearchersList.end(); ++itr)
             {
                 (*itr)->SetUnitMovementFlags(MOVEFLAG_WALK_MODE);
             }
             if (Player* player = GetPlayerForEscort())
                 DoScriptText(SAY_LE_KEEP_SAFE, me, player);
             break;
         case 1:
             DoScriptText(SAY_LE_NORTH, me);
             break;
         case 10:
             DoScriptText(SAY_LE_ARRIVE, me);
             break;
         case 12:
             DoScriptText(SAY_LE_BURIED, me);
             SetEscortPaused(true);
             break;
         case 13:
             SetRun();
             for (std::list<Creature*>::iterator itr = m_lResearchersList.begin(); itr != m_lResearchersList.end(); ++itr)
             {
                 (*itr)->SetUnitMovementFlags(MOVEFLAG_NONE);
             }
             break;
     }
 }
示例#2
0
//TODO: get rid of this many variables passed in function.
void npc_escortAI::Start(bool bIsActiveAttacker, bool bRun, uint64 uiPlayerGUID, const Quest* pQuest, bool bInstantRespawn, bool bCanLoopPath)
{
    if (m_creature->getVictim())
    {
        error_log("SD2: EscortAI attempt to Start while in combat.");
        return;
    }

    if (HasEscortState(STATE_ESCORT_ESCORTING))
    {
        error_log("SD2: EscortAI attempt to Start while already escorting.");
        return;
    }

    if (!WaypointList.empty())
        WaypointList.clear();

    FillPointMovementListForCreature();

    if (WaypointList.empty())
    {
        error_db_log("SD2: EscortAI Start with 0 waypoints (possible missing entry in script_waypoint).");
        return;
    }

    //set variables
    m_bIsActiveAttacker = bIsActiveAttacker;
    m_bIsRunning = bRun;

    m_uiPlayerGUID = uiPlayerGUID;
    m_pQuestForEscort = pQuest;

    m_bCanInstantRespawn = bInstantRespawn;
    m_bCanReturnToStart = bCanLoopPath;

    if (m_bCanReturnToStart && m_bCanInstantRespawn)
        debug_log("SD2: EscortAI is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn.");

    if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
    {
        m_creature->GetMotionMaster()->MovementExpired();
        m_creature->GetMotionMaster()->MoveIdle();
        debug_log("SD2: EscortAI start with WAYPOINT_MOTION_TYPE, changed to MoveIdle.");
    }

    //disable npcflags
    m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);

    debug_log("SD2: EscortAI started with %u waypoints. ActiveAttacker = %d, Run = %d, PlayerGUID = %u", WaypointList.size(), m_bIsActiveAttacker, m_bIsRunning, m_uiPlayerGUID);

    CurrentWP = WaypointList.begin();

    //Set initial speed
    if (m_bIsRunning)
        m_creature->RemoveSplineFlag(SPLINEFLAG_WALKMODE);

    AddEscortState(STATE_ESCORT_ESCORTING);

    JustStartedEscort();
}
示例#3
0
// TODO: get rid of this many variables passed in function.
void npc_escortAI::Start(bool bRun, const Player* pPlayer, const Quest* pQuest, bool bInstantRespawn, bool bCanLoopPath)
{
    if (m_creature->getVictim())
    {
        script_error_log("EscortAI attempt to Start while in combat.");
        return;
    }

    if (HasEscortState(STATE_ESCORT_ESCORTING))
    {
        script_error_log("EscortAI attempt to Start while already escorting.");
        return;
    }

    if (!WaypointList.empty())
        WaypointList.clear();

    FillPointMovementListForCreature();

    if (WaypointList.empty())
    {
        error_db_log("SD2: EscortAI Start with 0 waypoints (possible missing entry in script_waypoint).");
        return;
    }

    // set variables
    m_bIsRunning = bRun;

    m_playerGuid = pPlayer ? pPlayer->GetObjectGuid() : ObjectGuid();
    m_pQuestForEscort = pQuest;

    m_bCanInstantRespawn = bInstantRespawn;
    m_bCanReturnToStart = bCanLoopPath;

    if (m_bCanReturnToStart && m_bCanInstantRespawn)
        debug_log("SD2: EscortAI is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn.");

    if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
    {
        m_creature->GetMotionMaster()->MovementExpired();
        m_creature->GetMotionMaster()->MoveIdle();
        debug_log("SD2: EscortAI start with WAYPOINT_MOTION_TYPE, changed to MoveIdle.");
    }

    // disable npcflags
    m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);

    debug_log("SD2: EscortAI started with " SIZEFMTD " waypoints. Run = %d, PlayerGuid = %s", WaypointList.size(), m_bIsRunning, m_playerGuid.GetString().c_str());

    CurrentWP = WaypointList.begin();

    // Set initial speed
    m_creature->SetWalk(!m_bIsRunning);

    AddEscortState(STATE_ESCORT_ESCORTING);

    JustStartedEscort();
}
示例#4
0
// TODO: get rid of this many variables passed in function.
void npc_escortAI::Start(bool bRun, const Player* pPlayer, const Quest* pQuest, bool bInstantRespawn, bool bCanLoopPath)
{
    if (m_creature->getVictim())
    {
        script_error_log("EscortAI attempt to Start while in combat.");
        return;
    }

    if (HasEscortState(STATE_ESCORT_ESCORTING))
    {
        script_error_log("EscortAI attempt to Start while already escorting.");
        return;
    }

    if (!pSystemMgr.GetPathInfo(m_creature->GetEntry(), 1))
    {
        script_error_log("EscortAI attempt to start escorting for %s, but has no waypoints loaded", m_creature->GetGuidStr().c_str());
        return;
    }

    // set variables
    m_bIsRunning = bRun;

    m_playerGuid = pPlayer ? pPlayer->GetObjectGuid() : ObjectGuid();
    m_pQuestForEscort = pQuest;

    m_bCanInstantRespawn = bInstantRespawn;
    m_bCanReturnToStart = bCanLoopPath;

    if (m_bCanReturnToStart && m_bCanInstantRespawn)
        debug_log("SD2: EscortAI is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn.");

    // disable npcflags
    m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);

    AddEscortState(STATE_ESCORT_ESCORTING);

    // Set initial speed
    m_creature->SetWalk(!m_bIsRunning);

    m_creature->StopMoving();

    // Start moving along the path with 2500ms delay
    m_creature->GetMotionMaster()->Clear(false, true);
    m_creature->GetMotionMaster()->MoveWaypoint(1, 3, 2500);

    JustStartedEscort();
}