Core/Players: Don't set instanceId to 0 when player is on transport during loading, there CAN be transports inside instances
Core/Scripts: Added waypoint id to OnRelocate transport hook Core/Scripts: Make use of ZoneScript::GetGameObjectEntry at gameobject creation (makes it possible to override gameobject entries in instances) Core/Transports: Call InstanceScript::EventInform for transport events Core/Transports: Use guid from db for transports, not just its entry - adds partial support for instancing them (still cannot use transports table for it, but can spawn manually now) Scripts/Icecrown Citadel: Fixed crash in Deathbringer Saurfang when event is started by more than one person (can't do this anymore) Closes isssue #3749. --HG-- branch : trunk
This commit is contained in:
@@ -153,6 +153,14 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
|
||||
|
||||
SetPhaseMask(phaseMask,false);
|
||||
|
||||
SetZoneScript();
|
||||
if (m_zoneScript)
|
||||
{
|
||||
name_id = m_zoneScript->GetGameObjectEntry(guidlow, name_id);
|
||||
if (!name_id)
|
||||
return false;
|
||||
}
|
||||
|
||||
GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(name_id);
|
||||
if (!goinfo)
|
||||
{
|
||||
@@ -211,8 +219,6 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
|
||||
break;
|
||||
}
|
||||
|
||||
SetZoneScript();
|
||||
|
||||
LastUsedScriptID = GetGOInfo()->ScriptId;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -16066,10 +16066,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
// currently we do not support transport in bg
|
||||
else if (transGUID)
|
||||
{
|
||||
// There are no transports on instances
|
||||
instanceId = 0;
|
||||
|
||||
m_movementInfo.t_guid = MAKE_NEW_GUID(transGUID, 0, HIGHGUID_TRANSPORT);
|
||||
m_movementInfo.t_guid = MAKE_NEW_GUID(transGUID, 0, HIGHGUID_MO_TRANSPORT);
|
||||
m_movementInfo.t_pos.Relocate(fields[26].GetFloat(), fields[27].GetFloat(), fields[28].GetFloat(), fields[29].GetFloat());
|
||||
|
||||
if (!Trinity::IsValidMapCoord(
|
||||
@@ -16078,7 +16075,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
// transport size limited
|
||||
m_movementInfo.t_pos.m_positionX > 250 || m_movementInfo.t_pos.m_positionY > 250 || m_movementInfo.t_pos.m_positionZ > 250)
|
||||
{
|
||||
sLog.outError("Player (guidlow %d) have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.",
|
||||
sLog.outError("Player (guidlow %d) have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to bind location.",
|
||||
guid,GetPositionX()+m_movementInfo.t_pos.m_positionX,GetPositionY()+m_movementInfo.t_pos.m_positionY,
|
||||
GetPositionZ()+m_movementInfo.t_pos.m_positionZ,GetOrientation()+m_movementInfo.t_pos.m_orientation);
|
||||
|
||||
@@ -16098,7 +16095,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
}
|
||||
if (!m_transport)
|
||||
{
|
||||
sLog.outError("Player (guidlow %d) have problems with transport guid (%u). Teleport to default race/class locations.",
|
||||
sLog.outError("Player (guidlow %d) have problems with transport guid (%u). Teleport to bind location.",
|
||||
guid,transGUID);
|
||||
|
||||
RelocateToHomebind();
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
void MapManager::LoadTransports()
|
||||
{
|
||||
QueryResult_AutoPtr result = WorldDatabase.Query("SELECT entry, name, period, ScriptName FROM transports");
|
||||
QueryResult_AutoPtr result = WorldDatabase.Query("SELECT guid, entry, name, period, ScriptName FROM transports");
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
@@ -52,10 +52,11 @@ void MapManager::LoadTransports()
|
||||
bar.step();
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
std::string name = fields[1].GetCppString();
|
||||
uint32 period = fields[2].GetUInt32();
|
||||
uint32 scriptId = sObjectMgr.GetScriptId(fields[3].GetString());
|
||||
uint32 lowguid = fields[0].GetUInt32();
|
||||
uint32 entry = fields[1].GetUInt32();
|
||||
std::string name = fields[2].GetCppString();
|
||||
uint32 period = fields[3].GetUInt32();
|
||||
uint32 scriptId = sObjectMgr.GetScriptId(fields[4].GetString());
|
||||
|
||||
Transport *t = new Transport(period, scriptId);
|
||||
|
||||
@@ -87,12 +88,14 @@ void MapManager::LoadTransports()
|
||||
continue;
|
||||
}
|
||||
|
||||
float x, y, z, o;
|
||||
uint32 mapid;
|
||||
x = t->m_WayPoints[0].x; y = t->m_WayPoints[0].y; z = t->m_WayPoints[0].z; mapid = t->m_WayPoints[0].mapid; o = 1;
|
||||
float x = t->m_WayPoints[0].x;
|
||||
float y = t->m_WayPoints[0].y;
|
||||
float z = t->m_WayPoints[0].z;
|
||||
uint32 mapid = t->m_WayPoints[0].mapid;
|
||||
float o = 1.0f;
|
||||
|
||||
// creates the Gameobject
|
||||
if (!t->Create(entry, mapid, x, y, z, o, 100, 0))
|
||||
if (!t->Create(lowguid, entry, mapid, x, y, z, o, 100, 0))
|
||||
{
|
||||
delete t;
|
||||
continue;
|
||||
@@ -184,7 +187,23 @@ Transport::Transport(uint32 period, uint32 script) : GameObject(), m_period(peri
|
||||
m_updateFlag = (UPDATEFLAG_TRANSPORT | UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_ROTATION);
|
||||
}
|
||||
|
||||
bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags)
|
||||
Transport::~Transport()
|
||||
{
|
||||
std::set<uint64>::iterator it2;
|
||||
for (std::set<uint64>::iterator itr = m_NPCPassengerSet.begin(); itr != m_NPCPassengerSet.end();)
|
||||
{
|
||||
it2 = itr;
|
||||
++itr;
|
||||
if (Creature *npc = Creature::GetCreature(*this, *it2))
|
||||
npc->AddObjectToRemoveList();
|
||||
}
|
||||
m_NPCPassengerSet.clear();
|
||||
|
||||
m_WayPoints.clear();
|
||||
m_passengers.clear();
|
||||
}
|
||||
|
||||
bool Transport::Create(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags)
|
||||
{
|
||||
Relocate(x,y,z,ang);
|
||||
// instance id and phaseMask isn't set to values different from std.
|
||||
@@ -198,7 +217,7 @@ bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z,
|
||||
|
||||
Object::_Create(guidlow, 0, HIGHGUID_MO_TRANSPORT);
|
||||
|
||||
GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(guidlow);
|
||||
GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(entry);
|
||||
|
||||
if (!goinfo)
|
||||
{
|
||||
@@ -227,6 +246,8 @@ bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z,
|
||||
|
||||
SetName(goinfo->name);
|
||||
|
||||
SetZoneScript();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -486,9 +507,8 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
|
||||
++itr;
|
||||
|
||||
if (plr->isDead() && !plr->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
|
||||
{
|
||||
plr->ResurrectPlayer(1.0);
|
||||
}
|
||||
plr->ResurrectPlayer(1.0f);
|
||||
|
||||
plr->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT);
|
||||
}
|
||||
|
||||
@@ -571,7 +591,7 @@ void Transport::Update(uint32 p_diff)
|
||||
UpdateNPCPositions(); // COME BACK MARKER
|
||||
}
|
||||
|
||||
sScriptMgr.OnRelocate(this, m_curr->second.mapid, m_curr->second.x, m_curr->second.y, m_curr->second.z);
|
||||
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;
|
||||
|
||||
@@ -624,19 +644,21 @@ void Transport::DoEventIfAny(WayPointMap::value_type const& node, bool departure
|
||||
{
|
||||
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);
|
||||
EventInform(eventid);
|
||||
}
|
||||
}
|
||||
|
||||
void Transport::BuildStartMovePacket(Map const* targetMap)
|
||||
{
|
||||
SetByteValue(GAMEOBJECT_FLAGS ,0,41);
|
||||
SetByteValue(GAMEOBJECT_BYTES_1, 0, GO_STATE_ACTIVE);
|
||||
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
|
||||
SetGoState(GO_STATE_ACTIVE);
|
||||
UpdateForMap(targetMap);
|
||||
}
|
||||
|
||||
void Transport::BuildStopMovePacket(Map const* targetMap)
|
||||
{
|
||||
SetByteValue(GAMEOBJECT_FLAGS ,0,40);
|
||||
RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
|
||||
SetGoState(GO_STATE_READY);
|
||||
UpdateForMap(targetMap);
|
||||
}
|
||||
|
||||
@@ -645,7 +667,7 @@ uint32 Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y,
|
||||
Map* map = GetMap();
|
||||
Creature* pCreature = new Creature;
|
||||
|
||||
if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), GetMap(), this->GetPhaseMask(), entry, 0, (uint32)(this->GetGOInfo()->faction), 0, 0, 0, 0))
|
||||
if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), GetMap(), GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0, 0, 0, 0))
|
||||
{
|
||||
delete pCreature;
|
||||
return 0;
|
||||
@@ -657,11 +679,11 @@ uint32 Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y,
|
||||
pCreature->m_movementInfo.t_pos.Relocate(x, y, z, o);
|
||||
pCreature->setActive(true);
|
||||
|
||||
if (anim > 0)
|
||||
pCreature->SetUInt32Value(UNIT_NPC_EMOTESTATE,anim);
|
||||
if (anim)
|
||||
pCreature->SetUInt32Value(UNIT_NPC_EMOTESTATE, anim);
|
||||
|
||||
pCreature->Relocate(
|
||||
GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + M_PI)),
|
||||
GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))),
|
||||
GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())),
|
||||
z + GetPositionZ() ,
|
||||
o + GetOrientation());
|
||||
|
||||
@@ -43,8 +43,9 @@ class Transport : public GameObject
|
||||
{
|
||||
public:
|
||||
Transport(uint32 period, uint32 script);
|
||||
~Transport();
|
||||
|
||||
bool Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags);
|
||||
bool Create(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags);
|
||||
bool GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids);
|
||||
void Update(uint32 p_time);
|
||||
bool AddPassenger(Player* passenger);
|
||||
|
||||
Reference in New Issue
Block a user