mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[9830] Implement taxi/transport event scripts support.
This commit is contained in:
parent
e54c919adb
commit
3f5eccd8a9
9 changed files with 77 additions and 32 deletions
|
|
@ -1670,8 +1670,8 @@ struct TaxiPathNodeEntry
|
|||
float z; // 6 m_LocZ
|
||||
uint32 actionFlag; // 7 m_flags
|
||||
uint32 delay; // 8 m_delay
|
||||
// 9 m_arrivalEventID
|
||||
// 10 m_departureEventID
|
||||
uint32 arrivalEventID; // 9 m_arrivalEventID
|
||||
uint32 departureEventID; // 10 m_departureEventID
|
||||
};
|
||||
|
||||
struct TotemCategoryEntry
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ const char TalentEntryfmt[]="niiiiiiiixxxxixxixxxxxx";
|
|||
const char TalentTabEntryfmt[]="nxxxxxxxxxxxxxxxxxxxiiix";
|
||||
const char TaxiNodesEntryfmt[]="nifffssssssssssssssssxii";
|
||||
const char TaxiPathEntryfmt[]="niii";
|
||||
const char TaxiPathNodeEntryfmt[]="diiifffiixx";
|
||||
const char TaxiPathNodeEntryfmt[]="diiifffiiii";
|
||||
const char TotemCategoryEntryfmt[]="nxxxxxxxxxxxxxxxxxii";
|
||||
const char VehicleEntryfmt[]="niffffiiiiiiiifffffffffffffffssssfifixxx";
|
||||
const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiiixxxxxxxxxxxx";
|
||||
|
|
|
|||
|
|
@ -503,6 +503,17 @@ 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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
|
||||
|
|
|
|||
|
|
@ -4508,30 +4508,13 @@ void ObjectMgr::LoadEventScripts()
|
|||
LoadScripts(sEventScripts, "event_scripts");
|
||||
|
||||
std::set<uint32> evt_scripts;
|
||||
|
||||
// Load all possible script entries from gameobjects
|
||||
for(uint32 i = 1; i < sGOStorage.MaxEntry; ++i)
|
||||
{
|
||||
GameObjectInfo const * goInfo = sGOStorage.LookupEntry<GameObjectInfo>(i);
|
||||
if (goInfo)
|
||||
{
|
||||
switch(goInfo->type)
|
||||
{
|
||||
case GAMEOBJECT_TYPE_GOOBER:
|
||||
if (goInfo->goober.eventId)
|
||||
evt_scripts.insert(goInfo->goober.eventId);
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_CHEST:
|
||||
if (goInfo->chest.eventId)
|
||||
evt_scripts.insert(goInfo->chest.eventId);
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_CAMERA:
|
||||
if (goInfo->camera.eventID)
|
||||
evt_scripts.insert(goInfo->camera.eventID);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (GameObjectInfo const * goInfo = sGOStorage.LookupEntry<GameObjectInfo>(i))
|
||||
if (uint32 eventId = goInfo->GetEventScriptId())
|
||||
evt_scripts.insert(eventId);
|
||||
|
||||
// Load all possible script entries from spells
|
||||
for(uint32 i = 1; i < sSpellStore.GetNumRows(); ++i)
|
||||
{
|
||||
|
|
@ -4548,12 +4531,27 @@ void ObjectMgr::LoadEventScripts()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx)
|
||||
{
|
||||
for(size_t node_idx = 0; node_idx < sTaxiPathNodesByPath[path_idx].size(); ++node_idx)
|
||||
{
|
||||
TaxiPathNodeEntry const& node = sTaxiPathNodesByPath[path_idx][node_idx];
|
||||
|
||||
if (node.arrivalEventID)
|
||||
evt_scripts.insert(node.arrivalEventID);
|
||||
|
||||
if (node.departureEventID)
|
||||
evt_scripts.insert(node.departureEventID);
|
||||
}
|
||||
}
|
||||
|
||||
// Then check if all scripts are in above list of possible script entries
|
||||
for(ScriptMapMap::const_iterator itr = sEventScripts.begin(); itr != sEventScripts.end(); ++itr)
|
||||
{
|
||||
std::set<uint32>::const_iterator itr2 = evt_scripts.find(itr->first);
|
||||
if (itr2 == evt_scripts.end())
|
||||
sLog.outErrorDb("Table `event_scripts` has script (Id: %u) not referring to any gameobject_template type 10 data2 field, type 3 data6 field, type 13 data 2 field or any spell effect %u",
|
||||
sLog.outErrorDb("Table `event_scripts` has script (Id: %u) not referring to any gameobject_template type 10 data2 field, type 3 data6 field, type 13 data 2 field or any spell effect %u or path taxi node data",
|
||||
itr->first, SPELL_EFFECT_SEND_EVENT);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
WayPoint pos(keyFrames[0].node->mapid, keyFrames[0].node->x, keyFrames[0].node->y, keyFrames[0].node->z, teleport,
|
||||
keyFrames[0].node->arrivalEventID, keyFrames[0].node->departureEventID);
|
||||
m_WayPoints[0] = pos;
|
||||
t += keyFrames[0].node->delay * 1000;
|
||||
|
||||
|
|
@ -390,7 +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);
|
||||
WayPoint pos(keyFrames[i + 1].node->mapid, keyFrames[i + 1].node->x, keyFrames[i + 1].node->y, keyFrames[i + 1].node->z, teleport,
|
||||
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);
|
||||
|
||||
|
|
@ -490,9 +492,14 @@ void Transport::Update(time_t /*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)
|
||||
{
|
||||
|
|
@ -554,3 +561,12 @@ void Transport::UpdateForMap(Map const* targetMap)
|
|||
itr->getSource()->SendDirectMessage(&out_packet);
|
||||
}
|
||||
}
|
||||
|
||||
void Transport::DoEventIfAny(WayPointMap::value_type const& node, bool departure)
|
||||
{
|
||||
if (uint32 eventid = departure ? node.second.departureEventID : node.second.arrivalEventID)
|
||||
{
|
||||
DEBUG_LOG("Taxi %s event %u of node %u of %s (%s) path", departure ? "departure" : "arrival", eventid, node.first, GetName(), GetObjectGuid().GetString().c_str());
|
||||
GetMap()->ScriptsStart(sEventScripts, eventid, this, this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,13 +43,19 @@ class Transport : public GameObject
|
|||
struct WayPoint
|
||||
{
|
||||
WayPoint() : mapid(0), x(0), y(0), z(0), teleport(false) {}
|
||||
WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport) :
|
||||
mapid(_mapid), x(_x), y(_y), z(_z), teleport(_teleport) {}
|
||||
WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport, uint32 _arrivalEventID = 0, uint32 _departureEventID = 0)
|
||||
: mapid(_mapid), x(_x), y(_y), z(_z), teleport(_teleport),
|
||||
arrivalEventID(_arrivalEventID), departureEventID(_departureEventID)
|
||||
{
|
||||
}
|
||||
|
||||
uint32 mapid;
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
bool teleport;
|
||||
uint32 arrivalEventID;
|
||||
uint32 departureEventID;
|
||||
};
|
||||
|
||||
typedef std::map<uint32, WayPoint> WayPointMap;
|
||||
|
|
@ -69,6 +75,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
|
||||
|
|
|
|||
|
|
@ -356,10 +356,14 @@ bool FlightPathMovementGenerator::Update(Player &player, const uint32 &diff)
|
|||
i_destinationHolder.ResetUpdate(FLIGHT_TRAVEL_UPDATE);
|
||||
if (i_destinationHolder.HasArrived())
|
||||
{
|
||||
DoEventIfAny(player,(*i_path)[i_currentNode],false);
|
||||
|
||||
uint32 curMap = (*i_path)[i_currentNode].mapid;
|
||||
++i_currentNode;
|
||||
if (MovementInProgress())
|
||||
{
|
||||
DoEventIfAny(player,(*i_path)[i_currentNode],true);
|
||||
|
||||
DEBUG_LOG("loading node %u for player %s", i_currentNode, player.GetName());
|
||||
if ((*i_path)[i_currentNode].mapid == curMap)
|
||||
{
|
||||
|
|
@ -368,7 +372,6 @@ bool FlightPathMovementGenerator::Update(Player &player, const uint32 &diff)
|
|||
}
|
||||
return true;
|
||||
}
|
||||
//else HasArrived()
|
||||
}
|
||||
else
|
||||
return true;
|
||||
|
|
@ -398,6 +401,15 @@ void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport()
|
|||
}
|
||||
}
|
||||
|
||||
void FlightPathMovementGenerator::DoEventIfAny(Player& player, TaxiPathNodeEntry const& node, bool departure)
|
||||
{
|
||||
if (uint32 eventid = departure ? node.departureEventID : node.arrivalEventID)
|
||||
{
|
||||
DEBUG_LOG("Taxi %s event %u of node %u of path %u for player %s", departure ? "departure" : "arrival", eventid, node.index, node.path, player.GetName());
|
||||
player.GetMap()->ScriptsStart(sEventScripts, eventid, &player, &player);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Unique1's ASTAR Pathfinding Code... For future use & reference...
|
||||
//
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ public PathMovementBase<Player,TaxiPathNodeList const*>
|
|||
bool HasArrived() const { return (i_currentNode >= i_path->size()); }
|
||||
void SetCurrentNodeAfterTeleport();
|
||||
void SkipCurrentNode() { ++i_currentNode; }
|
||||
void DoEventIfAny(Player& player, TaxiPathNodeEntry const& node, bool departure);
|
||||
|
||||
// allow use for overwrite empty implementation
|
||||
bool GetDestination(float& x, float& y, float& z) const { return PathMovementBase<Player,TaxiPathNodeList const*>::GetDestination(x,y,z); }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9829"
|
||||
#define REVISION_NR "9830"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue