示例#1
0
void Transporter::Update()
{
    if (m_WayPoints.size() <= 1)
        return;

    m_timer = Util::getMSTime() % m_period;

    while (((m_timer - mCurrentWaypoint->first) % m_pathTime) > ((mNextWaypoint->first - mCurrentWaypoint->first) % m_pathTime))
    {
        GetNextWaypoint();

        // first check help in case client-server transport coordinates de-synchronization
        if (mCurrentWaypoint->second.mapid != GetMapId() || mCurrentWaypoint->second.teleport)
        {
            TeleportTransport(mCurrentWaypoint->second.mapid, GetMapId(), mCurrentWaypoint->second.x, mCurrentWaypoint->second.y, mCurrentWaypoint->second.z);
            break;
        }
        else
        {
            SetPosition(mCurrentWaypoint->second.x, mCurrentWaypoint->second.y, mCurrentWaypoint->second.z, std::atan2(mNextWaypoint->second.x, mNextWaypoint->second.y) + float(M_PI), false);
            UpdatePlayerPositions(mCurrentWaypoint->second.x, mCurrentWaypoint->second.y, mCurrentWaypoint->second.z, std::atan2(mNextWaypoint->second.x, mNextWaypoint->second.y) + float(M_PI));
            // After a few tests (Durotar<->Northrend we need this, otherwise npc disappear on entering new map/zone/area DankoDJ
            // Update Creature Position with Movement Info from Gameobject too prevent coord changes from Transporter Waypoint and Gameobject Position Aaron02
#if VERSION_STRING != Cata
            UpdateNPCPositions(obj_movement_info.transport_data.relativePosition.x, obj_movement_info.transport_data.relativePosition.y, obj_movement_info.transport_data.relativePosition.z, std::atan2(obj_movement_info.transport_data.relativePosition.x, obj_movement_info.transport_data.relativePosition.y) + float(M_PI));
#else
            UpdateNPCPositions(obj_movement_info.getTransportPosition()->x, obj_movement_info.getTransportPosition()->y, obj_movement_info.getTransportPosition()->z, std::atan2(obj_movement_info.getTransportPosition()->x, obj_movement_info.getTransportPosition()->y) + float(M_PI));
#endif
        }
        if (mCurrentWaypoint->second.delayed)
        {
            switch (GetGameObjectProperties()->display_id)
            {
            case 3015:
            case 7087:
            {
                PlaySoundToSet(5154);        // ShipDocked LightHouseFogHorn.wav
            }
            break;
            case 3031:
            {
                PlaySoundToSet(11804);        // ZeppelinDocked    ZeppelinHorn.wav
            }
            break;
            default:
            {
                PlaySoundToSet(5495);        // BoatDockingWarning    BoatDockedWarning.wav
            }
            break;
            }
            TransportGossip(GetGameObjectProperties()->display_id);
        }
    }
}
void Transporter::UpdatePosition()
{
    if (m_WayPoints.size() <= 1)
        return;

    m_timer = getMSTime() % m_period;

    while (((m_timer - mCurrentWaypoint->first) % m_pathTime) >= ((mNextWaypoint->first - mCurrentWaypoint->first) % m_pathTime))
    {
        /*printf("%s from %u %f %f %f to %u %f %f %f\n", this->GetInfo()->Name,
            mCurrentWaypoint->second.mapid, mCurrentWaypoint->second.x,mCurrentWaypoint->second.y,mCurrentWaypoint->second.z,
            mNextWaypoint->second.mapid, mNextWaypoint->second.x,mNextWaypoint->second.y,mNextWaypoint->second.z);*/

        mCurrentWaypoint = mNextWaypoint;
        mNextWaypoint = GetNextWaypoint();
        if (mCurrentWaypoint->second.mapid != GetMapId() || mCurrentWaypoint->second.teleport)
        {
            passengers.clear();
            TransportPassengers(mCurrentWaypoint->second.mapid, GetMapId(), mCurrentWaypoint->second.x, mCurrentWaypoint->second.y, mCurrentWaypoint->second.z);
            break;
        }
        else{
            SetPosition(mCurrentWaypoint->second.x, mCurrentWaypoint->second.y, mCurrentWaypoint->second.z, m_position.o, false);
            MovePassengers(mCurrentWaypoint->second.x, mCurrentWaypoint->second.y, mCurrentWaypoint->second.z, m_position.o);
        }

        if (mCurrentWaypoint->second.delayed)
        {
            //Transprter Script = sScriptMgr.CreateAIScriptClassForGameObject(GetEntry(), this);
            switch (GetInfo()->DisplayID)
            {
                case 3015:
                case 7087:
                {
                    PlaySoundToSet(5154);        // ShipDocked LightHouseFogHorn.wav
                }
                break;
                case 3031:
                {
                    PlaySoundToSet(11804);        // ZeppelinDocked    ZeppelinHorn.wav
                }
                break;
                default:
                {
                    PlaySoundToSet(5495);        // BoatDockingWarning    BoatDockedWarning.wav
                }
                break;
            }
            TransportGossip(GetInfo()->DisplayID);
        }
    }
}