*Transport events implemented. Need DB support for travelmasters. New script command 18: SCRIPT_COMMAND_PLAYSOUND.
--HG-- branch : trunk
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
DROP TABLE IF EXISTS `transport_events`;
|
||||||
|
CREATE TABLE `transport_events` (
|
||||||
|
`entry` int(11) unsigned NOT NULL default '0',
|
||||||
|
`waypoint_id` int(11) unsigned NOT NULL default '0',
|
||||||
|
`event_id` int(11) unsigned NOT NULL default '0'
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
@@ -7541,3 +7541,39 @@ ObjectMgr::ScriptNameMap & GetScriptNames()
|
|||||||
{
|
{
|
||||||
return objmgr.GetScriptNames();
|
return objmgr.GetScriptNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObjectMgr::LoadTransportEvents()
|
||||||
|
{
|
||||||
|
|
||||||
|
QueryResult *result = WorldDatabase.Query("SELECT entry, waypoint_id, event_id FROM transport_events");
|
||||||
|
|
||||||
|
if( !result )
|
||||||
|
{
|
||||||
|
barGoLink bar1( 1 );
|
||||||
|
bar1.step();
|
||||||
|
sLog.outString( "\n>> Transport events table is empty \n" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
barGoLink bar1( result->GetRowCount() );
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
bar1.step();
|
||||||
|
|
||||||
|
Field *fields = result->Fetch();
|
||||||
|
|
||||||
|
//Load event values
|
||||||
|
uint32 entry = fields[0].GetUInt32();
|
||||||
|
uint32 waypoint_id = fields[1].GetUInt32();
|
||||||
|
uint32 event_id = fields[2].GetUInt32();
|
||||||
|
|
||||||
|
uint32 event_count = (entry*100)+waypoint_id;
|
||||||
|
TransportEventMap[event_count] = event_id;
|
||||||
|
}
|
||||||
|
while(result->NextRow());
|
||||||
|
|
||||||
|
sLog.outString( "\n>> Loaded %u transport events \n", result->GetRowCount() );
|
||||||
|
|
||||||
|
delete result;
|
||||||
|
}
|
||||||
@@ -321,7 +321,9 @@ class ObjectMgr
|
|||||||
|
|
||||||
typedef std::vector<std::string> ScriptNameMap;
|
typedef std::vector<std::string> ScriptNameMap;
|
||||||
|
|
||||||
Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);}
|
UNORDERED_MAP<uint32, uint32> TransportEventMap;
|
||||||
|
|
||||||
|
Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);}
|
||||||
Player* GetPlayer(uint64 guid) const { return ObjectAccessor::FindPlayer(guid); }
|
Player* GetPlayer(uint64 guid) const { return ObjectAccessor::FindPlayer(guid); }
|
||||||
|
|
||||||
static GameObjectInfo const *GetGameObjectInfo(uint32 id) { return sGOStorage.LookupEntry<GameObjectInfo>(id); }
|
static GameObjectInfo const *GetGameObjectInfo(uint32 id) { return sGOStorage.LookupEntry<GameObjectInfo>(id); }
|
||||||
@@ -534,6 +536,8 @@ class ObjectMgr
|
|||||||
void LoadSpellScripts();
|
void LoadSpellScripts();
|
||||||
void LoadWaypointScripts();
|
void LoadWaypointScripts();
|
||||||
|
|
||||||
|
void LoadTransportEvents();
|
||||||
|
|
||||||
bool LoadTrinityStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value);
|
bool LoadTrinityStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value);
|
||||||
bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",MIN_TRINITY_STRING_ID,MAX_TRINITY_STRING_ID); }
|
bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",MIN_TRINITY_STRING_ID,MAX_TRINITY_STRING_ID); }
|
||||||
void LoadDbScriptStrings();
|
void LoadDbScriptStrings();
|
||||||
|
|||||||
+21
-8
@@ -29,6 +29,8 @@
|
|||||||
#include "Database/DBCStores.h"
|
#include "Database/DBCStores.h"
|
||||||
#include "ProgressBar.h"
|
#include "ProgressBar.h"
|
||||||
|
|
||||||
|
#include "World.h"
|
||||||
|
|
||||||
void MapManager::LoadTransports()
|
void MapManager::LoadTransports()
|
||||||
{
|
{
|
||||||
QueryResult *result = WorldDatabase.Query("SELECT entry, name, period FROM transports");
|
QueryResult *result = WorldDatabase.Query("SELECT entry, name, period FROM transports");
|
||||||
@@ -316,7 +318,7 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
|
|||||||
if (keyFrames[keyFrames.size() - 1].mapid != keyFrames[0].mapid)
|
if (keyFrames[keyFrames.size() - 1].mapid != keyFrames[0].mapid)
|
||||||
teleport = true;
|
teleport = true;
|
||||||
|
|
||||||
WayPoint pos(keyFrames[0].mapid, keyFrames[0].x, keyFrames[0].y, keyFrames[0].z, teleport);
|
WayPoint pos(keyFrames[0].mapid, keyFrames[0].x, keyFrames[0].y, keyFrames[0].z, teleport, 0);
|
||||||
m_WayPoints[0] = pos;
|
m_WayPoints[0] = pos;
|
||||||
t += keyFrames[0].delay * 1000;
|
t += keyFrames[0].delay * 1000;
|
||||||
|
|
||||||
@@ -350,7 +352,7 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sLog.outString("T: %d, D: %f, x: %f, y: %f, z: %f", t, d, newX, newY, newZ);
|
// 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);
|
WayPoint pos(keyFrames[i].mapid, newX, newY, newZ, teleport, i);
|
||||||
if (teleport)
|
if (teleport)
|
||||||
m_WayPoints[t] = pos;
|
m_WayPoints[t] = pos;
|
||||||
}
|
}
|
||||||
@@ -396,13 +398,13 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
|
|||||||
cM = keyFrames[i + 1].mapid;
|
cM = keyFrames[i + 1].mapid;
|
||||||
}
|
}
|
||||||
|
|
||||||
WayPoint pos(keyFrames[i + 1].mapid, keyFrames[i + 1].x, keyFrames[i + 1].y, keyFrames[i + 1].z, teleport);
|
WayPoint pos(keyFrames[i + 1].mapid, keyFrames[i + 1].x, keyFrames[i + 1].y, keyFrames[i + 1].z, teleport, i);
|
||||||
|
|
||||||
// sLog.outString("T: %d, x: %f, y: %f, z: %f, t:%d", t, pos.x, pos.y, pos.z, teleport);
|
// 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)
|
if(keyFrames[i+1].delay > 5)
|
||||||
pos.delayed = true;
|
pos.delayed = true;
|
||||||
|
*/
|
||||||
//if (teleport)
|
//if (teleport)
|
||||||
m_WayPoints[t] = pos;
|
m_WayPoints[t] = pos;
|
||||||
|
|
||||||
@@ -485,6 +487,13 @@ bool Transport::RemovePassenger(Player* passenger)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Transport::CheckForEvent(uint32 entry, uint32 wp_id)
|
||||||
|
{
|
||||||
|
uint32 key = entry*100+wp_id;
|
||||||
|
if(objmgr.TransportEventMap.find(key) != objmgr.TransportEventMap.end())
|
||||||
|
sWorld.ScriptsStart(sEventScripts, objmgr.TransportEventMap[key], this, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void Transport::Update(uint32 /*p_time*/)
|
void Transport::Update(uint32 /*p_time*/)
|
||||||
{
|
{
|
||||||
if (m_WayPoints.size() <= 1)
|
if (m_WayPoints.size() <= 1)
|
||||||
@@ -506,7 +515,7 @@ void Transport::Update(uint32 /*p_time*/)
|
|||||||
//MapManager::Instance().GetMap(m_curr->second.mapid)->GameobjectRelocation((GameObject *)this, m_curr->second.x, m_curr->second.y, m_curr->second.z, this->m_orientation);
|
//MapManager::Instance().GetMap(m_curr->second.mapid)->GameobjectRelocation((GameObject *)this, m_curr->second.x, m_curr->second.y, m_curr->second.z, this->m_orientation);
|
||||||
Relocate(m_curr->second.x, m_curr->second.y, m_curr->second.z);
|
Relocate(m_curr->second.x, m_curr->second.y, m_curr->second.z);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if(m_curr->second.delayed)
|
if(m_curr->second.delayed)
|
||||||
{
|
{
|
||||||
switch (GetEntry())
|
switch (GetEntry())
|
||||||
@@ -526,7 +535,7 @@ void Transport::Update(uint32 /*p_time*/)
|
|||||||
SendPlaySound(5154, false); break; // ShipDocked
|
SendPlaySound(5154, false); break; // ShipDocked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
for(PlayerSet::iterator itr = m_passengers.begin(); itr != m_passengers.end();)
|
for(PlayerSet::iterator itr = m_passengers.begin(); itr != m_passengers.end();)
|
||||||
{
|
{
|
||||||
@@ -547,5 +556,9 @@ void Transport::Update(uint32 /*p_time*/)
|
|||||||
|
|
||||||
if ((sLog.getLogFilter() & LOG_FILTER_TRANSPORT_MOVES)==0)
|
if ((sLog.getLogFilter() & LOG_FILTER_TRANSPORT_MOVES)==0)
|
||||||
sLog.outDetail("%s moved to %f %f %f %d", this->m_name.c_str(), m_curr->second.x, m_curr->second.y, m_curr->second.z, m_curr->second.mapid);
|
sLog.outDetail("%s moved to %f %f %f %d", this->m_name.c_str(), 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);
|
||||||
|
sLog.outDetail("%s is at wp id: %u", this->m_name.c_str(), m_curr->second.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ class Transport : private GameObject
|
|||||||
void Update(uint32 p_time);
|
void Update(uint32 p_time);
|
||||||
bool AddPassenger(Player* passenger);
|
bool AddPassenger(Player* passenger);
|
||||||
bool RemovePassenger(Player* passenger);
|
bool RemovePassenger(Player* passenger);
|
||||||
|
void CheckForEvent(uint32 entry, uint32 wp_id);
|
||||||
|
|
||||||
typedef std::set<Player*> PlayerSet;
|
typedef std::set<Player*> PlayerSet;
|
||||||
PlayerSet const& GetPassengers() const { return m_passengers; }
|
PlayerSet const& GetPassengers() const { return m_passengers; }
|
||||||
@@ -86,15 +87,15 @@ class Transport : private GameObject
|
|||||||
private:
|
private:
|
||||||
struct WayPoint
|
struct WayPoint
|
||||||
{
|
{
|
||||||
WayPoint() : mapid(0), x(0), y(0), z(0), teleport(false) {}
|
WayPoint() : mapid(0), x(0), y(0), z(0), teleport(false), id(0) {}
|
||||||
WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport) :
|
WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport, uint32 _id) :
|
||||||
mapid(_mapid), x(_x), y(_y), z(_z), teleport(_teleport), delayed(false) {}
|
mapid(_mapid), x(_x), y(_y), z(_z), teleport(_teleport), id(_id) {}
|
||||||
uint32 mapid;
|
uint32 mapid;
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
float z;
|
float z;
|
||||||
bool teleport;
|
bool teleport;
|
||||||
bool delayed;
|
uint32 id;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<uint32, WayPoint> WayPointMap;
|
typedef std::map<uint32, WayPoint> WayPointMap;
|
||||||
|
|||||||
+33
-12
@@ -63,6 +63,7 @@
|
|||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
#include "CreatureGroups.h"
|
#include "CreatureGroups.h"
|
||||||
|
#include "Transports.h"
|
||||||
|
|
||||||
INSTANTIATE_SINGLETON_1( World );
|
INSTANTIATE_SINGLETON_1( World );
|
||||||
|
|
||||||
@@ -1357,6 +1358,9 @@ void World::SetInitialWorldSettings()
|
|||||||
sLog.outString( "Loading Transports..." );
|
sLog.outString( "Loading Transports..." );
|
||||||
MapManager::Instance().LoadTransports();
|
MapManager::Instance().LoadTransports();
|
||||||
|
|
||||||
|
sLog.outString( "Loading Transports Events..." );
|
||||||
|
objmgr.LoadTransportEvents();
|
||||||
|
|
||||||
sLog.outString("Deleting expired bans..." );
|
sLog.outString("Deleting expired bans..." );
|
||||||
loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||||
|
|
||||||
@@ -1614,7 +1618,7 @@ void World::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// prepare static data
|
// prepare static data
|
||||||
uint64 sourceGUID = source->GetGUID();
|
uint64 sourceGUID = source ? source->GetGUID() : (uint64)0; //some script commands doesn't have source
|
||||||
uint64 targetGUID = target ? target->GetGUID() : (uint64)0;
|
uint64 targetGUID = target ? target->GetGUID() : (uint64)0;
|
||||||
uint64 ownerGUID = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : (uint64)0;
|
uint64 ownerGUID = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : (uint64)0;
|
||||||
|
|
||||||
@@ -1643,7 +1647,7 @@ void World::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* s
|
|||||||
// NOTE: script record _must_ exist until command executed
|
// NOTE: script record _must_ exist until command executed
|
||||||
|
|
||||||
// prepare static data
|
// prepare static data
|
||||||
uint64 sourceGUID = source->GetGUID();
|
uint64 sourceGUID = source ? source->GetGUID() : (uint64)0;
|
||||||
uint64 targetGUID = target ? target->GetGUID() : (uint64)0;
|
uint64 targetGUID = target ? target->GetGUID() : (uint64)0;
|
||||||
uint64 ownerGUID = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : (uint64)0;
|
uint64 ownerGUID = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : (uint64)0;
|
||||||
|
|
||||||
@@ -1697,12 +1701,22 @@ void World::ScriptsProcess()
|
|||||||
source = HashMapHolder<Player>::Find(step.sourceGUID);
|
source = HashMapHolder<Player>::Find(step.sourceGUID);
|
||||||
break;
|
break;
|
||||||
case HIGHGUID_GAMEOBJECT:
|
case HIGHGUID_GAMEOBJECT:
|
||||||
source = HashMapHolder<GameObject>::Find(step.sourceGUID);
|
source = HashMapHolder<GameObject>::Find(step.sourceGUID);
|
||||||
break;
|
break;
|
||||||
case HIGHGUID_CORPSE:
|
case HIGHGUID_CORPSE:
|
||||||
source = HashMapHolder<Corpse>::Find(step.sourceGUID);
|
source = HashMapHolder<Corpse>::Find(step.sourceGUID);
|
||||||
break;
|
break;
|
||||||
default:
|
case HIGHGUID_MO_TRANSPORT:
|
||||||
|
for (MapManager::TransportSet::iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter)
|
||||||
|
{
|
||||||
|
if((*iter)->GetGUID() == step.sourceGUID)
|
||||||
|
{
|
||||||
|
source = reinterpret_cast<Object*>(*iter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
sLog.outError("*_script source with unsupported high guid value %u",GUID_HIPART(step.sourceGUID));
|
sLog.outError("*_script source with unsupported high guid value %u",GUID_HIPART(step.sourceGUID));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2294,11 +2308,12 @@ void World::ScriptsProcess()
|
|||||||
else //check hashmap holders
|
else //check hashmap holders
|
||||||
{
|
{
|
||||||
if(CreatureData const* data = objmgr.GetCreatureData(step.script->datalong))
|
if(CreatureData const* data = objmgr.GetCreatureData(step.script->datalong))
|
||||||
ObjectAccessor::GetObjectInWorld<Creature>(data->mapid, data->posX, data->posY, MAKE_NEW_GUID(step.script->datalong, data->id, HIGHGUID_UNIT), target);
|
target = ObjectAccessor::GetObjectInWorld<Creature>(data->mapid, data->posX, data->posY, MAKE_NEW_GUID(step.script->datalong, data->id, HIGHGUID_UNIT), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!target)
|
if(!target)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//Lets choose our ScriptMap map
|
//Lets choose our ScriptMap map
|
||||||
ScriptMapMap datamap;
|
ScriptMapMap datamap;
|
||||||
switch(step.script->dataint)
|
switch(step.script->dataint)
|
||||||
@@ -2322,17 +2337,23 @@ void World::ScriptsProcess()
|
|||||||
datamap = sWaypointScripts;
|
datamap = sWaypointScripts;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
sLog.outError("SCRIPT_COMMAND_CALLSCRIPT ERROR: no scriptmap present... ignoring");
|
||||||
sLog.outError("SCRIPT_COMMAND_CALLSCRIPT ERROR: no scriptmap present... ignoring");
|
m_scriptSchedule.erase(iter);
|
||||||
m_scriptSchedule.erase(iter);
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 script_id = step.script->datalong2;
|
uint32 script_id = step.script->datalong2;
|
||||||
|
|
||||||
m_scriptSchedule.erase(iter);
|
m_scriptSchedule.erase(iter);
|
||||||
ScriptsStart(datamap, script_id, target, NULL);
|
ScriptsStart(datamap, script_id, target, NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SCRIPT_COMMAND_PLAYSOUND:
|
||||||
|
{
|
||||||
|
if(!source)
|
||||||
|
break;
|
||||||
|
//datalong sound_id, datalong2 onlyself
|
||||||
|
((WorldObject*)source)->SendPlaySound(step.script->datalong, step.script->datalong2);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -327,6 +327,7 @@ enum RealmZone
|
|||||||
#define SCRIPT_COMMAND_CAST_SPELL 15 // source (datalong2!=0) or target (datalong==0) unit, datalong = spell_id
|
#define SCRIPT_COMMAND_CAST_SPELL 15 // source (datalong2!=0) or target (datalong==0) unit, datalong = spell_id
|
||||||
#define SCRIPT_COMMAND_LOAD_PATH 16 // source = unit, path = datalong, repeatable datalong2
|
#define SCRIPT_COMMAND_LOAD_PATH 16 // source = unit, path = datalong, repeatable datalong2
|
||||||
#define SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT 17 // datalong scriptid, lowguid datalong2, dataint table
|
#define SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT 17 // datalong scriptid, lowguid datalong2, dataint table
|
||||||
|
#define SCRIPT_COMMAND_PLAYSOUND 18 // datalong soundid, datalong2 play only self
|
||||||
|
|
||||||
|
|
||||||
/// Storage class for commands issued for delayed execution
|
/// Storage class for commands issued for delayed execution
|
||||||
|
|||||||
Reference in New Issue
Block a user