Implement taxi/transport event scripts support. Author: Vladimir

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2010-06-23 01:59:32 +02:00
parent ffaffe3fd7
commit 968c27f55f
8 changed files with 72 additions and 28 deletions
@@ -500,6 +500,16 @@ struct GameObjectInfo
default: return 0;
}
}
uint32 GetEventScriptId() const
{
switch(type)
{
case GAMEOBJECT_TYPE_GOOBER: return goober.eventId;
case GAMEOBJECT_TYPE_CHEST: return chest.eventId;
case GAMEOBJECT_TYPE_CAMERA: return camera.eventID;
default: return 0;
}
}
};
class OPvPCapturePoint;
@@ -310,7 +310,8 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
if (keyFrames[keyFrames.size() - 1].node->mapid != keyFrames[0].node->mapid)
teleport = true;
WayPoint pos(keyFrames[0].node->mapid, keyFrames[0].node->x, keyFrames[0].node->y, keyFrames[0].node->z, teleport, 0);
WayPoint pos(keyFrames[0].node->mapid, keyFrames[0].node->x, keyFrames[0].node->y, keyFrames[0].node->z, teleport, 0,
keyFrames[0].node->arrivalEventID, keyFrames[0].node->departureEventID);
m_WayPoints[0] = pos;
t += keyFrames[0].node->delay * 1000;
@@ -390,8 +391,8 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
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);
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);
/*
if (keyFrames[i+1].delay > 5)
@@ -494,9 +495,13 @@ void Transport::Update(uint32 /*p_time*/)
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)
{
@@ -582,3 +587,11 @@ void Transport::UpdateForMap(Map const* targetMap)
}
}
void Transport::DoEventIfAny(WayPointMap::value_type const& node, bool departure)
{
if (uint32 eventid = departure ? node.second.departureEventID : node.second.arrivalEventID)
{
sLog.outDebug("Taxi %s event %u of node %u of %s path", departure ? "departure" : "arrival", eventid, node.first, GetName());
GetMap()->ScriptsStart(sEventScripts, eventid, this, this);
}
}
@@ -46,14 +46,20 @@ class Transport : public GameObject
struct WayPoint
{
WayPoint() : mapid(0), x(0), y(0), z(0), teleport(false), id(0) {}
WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport, uint32 _id) :
mapid(_mapid), x(_x), y(_y), z(_z), teleport(_teleport), id(_id) {}
WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport, uint32 _id = 0,
uint32 _arrivalEventID = 0, uint32 _departureEventID = 0)
: mapid(_mapid), x(_x), y(_y), z(_z), teleport(_teleport), id(_id),
arrivalEventID(_arrivalEventID), departureEventID(_departureEventID)
{
}
uint32 mapid;
float x;
float y;
float z;
bool teleport;
uint32 id;
uint32 arrivalEventID;
uint32 departureEventID;
};
typedef std::map<uint32, WayPoint> WayPointMap;
@@ -73,6 +79,7 @@ class Transport : public GameObject
private:
void TeleportTransport(uint32 newMapid, float x, float y, float z);
void UpdateForMap(Map const* map);
void DoEventIfAny(WayPointMap::value_type const& node, bool departure);
WayPointMap::const_iterator GetNextWayPoint();
};
#endif