Core/Transports: fixed generic elevators such as in Orgrimmar

* fixed Lady Deathwhisper's Elevator
* use a better value for returning to stop frame 0
This commit is contained in:
Ovahlord committed 2018-06-23 17:53:56 +02:00
1 parent 1cdbcade12
commit 46cad2a53c
4 files changed
+27 -30

No files matched your search

@@ -297,18 +297,20 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
m_goValue.Transport.PathProgress -= m_goValue.Transport.PathProgress % GetTransportPeriod(); // align to period
m_goValue.Transport.CurrentSeg = 0;
m_goValue.Transport.StateUpdateTimer = 0;
m_goValue.Transport.CurrentStopFrameIndex = 0;
m_goValue.Transport.StopFrames = new std::vector<uint32>();
m_goValue.Transport.StopFrames->push_back(0); // assign default stop frame
if (goinfo->transport.stopFrame1 > 0)
m_goValue.Transport.StopFrames->push_back(goinfo->transport.stopFrame1);
if (goinfo->transport.stopFrame2 > 0)
m_goValue.Transport.StopFrames->push_back(goinfo->transport.stopFrame2);
if (goinfo->transport.stopFrame3 > 0)
m_goValue.Transport.StopFrames->push_back(goinfo->transport.stopFrame3);
if (goinfo->transport.stopFrame4 > 0)
m_goValue.Transport.StopFrames->push_back(goinfo->transport.stopFrame4);
if (goinfo->transport.Timeto2ndfloor > 0)
{
if (!goinfo->transport.startOpen)
m_goValue.Transport.StopFrames->push_back(0);
m_goValue.Transport.StopFrames->push_back(goinfo->transport.Timeto2ndfloor);
}
if (goinfo->transport.Timeto3rdfloor > 0)
m_goValue.Transport.StopFrames->push_back(goinfo->transport.Timeto3rdfloor);
if (goinfo->transport.Timeto4thfloor > 0)
m_goValue.Transport.StopFrames->push_back(goinfo->transport.Timeto4thfloor);
if (goinfo->transport.Timeto5thfloor > 0)
m_goValue.Transport.StopFrames->push_back(goinfo->transport.Timeto5thfloor);
if (goinfo->transport.startOpen)
SetTransportState(GO_STATE_TRANSPORT_STOPPED, goinfo->transport.startOpen - 1);
else
@@ -2228,7 +2230,7 @@ void GameObject::SetTransportState(GOState state, uint32 stopFrame /*= 0*/)
m_goValue.Transport.StateUpdateTimer = 0;
m_goValue.Transport.PathProgress = getMSTime();
if (GetGoState() >= GO_STATE_TRANSPORT_STOPPED)
m_goValue.Transport.StopFrames->at(GetGoState() - GO_STATE_TRANSPORT_STOPPED);
m_goValue.Transport.PathProgress += m_goValue.Transport.StopFrames->at(GetGoState() - GO_STATE_TRANSPORT_STOPPED);
SetGoState(GO_STATE_TRANSPORT_ACTIVE);
}
else
@@ -2237,14 +2239,10 @@ void GameObject::SetTransportState(GOState state, uint32 stopFrame /*= 0*/)
ASSERT(stopFrame < m_goValue.Transport.StopFrames->size());
uint32 stopFrameTime = m_goValue.Transport.StopFrames->at(stopFrame);
// If we return to StopFrame 0 we are going to use the sum of passed transport frames to get a valid travel time to avoid "teleports"
if (!stopFrame)
for (uint8 i = 0; i <= m_goValue.Transport.CurrentStopFrameIndex; i++)
stopFrameTime += m_goValue.Transport.StopFrames->at(i);
if (!stopFrameTime) // returning to a previous stop frame that has no travel time (e.g. stop frame at 0ms)
stopFrameTime = m_goValue.Transport.StopFrames->at(stopFrame + 1);
m_goValue.Transport.PathProgress = getMSTime() + stopFrameTime;
m_goValue.Transport.CurrentStopFrameIndex = stopFrame;
SetGoState(GOState(GO_STATE_TRANSPORT_STOPPED + stopFrame));
}