mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 07:37:03 +00:00
[c12559] DBScripts - Add Map/Zone wide sound support to COMMAND_PLAY_SOUND
This commit is contained in:
parent
d275d04145
commit
7fec4dacae
4 changed files with 346 additions and 219 deletions
|
|
@ -206,7 +206,8 @@ Where "A -> B" means that the command is executed from A with B as target.
|
||||||
|
|
||||||
16 SCRIPT_COMMAND_PLAY_SOUND source = any object, target=any/player
|
16 SCRIPT_COMMAND_PLAY_SOUND source = any object, target=any/player
|
||||||
* datalong = sound_id
|
* datalong = sound_id
|
||||||
* datalong2 (bitmask: 0/1=anyone/target, 0/2=with distance dependent, so 1|2 = 3 is target with distance dependent)
|
* datalong2 (bitmask: 0/1=target-player, 0/2=with distance dependent, 0/4=map wide, 0/8=zone wide;
|
||||||
|
so 1|2 = 3 is target with distance dependent)
|
||||||
|
|
||||||
17 SCRIPT_COMMAND_CREATE_ITEM source or target must be player
|
17 SCRIPT_COMMAND_CREATE_ITEM source or target must be player
|
||||||
* datalong = item entry
|
* datalong = item entry
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
#include "Policies/SingletonImp.h"
|
#include "Policies/Singleton.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "ProgressBar.h"
|
#include "ProgressBar.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
|
@ -28,6 +28,9 @@
|
||||||
#include "Cell.h"
|
#include "Cell.h"
|
||||||
#include "CellImpl.h"
|
#include "CellImpl.h"
|
||||||
#include "SQLStorages.h"
|
#include "SQLStorages.h"
|
||||||
|
#include "BattleGround/BattleGround.h"
|
||||||
|
#include "OutdoorPvP/OutdoorPvP.h"
|
||||||
|
#include "WaypointMovementGenerator.h"
|
||||||
|
|
||||||
#include "revision_nr.h"
|
#include "revision_nr.h"
|
||||||
|
|
||||||
|
|
@ -38,6 +41,7 @@ ScriptMapMapName sGameObjectScripts;
|
||||||
ScriptMapMapName sGameObjectTemplateScripts;
|
ScriptMapMapName sGameObjectTemplateScripts;
|
||||||
ScriptMapMapName sEventScripts;
|
ScriptMapMapName sEventScripts;
|
||||||
ScriptMapMapName sGossipScripts;
|
ScriptMapMapName sGossipScripts;
|
||||||
|
ScriptMapMapName sCreatureDeathScripts;
|
||||||
ScriptMapMapName sCreatureMovementScripts;
|
ScriptMapMapName sCreatureMovementScripts;
|
||||||
|
|
||||||
INSTANTIATE_SINGLETON_1(ScriptMgr);
|
INSTANTIATE_SINGLETON_1(ScriptMgr);
|
||||||
|
|
@ -368,7 +372,7 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename)
|
||||||
info->type == GAMEOBJECT_TYPE_BUTTON ||
|
info->type == GAMEOBJECT_TYPE_BUTTON ||
|
||||||
info->type == GAMEOBJECT_TYPE_TRAP)
|
info->type == GAMEOBJECT_TYPE_TRAP)
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("Table `%s` have gameobject type (%u) unsupported by command SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id %u", tablename, info->id, tmp.id);
|
sLog.outErrorDb("Table `%s` have gameobject type (%u) unsupported by command SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id %u", tablename, info->type, tmp.id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -458,6 +462,11 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename)
|
||||||
tablename, tmp.playSound.soundId, tmp.id);
|
tablename, tmp.playSound.soundId, tmp.id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// bitmask: 0/1=target-player, 0/2=with distance dependent, 0/4=map wide, 0/8=zone wide
|
||||||
|
if (tmp.playSound.flags & ~(1 | 2 | 4 | 8))
|
||||||
|
sLog.outErrorDb("Table `%s` using unsupported sound flags (datalong2: %u) in SCRIPT_COMMAND_PLAY_SOUND for script id %u, unsupported flags will be ignored", tablename, tmp.playSound.flags, tmp.id);
|
||||||
|
if ((tmp.playSound.flags & (1 | 2)) > 0 && (tmp.playSound.flags & (4 | 8)) > 0)
|
||||||
|
sLog.outErrorDb("Table `%s` uses sound flags (datalong2: %u) in SCRIPT_COMMAND_PLAY_SOUND for script id %u, combining (1|2) with (4|8) makes no sense", tablename, tmp.playSound.flags, tmp.id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SCRIPT_COMMAND_CREATE_ITEM: // 17
|
case SCRIPT_COMMAND_CREATE_ITEM: // 17
|
||||||
|
|
@ -622,6 +631,17 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SCRIPT_COMMAND_TERMINATE_SCRIPT: // 31
|
||||||
|
{
|
||||||
|
if (tmp.terminateScript.npcEntry && !ObjectMgr::GetCreatureTemplate(tmp.terminateScript.npcEntry))
|
||||||
|
{
|
||||||
|
sLog.outErrorDb("Table `%s` has datalong = %u in SCRIPT_COMMAND_TERMINATE_SCRIPT for script id %u, but this npc entry does not exist.", tablename, tmp.sendTaxiPath.taxiPathId, tmp.id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SCRIPT_COMMAND_PAUSE_WAYPOINTS: // 32
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("Table `%s` unknown command %u, skipping.", tablename, tmp.command);
|
sLog.outErrorDb("Table `%s` unknown command %u, skipping.", tablename, tmp.command);
|
||||||
|
|
@ -648,55 +668,55 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename)
|
||||||
|
|
||||||
void ScriptMgr::LoadGameObjectScripts()
|
void ScriptMgr::LoadGameObjectScripts()
|
||||||
{
|
{
|
||||||
LoadScripts(sGameObjectScripts, "gameobject_scripts");
|
LoadScripts(sGameObjectScripts, "dbscripts_on_go_use");
|
||||||
|
|
||||||
// check ids
|
// check ids
|
||||||
for (ScriptMapMap::const_iterator itr = sGameObjectScripts.second.begin(); itr != sGameObjectScripts.second.end(); ++itr)
|
for (ScriptMapMap::const_iterator itr = sGameObjectScripts.second.begin(); itr != sGameObjectScripts.second.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (!sObjectMgr.GetGOData(itr->first))
|
if (!sObjectMgr.GetGOData(itr->first))
|
||||||
sLog.outErrorDb("Table `gameobject_scripts` has not existing gameobject (GUID: %u) as script id", itr->first);
|
sLog.outErrorDb("Table `dbscripts_on_go_use` has not existing gameobject (GUID: %u) as script id", itr->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptMgr::LoadGameObjectTemplateScripts()
|
void ScriptMgr::LoadGameObjectTemplateScripts()
|
||||||
{
|
{
|
||||||
LoadScripts(sGameObjectTemplateScripts, "gameobject_template_scripts");
|
LoadScripts(sGameObjectTemplateScripts, "dbscripts_on_go_template_use");
|
||||||
|
|
||||||
// check ids
|
// check ids
|
||||||
for (ScriptMapMap::const_iterator itr = sGameObjectTemplateScripts.second.begin(); itr != sGameObjectTemplateScripts.second.end(); ++itr)
|
for (ScriptMapMap::const_iterator itr = sGameObjectTemplateScripts.second.begin(); itr != sGameObjectTemplateScripts.second.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (!sObjectMgr.GetGameObjectInfo(itr->first))
|
if (!sObjectMgr.GetGameObjectInfo(itr->first))
|
||||||
sLog.outErrorDb("Table `gameobject_template_scripts` has not existing gameobject (Entry: %u) as script id", itr->first);
|
sLog.outErrorDb("Table `dbscripts_on_go_template_use` has not existing gameobject (Entry: %u) as script id", itr->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptMgr::LoadQuestEndScripts()
|
void ScriptMgr::LoadQuestEndScripts()
|
||||||
{
|
{
|
||||||
LoadScripts(sQuestEndScripts, "quest_end_scripts");
|
LoadScripts(sQuestEndScripts, "dbscripts_on_quest_end");
|
||||||
|
|
||||||
// check ids
|
// check ids
|
||||||
for (ScriptMapMap::const_iterator itr = sQuestEndScripts.second.begin(); itr != sQuestEndScripts.second.end(); ++itr)
|
for (ScriptMapMap::const_iterator itr = sQuestEndScripts.second.begin(); itr != sQuestEndScripts.second.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (!sObjectMgr.GetQuestTemplate(itr->first))
|
if (!sObjectMgr.GetQuestTemplate(itr->first))
|
||||||
sLog.outErrorDb("Table `quest_end_scripts` has not existing quest (Id: %u) as script id", itr->first);
|
sLog.outErrorDb("Table `dbscripts_on_quest_end` has not existing quest (Id: %u) as script id", itr->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptMgr::LoadQuestStartScripts()
|
void ScriptMgr::LoadQuestStartScripts()
|
||||||
{
|
{
|
||||||
LoadScripts(sQuestStartScripts, "quest_start_scripts");
|
LoadScripts(sQuestStartScripts, "dbscripts_on_quest_start");
|
||||||
|
|
||||||
// check ids
|
// check ids
|
||||||
for (ScriptMapMap::const_iterator itr = sQuestStartScripts.second.begin(); itr != sQuestStartScripts.second.end(); ++itr)
|
for (ScriptMapMap::const_iterator itr = sQuestStartScripts.second.begin(); itr != sQuestStartScripts.second.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (!sObjectMgr.GetQuestTemplate(itr->first))
|
if (!sObjectMgr.GetQuestTemplate(itr->first))
|
||||||
sLog.outErrorDb("Table `quest_start_scripts` has not existing quest (Id: %u) as script id", itr->first);
|
sLog.outErrorDb("Table `dbscripts_on_quest_start` has not existing quest (Id: %u) as script id", itr->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptMgr::LoadSpellScripts()
|
void ScriptMgr::LoadSpellScripts()
|
||||||
{
|
{
|
||||||
LoadScripts(sSpellScripts, "spell_scripts");
|
LoadScripts(sSpellScripts, "dbscripts_on_spell");
|
||||||
|
|
||||||
// check ids
|
// check ids
|
||||||
for (ScriptMapMap::const_iterator itr = sSpellScripts.second.begin(); itr != sSpellScripts.second.end(); ++itr)
|
for (ScriptMapMap::const_iterator itr = sSpellScripts.second.begin(); itr != sSpellScripts.second.end(); ++itr)
|
||||||
|
|
@ -704,7 +724,7 @@ void ScriptMgr::LoadSpellScripts()
|
||||||
SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first);
|
SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first);
|
||||||
if (!spellInfo)
|
if (!spellInfo)
|
||||||
{
|
{
|
||||||
sLog.outErrorDb("Table `spell_scripts` has not existing spell (Id: %u) as script id", itr->first);
|
sLog.outErrorDb("Table `dbscripts_on_spell` has not existing spell (Id: %u) as script id", itr->first);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -720,97 +740,53 @@ void ScriptMgr::LoadSpellScripts()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
sLog.outErrorDb("Table `spell_scripts` has unsupported spell (Id: %u)", itr->first);
|
sLog.outErrorDb("Table `dbscripts_on_spell` has unsupported spell (Id: %u)", itr->first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptMgr::LoadEventScripts()
|
void ScriptMgr::LoadEventScripts()
|
||||||
{
|
{
|
||||||
LoadScripts(sEventScripts, "event_scripts");
|
LoadScripts(sEventScripts, "dbscripts_on_event");
|
||||||
|
|
||||||
std::set<uint32> evt_scripts;
|
std::set<uint32> eventIds; // Store possible event ids
|
||||||
|
CollectPossibleEventIds(eventIds);
|
||||||
// Load all possible script entries from gameobjects
|
|
||||||
for (uint32 i = 1; i < sGOStorage.MaxEntry; ++i)
|
|
||||||
{
|
|
||||||
if (GameObjectInfo const* goInfo = sGOStorage.LookupEntry<GameObjectInfo>(i))
|
|
||||||
{
|
|
||||||
if (uint32 eventId = goInfo->GetEventScriptId())
|
|
||||||
evt_scripts.insert(eventId);
|
|
||||||
|
|
||||||
if (goInfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT)
|
|
||||||
{
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.neutralEventID1);
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.neutralEventID2);
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.contestedEventID1);
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.contestedEventID2);
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.progressEventID1);
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.progressEventID2);
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.winEventID1);
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.winEventID2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load all possible script entries from spells
|
|
||||||
for (uint32 i = 1; i < sSpellStore.GetNumRows(); ++i)
|
|
||||||
{
|
|
||||||
SpellEntry const* spell = sSpellStore.LookupEntry(i);
|
|
||||||
if (spell)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < MAX_EFFECT_INDEX; ++j)
|
|
||||||
{
|
|
||||||
SpellEffectEntry const* spellEffect = spell->GetSpellEffect(SpellEffectIndex(j));
|
|
||||||
if (!spellEffect)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (spellEffect->Effect == SPELL_EFFECT_SEND_EVENT)
|
|
||||||
{
|
|
||||||
if (spellEffect->EffectMiscValue)
|
|
||||||
evt_scripts.insert(spellEffect->EffectMiscValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
// Then check if all scripts are in above list of possible script entries
|
||||||
for (ScriptMapMap::const_iterator itr = sEventScripts.second.begin(); itr != sEventScripts.second.end(); ++itr)
|
for (ScriptMapMap::const_iterator itr = sEventScripts.second.begin(); itr != sEventScripts.second.end(); ++itr)
|
||||||
{
|
{
|
||||||
std::set<uint32>::const_iterator itr2 = evt_scripts.find(itr->first);
|
std::set<uint32>::const_iterator itr2 = eventIds.find(itr->first);
|
||||||
if (itr2 == evt_scripts.end())
|
if (itr2 == eventIds.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, type 29 or any spell effect %u or path taxi node data",
|
sLog.outErrorDb("Table `dbscripts_on_event` has script (Id: %u) not referring to any fitting gameobject_template or any spell effect %u or path taxi node data",
|
||||||
itr->first, SPELL_EFFECT_SEND_EVENT);
|
itr->first, SPELL_EFFECT_SEND_EVENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptMgr::LoadGossipScripts()
|
void ScriptMgr::LoadGossipScripts()
|
||||||
{
|
{
|
||||||
LoadScripts(sGossipScripts, "gossip_scripts");
|
LoadScripts(sGossipScripts, "dbscripts_on_gossip");
|
||||||
|
|
||||||
// checks are done in LoadGossipMenuItems and LoadGossipMenu
|
// checks are done in LoadGossipMenuItems and LoadGossipMenu
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptMgr::LoadCreatureMovementScripts()
|
void ScriptMgr::LoadCreatureMovementScripts()
|
||||||
{
|
{
|
||||||
LoadScripts(sCreatureMovementScripts, "creature_movement_scripts");
|
LoadScripts(sCreatureMovementScripts, "dbscripts_on_creature_movement");
|
||||||
|
|
||||||
// checks are done in WaypointManager::Load
|
// checks are done in WaypointManager::Load
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::LoadCreatureDeathScripts()
|
||||||
|
{
|
||||||
|
LoadScripts(sCreatureDeathScripts, "dbscripts_on_creature_death");
|
||||||
|
|
||||||
|
// check ids
|
||||||
|
for(ScriptMapMap::const_iterator itr = sCreatureDeathScripts.second.begin(); itr != sCreatureDeathScripts.second.end(); ++itr)
|
||||||
|
{
|
||||||
|
if (!sObjectMgr.GetCreatureTemplate(itr->first))
|
||||||
|
sLog.outErrorDb("Table `dbscripts_on_creature_death` has not existing creature (Entry: %u) as script id", itr->first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptMgr::LoadDbScriptStrings()
|
void ScriptMgr::LoadDbScriptStrings()
|
||||||
{
|
{
|
||||||
sObjectMgr.LoadMangosStrings(WorldDatabase, "db_script_string", MIN_DB_SCRIPT_STRING_ID, MAX_DB_SCRIPT_STRING_ID);
|
sObjectMgr.LoadMangosStrings(WorldDatabase, "db_script_string", MIN_DB_SCRIPT_STRING_ID, MAX_DB_SCRIPT_STRING_ID);
|
||||||
|
|
@ -828,6 +804,7 @@ void ScriptMgr::LoadDbScriptStrings()
|
||||||
CheckScriptTexts(sGameObjectTemplateScripts, ids);
|
CheckScriptTexts(sGameObjectTemplateScripts, ids);
|
||||||
CheckScriptTexts(sEventScripts, ids);
|
CheckScriptTexts(sEventScripts, ids);
|
||||||
CheckScriptTexts(sGossipScripts, ids);
|
CheckScriptTexts(sGossipScripts, ids);
|
||||||
|
CheckScriptTexts(sCreatureDeathScripts, ids);
|
||||||
CheckScriptTexts(sCreatureMovementScripts, ids);
|
CheckScriptTexts(sCreatureMovementScripts, ids);
|
||||||
|
|
||||||
sWaypointMgr.CheckTextsExistance(ids);
|
sWaypointMgr.CheckTextsExistance(ids);
|
||||||
|
|
@ -1019,23 +996,32 @@ Player* ScriptAction::GetPlayerTargetOrSourceAndLog(WorldObject* pSource, WorldO
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle one Script Step
|
/// Handle one Script Step
|
||||||
void ScriptAction::HandleScriptStep()
|
// Return true if and only if further parts of this script shall be skipped
|
||||||
|
bool ScriptAction::HandleScriptStep()
|
||||||
{
|
{
|
||||||
|
WorldObject* pSource;
|
||||||
|
WorldObject* pTarget;
|
||||||
|
Object* pSourceOrItem; // Stores a provided pSource (if exists as WorldObject) or source-item
|
||||||
|
|
||||||
|
{ // Add scope for source & target variables so that they are not used below
|
||||||
Object* source = NULL;
|
Object* source = NULL;
|
||||||
Object* target = NULL;
|
Object* target = NULL;
|
||||||
if (!GetScriptCommandObject(m_sourceGuid, true, source))
|
if (!GetScriptCommandObject(m_sourceGuid, true, source))
|
||||||
return;
|
return false;
|
||||||
if (!GetScriptCommandObject(m_targetGuid, false, target))
|
if (!GetScriptCommandObject(m_targetGuid, false, target))
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
// Give some debug log output for easier use
|
// Give some debug log output for easier use
|
||||||
DEBUG_LOG("DB-SCRIPTS: Process table `%s` id %u, command %u for source %s (%sin world), target %s (%sin world)", m_table, m_script->id, m_script->command, m_sourceGuid.GetString().c_str(), source ? "" : "not ", m_targetGuid.GetString().c_str(), target ? "" : "not ");
|
DEBUG_LOG("DB-SCRIPTS: Process table `%s` id %u, command %u for source %s (%sin world), target %s (%sin world)", m_table, m_script->id, m_script->command, m_sourceGuid.GetString().c_str(), source ? "" : "not ", m_targetGuid.GetString().c_str(), target ? "" : "not ");
|
||||||
|
|
||||||
// Get expected source and target (if defined with buddy)
|
// Get expected source and target (if defined with buddy)
|
||||||
WorldObject* pSource = source && source->isType(TYPEMASK_WORLDOBJECT) ? (WorldObject*)source : NULL;
|
pSource = source && source->isType(TYPEMASK_WORLDOBJECT) ? (WorldObject*)source : NULL;
|
||||||
WorldObject* pTarget = target && target->isType(TYPEMASK_WORLDOBJECT) ? (WorldObject*)target : NULL;
|
pTarget = target && target->isType(TYPEMASK_WORLDOBJECT) ? (WorldObject*)target : NULL;
|
||||||
if (!GetScriptProcessTargets(pSource, pTarget, pSource, pTarget))
|
if (!GetScriptProcessTargets(pSource, pTarget, pSource, pTarget))
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
|
pSourceOrItem = pSource ? pSource : (source && source->isType(TYPEMASK_ITEM) ? source : NULL);
|
||||||
|
}
|
||||||
|
|
||||||
switch (m_script->command)
|
switch (m_script->command)
|
||||||
{
|
{
|
||||||
|
|
@ -1111,20 +1097,18 @@ void ScriptAction::HandleScriptStep()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SCRIPT_COMMAND_FIELD_SET: // 2
|
case SCRIPT_COMMAND_FIELD_SET: // 2
|
||||||
// TODO
|
if (!pSourceOrItem)
|
||||||
if (!source)
|
|
||||||
{
|
{
|
||||||
sLog.outError(" DB-SCRIPTS: Process table `%s` id %u, command %u call for NULL object.", m_table, m_script->id, m_script->command);
|
sLog.outError(" DB-SCRIPTS: Process table `%s` id %u, command %u call for NULL object.", m_table, m_script->id, m_script->command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (m_script->setField.fieldId <= OBJECT_FIELD_ENTRY || m_script->setField.fieldId >= pSourceOrItem->GetValuesCount())
|
||||||
if (m_script->setField.fieldId <= OBJECT_FIELD_ENTRY || m_script->setField.fieldId >= source->GetValuesCount())
|
|
||||||
{
|
{
|
||||||
sLog.outError(" DB-SCRIPTS: Process table `%s` id %u, command %u call for wrong field %u (max count: %u) in object (TypeId: %u).", m_table, m_script->id, m_script->command, m_script->setField.fieldId, source->GetValuesCount(), source->GetTypeId());
|
sLog.outError(" DB-SCRIPTS: Process table `%s` id %u, command %u call for wrong field %u (max count: %u) in %s.",
|
||||||
|
m_table, m_script->id, m_script->command, m_script->setField.fieldId, pSourceOrItem->GetValuesCount(), pSourceOrItem->GetGuidStr().c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
pSourceOrItem->SetUInt32Value(m_script->setField.fieldId, m_script->setField.fieldValue);
|
||||||
source->SetUInt32Value(m_script->setField.fieldId, m_script->setField.fieldValue);
|
|
||||||
break;
|
break;
|
||||||
case SCRIPT_COMMAND_MOVE_TO: // 3
|
case SCRIPT_COMMAND_MOVE_TO: // 3
|
||||||
{
|
{
|
||||||
|
|
@ -1158,36 +1142,32 @@ void ScriptAction::HandleScriptStep()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SCRIPT_COMMAND_FLAG_SET: // 4
|
case SCRIPT_COMMAND_FLAG_SET: // 4
|
||||||
// TODO
|
if (!pSourceOrItem)
|
||||||
if (!source)
|
|
||||||
{
|
{
|
||||||
sLog.outError("SCRIPT_COMMAND_FLAG_SET (script id %u) call for NULL object.", m_script->id);
|
sLog.outError("SCRIPT_COMMAND_FLAG_SET (script id %u) call for NULL object.", m_script->id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (m_script->setFlag.fieldId <= OBJECT_FIELD_ENTRY || m_script->setFlag.fieldId >= source->GetValuesCount())
|
if (m_script->setFlag.fieldId <= OBJECT_FIELD_ENTRY || m_script->setFlag.fieldId >= pSourceOrItem->GetValuesCount())
|
||||||
{
|
{
|
||||||
sLog.outError("SCRIPT_COMMAND_FLAG_SET (script id %u) call for wrong field %u (max count: %u) in object (TypeId: %u).",
|
sLog.outError("SCRIPT_COMMAND_FLAG_SET (script id %u) call for wrong field %u (max count: %u) in %s.",
|
||||||
m_script->id, m_script->setFlag.fieldId, source->GetValuesCount(), source->GetTypeId());
|
m_script->id, m_script->setFlag.fieldId, pSourceOrItem->GetValuesCount(), pSourceOrItem->GetGuidStr().c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
pSourceOrItem->SetFlag(m_script->setFlag.fieldId, m_script->setFlag.fieldValue);
|
||||||
source->SetFlag(m_script->setFlag.fieldId, m_script->setFlag.fieldValue);
|
|
||||||
break;
|
break;
|
||||||
case SCRIPT_COMMAND_FLAG_REMOVE: // 5
|
case SCRIPT_COMMAND_FLAG_REMOVE: // 5
|
||||||
// TODO
|
if (!pSourceOrItem)
|
||||||
if (!source)
|
|
||||||
{
|
{
|
||||||
sLog.outError("SCRIPT_COMMAND_FLAG_REMOVE (script id %u) call for NULL object.", m_script->id);
|
sLog.outError("SCRIPT_COMMAND_FLAG_REMOVE (script id %u) call for NULL object.", m_script->id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (m_script->removeFlag.fieldId <= OBJECT_FIELD_ENTRY || m_script->removeFlag.fieldId >= source->GetValuesCount())
|
if (m_script->removeFlag.fieldId <= OBJECT_FIELD_ENTRY || m_script->removeFlag.fieldId >= pSourceOrItem->GetValuesCount())
|
||||||
{
|
{
|
||||||
sLog.outError("SCRIPT_COMMAND_FLAG_REMOVE (script id %u) call for wrong field %u (max count: %u) in object (TypeId: %u).",
|
sLog.outError("SCRIPT_COMMAND_FLAG_REMOVE (script id %u) call for wrong field %u (max count: %u) in %s.",
|
||||||
m_script->id, m_script->removeFlag.fieldId, source->GetValuesCount(), source->GetTypeId());
|
m_script->id, m_script->removeFlag.fieldId, pSourceOrItem->GetValuesCount(), pSourceOrItem->GetGuidStr().c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
pSourceOrItem->RemoveFlag(m_script->removeFlag.fieldId, m_script->removeFlag.fieldValue);
|
||||||
source->RemoveFlag(m_script->removeFlag.fieldId, m_script->removeFlag.fieldValue);
|
|
||||||
break;
|
break;
|
||||||
case SCRIPT_COMMAND_TELEPORT_TO: // 6
|
case SCRIPT_COMMAND_TELEPORT_TO: // 6
|
||||||
{
|
{
|
||||||
|
|
@ -1323,7 +1303,7 @@ void ScriptAction::HandleScriptStep()
|
||||||
float z = m_script->z;
|
float z = m_script->z;
|
||||||
float o = m_script->o;
|
float o = m_script->o;
|
||||||
|
|
||||||
Creature* pCreature = pSource->SummonCreature(m_script->summonCreature.creatureEntry, x, y, z, o, m_script->summonCreature.despawnDelay ? TEMPSUMMON_TIMED_OR_DEAD_DESPAWN : TEMPSUMMON_DEAD_DESPAWN, m_script->summonCreature.despawnDelay, (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL) ? true : false);
|
Creature* pCreature = pSource->SummonCreature(m_script->summonCreature.creatureEntry, x, y, z, o, m_script->summonCreature.despawnDelay ? TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN : TEMPSUMMON_DEAD_DESPAWN, m_script->summonCreature.despawnDelay, (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL) ? true : false);
|
||||||
if (!pCreature)
|
if (!pCreature)
|
||||||
{
|
{
|
||||||
sLog.outError(" DB-SCRIPTS: Process table `%s` id %u, command %u failed for creature (entry: %u).", m_table, m_script->id, m_script->command, m_script->summonCreature.creatureEntry);
|
sLog.outError(" DB-SCRIPTS: Process table `%s` id %u, command %u failed for creature (entry: %u).", m_table, m_script->id, m_script->command, m_script->summonCreature.creatureEntry);
|
||||||
|
|
@ -1374,7 +1354,7 @@ void ScriptAction::HandleScriptStep()
|
||||||
pDoor->UseDoorOrButton(time_to_reset);
|
pDoor->UseDoorOrButton(time_to_reset);
|
||||||
|
|
||||||
if (pTarget && pTarget->isType(TYPEMASK_GAMEOBJECT) && ((GameObject*)pTarget)->GetGoType() == GAMEOBJECT_TYPE_BUTTON)
|
if (pTarget && pTarget->isType(TYPEMASK_GAMEOBJECT) && ((GameObject*)pTarget)->GetGoType() == GAMEOBJECT_TYPE_BUTTON)
|
||||||
((GameObject*)target)->UseDoorOrButton(time_to_reset);
|
((GameObject*)pTarget)->UseDoorOrButton(time_to_reset);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1408,7 +1388,7 @@ void ScriptAction::HandleScriptStep()
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SCRIPT_COMMAND_PLAY_SOUND: // 16 // TODO
|
case SCRIPT_COMMAND_PLAY_SOUND: // 16
|
||||||
{
|
{
|
||||||
if (!pSource)
|
if (!pSource)
|
||||||
{
|
{
|
||||||
|
|
@ -1416,31 +1396,21 @@ void ScriptAction::HandleScriptStep()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// bitmask: 0/1=anyone/target, 0/2=with distance dependent
|
// bitmask: 0/1=target-player, 0/2=with distance dependent, 0/4=map wide, 0/8=zone wide
|
||||||
Player* pTarget = NULL;
|
Player* pSoundTarget = NULL;
|
||||||
|
|
||||||
if (m_script->playSound.flags & 1)
|
if (m_script->playSound.flags & 1)
|
||||||
{
|
{
|
||||||
if (!target)
|
pSoundTarget = GetPlayerTargetOrSourceAndLog(pSource, pTarget);
|
||||||
{
|
if (!pSoundTarget)
|
||||||
sLog.outError(" DB-SCRIPTS: Process table `%s` id %u, command %u in targeted mode call for NULL target.", m_table, m_script->id, m_script->command);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target->GetTypeId() != TYPEID_PLAYER)
|
|
||||||
{
|
|
||||||
sLog.outError(" DB-SCRIPTS: Process table `%s` id %u, command %u in targeted mode call for non-player (TypeId: %u), skipping.", m_table, m_script->id, m_script->command, target->GetTypeId());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
pTarget = (Player*)target;
|
|
||||||
}
|
|
||||||
|
|
||||||
// bitmask: 0/1=anyone/target, 0/2=with distance dependent
|
|
||||||
if (m_script->playSound.flags & 2)
|
if (m_script->playSound.flags & 2)
|
||||||
pSource->PlayDistanceSound(m_script->playSound.soundId, pTarget);
|
pSource->PlayDistanceSound(m_script->playSound.soundId, pSoundTarget);
|
||||||
|
else if (m_script->playSound.flags & (4 | 8))
|
||||||
|
m_map->PlayDirectSoundToMap(m_script->playSound.soundId, m_script->playSound.flags & 8 ? pSource->GetZoneId() : 0);
|
||||||
else
|
else
|
||||||
pSource->PlayDirectSound(m_script->playSound.soundId, pTarget);
|
pSource->PlayDirectSound(m_script->playSound.soundId, pSoundTarget);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1575,7 +1545,7 @@ void ScriptAction::HandleScriptStep()
|
||||||
if (LogIfNotCreature(pSource))
|
if (LogIfNotCreature(pSource))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
((Creature*)pSource)->SetWalk(!m_script->run.run);
|
((Creature*)pSource)->SetWalk(!m_script->run.run, true);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1587,7 +1557,7 @@ void ScriptAction::HandleScriptStep()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
Creature* pAttacker = static_cast<Creature*>(pSource);
|
Creature* pAttacker = static_cast<Creature*>(pSource);
|
||||||
Unit* unitTarget = static_cast<Unit*>(target);
|
Unit* unitTarget = static_cast<Unit*>(pTarget);
|
||||||
|
|
||||||
if (pAttacker->IsFriendlyTo(unitTarget))
|
if (pAttacker->IsFriendlyTo(unitTarget))
|
||||||
{
|
{
|
||||||
|
|
@ -1667,10 +1637,64 @@ void ScriptAction::HandleScriptStep()
|
||||||
pPlayer->ActivateTaxiPathTo(m_script->sendTaxiPath.taxiPathId);
|
pPlayer->ActivateTaxiPathTo(m_script->sendTaxiPath.taxiPathId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SCRIPT_COMMAND_TERMINATE_SCRIPT: // 31
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
if (m_script->terminateScript.npcEntry)
|
||||||
|
{
|
||||||
|
WorldObject* pSearcher = pSource ? pSource : pTarget;
|
||||||
|
if (pSearcher->GetTypeId() == TYPEID_PLAYER && pTarget && pTarget->GetTypeId() != TYPEID_PLAYER)
|
||||||
|
pSearcher = pTarget;
|
||||||
|
|
||||||
|
Creature* pCreatureBuddy = NULL;
|
||||||
|
MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*pSearcher, m_script->terminateScript.npcEntry, true, false, m_script->terminateScript.searchDist);
|
||||||
|
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(pCreatureBuddy, u_check);
|
||||||
|
Cell::VisitGridObjects(pSearcher, searcher, m_script->terminateScript.searchDist);
|
||||||
|
|
||||||
|
if (!(m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL) && !pCreatureBuddy)
|
||||||
|
{
|
||||||
|
DEBUG_LOG("DB-SCRIPTS: Process table `%s` id %u, terminate further steps of this script! (as searched npc %u was not found alive)", m_table, m_script->id, m_script->terminateScript.npcEntry);
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
else if (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL && pCreatureBuddy)
|
||||||
|
{
|
||||||
|
DEBUG_LOG("DB-SCRIPTS: Process table `%s` id %u, terminate further steps of this script! (as searched npc %u was found alive)", m_table, m_script->id, m_script->terminateScript.npcEntry);
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
result = true;
|
||||||
|
|
||||||
|
if (result) // Terminate further steps of this script
|
||||||
|
{
|
||||||
|
if (m_script->textId[0] && !LogIfNotCreature(pSource))
|
||||||
|
{
|
||||||
|
Creature* cSource = static_cast<Creature*>(pSource);
|
||||||
|
if (cSource->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
|
||||||
|
(static_cast<WaypointMovementGenerator<Creature>* >(cSource->GetMotionMaster()->top()))->AddToWaypointPauseTime(m_script->textId[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SCRIPT_COMMAND_PAUSE_WAYPOINTS: // 32
|
||||||
|
{
|
||||||
|
if (LogIfNotCreature(pSource))
|
||||||
|
return false;
|
||||||
|
if (m_script->pauseWaypoint.doPause)
|
||||||
|
((Creature*)pSource)->addUnitState(UNIT_STAT_WAYPOINT_PAUSED);
|
||||||
|
else
|
||||||
|
((Creature*)pSource)->clearUnitState(UNIT_STAT_WAYPOINT_PAUSED);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
sLog.outError(" DB-SCRIPTS: Process table `%s` id %u, command %u unknown command used.", m_table, m_script->id, m_script->command);
|
sLog.outError(" DB-SCRIPTS: Process table `%s` id %u, command %u unknown command used.", m_table, m_script->id, m_script->command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /////////////////////////////////////////////////////////
|
// /////////////////////////////////////////////////////////
|
||||||
|
|
@ -1741,66 +1765,8 @@ void ScriptMgr::LoadEventIdScripts()
|
||||||
|
|
||||||
BarGoLink bar(result->GetRowCount());
|
BarGoLink bar(result->GetRowCount());
|
||||||
|
|
||||||
// TODO: remove duplicate code below, same way to collect event id's used in LoadEventScripts()
|
std::set<uint32> eventIds; // Store possible event ids
|
||||||
std::set<uint32> evt_scripts;
|
CollectPossibleEventIds(eventIds);
|
||||||
|
|
||||||
// Load all possible event entries from gameobjects
|
|
||||||
for (uint32 i = 1; i < sGOStorage.MaxEntry; ++i)
|
|
||||||
{
|
|
||||||
if (GameObjectInfo const* goInfo = sGOStorage.LookupEntry<GameObjectInfo>(i))
|
|
||||||
{
|
|
||||||
if (uint32 eventId = goInfo->GetEventScriptId())
|
|
||||||
evt_scripts.insert(eventId);
|
|
||||||
|
|
||||||
if (goInfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT)
|
|
||||||
{
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.neutralEventID1);
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.neutralEventID2);
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.contestedEventID1);
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.contestedEventID2);
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.progressEventID1);
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.progressEventID2);
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.winEventID1);
|
|
||||||
evt_scripts.insert(goInfo->capturePoint.winEventID2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load all possible event entries from spells
|
|
||||||
for (uint32 i = 1; i < sSpellStore.GetNumRows(); ++i)
|
|
||||||
{
|
|
||||||
SpellEntry const* spell = sSpellStore.LookupEntry(i);
|
|
||||||
if (spell)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < MAX_EFFECT_INDEX; ++j)
|
|
||||||
{
|
|
||||||
SpellEffectEntry const* spellEffect = spell->GetSpellEffect(SpellEffectIndex(j));
|
|
||||||
if (!spellEffect)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (spellEffect->Effect == SPELL_EFFECT_SEND_EVENT)
|
|
||||||
{
|
|
||||||
if (spellEffect->EffectMiscValue)
|
|
||||||
evt_scripts.insert(spellEffect->EffectMiscValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load all possible event entries from taxi path nodes
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
@ -1812,8 +1778,8 @@ void ScriptMgr::LoadEventIdScripts()
|
||||||
uint32 eventId = fields[0].GetUInt32();
|
uint32 eventId = fields[0].GetUInt32();
|
||||||
const char* scriptName = fields[1].GetString();
|
const char* scriptName = fields[1].GetString();
|
||||||
|
|
||||||
std::set<uint32>::const_iterator itr = evt_scripts.find(eventId);
|
std::set<uint32>::const_iterator itr = eventIds.find(eventId);
|
||||||
if (itr == evt_scripts.end())
|
if (itr == eventIds.end())
|
||||||
sLog.outErrorDb("Table `scripted_event_id` has id %u not referring to any gameobject_template type 10 data2 field, type 3 data6 field, type 13 data 2 field, type 29 or any spell effect %u or path taxi node data",
|
sLog.outErrorDb("Table `scripted_event_id` has id %u not referring to any gameobject_template type 10 data2 field, type 3 data6 field, type 13 data 2 field, type 29 or any spell effect %u or path taxi node data",
|
||||||
eventId, SPELL_EFFECT_SEND_EVENT);
|
eventId, SPELL_EFFECT_SEND_EVENT);
|
||||||
|
|
||||||
|
|
@ -2146,6 +2112,125 @@ void ScriptMgr::UnloadScriptLibrary()
|
||||||
m_pOnAuraDummy = NULL;
|
m_pOnAuraDummy = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::CollectPossibleEventIds(std::set<uint32>& eventIds)
|
||||||
|
{
|
||||||
|
// Load all possible script entries from gameobjects
|
||||||
|
for (SQLStorageBase::SQLSIterator<GameObjectInfo> itr = sGOStorage.getDataBegin<GameObjectInfo>(); itr < sGOStorage.getDataEnd<GameObjectInfo>(); ++itr)
|
||||||
|
{
|
||||||
|
switch (itr->type)
|
||||||
|
{
|
||||||
|
case GAMEOBJECT_TYPE_GOOBER:
|
||||||
|
eventIds.insert(itr->goober.eventId);
|
||||||
|
break;
|
||||||
|
case GAMEOBJECT_TYPE_CHEST:
|
||||||
|
eventIds.insert(itr->chest.eventId);
|
||||||
|
break;
|
||||||
|
case GAMEOBJECT_TYPE_CAMERA:
|
||||||
|
eventIds.insert(itr->camera.eventID);
|
||||||
|
break;
|
||||||
|
case GAMEOBJECT_TYPE_CAPTURE_POINT:
|
||||||
|
eventIds.insert(itr->capturePoint.neutralEventID1);
|
||||||
|
eventIds.insert(itr->capturePoint.neutralEventID2);
|
||||||
|
eventIds.insert(itr->capturePoint.contestedEventID1);
|
||||||
|
eventIds.insert(itr->capturePoint.contestedEventID2);
|
||||||
|
eventIds.insert(itr->capturePoint.progressEventID1);
|
||||||
|
eventIds.insert(itr->capturePoint.progressEventID2);
|
||||||
|
eventIds.insert(itr->capturePoint.winEventID1);
|
||||||
|
eventIds.insert(itr->capturePoint.winEventID2);
|
||||||
|
break;
|
||||||
|
case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING:
|
||||||
|
eventIds.insert(itr->destructibleBuilding.damagedEvent);
|
||||||
|
eventIds.insert(itr->destructibleBuilding.destroyedEvent);
|
||||||
|
eventIds.insert(itr->destructibleBuilding.intactEvent);
|
||||||
|
eventIds.insert(itr->destructibleBuilding.rebuildingEvent);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load all possible script entries from spells
|
||||||
|
for (uint32 i = 1; i < sSpellStore.GetNumRows(); ++i)
|
||||||
|
{
|
||||||
|
SpellEntry const* spell = sSpellStore.LookupEntry(i);
|
||||||
|
if (spell)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < MAX_EFFECT_INDEX; ++j)
|
||||||
|
{
|
||||||
|
SpellEffectEntry const* spellEffect = spell->GetSpellEffect(SpellEffectIndex(j));
|
||||||
|
if (!spellEffect)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (spellEffect->Effect == SPELL_EFFECT_SEND_EVENT)
|
||||||
|
{
|
||||||
|
if (spellEffect->EffectMiscValue)
|
||||||
|
eventIds.insert(spellEffect->EffectMiscValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load all possible event entries from taxi path nodes
|
||||||
|
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)
|
||||||
|
eventIds.insert(node.arrivalEventID);
|
||||||
|
|
||||||
|
if (node.departureEventID)
|
||||||
|
eventIds.insert(node.departureEventID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Starters for events
|
||||||
|
bool StartEvents_Event(Map* map, uint32 id, Object* source, Object* target, bool isStart/*=true*/, Unit* forwardToPvp/*=NULL*/)
|
||||||
|
{
|
||||||
|
MANGOS_ASSERT(source);
|
||||||
|
|
||||||
|
// Handle SD2 script
|
||||||
|
if (sScriptMgr.OnProcessEvent(id, source, target, isStart))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Handle PvP Calls
|
||||||
|
if (forwardToPvp && source->GetTypeId() == TYPEID_GAMEOBJECT)
|
||||||
|
{
|
||||||
|
BattleGround* bg = NULL;
|
||||||
|
OutdoorPvP* opvp = NULL;
|
||||||
|
if (forwardToPvp->GetTypeId() == TYPEID_PLAYER)
|
||||||
|
{
|
||||||
|
bg = ((Player*)forwardToPvp)->GetBattleGround();
|
||||||
|
if (!bg)
|
||||||
|
opvp = sOutdoorPvPMgr.GetScript(((Player*)forwardToPvp)->GetCachedZoneId());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (map->IsBattleGroundOrArena())
|
||||||
|
bg = ((BattleGroundMap*)map)->GetBG();
|
||||||
|
else // Use the go, because GOs don't move
|
||||||
|
opvp = sOutdoorPvPMgr.GetScript(((GameObject*)source)->GetZoneId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bg && bg->HandleEvent(id, static_cast<GameObject*>(source)))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (opvp && opvp->HandleEvent(id, static_cast<GameObject*>(source)))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map::ScriptExecutionParam execParam = Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE_TARGET;
|
||||||
|
if (source->isType(TYPEMASK_CREATURE_OR_GAMEOBJECT))
|
||||||
|
execParam = Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE;
|
||||||
|
else if (target && target->isType(TYPEMASK_CREATURE_OR_GAMEOBJECT))
|
||||||
|
execParam = Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_TARGET;
|
||||||
|
|
||||||
|
return map->ScriptsStart(sEventScripts, id, source, target, execParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrappers
|
||||||
uint32 GetAreaTriggerScriptId(uint32 triggerId)
|
uint32 GetAreaTriggerScriptId(uint32 triggerId)
|
||||||
{
|
{
|
||||||
return sScriptMgr.GetAreaTriggerScriptId(triggerId);
|
return sScriptMgr.GetAreaTriggerScriptId(triggerId);
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ enum ScriptCommand // resSource, resTar
|
||||||
SCRIPT_COMMAND_CAST_SPELL = 15, // resSource = Unit, cast spell at resTarget = Unit
|
SCRIPT_COMMAND_CAST_SPELL = 15, // resSource = Unit, cast spell at resTarget = Unit
|
||||||
// datalong=spellid
|
// datalong=spellid
|
||||||
// data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL = cast triggered
|
// data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL = cast triggered
|
||||||
SCRIPT_COMMAND_PLAY_SOUND = 16, // resSource = WorldObject, target=any/player, datalong (sound_id), datalong2 (bitmask: 0/1=anyone/target, 0/2=with distance dependent, so 1|2 = 3 is target with distance dependent)
|
SCRIPT_COMMAND_PLAY_SOUND = 16, // resSource = WorldObject, target=any/player, datalong (sound_id), datalong2 (bitmask: 0/1=target-player, 0/2=with distance dependent, 0/4=map wide, 0/8=zone wide; so 1|2 = 3 is target with distance dependent)
|
||||||
SCRIPT_COMMAND_CREATE_ITEM = 17, // source or target must be player, datalong = item entry, datalong2 = amount
|
SCRIPT_COMMAND_CREATE_ITEM = 17, // source or target must be player, datalong = item entry, datalong2 = amount
|
||||||
SCRIPT_COMMAND_DESPAWN_SELF = 18, // resSource = Creature, datalong = despawn delay
|
SCRIPT_COMMAND_DESPAWN_SELF = 18, // resSource = Creature, datalong = despawn delay
|
||||||
SCRIPT_COMMAND_PLAY_MOVIE = 19, // target can only be a player, datalog = movie id
|
SCRIPT_COMMAND_PLAY_MOVIE = 19, // target can only be a player, datalog = movie id
|
||||||
|
|
@ -91,6 +91,13 @@ enum ScriptCommand // resSource, resTar
|
||||||
// datalong=NPCFlags
|
// datalong=NPCFlags
|
||||||
// datalong2:0x00=toggle, 0x01=add, 0x02=remove
|
// datalong2:0x00=toggle, 0x01=add, 0x02=remove
|
||||||
SCRIPT_COMMAND_SEND_TAXI_PATH = 30, // datalong = taxi path id (source or target must be player)
|
SCRIPT_COMMAND_SEND_TAXI_PATH = 30, // datalong = taxi path id (source or target must be player)
|
||||||
|
SCRIPT_COMMAND_TERMINATE_SCRIPT = 31, // datalong = search for npc entry if provided
|
||||||
|
// datalong2= search distance
|
||||||
|
// data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL: terminate steps of this script if npc found
|
||||||
|
// ELSE: terminate steps of this script if npc not found
|
||||||
|
// dataint=diff to change a waittime of current Waypoint Movement
|
||||||
|
SCRIPT_COMMAND_PAUSE_WAYPOINTS = 32, // resSource = Creature
|
||||||
|
// datalong = 0: unpause waypoint 1: pause waypoint
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_TEXT_ID 4 // used for SCRIPT_COMMAND_TALK
|
#define MAX_TEXT_ID 4 // used for SCRIPT_COMMAND_TALK
|
||||||
|
|
@ -287,12 +294,25 @@ struct ScriptInfo
|
||||||
uint32 change_flag; // datalong2
|
uint32 change_flag; // datalong2
|
||||||
} npcFlag;
|
} npcFlag;
|
||||||
|
|
||||||
struct
|
struct // SCRIPT_COMMAND_SEND_TAXI_PATH (30)
|
||||||
{
|
{
|
||||||
uint32 taxiPathId; // datalong
|
uint32 taxiPathId; // datalong
|
||||||
uint32 empty;
|
uint32 empty;
|
||||||
} sendTaxiPath;
|
} sendTaxiPath;
|
||||||
|
|
||||||
|
struct // SCRIPT_COMMAND_TERMINATE_SCRIPT (31)
|
||||||
|
{
|
||||||
|
uint32 npcEntry; // datalong
|
||||||
|
uint32 searchDist; // datalong2
|
||||||
|
// changeWaypointWaitTime // dataint
|
||||||
|
} terminateScript;
|
||||||
|
|
||||||
|
struct // SCRIPT_COMMAND_PAUSE_WAYPOINTS (32)
|
||||||
|
{
|
||||||
|
uint32 doPause; // datalong
|
||||||
|
uint32 empty;
|
||||||
|
} pauseWaypoint;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint32 data[2];
|
uint32 data[2];
|
||||||
|
|
@ -351,6 +371,7 @@ struct ScriptInfo
|
||||||
case SCRIPT_COMMAND_MOVEMENT:
|
case SCRIPT_COMMAND_MOVEMENT:
|
||||||
case SCRIPT_COMMAND_MORPH_TO_ENTRY_OR_MODEL:
|
case SCRIPT_COMMAND_MORPH_TO_ENTRY_OR_MODEL:
|
||||||
case SCRIPT_COMMAND_MOUNT_TO_ENTRY_OR_MODEL:
|
case SCRIPT_COMMAND_MOUNT_TO_ENTRY_OR_MODEL:
|
||||||
|
case SCRIPT_COMMAND_TERMINATE_SCRIPT:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -365,7 +386,21 @@ class ScriptAction
|
||||||
m_table(_table), m_map(_map), m_sourceGuid(_sourceGuid), m_targetGuid(_targetGuid), m_ownerGuid(_ownerGuid), m_script(_script)
|
m_table(_table), m_map(_map), m_sourceGuid(_sourceGuid), m_targetGuid(_targetGuid), m_ownerGuid(_ownerGuid), m_script(_script)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void HandleScriptStep();
|
bool HandleScriptStep(); // return true IF AND ONLY IF the script should be terminated
|
||||||
|
|
||||||
|
const char* GetTableName() const { return m_table; }
|
||||||
|
uint32 GetId() const { return m_script->id; }
|
||||||
|
ObjectGuid GetSourceGuid() const { return m_sourceGuid; }
|
||||||
|
ObjectGuid GetTargetGuid() const { return m_targetGuid; }
|
||||||
|
ObjectGuid GetOwnerGuid() const { return m_ownerGuid; }
|
||||||
|
|
||||||
|
bool IsSameScript(const char* table, uint32 id, ObjectGuid sourceGuid, ObjectGuid targetGuid, ObjectGuid ownerGuid) const
|
||||||
|
{
|
||||||
|
return table == m_table && id == GetId() &&
|
||||||
|
(sourceGuid == m_sourceGuid || !sourceGuid) &&
|
||||||
|
(targetGuid == m_targetGuid || !targetGuid) &&
|
||||||
|
(ownerGuid == m_ownerGuid || !ownerGuid);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char* m_table; // of which table the script was started
|
const char* m_table; // of which table the script was started
|
||||||
|
|
@ -395,6 +430,7 @@ extern ScriptMapMapName sGameObjectScripts;
|
||||||
extern ScriptMapMapName sGameObjectTemplateScripts;
|
extern ScriptMapMapName sGameObjectTemplateScripts;
|
||||||
extern ScriptMapMapName sEventScripts;
|
extern ScriptMapMapName sEventScripts;
|
||||||
extern ScriptMapMapName sGossipScripts;
|
extern ScriptMapMapName sGossipScripts;
|
||||||
|
extern ScriptMapMapName sCreatureDeathScripts;
|
||||||
extern ScriptMapMapName sCreatureMovementScripts;
|
extern ScriptMapMapName sCreatureMovementScripts;
|
||||||
|
|
||||||
enum ScriptLoadResult
|
enum ScriptLoadResult
|
||||||
|
|
@ -418,6 +454,7 @@ class ScriptMgr
|
||||||
void LoadEventScripts();
|
void LoadEventScripts();
|
||||||
void LoadSpellScripts();
|
void LoadSpellScripts();
|
||||||
void LoadGossipScripts();
|
void LoadGossipScripts();
|
||||||
|
void LoadCreatureDeathScripts();
|
||||||
void LoadCreatureMovementScripts();
|
void LoadCreatureMovementScripts();
|
||||||
|
|
||||||
void LoadDbScriptStrings();
|
void LoadDbScriptStrings();
|
||||||
|
|
@ -468,6 +505,7 @@ class ScriptMgr
|
||||||
bool OnAuraDummy(Aura const* pAura, bool apply);
|
bool OnAuraDummy(Aura const* pAura, bool apply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void CollectPossibleEventIds(std::set<uint32>& eventIds);
|
||||||
void LoadScripts(ScriptMapMapName& scripts, const char* tablename);
|
void LoadScripts(ScriptMapMapName& scripts, const char* tablename);
|
||||||
void CheckScriptTexts(ScriptMapMapName const& scripts, std::set<int32>& ids);
|
void CheckScriptTexts(ScriptMapMapName const& scripts, std::set<int32>& ids);
|
||||||
|
|
||||||
|
|
@ -520,6 +558,9 @@ class ScriptMgr
|
||||||
bool (MANGOS_IMPORT* m_pOnAuraDummy)(Aura const*, bool);
|
bool (MANGOS_IMPORT* m_pOnAuraDummy)(Aura const*, bool);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Starters for events
|
||||||
|
bool StartEvents_Event(Map* map, uint32 id, Object* source, Object* target, bool isStart = true, Unit* forwardToPvp = NULL);
|
||||||
|
|
||||||
#define sScriptMgr MaNGOS::Singleton<ScriptMgr>::Instance()
|
#define sScriptMgr MaNGOS::Singleton<ScriptMgr>::Instance()
|
||||||
|
|
||||||
MANGOS_DLL_SPEC uint32 GetAreaTriggerScriptId(uint32 triggerId);
|
MANGOS_DLL_SPEC uint32 GetAreaTriggerScriptId(uint32 triggerId);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "12558"
|
#define REVISION_NR "12559"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue