本文整理汇总了C++中GetNextWayPoint函数的典型用法代码示例。如果您正苦于以下问题:C++ GetNextWayPoint函数的具体用法?C++ GetNextWayPoint怎么用?C++ GetNextWayPoint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetNextWayPoint函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AI
void Transport::Update(uint32 p_diff)
{
if (!AI())
{
if (!AIM_Initialize())
sLog->outError("Could not initialize GameObjectAI for Transport");
} else
AI()->UpdateAI(p_diff);
if (m_WayPoints.size() <= 1)
return;
m_timer = getMSTime() % m_period;
while (((m_timer - m_curr->first) % m_pathTime) > ((m_next->first - m_curr->first) % m_pathTime))
{
DoEventIfAny(*m_curr, true);
m_curr = GetNextWayPoint();
m_next = GetNextWayPoint();
DoEventIfAny(*m_curr, false);
// first check help in case client-server transport coordinates de-synchronization
if (m_curr->second.mapid != GetMapId() || m_curr->second.teleport)
{
TeleportTransport(m_curr->second.mapid, m_curr->second.x, m_curr->second.y, m_curr->second.z);
}
else
{
Relocate(m_curr->second.x, m_curr->second.y, m_curr->second.z, GetAngle(m_next->second.x, m_next->second.y) + float(M_PI));
UpdateNPCPositions(); // COME BACK MARKER
}
sScriptMgr->OnRelocate(this, m_curr->first, m_curr->second.mapid, m_curr->second.x, m_curr->second.y, m_curr->second.z);
m_nextNodeTime = m_curr->first;
if (m_curr == m_WayPoints.begin())
sLog->outDebug(LOG_FILTER_TRANSPORTS, " ************ BEGIN ************** %s", m_name.c_str());
sLog->outDebug(LOG_FILTER_TRANSPORTS, "%s moved to %d %f %f %f %d", m_name.c_str(), m_curr->second.id, m_curr->second.x, m_curr->second.y, m_curr->second.z, m_curr->second.mapid);
}
sScriptMgr->OnTransportUpdate(this, p_diff);
}
示例2: getMSTime
void Transport::Update(uint32 /*p_time*/)
{
if (m_WayPoints.size() <= 1)
return;
m_timer = getMSTime() % m_period;
while (((m_timer - m_curr->first) % m_pathTime) > ((m_next->first - m_curr->first) % m_pathTime))
{
m_curr = GetNextWayPoint();
m_next = GetNextWayPoint();
// first check help in case client-server transport coordinates de-synchronization
if (m_curr->second.mapid != GetMapId() || m_curr->second.teleport)
{
TeleportTransport(m_curr->second.mapid, m_curr->second.x, m_curr->second.y, m_curr->second.z);
}
else
{
Relocate(m_curr->second.x, m_curr->second.y, m_curr->second.z);
}
/*
for (PlayerSet::iterator itr = m_passengers.begin(); itr != m_passengers.end();)
{
PlayerSet::iterator it2 = itr;
++itr;
//(*it2)->SetPosition(m_curr->second.x + (*it2)->GetTransOffsetX(), m_curr->second.y + (*it2)->GetTransOffsetY(), m_curr->second.z + (*it2)->GetTransOffsetZ(), (*it2)->GetTransOffsetO());
}
*/
m_nextNodeTime = m_curr->first;
if (m_curr == m_WayPoints.begin() && (sLog->getLogFilter() & LOG_FILTER_TRANSPORT_MOVES) == 0)
sLog->outDebug(" ************ BEGIN ************** %s", this->m_name.c_str());
if ((sLog->getLogFilter() & LOG_FILTER_TRANSPORT_MOVES) == 0)
sLog->outDebug("%s moved to %d %f %f %f %d", this->m_name.c_str(), m_curr->second.id, m_curr->second.x, m_curr->second.y, m_curr->second.z, m_curr->second.mapid);
//Transport Event System
CheckForEvent(this->GetEntry(), m_curr->second.id);
}
}
示例3: GetScript
void SmartAI::MovepointReached(uint32 id)
{
// override the id, path can be resumed any time and counter will reset
// mCurrentWPID holds proper id
// xinef: both point movement and escort generator can enter this function
if (id == SMART_ESCORT_LAST_OOC_POINT)
{
mOOCReached = true;
return;
}
mWPReached = true;
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_REACHED, NULL, mCurrentWPID);
if (mLastWP)
{
me->SetPosition(mLastWP->x, mLastWP->y, mLastWP->z, me->GetOrientation());
me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation());
}
if (HasEscortState(SMART_ESCORT_PAUSED))
{
if (me->GetMotionMaster()->GetMotionSlotType(MOTION_SLOT_ACTIVE) == ESCORT_MOTION_TYPE)
me->GetMotionMaster()->MovementExpired();
me->StopMovingOnCurrentPos();
me->GetMotionMaster()->MoveIdle();
}
// Xinef: Can be unset in ProcessEvents
else if (HasEscortState(SMART_ESCORT_ESCORTING) && me->GetMotionMaster()->GetCurrentMovementGeneratorType() == ESCORT_MOTION_TYPE)
{
mWPReached = false;
if (mCurrentWPID == GetWPCount())
EndPath();
else if (GetNextWayPoint())
{
SetRun(mRun);
// xinef: if we have reached waypoint, and there is no working spline movement it means our splitted array has ended, make new one
if (me->movespline->Finalized())
ResumePath();
}
}
}
示例4: StopPath
void SmartAI::StartPath(bool run, uint32 path, bool repeat, Unit* invoker)
{
if (me->IsInCombat())// no wp movement in combat
{
sLog->outError("SmartAI::StartPath: Creature entry %u wanted to start waypoint movement while in combat, ignoring.", me->GetEntry());
return;
}
if (HasEscortState(SMART_ESCORT_ESCORTING))
StopPath();
if (path)
{
if (!LoadPath(path))
return;
}
if (!mWayPoints || mWayPoints->empty())
return;
if (WayPoint* wp = GetNextWayPoint())
{
AddEscortState(SMART_ESCORT_ESCORTING);
mCanRepeatPath = repeat;
SetRun(run);
if (invoker && invoker->GetTypeId() == TYPEID_PLAYER)
{
mEscortNPCFlags = me->GetUInt32Value(UNIT_NPC_FLAGS);
me->SetUInt32Value(UNIT_NPC_FLAGS, 0);
}
Movement::PointsArray pathPoints;
GenerateWayPointArray(&pathPoints);
me->GetMotionMaster()->MoveSplinePath(&pathPoints);
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_START, NULL, wp->id, GetScript()->GetPathId());
}
}
示例5: k
//.........这里部分代码省略.........
m_WayPoints[0] = pos;
t += keyFrames[0].node->delay * 1000;
uint32 cM = keyFrames[0].node->mapid;
for(size_t i = 0; i < keyFrames.size() - 1; ++i)
{
float d = 0;
float tFrom = keyFrames[i].tFrom;
float tTo = keyFrames[i].tTo;
// keep the generation of all these points; we use only a few now, but may need the others later
if(((d < keyFrames[i + 1].distFromPrev) && (tTo > 0)))
{
while((d < keyFrames[i + 1].distFromPrev) && (tTo > 0))
{
tFrom += 100;
tTo -= 100;
if(d > 0)
{
float newX = keyFrames[i].node->x + (keyFrames[i + 1].node->x - keyFrames[i].node->x) * d / keyFrames[i + 1].distFromPrev;
float newY = keyFrames[i].node->y + (keyFrames[i + 1].node->y - keyFrames[i].node->y) * d / keyFrames[i + 1].distFromPrev;
float newZ = keyFrames[i].node->z + (keyFrames[i + 1].node->z - keyFrames[i].node->z) * d / keyFrames[i + 1].distFromPrev;
teleport = false;
if(keyFrames[i].node->mapid != cM)
{
teleport = true;
cM = keyFrames[i].node->mapid;
}
// sLog->outString("T: %d, D: %f, x: %f, y: %f, z: %f", t, d, newX, newY, newZ);
WayPoint pos(keyFrames[i].node->mapid, newX, newY, newZ, teleport, 0);
if(teleport)
m_WayPoints[t] = pos;
}
if(tFrom < tTo) // caught in tFrom dock's "gravitational pull"
{
if(tFrom <= 30000)
{
d = 0.5f * (tFrom / 1000) * (tFrom / 1000);
}
else
{
d = 0.5f * 30 * 30 + 30 * ((tFrom - 30000) / 1000);
}
d = d - keyFrames[i].distSinceStop;
}
else
{
if(tTo <= 30000)
{
d = 0.5f * (tTo / 1000) * (tTo / 1000);
}
else
{
d = 0.5f * 30 * 30 + 30 * ((tTo - 30000) / 1000);
}
d = keyFrames[i].distUntilStop - d;
}
t += 100;
}
t -= 100;
}
if(keyFrames[i + 1].tFrom > keyFrames[i + 1].tTo)
t += 100 - ((long)keyFrames[i + 1].tTo % 100);
else
t += (long)keyFrames[i + 1].tTo % 100;
teleport = false;
if((keyFrames[i + 1].node->actionFlag == 1) || (keyFrames[i + 1].node->mapid != keyFrames[i].node->mapid))
{
teleport = true;
cM = keyFrames[i + 1].node->mapid;
}
WayPoint pos(keyFrames[i + 1].node->mapid, keyFrames[i + 1].node->x, keyFrames[i + 1].node->y, keyFrames[i + 1].node->z, teleport,
0, keyFrames[i + 1].node->arrivalEventID, keyFrames[i + 1].node->departureEventID);
// sLog->outString("T: %d, x: %f, y: %f, z: %f, t:%d", t, pos.x, pos.y, pos.z, teleport);
m_WayPoints[t] = pos;
t += keyFrames[i + 1].node->delay * 1000;
// sLog->outString("------");
}
uint32 timer = t;
// sLog->outDetail(" Generated %lu waypoints, total time %u.", (unsigned long)m_WayPoints.size(), timer);
m_curr = m_WayPoints.begin();
m_next = GetNextWayPoint();
m_pathTime = timer;
m_nextNodeTime = m_curr->first;
return true;
}
示例6: StopPath
void SmartAI::UpdatePath(const uint32 diff)
{
if (!HasEscortState(SMART_ESCORT_ESCORTING))
return;
if (mEscortInvokerCheckTimer < diff)
{
if (!IsEscortInvokerInRange())
{
StopPath(mDespawnTime, mEscortQuestID, true);
}
mEscortInvokerCheckTimer = 1000;
} else mEscortInvokerCheckTimer -= diff;
// handle pause
if (HasEscortState(SMART_ESCORT_PAUSED))
{
if (mWPPauseTimer < diff)
{
if (!me->isInCombat() && !HasEscortState(SMART_ESCORT_RETURNING) && (mWPReached || mLastWPIDReached == SMART_ESCORT_LAST_OOC_POINT || mForcedPaused))
{
GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_RESUMED, NULL, mLastWP->id, GetScript()->GetPathId());
RemoveEscortState(SMART_ESCORT_PAUSED);
if (mForcedPaused)// if paused between 2 wps resend movement
{
ResumePath();
mWPReached = false;
mForcedPaused = false;
}
if (mLastWPIDReached == SMART_ESCORT_LAST_OOC_POINT)
mWPReached = true;
}
mWPPauseTimer = 0;
} else {
mWPPauseTimer -= diff;
}
}
if (HasEscortState(SMART_ESCORT_RETURNING))
{
if (mWPReached)//reached OOC WP
{
RemoveEscortState(SMART_ESCORT_RETURNING);
if (!HasEscortState(SMART_ESCORT_PAUSED))
ResumePath();
mWPReached = false;
}
}
if (me->isInCombat() || HasEscortState(SMART_ESCORT_PAUSED | SMART_ESCORT_RETURNING))
return;
// handle next wp
if (mWPReached)//reached WP
{
mWPReached = false;
if (mCurrentWPID == GetWPCount())
{
EndPath();
} else {
WayPoint* wp = GetNextWayPoint();
if (wp)
{
SetRun(mRun);
me->GetMotionMaster()->MovePoint(wp->id, wp->x, wp->y, wp->z);
}
}
}
}
示例7: k
//.........这里部分代码省略.........
// Now we're completely set up; we can move along the length of each waypoint at 100 ms intervals
// speed = max(30, t) (remember x = 0.5s^2, and when accelerating, a = 1 unit/s^2
int t = 0;
bool teleport = false;
if (keyFrames[keyFrames.size() - 1].mapid != keyFrames[0].mapid)
teleport = true;
WayPoint pos(keyFrames[0].mapid, keyFrames[0].x, keyFrames[0].y, keyFrames[0].z, teleport);
m_WayPoints[0] = pos;
t += keyFrames[0].delay * 1000;
int cM = keyFrames[0].mapid;
for (size_t i = 0; i < keyFrames.size() - 1; i++) { //
float d = 0;
float tFrom = keyFrames[i].tFrom;
float tTo = keyFrames[i].tTo;
// keep the generation of all these points; we use only a few now, but may need the others later
if (((d < keyFrames[i + 1].distFromPrev) && (tTo > 0))) {
while ((d < keyFrames[i + 1].distFromPrev) && (tTo > 0)) {
tFrom += 100;
tTo -= 100;
if (d > 0) {
float newX, newY, newZ;
newX = keyFrames[i].x + (keyFrames[i + 1].x - keyFrames[i].x) * d / keyFrames[i + 1].distFromPrev;
newY = keyFrames[i].y + (keyFrames[i + 1].y - keyFrames[i].y) * d / keyFrames[i + 1].distFromPrev;
newZ = keyFrames[i].z + (keyFrames[i + 1].z - keyFrames[i].z) * d / keyFrames[i + 1].distFromPrev;
bool teleport = false;
if (keyFrames[i].mapid != cM) {
teleport = true;
cM = keyFrames[i].mapid;
}
// sLog.outString("T: %d, D: %f, x: %f, y: %f, z: %f", t, d, newX, newY, newZ);
WayPoint pos(keyFrames[i].mapid, newX, newY, newZ, teleport);
if (teleport)
m_WayPoints[t] = pos;
}
if (tFrom < tTo) { // caught in tFrom dock's "gravitational pull"
if (tFrom <= 30000) {
d = 0.5 * (tFrom / 1000) * (tFrom / 1000);
} else {
d = 0.5 * 30 * 30 + 30 * ((tFrom - 30000) / 1000);
}
d = d - keyFrames[i].distSinceStop;
} else {
if (tTo <= 30000) {
d = 0.5 * (tTo / 1000) * (tTo / 1000);
} else {
d = 0.5 * 30 * 30 + 30 * ((tTo - 30000) / 1000);
}
d = keyFrames[i].distUntilStop - d;
}
t += 100;
}
t -= 100;
}
if (keyFrames[i + 1].tFrom > keyFrames[i + 1].tTo)
t += 100 - ((long)keyFrames[i + 1].tTo % 100);
else
t += (long)keyFrames[i + 1].tTo % 100;
bool teleport = false;
if ((keyFrames[i + 1].actionflag == 1) || (keyFrames[i + 1].mapid != keyFrames[i].mapid)) {
teleport = true;
cM = keyFrames[i + 1].mapid;
}
WayPoint pos(keyFrames[i + 1].mapid, keyFrames[i + 1].x, keyFrames[i + 1].y, keyFrames[i + 1].z, teleport);
// sLog.outString("T: %d, x: %f, y: %f, z: %f, t:%d", t, pos.x, pos.y, pos.z, teleport);
//if (teleport)
m_WayPoints[t] = pos;
t += keyFrames[i + 1].delay * 1000;
// sLog.outString("------");
}
uint32 timer = t;
// sLog.outDetail(" Generated %d waypoints, total time %u.", m_WayPoints.size(), timer);
m_curr = m_WayPoints.begin();
m_curr = GetNextWayPoint();
m_next = GetNextWayPoint();
m_pathTime = timer;
m_lastMovement = getMSTime();
m_nextNodeTime = m_curr->first;
m_curMap = m_curr->second.mapid;
return true;
}