Big update.

This commit is contained in:
UltraNix
2022-03-12 22:28:00 +01:00
parent 6006eeeb01
commit 12d41d1314
2064 changed files with 427245 additions and 268481 deletions

View File

@@ -16,6 +16,7 @@
*/
#include "CellImpl.h"
#include "GameTime.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "Map.h"
@@ -53,7 +54,7 @@ void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, O
sa.ownerGUID = ownerGUID;
sa.script = &iter->second;
m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(sWorld->GetGameTime() + iter->first), sa));
m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(GameTime::GetGameTime().count() + iter->first), sa));
if (iter->first == 0)
immedScript = true;
@@ -83,7 +84,7 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou
sa.ownerGUID = ownerGUID;
sa.script = &script;
m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(sWorld->GetGameTime() + delay), sa));
m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(GameTime::GetGameTime().count() + delay), sa));
sScriptMgr->IncreaseScheduledScriptsCount();
@@ -101,7 +102,7 @@ inline Player* Map::_GetScriptPlayerSourceOrTarget(Object* source, Object* targe
{
Player* player = nullptr;
if (!source && !target)
LOG_ERROR("maps.script", "%s source and target objects are nullptr.", scriptInfo->GetDebugInfo().c_str());
LOG_ERROR("maps.script", "{} source and target objects are nullptr.", scriptInfo->GetDebugInfo());
else
{
// Check target first, then source.
@@ -111,7 +112,7 @@ inline Player* Map::_GetScriptPlayerSourceOrTarget(Object* source, Object* targe
player = source->ToPlayer();
if (!player)
LOG_ERROR("maps.script", "%s neither source nor target object is player (source: TypeId: %u, Entry: %u, GUID: %s; target: TypeId: %u, Entry: %u, GUID: %s), skipping.",
LOG_ERROR("maps.script", "{} neither source nor target object is player (source: TypeId: {}, Entry: {}, GUID: {}; target: TypeId: {}, Entry: {}, GUID: {}), skipping.",
scriptInfo->GetDebugInfo().c_str(),
source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUID().ToString().c_str() : "",
target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUID().ToString().c_str() : "");
@@ -123,7 +124,7 @@ inline Creature* Map::_GetScriptCreatureSourceOrTarget(Object* source, Object* t
{
Creature* creature = nullptr;
if (!source && !target)
LOG_ERROR("maps.script", "%s source and target objects are nullptr.", scriptInfo->GetDebugInfo().c_str());
LOG_ERROR("maps.script", "{} source and target objects are nullptr.", scriptInfo->GetDebugInfo());
else
{
if (bReverse)
@@ -144,7 +145,7 @@ inline Creature* Map::_GetScriptCreatureSourceOrTarget(Object* source, Object* t
}
if (!creature)
LOG_ERROR("maps.script", "%s neither source nor target are creatures (source: TypeId: %u, Entry: %u, GUID: %s; target: TypeId: %u, Entry: %u, GUID: %s), skipping.",
LOG_ERROR("maps.script", "{} neither source nor target are creatures (source: TypeId: {}, Entry: {}, GUID: {}; target: TypeId: {}, Entry: {}, GUID: {}), skipping.",
scriptInfo->GetDebugInfo().c_str(),
source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUID().ToString().c_str() : "",
target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUID().ToString().c_str() : "");
@@ -156,16 +157,16 @@ inline Unit* Map::_GetScriptUnit(Object* obj, bool isSource, const ScriptInfo* s
{
Unit* unit = nullptr;
if (!obj)
LOG_ERROR("maps.script", "%s %s object is nullptr.", scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
LOG_ERROR("maps.script", "{} {} object is nullptr.", scriptInfo->GetDebugInfo(), isSource ? "source" : "target");
else if (!obj->isType(TYPEMASK_UNIT))
LOG_ERROR("maps.script", "%s %s object is not unit (TypeId: %u, Entry: %u, GUID: %s), skipping.",
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUID().ToString().c_str());
LOG_ERROR("maps.script", "{} {} object is not unit (TypeId: {}, Entry: {}, GUID: {}), skipping.",
scriptInfo->GetDebugInfo(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUID().ToString());
else
{
unit = obj->ToUnit();
if (!unit)
LOG_ERROR("maps.script", "%s %s object could not be casted to unit.",
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
LOG_ERROR("maps.script", "{} {} object could not be casted to unit.",
scriptInfo->GetDebugInfo(), isSource ? "source" : "target");
}
return unit;
}
@@ -174,13 +175,13 @@ inline Player* Map::_GetScriptPlayer(Object* obj, bool isSource, const ScriptInf
{
Player* player = nullptr;
if (!obj)
LOG_ERROR("maps.script", "%s %s object is nullptr.", scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
LOG_ERROR("maps.script", "{} {} object is nullptr.", scriptInfo->GetDebugInfo(), isSource ? "source" : "target");
else
{
player = obj->ToPlayer();
if (!player)
LOG_ERROR("maps.script", "%s %s object is not a player (%s).",
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetGUID().ToString().c_str());
LOG_ERROR("maps.script", "{} {} object is not a player ({}).",
scriptInfo->GetDebugInfo(), isSource ? "source" : "target", obj->GetGUID().ToString());
}
return player;
}
@@ -189,13 +190,13 @@ inline Creature* Map::_GetScriptCreature(Object* obj, bool isSource, const Scrip
{
Creature* creature = nullptr;
if (!obj)
LOG_ERROR("maps.script", "%s %s object is nullptr.", scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
LOG_ERROR("maps.script", "{} {} object is nullptr.", scriptInfo->GetDebugInfo(), isSource ? "source" : "target");
else
{
creature = obj->ToCreature();
if (!creature)
LOG_ERROR("maps.script", "%s %s object is not a creature (%s).", scriptInfo->GetDebugInfo().c_str(),
isSource ? "source" : "target", obj->GetGUID().ToString().c_str());
LOG_ERROR("maps.script", "{} {} object is not a creature ({}).", scriptInfo->GetDebugInfo(),
isSource ? "source" : "target", obj->GetGUID().ToString());
}
return creature;
}
@@ -204,14 +205,14 @@ inline WorldObject* Map::_GetScriptWorldObject(Object* obj, bool isSource, const
{
WorldObject* pWorldObject = nullptr;
if (!obj)
LOG_ERROR("maps.script", "%s %s object is nullptr.",
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
LOG_ERROR("maps.script", "{} {} object is nullptr.",
scriptInfo->GetDebugInfo(), isSource ? "source" : "target");
else
{
pWorldObject = dynamic_cast<WorldObject*>(obj);
if (!pWorldObject)
LOG_ERROR("maps.script", "%s %s object is not a world object (%s).",
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetGUID().ToString().c_str());
LOG_ERROR("maps.script", "{} {} object is not a world object ({}).",
scriptInfo->GetDebugInfo(), isSource ? "source" : "target", obj->GetGUID().ToString());
}
return pWorldObject;
}
@@ -229,28 +230,28 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script
case SCRIPT_COMMAND_CLOSE_DOOR:
break;
default:
LOG_ERROR("maps.script", "%s unknown command for _ScriptProcessDoor.", scriptInfo->GetDebugInfo().c_str());
LOG_ERROR("maps.script", "{} unknown command for _ScriptProcessDoor.", scriptInfo->GetDebugInfo());
return;
}
if (!guid)
LOG_ERROR("maps.script", "%s door guid is not specified.", scriptInfo->GetDebugInfo().c_str());
LOG_ERROR("maps.script", "{} door guid is not specified.", scriptInfo->GetDebugInfo());
else if (!source)
LOG_ERROR("maps.script", "%s source object is nullptr.", scriptInfo->GetDebugInfo().c_str());
LOG_ERROR("maps.script", "{} source object is nullptr.", scriptInfo->GetDebugInfo());
else if (!source->isType(TYPEMASK_UNIT))
LOG_ERROR("maps.script", "%s source object is not unit (%s), skipping.", scriptInfo->GetDebugInfo().c_str(), source->GetGUID().ToString().c_str());
LOG_ERROR("maps.script", "{} source object is not unit ({}), skipping.", scriptInfo->GetDebugInfo(), source->GetGUID().ToString());
else
{
WorldObject* wSource = dynamic_cast <WorldObject*> (source);
if (!wSource)
LOG_ERROR("maps.script", "%s source object could not be casted to world object (%s), skipping.", scriptInfo->GetDebugInfo().c_str(), source->GetGUID().ToString().c_str());
LOG_ERROR("maps.script", "{} source object could not be casted to world object ({}), skipping.", scriptInfo->GetDebugInfo(), source->GetGUID().ToString());
else
{
GameObject* pDoor = _FindGameObject(wSource, guid);
if (!pDoor)
LOG_ERROR("maps.script", "%s gameobject was not found (guid: %u).", scriptInfo->GetDebugInfo().c_str(), guid);
LOG_ERROR("maps.script", "{} gameobject was not found (guid: {}).", scriptInfo->GetDebugInfo(), guid);
else if (pDoor->GetGoType() != GAMEOBJECT_TYPE_DOOR)
LOG_ERROR("maps.script", "%s gameobject is not a door (%s).",
scriptInfo->GetDebugInfo().c_str(), pDoor->GetGUID().ToString().c_str());
LOG_ERROR("maps.script", "{} gameobject is not a door ({}).",
scriptInfo->GetDebugInfo(), pDoor->GetGUID().ToString());
else if (bOpen == (pDoor->GetGoState() == GO_STATE_READY))
{
pDoor->UseDoorOrButton(nTimeToToggle);
@@ -284,7 +285,7 @@ void Map::ScriptsProcess()
///- Process overdue queued scripts
ScriptScheduleMap::iterator iter = m_scriptSchedule.begin();
// ok as multimap is a *sorted* associative container
while (!m_scriptSchedule.empty() && (iter->first <= sWorld->GetGameTime()))
while (!m_scriptSchedule.empty() && (iter->first <= GameTime::GetGameTime().count()))
{
ScriptAction const& step = iter->second;
@@ -318,8 +319,8 @@ void Map::ScriptsProcess()
source = GetTransport(step.sourceGUID);
break;
default:
LOG_ERROR("maps.script", "%s source with unsupported high guid (%s).",
step.script->GetDebugInfo().c_str(), step.sourceGUID.ToString().c_str());
LOG_ERROR("maps.script", "{} source with unsupported high guid ({}).",
step.script->GetDebugInfo(), step.sourceGUID.ToString());
break;
}
}
@@ -350,8 +351,8 @@ void Map::ScriptsProcess()
target = GetTransport(step.targetGUID);
break;
default:
LOG_ERROR("maps.script", "%s target with unsupported high guid (%s).",
step.script->GetDebugInfo().c_str(), step.targetGUID.ToString().c_str());
LOG_ERROR("maps.script", "{} target with unsupported high guid ({}).",
step.script->GetDebugInfo(), step.targetGUID.ToString());
break;
}
}
@@ -362,7 +363,7 @@ void Map::ScriptsProcess()
{
if (step.script->Talk.ChatType > CHAT_TYPE_WHISPER && step.script->Talk.ChatType != CHAT_MSG_RAID_BOSS_WHISPER)
{
LOG_ERROR("maps.script", "%s invalid chat type (%u) specified, skipping.", step.script->GetDebugInfo().c_str(), step.script->Talk.ChatType);
LOG_ERROR("maps.script", "{} invalid chat type ({}) specified, skipping.", step.script->GetDebugInfo(), step.script->Talk.ChatType);
break;
}
@@ -380,7 +381,7 @@ void Map::ScriptsProcess()
Unit* sourceUnit = source->ToUnit();
if (!sourceUnit)
{
LOG_ERROR("scripts", "%s source object (%s) is not an unit, skipping.", step.script->GetDebugInfo().c_str(), source->GetGUID().ToString().c_str());
LOG_ERROR("scripts", "{} source object ({}) is not an unit, skipping.", step.script->GetDebugInfo(), source->GetGUID().ToString());
break;
}
@@ -401,7 +402,7 @@ void Map::ScriptsProcess()
{
Player* receiver = target ? target->ToPlayer() : nullptr;
if (!receiver)
LOG_ERROR("scripts", "%s attempt to whisper to non-player unit, skipping.", step.script->GetDebugInfo().c_str());
LOG_ERROR("scripts", "{} attempt to whisper to non-player unit, skipping.", step.script->GetDebugInfo());
else
sourceUnit->Whisper(step.script->Talk.TextID, receiver, step.script->Talk.ChatType == CHAT_MSG_RAID_BOSS_WHISPER);
break;
@@ -429,8 +430,8 @@ void Map::ScriptsProcess()
{
// Validate field number.
if (step.script->FieldSet.FieldID <= OBJECT_FIELD_ENTRY || step.script->FieldSet.FieldID >= cSource->GetValuesCount())
LOG_ERROR("maps.script", "%s wrong field %u (max count: %u) in object (%s) specified, skipping.",
step.script->GetDebugInfo().c_str(), step.script->FieldSet.FieldID, cSource->GetValuesCount(), cSource->GetGUID().ToString().c_str());
LOG_ERROR("maps.script", "{} wrong field {} (max count: {}) in object ({}) specified, skipping.",
step.script->GetDebugInfo(), step.script->FieldSet.FieldID, cSource->GetValuesCount(), cSource->GetGUID().ToString());
else
cSource->SetUInt32Value(step.script->FieldSet.FieldID, step.script->FieldSet.FieldValue);
}
@@ -457,8 +458,8 @@ void Map::ScriptsProcess()
{
// Validate field number.
if (step.script->FlagToggle.FieldID <= OBJECT_FIELD_ENTRY || step.script->FlagToggle.FieldID >= cSource->GetValuesCount())
LOG_ERROR("maps.script", "%s wrong field %u (max count: %u) in object (%s) specified, skipping.",
step.script->GetDebugInfo().c_str(), step.script->FlagToggle.FieldID, cSource->GetValuesCount(), cSource->GetGUID().ToString().c_str());
LOG_ERROR("maps.script", "{} wrong field {} (max count: {}) in object ({}) specified, skipping.",
step.script->GetDebugInfo(), step.script->FlagToggle.FieldID, cSource->GetValuesCount(), cSource->GetGUID().ToString());
else
cSource->SetFlag(step.script->FlagToggle.FieldID, step.script->FlagToggle.FieldValue);
}
@@ -470,8 +471,8 @@ void Map::ScriptsProcess()
{
// Validate field number.
if (step.script->FlagToggle.FieldID <= OBJECT_FIELD_ENTRY || step.script->FlagToggle.FieldID >= cSource->GetValuesCount())
LOG_ERROR("maps.script", "%s wrong field %u (max count: %u) in object (%s) specified, skipping.",
step.script->GetDebugInfo().c_str(), step.script->FlagToggle.FieldID, cSource->GetValuesCount(), cSource->GetGUID().ToString().c_str());
LOG_ERROR("maps.script", "{} wrong field {} (max count: {}) in object ({}) specified, skipping.",
step.script->GetDebugInfo(), step.script->FlagToggle.FieldID, cSource->GetValuesCount(), cSource->GetGUID().ToString());
else
cSource->RemoveFlag(step.script->FlagToggle.FieldID, step.script->FlagToggle.FieldValue);
}
@@ -496,12 +497,12 @@ void Map::ScriptsProcess()
{
if (!source)
{
LOG_ERROR("maps.script", "%s source object is nullptr.", step.script->GetDebugInfo().c_str());
LOG_ERROR("maps.script", "{} source object is nullptr.", step.script->GetDebugInfo());
break;
}
if (!target)
{
LOG_ERROR("maps.script", "%s target object is nullptr.", step.script->GetDebugInfo().c_str());
LOG_ERROR("maps.script", "{} target object is nullptr.", step.script->GetDebugInfo());
break;
}
@@ -512,7 +513,7 @@ void Map::ScriptsProcess()
{
if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER)
{
LOG_ERROR("maps.script", "%s source is not unit, gameobject or player (%s), skipping.", step.script->GetDebugInfo().c_str(), source->GetGUID().ToString().c_str());
LOG_ERROR("maps.script", "{} source is not unit, gameobject or player ({}), skipping.", step.script->GetDebugInfo(), source->GetGUID().ToString());
break;
}
worldObject = dynamic_cast<WorldObject*>(source);
@@ -524,14 +525,14 @@ void Map::ScriptsProcess()
{
if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER)
{
LOG_ERROR("maps.script", "%s target is not unit, gameobject or player (%s), skipping.", step.script->GetDebugInfo().c_str(), target->GetGUID().ToString().c_str());
LOG_ERROR("maps.script", "{} target is not unit, gameobject or player ({}), skipping.", step.script->GetDebugInfo(), target->GetGUID().ToString());
break;
}
worldObject = dynamic_cast<WorldObject*>(target);
}
else
{
LOG_ERROR("maps.script", "%s neither source nor target is player (source: %s; target: %s), skipping.",
LOG_ERROR("maps.script", "{} neither source nor target is player (source: {}; target: {}), skipping.",
step.script->GetDebugInfo().c_str(), source->GetGUID().ToString().c_str(), target->GetGUID().ToString().c_str());
break;
}
@@ -561,7 +562,7 @@ void Map::ScriptsProcess()
case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT:
if (!step.script->RespawnGameobject.GOGuid)
{
LOG_ERROR("maps.script", "%s gameobject guid (datalong) is not specified.", step.script->GetDebugInfo().c_str());
LOG_ERROR("maps.script", "{} gameobject guid (datalong) is not specified.", step.script->GetDebugInfo());
break;
}
@@ -571,7 +572,7 @@ void Map::ScriptsProcess()
GameObject* pGO = _FindGameObject(pSummoner, step.script->RespawnGameobject.GOGuid);
if (!pGO)
{
LOG_ERROR("maps.script", "%s gameobject was not found (guid: %u).", step.script->GetDebugInfo().c_str(), step.script->RespawnGameobject.GOGuid);
LOG_ERROR("maps.script", "{} gameobject was not found (guid: {}).", step.script->GetDebugInfo(), step.script->RespawnGameobject.GOGuid);
break;
}
@@ -580,8 +581,8 @@ void Map::ScriptsProcess()
pGO->GetGoType() == GAMEOBJECT_TYPE_BUTTON ||
pGO->GetGoType() == GAMEOBJECT_TYPE_TRAP)
{
LOG_ERROR("maps.script", "%s can not be used with gameobject of type %u (guid: %u).",
step.script->GetDebugInfo().c_str(), uint32(pGO->GetGoType()), step.script->RespawnGameobject.GOGuid);
LOG_ERROR("maps.script", "{} can not be used with gameobject of type {} (guid: {}).",
step.script->GetDebugInfo(), uint32(pGO->GetGoType()), step.script->RespawnGameobject.GOGuid);
break;
}
@@ -603,7 +604,7 @@ void Map::ScriptsProcess()
if (WorldObject* pSummoner = _GetScriptWorldObject(source, true, step.script))
{
if (!step.script->TempSummonCreature.CreatureEntry)
LOG_ERROR("maps.script", "%s creature entry (datalong) is not specified.", step.script->GetDebugInfo().c_str());
LOG_ERROR("maps.script", "{} creature entry (datalong) is not specified.", step.script->GetDebugInfo());
else
{
uint32 entry = step.script->TempSummonCreature.CreatureEntry;
@@ -619,7 +620,7 @@ void Map::ScriptsProcess()
break;
if (!pSummoner->SummonCreature(entry, x, y, z, o, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, step.script->TempSummonCreature.DespawnDelay))
LOG_ERROR("maps.script", "%s creature was not spawned (entry: %u).", step.script->GetDebugInfo().c_str(), step.script->TempSummonCreature.CreatureEntry);
LOG_ERROR("maps.script", "{} creature was not spawned (entry: {}).", step.script->GetDebugInfo(), step.script->TempSummonCreature.CreatureEntry);
}
}
break;
@@ -637,13 +638,13 @@ void Map::ScriptsProcess()
// Target must be GameObject.
if (!target)
{
LOG_ERROR("maps.script", "%s target object is nullptr.", step.script->GetDebugInfo().c_str());
LOG_ERROR("maps.script", "{} target object is nullptr.", step.script->GetDebugInfo());
break;
}
if (target->GetTypeId() != TYPEID_GAMEOBJECT)
{
LOG_ERROR("maps.script", "%s target object is not gameobject (%s), skipping.", step.script->GetDebugInfo().c_str(), target->GetGUID().ToString().c_str());
LOG_ERROR("maps.script", "{} target object is not gameobject ({}), skipping.", step.script->GetDebugInfo(), target->GetGUID().ToString());
break;
}
@@ -666,7 +667,7 @@ void Map::ScriptsProcess()
// TODO: Allow gameobjects to be targets and casters
if (!source && !target)
{
LOG_ERROR("maps.script", "%s source and target objects are nullptr.", step.script->GetDebugInfo().c_str());
LOG_ERROR("maps.script", "{} source and target objects are nullptr.", step.script->GetDebugInfo());
break;
}
@@ -693,19 +694,19 @@ void Map::ScriptsProcess()
break;
case SF_CASTSPELL_SEARCH_CREATURE: // source -> creature with entry
uSource = source ? source->ToUnit() : nullptr;
uTarget = uSource ? GetClosestCreatureWithEntry(uSource, abs(step.script->CastSpell.CreatureEntry), step.script->CastSpell.SearchRadius) : nullptr;
uTarget = uSource ? GetClosestCreatureWithEntry(uSource, std::abs(step.script->CastSpell.CreatureEntry), step.script->CastSpell.SearchRadius) : nullptr;
break;
}
if (!uSource || !uSource->isType(TYPEMASK_UNIT))
{
LOG_ERROR("maps.script", "%s no source unit found for spell %u", step.script->GetDebugInfo().c_str(), step.script->CastSpell.SpellID);
LOG_ERROR("maps.script", "{} no source unit found for spell {}", step.script->GetDebugInfo(), step.script->CastSpell.SpellID);
break;
}
if (!uTarget || !uTarget->isType(TYPEMASK_UNIT))
{
LOG_ERROR("maps.script", "%s no target unit found for spell %u", step.script->GetDebugInfo().c_str(), step.script->CastSpell.SpellID);
LOG_ERROR("maps.script", "{} no target unit found for spell {}", step.script->GetDebugInfo(), step.script->CastSpell.SpellID);
break;
}
@@ -720,9 +721,9 @@ void Map::ScriptsProcess()
// Source must be WorldObject.
if (WorldObject* object = _GetScriptWorldObject(source, true, step.script))
{
// PlaySound.Flags bitmask: 0/1=anyone/target
// Playsound.Flags bitmask: 0/1=anyone/target
Player* player = nullptr;
if (step.script->PlaySound.Flags & SF_PLAYSOUND_TARGET_PLAYER)
if (step.script->Playsound.Flags & SF_PLAYSOUND_TARGET_PLAYER)
{
// Target must be Player.
player = _GetScriptPlayer(target, false, step.script);
@@ -730,11 +731,11 @@ void Map::ScriptsProcess()
break;
}
// PlaySound.Flags bitmask: 0/2=without/with distance dependent
if (step.script->PlaySound.Flags & SF_PLAYSOUND_DISTANCE_SOUND)
object->PlayDistanceSound(step.script->PlaySound.SoundID, player);
// Playsound.Flags bitmask: 0/2=without/with distance dependent
if (step.script->Playsound.Flags & SF_PLAYSOUND_DISTANCE_SOUND)
object->PlayDistanceSound(step.script->Playsound.SoundID, player);
else
object->PlayDirectSound(step.script->PlaySound.SoundID, player);
object->PlayDirectSound(step.script->Playsound.SoundID, player);
}
break;
@@ -765,7 +766,7 @@ void Map::ScriptsProcess()
if (Unit* unit = _GetScriptUnit(source, true, step.script))
{
if (!sWaypointMgr->GetPath(step.script->LoadPath.PathID))
LOG_ERROR("maps.script", "%s source object has an invalid path (%u), skipping.", step.script->GetDebugInfo().c_str(), step.script->LoadPath.PathID);
LOG_ERROR("maps.script", "{} source object has an invalid path ({}), skipping.", step.script->GetDebugInfo(), step.script->LoadPath.PathID);
else
unit->GetMotionMaster()->MovePath(step.script->LoadPath.PathID, step.script->LoadPath.IsRepeatable);
}
@@ -775,12 +776,12 @@ void Map::ScriptsProcess()
{
if (!step.script->CallScript.CreatureEntry)
{
LOG_ERROR("maps.script", "%s creature entry is not specified, skipping.", step.script->GetDebugInfo().c_str());
LOG_ERROR("maps.script", "{} creature entry is not specified, skipping.", step.script->GetDebugInfo());
break;
}
if (!step.script->CallScript.ScriptID)
{
LOG_ERROR("maps.script", "%s script id is not specified, skipping.", step.script->GetDebugInfo().c_str());
LOG_ERROR("maps.script", "{} script id is not specified, skipping.", step.script->GetDebugInfo());
break;
}
@@ -798,7 +799,7 @@ void Map::ScriptsProcess()
if (!cTarget)
{
LOG_ERROR("maps.script", "%s target was not found (entry: %u)", step.script->GetDebugInfo().c_str(), step.script->CallScript.CreatureEntry);
LOG_ERROR("maps.script", "{} target was not found (entry: {})", step.script->GetDebugInfo(), step.script->CallScript.CreatureEntry);
break;
}
@@ -807,7 +808,7 @@ void Map::ScriptsProcess()
//if no scriptmap present...
if (!datamap)
{
LOG_ERROR("maps.script", "%s unknown scriptmap (%u) specified, skipping.", step.script->GetDebugInfo().c_str(), step.script->CallScript.ScriptType);
LOG_ERROR("maps.script", "{} unknown scriptmap ({}) specified, skipping.", step.script->GetDebugInfo(), step.script->CallScript.ScriptType);
break;
}
@@ -821,7 +822,7 @@ void Map::ScriptsProcess()
if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
{
if (cSource->isDead())
LOG_ERROR("maps.script", "%s creature is already dead (%s)", step.script->GetDebugInfo().c_str(), cSource->GetGUID().ToString().c_str());
LOG_ERROR("maps.script", "{} creature is already dead ({})", step.script->GetDebugInfo(), cSource->GetGUID().ToString());
else
{
cSource->setDeathState(JUST_DIED);
@@ -896,7 +897,7 @@ void Map::ScriptsProcess()
break;
default:
LOG_ERROR("maps.script", "Unknown script command %s.", step.script->GetDebugInfo().c_str());
LOG_ERROR("maps.script", "Unknown script command {}.", step.script->GetDebugInfo());
break;
}

View File

@@ -0,0 +1,83 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnAccountLogin(uint32 accountId)
{
ExecuteScript<AccountScript>([&](AccountScript* script)
{
script->OnAccountLogin(accountId);
});
}
//void ScriptMgr::OnAccountLogout(uint32 accountId)
//{
// ExecuteScript<AccountScript>([&](AccountScript* script)
// {
// script->OnAccountLogout(accountId);
// });
//}
void ScriptMgr::OnLastIpUpdate(uint32 accountId, std::string ip)
{
ExecuteScript<AccountScript>([&](AccountScript* script)
{
script->OnLastIpUpdate(accountId, ip);
});
}
void ScriptMgr::OnFailedAccountLogin(uint32 accountId)
{
ExecuteScript<AccountScript>([&](AccountScript* script)
{
script->OnFailedAccountLogin(accountId);
});
}
void ScriptMgr::OnEmailChange(uint32 accountId)
{
ExecuteScript<AccountScript>([&](AccountScript* script)
{
script->OnEmailChange(accountId);
});
}
void ScriptMgr::OnFailedEmailChange(uint32 accountId)
{
ExecuteScript<AccountScript>([&](AccountScript* script)
{
script->OnFailedEmailChange(accountId);
});
}
void ScriptMgr::OnPasswordChange(uint32 accountId)
{
ExecuteScript<AccountScript>([&](AccountScript* script)
{
script->OnPasswordChange(accountId);
});
}
void ScriptMgr::OnFailedPasswordChange(uint32 accountId)
{
ExecuteScript<AccountScript>([&](AccountScript* script)
{
script->OnFailedPasswordChange(accountId);
});
}

View File

@@ -0,0 +1,27 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
bool ScriptMgr::OnCriteriaCheck(uint32 scriptId, Player* source, Unit* target, uint32 criteria_id)
{
ASSERT(source);
// target can be nullptr.
auto tempScript = ScriptRegistry<AchievementCriteriaScript>::GetScriptById(scriptId);
return tempScript ? tempScript->OnCheck(source, target, criteria_id) : false;
}

View File

@@ -0,0 +1,80 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::SetRealmCompleted(AchievementEntry const* achievement)
{
ExecuteScript<AchievementScript>([&](AchievementScript* script)
{
script->SetRealmCompleted(achievement);
});
}
bool ScriptMgr::IsCompletedCriteria(AchievementMgr* mgr, AchievementCriteriaEntry const* achievementCriteria, AchievementEntry const* achievement, CriteriaProgress const* progress)
{
auto ret = IsValidBoolScript<AchievementScript>([&](AchievementScript* script)
{
return !script->IsCompletedCriteria(mgr, achievementCriteria, achievement, progress);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::IsRealmCompleted(AchievementGlobalMgr const* globalmgr, AchievementEntry const* achievement, SystemTimePoint completionTime)
{
auto ret = IsValidBoolScript<AchievementScript>([&](AchievementScript* script)
{
return !script->IsRealmCompleted(globalmgr, achievement, completionTime);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnBeforeCheckCriteria(AchievementMgr* mgr, AchievementCriteriaEntryList const* achievementCriteriaList)
{
ExecuteScript<AchievementScript>([&](AchievementScript* script)
{
script->OnBeforeCheckCriteria(mgr, achievementCriteriaList);
});
}
bool ScriptMgr::CanCheckCriteria(AchievementMgr* mgr, AchievementCriteriaEntry const* achievementCriteria)
{
auto ret = IsValidBoolScript<AchievementScript>([&](AchievementScript* script)
{
return !script->CanCheckCriteria(mgr, achievementCriteria);
});
if (ret && *ret)
{
return false;
}
return true;
}

View File

@@ -0,0 +1,60 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnCreatureAddWorld(Creature* creature)
{
ASSERT(creature);
ExecuteScript<AllCreatureScript>([&](AllCreatureScript* script)
{
script->OnCreatureAddWorld(creature);
});
}
void ScriptMgr::OnCreatureRemoveWorld(Creature* creature)
{
ASSERT(creature);
ExecuteScript<AllCreatureScript>([&](AllCreatureScript* script)
{
script->OnCreatureRemoveWorld(creature);
});
}
void ScriptMgr::Creature_SelectLevel(const CreatureTemplate* cinfo, Creature* creature)
{
ExecuteScript<AllCreatureScript>([&](AllCreatureScript* script)
{
script->Creature_SelectLevel(cinfo, creature);
});
}
//bool ScriptMgr::CanCreatureSendListInventory(Player* player, Creature* creature, uint32 vendorEntry)
//{
// auto ret = IsValidBoolScript<AllCreatureScript>([&](AllCreatureScript* script)
// {
// return !script->CanCreatureSendListInventory(player, creature, vendorEntry);
// });
//
// if (ret && *ret)
// return false;
//
// return true;
//}

View File

@@ -0,0 +1,39 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnGameObjectAddWorld(GameObject* go)
{
ASSERT(go);
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
script->OnGameObjectAddWorld(go);
});
}
void ScriptMgr::OnGameObjectRemoveWorld(GameObject* go)
{
ASSERT(go);
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
script->OnGameObjectRemoveWorld(go);
});
}

View File

@@ -0,0 +1,353 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
namespace
{
template<class ScriptName>
inline void ForeachMaps([[maybe_unused]] Map* map, [[maybe_unused]] std::function<void(ScriptName*)> executeHook)
{
static_assert(Acore::dependant_false_v<ScriptName>, "Unsupported type used for ForeachMaps");
}
template<>
inline void ForeachMaps(Map* map, std::function<void(WorldMapScript*)> executeHook)
{
auto mapEntry = map->GetEntry();
if (!mapEntry)
{
return;
}
if (!mapEntry->IsWorldMap())
{
return;
}
if (ScriptRegistry<WorldMapScript>::ScriptPointerList.empty())
{
return;
}
for (auto const& [scriptID, script] : ScriptRegistry<WorldMapScript>::ScriptPointerList)
{
MapEntry const* mapEntry = script->GetEntry();
if (!mapEntry)
{
continue;
}
if (mapEntry->MapID != map->GetId())
{
continue;
}
executeHook(script);
return;
}
}
template<>
inline void ForeachMaps(Map* map, std::function<void(InstanceMapScript*)> executeHook)
{
auto mapEntry = map->GetEntry();
if (!mapEntry)
{
return;
}
if (!mapEntry->IsDungeon())
{
return;
}
if (ScriptRegistry<InstanceMapScript>::ScriptPointerList.empty())
{
return;
}
for (auto const& [scriptID, script] : ScriptRegistry<InstanceMapScript>::ScriptPointerList)
{
MapEntry const* mapEntry = script->GetEntry();
if (!mapEntry)
{
continue;
}
if (mapEntry->MapID != map->GetId())
{
continue;
}
executeHook(script);
return;
}
}
template<>
inline void ForeachMaps(Map* map, std::function<void(BattlegroundMapScript*)> executeHook)
{
auto mapEntry = map->GetEntry();
if (!mapEntry)
{
return;
}
if (!mapEntry->IsBattleground())
{
return;
}
if (ScriptRegistry<BattlegroundMapScript>::ScriptPointerList.empty())
{
return;
}
for (auto const& [scriptID, script] : ScriptRegistry<BattlegroundMapScript>::ScriptPointerList)
{
MapEntry const* mapEntry = script->GetEntry();
if (!mapEntry)
{
continue;
}
if (mapEntry->MapID != map->GetId())
{
continue;
}
executeHook(script);
return;
}
}
}
void ScriptMgr::OnCreateMap(Map* map)
{
ASSERT(map);
ExecuteScript<AllMapScript>([&](AllMapScript* script)
{
script->OnCreateMap(map);
});
ForeachMaps<WorldMapScript>(map,
[&](WorldMapScript* script)
{
script->OnCreate(map);
});
ForeachMaps<InstanceMapScript>(map,
[&](InstanceMapScript* script)
{
script->OnCreate((InstanceMap*)map);
});
ForeachMaps<BattlegroundMapScript>(map,
[&](BattlegroundMapScript* script)
{
script->OnCreate((BattlegroundMap*)map);
});
}
void ScriptMgr::OnDestroyMap(Map* map)
{
ASSERT(map);
ExecuteScript<AllMapScript>([&](AllMapScript* script)
{
script->OnDestroyMap(map);
});
ForeachMaps<WorldMapScript>(map,
[&](WorldMapScript* script)
{
script->OnDestroy(map);
});
ForeachMaps<InstanceMapScript>(map,
[&](InstanceMapScript* script)
{
script->OnDestroy((InstanceMap*)map);
});
ForeachMaps<BattlegroundMapScript>(map,
[&](BattlegroundMapScript* script)
{
script->OnDestroy((BattlegroundMap*)map);
});
}
void ScriptMgr::OnLoadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy)
{
ASSERT(map);
ASSERT(gmap);
ForeachMaps<WorldMapScript>(map,
[&](WorldMapScript* script)
{
script->OnLoadGridMap(map, gmap, gx, gy);
});
ForeachMaps<InstanceMapScript>(map,
[&](InstanceMapScript* script)
{
script->OnLoadGridMap((InstanceMap*)map, gmap, gx, gy);
});
ForeachMaps<BattlegroundMapScript>(map,
[&](BattlegroundMapScript* script)
{
script->OnLoadGridMap((BattlegroundMap*)map, gmap, gx, gy);
});
}
void ScriptMgr::OnUnloadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy)
{
ASSERT(map);
ASSERT(gmap);
ForeachMaps<WorldMapScript>(map,
[&](WorldMapScript* script)
{
script->OnUnloadGridMap(map, gmap, gx, gy);
});
ForeachMaps<InstanceMapScript>(map,
[&](InstanceMapScript* script)
{
script->OnUnloadGridMap((InstanceMap*)map, gmap, gx, gy);
});
ForeachMaps<BattlegroundMapScript>(map,
[&](BattlegroundMapScript* script)
{
script->OnUnloadGridMap((BattlegroundMap*)map, gmap, gx, gy);
});
}
void ScriptMgr::OnPlayerEnterMap(Map* map, Player* player)
{
ASSERT(map);
ASSERT(player);
ExecuteScript<AllMapScript>([&](AllMapScript* script)
{
script->OnPlayerEnterAll(map, player);
});
ExecuteScript<PlayerScript>([&](PlayerScript* script)
{
script->OnMapChanged(player);
});
ForeachMaps<WorldMapScript>(map,
[&](WorldMapScript* script)
{
script->OnPlayerEnter(map, player);
});
ForeachMaps<InstanceMapScript>(map,
[&](InstanceMapScript* script)
{
script->OnPlayerEnter((InstanceMap*)map, player);
});
ForeachMaps<BattlegroundMapScript>(map,
[&](BattlegroundMapScript* script)
{
script->OnPlayerEnter((BattlegroundMap*)map, player);
});
}
void ScriptMgr::OnPlayerLeaveMap(Map* map, Player* player)
{
ASSERT(map);
ASSERT(player);
ExecuteScript<AllMapScript>([&](AllMapScript* script)
{
script->OnPlayerLeaveAll(map, player);
});
ForeachMaps<WorldMapScript>(map,
[&](WorldMapScript* script)
{
script->OnPlayerLeave(map, player);
});
ForeachMaps<InstanceMapScript>(map,
[&](InstanceMapScript* script)
{
script->OnPlayerLeave((InstanceMap*)map, player);
});
ForeachMaps<BattlegroundMapScript>(map,
[&](BattlegroundMapScript* script)
{
script->OnPlayerLeave((BattlegroundMap*)map, player);
});
}
void ScriptMgr::OnMapUpdate(Map* map, uint32 diff)
{
ASSERT(map);
ExecuteScript<AllMapScript>([&](AllMapScript* script)
{
script->OnMapUpdate(map, diff);
});
ForeachMaps<WorldMapScript>(map,
[&](WorldMapScript* script)
{
script->OnUpdate(map, diff);
});
ForeachMaps<InstanceMapScript>(map,
[&](InstanceMapScript* script)
{
script->OnUpdate((InstanceMap*)map, diff);
});
ForeachMaps<BattlegroundMapScript>(map,
[&](BattlegroundMapScript* script)
{
script->OnUpdate((BattlegroundMap*)map, diff);
});
}
void ScriptMgr::OnBeforeCreateInstanceScript(InstanceMap* instanceMap, InstanceScript* instanceData, bool load, std::string data, uint32 completedEncounterMask)
{
ExecuteScript<AllMapScript>([&](AllMapScript* script)
{
script->OnBeforeCreateInstanceScript(instanceMap, instanceData, load, data, completedEncounterMask);
});
}
void ScriptMgr::OnDestroyInstance(MapInstanced* mapInstanced, Map* map)
{
ExecuteScript<AllMapScript>([&](AllMapScript* script)
{
script->OnDestroyInstance(mapInstanced, map);
});
}

View File

@@ -0,0 +1,38 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
bool ScriptMgr::OnAreaTrigger(Player* player, AreaTrigger const* trigger)
{
ASSERT(player);
ASSERT(trigger);
auto ret = IsValidBoolScript<ElunaScript>([&](ElunaScript* script)
{
return script->CanAreaTrigger(player, trigger);
});
if (ret && *ret)
{
return false;
}
auto tempScript = ScriptRegistry<AreaTriggerScript>::GetScriptById(sObjectMgr->GetAreaTriggerScriptId(trigger->entry));
return tempScript ? tempScript->OnTrigger(player, trigger) : false;
}

View File

@@ -0,0 +1,57 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
bool ScriptMgr::CanAddMember(ArenaTeam* team, ObjectGuid PlayerGuid)
{
auto ret = IsValidBoolScript<ArenaScript>([&](ArenaScript* script)
{
return !script->CanAddMember(team, PlayerGuid);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnGetPoints(ArenaTeam* team, uint32 memberRating, float& points)
{
ExecuteScript<ArenaScript>([&](ArenaScript* script)
{
script->OnGetPoints(team, memberRating, points);
});
}
bool ScriptMgr::CanSaveToDB(ArenaTeam* team)
{
auto ret = IsValidBoolScript<ArenaScript>([&](ArenaScript* script)
{
return !script->CanSaveToDB(team);
});
if (ret && *ret)
{
return false;
}
return true;
}

View File

@@ -0,0 +1,59 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnGetSlotByType(const uint32 type, uint8& slot)
{
ExecuteScript<ArenaTeamScript>([&](ArenaTeamScript* script)
{
script->OnGetSlotByType(type, slot);
});
}
void ScriptMgr::OnGetArenaPoints(ArenaTeam* at, float& points)
{
ExecuteScript<ArenaTeamScript>([&](ArenaTeamScript* script)
{
script->OnGetArenaPoints(at, points);
});
}
void ScriptMgr::OnArenaTypeIDToQueueID(const BattlegroundTypeId bgTypeId, const uint8 arenaType, uint32& queueTypeID)
{
ExecuteScript<ArenaTeamScript>([&](ArenaTeamScript* script)
{
script->OnTypeIDToQueueID(bgTypeId, arenaType, queueTypeID);
});
}
void ScriptMgr::OnArenaQueueIdToArenaType(const BattlegroundQueueTypeId bgQueueTypeId, uint8& ArenaType)
{
ExecuteScript<ArenaTeamScript>([&](ArenaTeamScript* script)
{
script->OnQueueIdToArenaType(bgQueueTypeId, ArenaType);
});
}
void ScriptMgr::OnSetArenaMaxPlayersPerTeam(const uint8 arenaType, uint32& maxPlayerPerTeam)
{
ExecuteScript<ArenaTeamScript>([&](ArenaTeamScript* script)
{
script->OnSetArenaMaxPlayersPerTeam(arenaType, maxPlayerPerTeam);
});
}

View File

@@ -0,0 +1,119 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnAuctionAdd(AuctionHouseObject* ah, AuctionEntry* entry)
{
ASSERT(ah);
ASSERT(entry);
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnAuctionAdd(ah, entry);
});
}
void ScriptMgr::OnAuctionRemove(AuctionHouseObject* ah, AuctionEntry* entry)
{
ASSERT(ah);
ASSERT(entry);
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnAuctionRemove(ah, entry);
});
}
void ScriptMgr::OnAuctionSuccessful(AuctionHouseObject* ah, AuctionEntry* entry)
{
ASSERT(ah);
ASSERT(entry);
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnAuctionSuccessful(ah, entry);
});
}
void ScriptMgr::OnAuctionExpire(AuctionHouseObject* ah, AuctionEntry* entry)
{
ASSERT(ah);
ASSERT(entry);
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnAuctionExpire(ah, entry);
});
}
void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionWonMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* bidder, uint32& bidder_accId, bool& sendNotification, bool& updateAchievementCriteria, bool& sendMail)
{
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnBeforeAuctionHouseMgrSendAuctionWonMail(auctionHouseMgr, auction, bidder, bidder_accId, sendNotification, updateAchievementCriteria, sendMail);
});
}
void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionSalePendingMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* owner, uint32& owner_accId, bool& sendMail)
{
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnBeforeAuctionHouseMgrSendAuctionSalePendingMail(auctionHouseMgr, auction, owner, owner_accId, sendMail);
});
}
void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* owner, uint32& owner_accId, uint32& profit, bool& sendNotification, bool& updateAchievementCriteria, bool& sendMail)
{
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(auctionHouseMgr, auction, owner, owner_accId, profit, sendNotification, updateAchievementCriteria, sendMail);
});
}
void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionExpiredMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* owner, uint32& owner_accId, bool& sendNotification, bool& sendMail)
{
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnBeforeAuctionHouseMgrSendAuctionExpiredMail(auctionHouseMgr, auction, owner, owner_accId, sendNotification, sendMail);
});
}
void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* oldBidder, uint32& oldBidder_accId, Player* newBidder, uint32& newPrice, bool& sendNotification, bool& sendMail)
{
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail(auctionHouseMgr, auction, oldBidder, oldBidder_accId, newBidder, newPrice, sendNotification, sendMail);
});
}
void ScriptMgr::OnBeforeAuctionHouseMgrSendAuctionCancelledToBidderMail(AuctionHouseMgr* auctionHouseMgr, AuctionEntry* auction, Player* bidder, uint32& bidder_accId, bool& sendMail)
{
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnBeforeAuctionHouseMgrSendAuctionCancelledToBidderMail(auctionHouseMgr, auction, bidder, bidder_accId, sendMail);
});
}
void ScriptMgr::OnBeforeAuctionHouseMgrUpdate()
{
ExecuteScript<AuctionHouseScript>([&](AuctionHouseScript* script)
{
script->OnBeforeAuctionHouseMgrUpdate();
});
}

View File

@@ -0,0 +1,191 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnBattlegroundStart(Battleground* bg)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundStart(bg);
});
}
void ScriptMgr::OnBattlegroundEndReward(Battleground* bg, Player* player, TeamId winnerTeamId)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundEndReward(bg, player, winnerTeamId);
});
}
void ScriptMgr::OnBattlegroundUpdate(Battleground* bg, uint32 diff)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundUpdate(bg, diff);
});
}
void ScriptMgr::OnBattlegroundAddPlayer(Battleground* bg, Player* player)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundAddPlayer(bg, player);
});
}
void ScriptMgr::OnBattlegroundBeforeAddPlayer(Battleground* bg, Player* player)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundBeforeAddPlayer(bg, player);
});
}
void ScriptMgr::OnBattlegroundRemovePlayerAtLeave(Battleground* bg, Player* player)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundRemovePlayerAtLeave(bg, player);
});
}
void ScriptMgr::OnAddGroup(BattlegroundQueue* queue, GroupQueueInfo* ginfo, uint32& index, Player* leader, Group* grp, PvPDifficultyEntry const* bracketEntry, bool isPremade)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnAddGroup(queue, ginfo, index, leader, grp, bracketEntry, isPremade);
});
}
bool ScriptMgr::CanFillPlayersToBG(BattlegroundQueue* queue, Battleground* bg, const int32 aliFree, const int32 hordeFree, BattlegroundBracketId bracket_id)
{
auto ret = IsValidBoolScript<BGScript>([&](BGScript* script)
{
return !script->CanFillPlayersToBG(queue, bg, aliFree, hordeFree, bracket_id);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::CanFillPlayersToBGWithSpecific(BattlegroundQueue* queue, Battleground* bg, const int32 aliFree, const int32 hordeFree,
BattlegroundBracketId thisBracketId, BattlegroundQueue* specificQueue, BattlegroundBracketId specificBracketId)
{
auto ret = IsValidBoolScript<BGScript>([&](BGScript* script)
{
return !script->CanFillPlayersToBGWithSpecific(queue, bg, aliFree, hordeFree, thisBracketId, specificQueue, specificBracketId);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnCheckNormalMatch(BattlegroundQueue* queue, uint32& Coef, Battleground* bgTemplate, BattlegroundBracketId bracket_id, uint32& minPlayers, uint32& maxPlayers)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnCheckNormalMatch(queue, Coef, bgTemplate, bracket_id, minPlayers, maxPlayers);
});
}
void ScriptMgr::OnQueueUpdate(BattlegroundQueue* queue, BattlegroundBracketId bracket_id, bool isRated, uint32 arenaRatedTeamId)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnQueueUpdate(queue, bracket_id, isRated, arenaRatedTeamId);
});
}
bool ScriptMgr::CanSendMessageBGQueue(BattlegroundQueue* queue, Player* leader, Battleground* bg, PvPDifficultyEntry const* bracketEntry)
{
auto ret = IsValidBoolScript<BGScript>([&](BGScript* script)
{
return !script->CanSendMessageBGQueue(queue, leader, bg, bracketEntry);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::OnBeforeSendJoinMessageArenaQueue(BattlegroundQueue* queue, Player* leader, GroupQueueInfo* ginfo, PvPDifficultyEntry const* bracketEntry, bool isRated)
{
auto ret = IsValidBoolScript<BGScript>([&](BGScript* script)
{
return !script->OnBeforeSendJoinMessageArenaQueue(queue, leader, ginfo, bracketEntry, isRated);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::OnBeforeSendExitMessageArenaQueue(BattlegroundQueue* queue, GroupQueueInfo* ginfo)
{
auto ret = IsValidBoolScript<BGScript>([&](BGScript* script)
{
return !script->OnBeforeSendExitMessageArenaQueue(queue, ginfo);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnBattlegroundEnd(Battleground* bg, TeamId winnerTeam)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundEnd(bg, winnerTeam);
});
}
void ScriptMgr::OnBattlegroundDestroy(Battleground* bg)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundDestroy(bg);
});
}
void ScriptMgr::OnBattlegroundCreate(Battleground* bg)
{
ExecuteScript<BGScript>([&](BGScript* script)
{
script->OnBattlegroundCreate(bg);
});
}

View File

@@ -0,0 +1,25 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
Battleground* ScriptMgr::CreateBattleground(BattlegroundTypeId /*typeId*/)
{
// TODO: Implement script-side battlegrounds.
ABORT();
return nullptr;
}

View File

@@ -0,0 +1,42 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnHandleDevCommand(Player* player, bool& enable)
{
ExecuteScript<CommandSC>([&](CommandSC* script)
{
script->OnHandleDevCommand(player, enable);
});
}
bool ScriptMgr::CanExecuteCommand(ChatHandler& handler, std::string_view cmdStr)
{
auto ret = IsValidBoolScript<CommandSC>([&](CommandSC* script)
{
return !script->CanExecuteCommand(handler, cmdStr);
});
if (ret && *ret)
{
return false;
}
return true;
}

View File

@@ -0,0 +1,32 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Chat.h"
#include "ScriptMgr.h"
Acore::ChatCommands::ChatCommandTable ScriptMgr::GetChatCommands()
{
Acore::ChatCommands::ChatCommandTable table;
for (auto const& [scriptID, script] : ScriptRegistry<CommandScript>::ScriptPointerList)
{
Acore::ChatCommands::ChatCommandTable cmds = script->GetCommands();
std::move(cmds.begin(), cmds.end(), std::back_inserter(table));
}
return table;
}

View File

@@ -0,0 +1,26 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
bool ScriptMgr::OnConditionCheck(Condition* condition, ConditionSourceInfo& sourceInfo)
{
ASSERT(condition);
auto tempScript = ScriptRegistry<ConditionScript>::GetScriptById(condition->ScriptId);
return tempScript ? tempScript->OnConditionCheck(condition, sourceInfo) : true;
}

View File

@@ -0,0 +1,186 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
#include "ScriptedGossip.h"
bool ScriptMgr::OnGossipHello(Player* player, Creature* creature)
{
ASSERT(player);
ASSERT(creature);
auto ret = IsValidBoolScript<AllCreatureScript>([&](AllCreatureScript* script)
{
return script->CanCreatureGossipHello(player, creature);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<CreatureScript>::GetScriptById(creature->GetScriptId());
ClearGossipMenuFor(player);
return tempScript ? tempScript->OnGossipHello(player, creature) : false;
}
bool ScriptMgr::OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
{
ASSERT(player);
ASSERT(creature);
auto ret = IsValidBoolScript<AllCreatureScript>([&](AllCreatureScript* script)
{
return script->CanCreatureGossipSelect(player, creature, sender, action);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<CreatureScript>::GetScriptById(creature->GetScriptId());
return tempScript ? tempScript->OnGossipSelect(player, creature, sender, action) : false;
}
bool ScriptMgr::OnGossipSelectCode(Player* player, Creature* creature, uint32 sender, uint32 action, const char* code)
{
ASSERT(player);
ASSERT(creature);
ASSERT(code);
auto ret = IsValidBoolScript<AllCreatureScript>([&](AllCreatureScript* script)
{
return script->CanCreatureGossipSelectCode(player, creature, sender, action, code);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<CreatureScript>::GetScriptById(creature->GetScriptId());
return tempScript ? tempScript->OnGossipSelectCode(player, creature, sender, action, code) : false;
}
bool ScriptMgr::OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
{
ASSERT(player);
ASSERT(creature);
ASSERT(quest);
auto ret = IsValidBoolScript<AllCreatureScript>([&](AllCreatureScript* script)
{
return script->CanCreatureQuestAccept(player, creature, quest);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<CreatureScript>::GetScriptById(creature->GetScriptId());
ClearGossipMenuFor(player);
return tempScript ? tempScript->OnQuestAccept(player, creature, quest) : false;
}
bool ScriptMgr::OnQuestSelect(Player* player, Creature* creature, Quest const* quest)
{
ASSERT(player);
ASSERT(creature);
ASSERT(quest);
auto tempScript = ScriptRegistry<CreatureScript>::GetScriptById(creature->GetScriptId());
ClearGossipMenuFor(player);
return tempScript ? tempScript->OnQuestSelect(player, creature, quest) : false;
}
bool ScriptMgr::OnQuestComplete(Player* player, Creature* creature, Quest const* quest)
{
ASSERT(player);
ASSERT(creature);
ASSERT(quest);
auto tempScript = ScriptRegistry<CreatureScript>::GetScriptById(creature->GetScriptId());
ClearGossipMenuFor(player);
return tempScript ? tempScript->OnQuestComplete(player, creature, quest) : false;
}
bool ScriptMgr::OnQuestReward(Player* player, Creature* creature, Quest const* quest, uint32 opt)
{
ASSERT(player);
ASSERT(creature);
ASSERT(quest);
auto ret = IsValidBoolScript<AllCreatureScript>([&](AllCreatureScript* script)
{
return script->CanCreatureQuestReward(player, creature, quest, opt);
});
if (ret && *ret)
{
return false;
}
auto tempScript = ScriptRegistry<CreatureScript>::GetScriptById(creature->GetScriptId());
ClearGossipMenuFor(player);
return tempScript ? tempScript->OnQuestReward(player, creature, quest, opt) : false;
}
uint32 ScriptMgr::GetDialogStatus(Player* player, Creature* creature)
{
ASSERT(player);
ASSERT(creature);
auto tempScript = ScriptRegistry<CreatureScript>::GetScriptById(creature->GetScriptId());
ClearGossipMenuFor(player);
return tempScript ? tempScript->GetDialogStatus(player, creature) : DIALOG_STATUS_SCRIPTED_NO_STATUS;
}
CreatureAI* ScriptMgr::GetCreatureAI(Creature* creature)
{
ASSERT(creature);
auto retAI = GetReturnAIScript<AllCreatureScript, CreatureAI>([creature](AllCreatureScript* script)
{
return script->GetCreatureAI(creature);
});
if (retAI)
{
return retAI;
}
auto tempScript = ScriptRegistry<CreatureScript>::GetScriptById(creature->GetScriptId());
return tempScript ? tempScript->GetAI(creature) : nullptr;
}
void ScriptMgr::OnCreatureUpdate(Creature* creature, uint32 diff)
{
ASSERT(creature);
ExecuteScript<AllCreatureScript>([&](AllCreatureScript* script)
{
script->OnAllCreatureUpdate(creature, diff);
});
if (auto tempScript = ScriptRegistry<CreatureScript>::GetScriptById(creature->GetScriptId()))
{
tempScript->OnUpdate(creature, diff);
}
}

View File

@@ -0,0 +1,82 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
bool ScriptMgr::OnDatabasesLoading()
{
auto ret = IsValidBoolScript<DatabaseScript>([&](DatabaseScript* script)
{
return !script->OnDatabasesLoading();
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnAfterDatabasesLoaded(uint32 updateFlags)
{
ExecuteScript<DatabaseScript>([&](DatabaseScript* script)
{
script->OnAfterDatabasesLoaded(updateFlags);
});
}
void ScriptMgr::OnDatabasesKeepAlive()
{
ExecuteScript<DatabaseScript>([&](DatabaseScript* script)
{
script->OnDatabasesKeepAlive();
});
}
void ScriptMgr::OnDatabasesClosing()
{
ExecuteScript<DatabaseScript>([&](DatabaseScript* script)
{
script->OnDatabasesClosing();
});
}
void ScriptMgr::OnDatabaseWarnAboutSyncQueries(bool apply)
{
ExecuteScript<DatabaseScript>([&](DatabaseScript* script)
{
script->OnDatabaseWarnAboutSyncQueries(apply);
});
}
void ScriptMgr::OnDatabaseSelectIndexLogout(Player* player, uint32& statementIndex, uint32& statementParam)
{
ExecuteScript<DatabaseScript>([&](DatabaseScript* script)
{
script->OnDatabaseSelectIndexLogout(player, statementIndex, statementParam);
});
}
void ScriptMgr::OnDatabaseGetDBRevision(std::string& revision)
{
ExecuteScript<DatabaseScript>([&](DatabaseScript* script)
{
script->OnDatabaseGetDBRevision(revision);
});
}

View File

@@ -0,0 +1,28 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
void ScriptMgr::OnDynamicObjectUpdate(DynamicObject* dynobj, uint32 diff)
{
ASSERT(dynobj);
for (auto const& [scriptID, script] : ScriptRegistry<DynamicObjectScript>::ScriptPointerList)
{
script->OnUpdate(dynobj, diff);
}
}

View File

@@ -0,0 +1,94 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnHonorCalculation(float& honor, uint8 level, float multiplier)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnHonorCalculation(honor, level, multiplier);
});
}
void ScriptMgr::OnGrayLevelCalculation(uint8& grayLevel, uint8 playerLevel)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnGrayLevelCalculation(grayLevel, playerLevel);
});
}
void ScriptMgr::OnColorCodeCalculation(XPColorChar& color, uint8 playerLevel, uint8 mobLevel)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnColorCodeCalculation(color, playerLevel, mobLevel);
});
}
void ScriptMgr::OnZeroDifferenceCalculation(uint8& diff, uint8 playerLevel)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnZeroDifferenceCalculation(diff, playerLevel);
});
}
void ScriptMgr::OnBaseGainCalculation(uint32& gain, uint8 playerLevel, uint8 mobLevel, ContentLevels content)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnBaseGainCalculation(gain, playerLevel, mobLevel, content);
});
}
void ScriptMgr::OnGainCalculation(uint32& gain, Player* player, Unit* unit)
{
ASSERT(player);
ASSERT(unit);
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnGainCalculation(gain, player, unit);
});
}
void ScriptMgr::OnGroupRateCalculation(float& rate, uint32 count, bool isRaid)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnGroupRateCalculation(rate, count, isRaid);
});
}
void ScriptMgr::OnAfterArenaRatingCalculation(Battleground* const bg, int32& winnerMatchmakerChange, int32& loserMatchmakerChange, int32& winnerChange, int32& loserChange)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnAfterArenaRatingCalculation(bg, winnerMatchmakerChange, loserMatchmakerChange, winnerChange, loserChange);
});
}
void ScriptMgr::OnBeforeUpdatingPersonalRating(int32& mod, uint32 type)
{
ExecuteScript<FormulaScript>([&](FormulaScript* script)
{
script->OnBeforeUpdatingPersonalRating(mod, type);
});
}

View File

@@ -0,0 +1,43 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnGameEventStart(uint16 EventID)
{
ExecuteScript<GameEventScript>([&](GameEventScript* script)
{
script->OnStart(EventID);
});
}
void ScriptMgr::OnGameEventStop(uint16 EventID)
{
ExecuteScript<GameEventScript>([&](GameEventScript* script)
{
script->OnStop(EventID);
});
}
void ScriptMgr::OnGameEventCheck(uint16 EventID)
{
ExecuteScript<GameEventScript>([&](GameEventScript* script)
{
script->OnEventCheck(EventID);
});
}

View File

@@ -0,0 +1,224 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
#include "ScriptedGossip.h"
bool ScriptMgr::OnGossipHello(Player* player, GameObject* go)
{
ASSERT(player);
ASSERT(go);
auto ret = IsValidBoolScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
return script->CanGameObjectGossipHello(player, go);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId());
ClearGossipMenuFor(player);
return tempScript ? tempScript->OnGossipHello(player, go) : false;
}
bool ScriptMgr::OnGossipSelect(Player* player, GameObject* go, uint32 sender, uint32 action)
{
ASSERT(player);
ASSERT(go);
auto ret = IsValidBoolScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
return script->CanGameObjectGossipSelect(player, go, sender, action);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId());
return tempScript ? tempScript->OnGossipSelect(player, go, sender, action) : false;
}
bool ScriptMgr::OnGossipSelectCode(Player* player, GameObject* go, uint32 sender, uint32 action, const char* code)
{
ASSERT(player);
ASSERT(go);
ASSERT(code);
auto ret = IsValidBoolScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
return script->CanGameObjectGossipSelectCode(player, go, sender, action, code);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId());
return tempScript ? tempScript->OnGossipSelectCode(player, go, sender, action, code) : false;
}
bool ScriptMgr::OnQuestAccept(Player* player, GameObject* go, Quest const* quest)
{
ASSERT(player);
ASSERT(go);
ASSERT(quest);
auto ret = IsValidBoolScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
return script->CanGameObjectQuestAccept(player, go, quest);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId());
ClearGossipMenuFor(player);
return tempScript ? tempScript->OnQuestAccept(player, go, quest) : false;
}
bool ScriptMgr::OnQuestReward(Player* player, GameObject* go, Quest const* quest, uint32 opt)
{
ASSERT(player);
ASSERT(go);
ASSERT(quest);
auto ret = IsValidBoolScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
return script->CanGameObjectQuestReward(player, go, quest, opt);
});
if (ret && *ret)
{
return false;
}
auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId());
ClearGossipMenuFor(player);
return tempScript ? tempScript->OnQuestReward(player, go, quest, opt) : false;
}
uint32 ScriptMgr::GetDialogStatus(Player* player, GameObject* go)
{
ASSERT(player);
ASSERT(go);
auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId());
ClearGossipMenuFor(player);
return tempScript ? tempScript->GetDialogStatus(player, go) : DIALOG_STATUS_SCRIPTED_NO_STATUS;
}
void ScriptMgr::OnGameObjectDestroyed(GameObject* go, Player* player)
{
ASSERT(go);
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
script->OnGameObjectDestroyed(go, player);
});
if (auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId()))
{
tempScript->OnDestroyed(go, player);
}
}
void ScriptMgr::OnGameObjectDamaged(GameObject* go, Player* player)
{
ASSERT(go);
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
script->OnGameObjectDamaged(go, player);
});
if (auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId()))
{
tempScript->OnDamaged(go, player);
}
}
void ScriptMgr::OnGameObjectLootStateChanged(GameObject* go, uint32 state, Unit* unit)
{
ASSERT(go);
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
script->OnGameObjectLootStateChanged(go, state, unit);
});
if (auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId()))
{
tempScript->OnLootStateChanged(go, state, unit);
}
}
void ScriptMgr::OnGameObjectStateChanged(GameObject* go, uint32 state)
{
ASSERT(go);
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
script->OnGameObjectStateChanged(go, state);
});
if (auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId()))
{
tempScript->OnGameObjectStateChanged(go, state);
}
}
void ScriptMgr::OnGameObjectUpdate(GameObject* go, uint32 diff)
{
ASSERT(go);
ExecuteScript<AllGameObjectScript>([&](AllGameObjectScript* script)
{
script->OnGameObjectUpdate(go, diff);
});
if (auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId()))
{
tempScript->OnUpdate(go, diff);
}
}
GameObjectAI* ScriptMgr::GetGameObjectAI(GameObject* go)
{
ASSERT(go);
auto retAI = GetReturnAIScript<AllGameObjectScript, GameObjectAI>([go](AllGameObjectScript* script)
{
return script->GetGameObjectAI(go);
});
if (retAI)
{
return retAI;
}
auto tempScript = ScriptRegistry<GameObjectScript>::GetScriptById(go->GetScriptId());
return tempScript ? tempScript->GetAI(go) : nullptr;
}

View File

@@ -0,0 +1,163 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Player.h"
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnGlobalItemDelFromDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
{
ASSERT(trans);
ASSERT(itemGuid);
ExecuteScript<GlobalScript>([&](GlobalScript* script)
{
script->OnItemDelFromDB(trans, itemGuid);
});
}
void ScriptMgr::OnGlobalMirrorImageDisplayItem(Item const* item, uint32& display)
{
ExecuteScript<GlobalScript>([&](GlobalScript* script)
{
script->OnMirrorImageDisplayItem(item, display);
});
}
void ScriptMgr::OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map<ObjectGuid, uint32>& ap)
{
ExecuteScript<GlobalScript>([&](GlobalScript* script)
{
script->OnBeforeUpdateArenaPoints(at, ap);
});
}
void ScriptMgr::OnAfterRefCount(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, uint32& maxcount, LootStore const& store)
{
ExecuteScript<GlobalScript>([&](GlobalScript* script)
{
script->OnAfterRefCount(player, LootStoreItem, loot, canRate, lootMode, maxcount, store);
});
}
void ScriptMgr::OnBeforeDropAddItem(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, LootStore const& store)
{
ExecuteScript<GlobalScript>([&](GlobalScript* script)
{
script->OnBeforeDropAddItem(player, loot, canRate, lootMode, LootStoreItem, store);
});
}
bool ScriptMgr::OnItemRoll(Player const* player, LootStoreItem const* lootStoreItem, float& chance, Loot& loot, LootStore const& store)
{
auto ret = IsValidBoolScript<GlobalScript>([&](GlobalScript* script)
{
return !script->OnItemRoll(player, lootStoreItem, chance, loot, store);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::OnBeforeLootEqualChanced(Player const* player, LootStoreItemList EqualChanced, Loot& loot, LootStore const& store)
{
auto ret = IsValidBoolScript<GlobalScript>([&](GlobalScript* script)
{
return !script->OnBeforeLootEqualChanced(player, EqualChanced, loot, store);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnInitializeLockedDungeons(Player* player, uint8& level, uint32& lockData, lfg::LFGDungeonData const* dungeon)
{
ExecuteScript<GlobalScript>([&](GlobalScript* script)
{
script->OnInitializeLockedDungeons(player, level, lockData, dungeon);
});
}
void ScriptMgr::OnAfterInitializeLockedDungeons(Player* player)
{
ExecuteScript<GlobalScript>([&](GlobalScript* script)
{
script->OnAfterInitializeLockedDungeons(player);
});
}
void ScriptMgr::OnAfterUpdateEncounterState(Map* map, EncounterCreditType type, uint32 creditEntry, Unit* source, Difficulty difficulty_fixed, DungeonEncounterList const* encounters, uint32 dungeonCompleted, bool updated)
{
ExecuteScript<GlobalScript>([&](GlobalScript* script)
{
script->OnAfterUpdateEncounterState(map, type, creditEntry, source, difficulty_fixed, encounters, dungeonCompleted, updated);
});
}
void ScriptMgr::OnBeforeWorldObjectSetPhaseMask(WorldObject const* worldObject, uint32& oldPhaseMask, uint32& newPhaseMask, bool& useCombinedPhases, bool& update)
{
ExecuteScript<GlobalScript>([&](GlobalScript* script)
{
script->OnBeforeWorldObjectSetPhaseMask(worldObject, oldPhaseMask, newPhaseMask, useCombinedPhases, update);
});
}
bool ScriptMgr::OnIsAffectedBySpellModCheck(SpellInfo const* affectSpell, SpellInfo const* checkSpell, SpellModifier const* mod)
{
auto ret = IsValidBoolScript<GlobalScript>([&](GlobalScript* script)
{
return !script->OnIsAffectedBySpellModCheck(affectSpell, checkSpell, mod);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::OnSpellHealingBonusTakenNegativeModifiers(Unit const* target, Unit const* caster, SpellInfo const* spellInfo, float& val)
{
auto ret = IsValidBoolScript<GlobalScript>([&](GlobalScript* script)
{
return script->OnSpellHealingBonusTakenNegativeModifiers(target, caster, spellInfo, val);
});
if (ret && *ret)
{
return true;
}
return false;
}
void ScriptMgr::OnLoadSpellCustomAttr(SpellInfo* spell)
{
ExecuteScript<GlobalScript>([&](GlobalScript* script)
{
script->OnLoadSpellCustomAttr(spell);
});
}

View File

@@ -0,0 +1,92 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnGroupAddMember(Group* group, ObjectGuid guid)
{
ASSERT(group);
ExecuteScript<GroupScript>([&](GroupScript* script)
{
script->OnAddMember(group, guid);
});
}
void ScriptMgr::OnGroupInviteMember(Group* group, ObjectGuid guid)
{
ASSERT(group);
ExecuteScript<GroupScript>([&](GroupScript* script)
{
script->OnInviteMember(group, guid);
});
}
void ScriptMgr::OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, const char* reason)
{
ASSERT(group);
ExecuteScript<GroupScript>([&](GroupScript* script)
{
script->OnRemoveMember(group, guid, method, kicker, reason);
});
}
void ScriptMgr::OnGroupChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid)
{
ASSERT(group);
ExecuteScript<GroupScript>([&](GroupScript* script)
{
script->OnChangeLeader(group, newLeaderGuid, oldLeaderGuid);
});
}
void ScriptMgr::OnGroupDisband(Group* group)
{
ASSERT(group);
ExecuteScript<GroupScript>([&](GroupScript* script)
{
script->OnDisband(group);
});
}
bool ScriptMgr::CanGroupJoinBattlegroundQueue(Group const* group, Player* member, Battleground const* bgTemplate, uint32 MinPlayerCount, bool isRated, uint32 arenaSlot)
{
auto ret = IsValidBoolScript<GroupScript>([&](GroupScript* script)
{
return !script->CanGroupJoinBattlegroundQueue(group, member, bgTemplate, MinPlayerCount, isRated, arenaSlot);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnCreate(Group* group, Player* leader)
{
ExecuteScript<GroupScript>([&](GroupScript* script)
{
script->OnCreate(group, leader);
});
}

View File

@@ -0,0 +1,123 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnGuildAddMember(Guild* guild, Player* player, uint8& plRank)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnAddMember(guild, player, plRank);
});
}
void ScriptMgr::OnGuildRemoveMember(Guild* guild, Player* player, bool isDisbanding, bool isKicked)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnRemoveMember(guild, player, isDisbanding, isKicked);
});
}
void ScriptMgr::OnGuildMOTDChanged(Guild* guild, const std::string& newMotd)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnMOTDChanged(guild, newMotd);
});
}
void ScriptMgr::OnGuildInfoChanged(Guild* guild, const std::string& newInfo)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnInfoChanged(guild, newInfo);
});
}
void ScriptMgr::OnGuildCreate(Guild* guild, Player* leader, const std::string& name)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnCreate(guild, leader, name);
});
}
void ScriptMgr::OnGuildDisband(Guild* guild)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnDisband(guild);
});
}
void ScriptMgr::OnGuildMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnMemberWitdrawMoney(guild, player, amount, isRepair);
});
}
void ScriptMgr::OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32& amount)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnMemberDepositMoney(guild, player, amount);
});
}
void ScriptMgr::OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId,
bool isDestBank, uint8 destContainer, uint8 destSlotId)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnItemMove(guild, player, pItem, isSrcBank, srcContainer, srcSlotId, isDestBank, destContainer, destSlotId);
});
}
void ScriptMgr::OnGuildEvent(Guild* guild, uint8 eventType, ObjectGuid::LowType playerGuid1, ObjectGuid::LowType playerGuid2, uint8 newRank)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnEvent(guild, eventType, playerGuid1, playerGuid2, newRank);
});
}
void ScriptMgr::OnGuildBankEvent(Guild* guild, uint8 eventType, uint8 tabId, ObjectGuid::LowType playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId)
{
ExecuteScript<GuildScript>([&](GuildScript* script)
{
script->OnBankEvent(guild, eventType, tabId, playerGuid, itemOrMoney, itemStackCount, destTabId);
});
}
bool ScriptMgr::CanGuildSendBankList(Guild const* guild, WorldSession* session, uint8 tabId, bool sendAllSlots)
{
auto ret = IsValidBoolScript<GuildScript>([&](GuildScript* script)
{
return !script->CanGuildSendBankList(guild, session, tabId, sendAllSlots);
});
if (ret && *ret)
{
return false;
}
return true;
}

View File

@@ -0,0 +1,26 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
InstanceScript* ScriptMgr::CreateInstanceScript(InstanceMap* map)
{
ASSERT(map);
auto tempScript = ScriptRegistry<InstanceMapScript>::GetScriptById(map->GetScriptId());
return tempScript ? tempScript->GetInstanceScript(map) : nullptr;
}

View File

@@ -0,0 +1,141 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
#include "ScriptedGossip.h"
bool ScriptMgr::OnQuestAccept(Player* player, Item* item, Quest const* quest)
{
ASSERT(player);
ASSERT(item);
ASSERT(quest);
auto ret = IsValidBoolScript<AllItemScript>([&](AllItemScript* script)
{
return !script->CanItemQuestAccept(player, item, quest);
});
if (ret && *ret)
{
return false;
}
auto tempScript = ScriptRegistry<ItemScript>::GetScriptById(item->GetScriptId());
ClearGossipMenuFor(player);
return tempScript ? tempScript->OnQuestAccept(player, item, quest) : false;
}
bool ScriptMgr::OnItemUse(Player* player, Item* item, SpellCastTargets const& targets)
{
ASSERT(player);
ASSERT(item);
auto ret = IsValidBoolScript<AllItemScript>([&](AllItemScript* script)
{
return script->CanItemUse(player, item, targets);
});
if (ret && *ret)
{
return true;
}
auto tempScript = ScriptRegistry<ItemScript>::GetScriptById(item->GetScriptId());
return tempScript ? tempScript->OnUse(player, item, targets) : false;
}
bool ScriptMgr::OnItemExpire(Player* player, ItemTemplate const* proto)
{
ASSERT(player);
ASSERT(proto);
auto ret = IsValidBoolScript<AllItemScript>([&](AllItemScript* script)
{
return !script->CanItemExpire(player, proto);
});
if (ret && *ret)
{
return false;
}
auto tempScript = ScriptRegistry<ItemScript>::GetScriptById(proto->ScriptId);
return tempScript ? tempScript->OnExpire(player, proto) : false;
}
bool ScriptMgr::OnItemRemove(Player* player, Item* item)
{
ASSERT(player);
ASSERT(item);
auto ret = IsValidBoolScript<AllItemScript>([&](AllItemScript* script)
{
return !script->CanItemRemove(player, item);
});
if (ret && *ret)
{
return false;
}
auto tempScript = ScriptRegistry<ItemScript>::GetScriptById(item->GetScriptId());
return tempScript ? tempScript->OnRemove(player, item) : false;
}
bool ScriptMgr::OnCastItemCombatSpell(Player* player, Unit* victim, SpellInfo const* spellInfo, Item* item)
{
ASSERT(player);
ASSERT(victim);
ASSERT(spellInfo);
ASSERT(item);
auto tempScript = ScriptRegistry<ItemScript>::GetScriptById(item->GetScriptId());
return tempScript ? tempScript->OnCastItemCombatSpell(player, victim, spellInfo, item) : true;
}
void ScriptMgr::OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action)
{
ASSERT(player);
ASSERT(item);
ExecuteScript<AllItemScript>([&](AllItemScript* script)
{
script->OnItemGossipSelect(player, item, sender, action);
});
if (auto tempScript = ScriptRegistry<ItemScript>::GetScriptById(item->GetScriptId()))
{
tempScript->OnGossipSelect(player, item, sender, action);
}
}
void ScriptMgr::OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code)
{
ASSERT(player);
ASSERT(item);
ExecuteScript<AllItemScript>([&](AllItemScript* script)
{
script->OnItemGossipSelectCode(player, item, sender, action, code);
});
if (auto tempScript = ScriptRegistry<ItemScript>::GetScriptById(item->GetScriptId()))
{
tempScript->OnGossipSelectCode(player, item, sender, action, code);
}
}

View File

@@ -0,0 +1,29 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnLootMoney(Player* player, uint32 gold)
{
ASSERT(player);
ExecuteScript<LootScript>([&](LootScript* script)
{
script->OnLootMoney(player, gold);
});
}

View File

@@ -0,0 +1,27 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnBeforeMailDraftSendMailTo(MailDraft* mailDraft, MailReceiver const& receiver, MailSender const& sender, MailCheckMask& checked, uint32& deliver_delay, uint32& custom_expiration, bool& deleteMailItemsFromDB, bool& sendMail)
{
ExecuteScript<MailScript>([&](MailScript* script)
{
script->OnBeforeMailDraftSendMailTo(mailDraft, receiver, sender, checked, deliver_delay, custom_expiration, deleteMailItemsFromDB, sendMail);\
});
}

View File

@@ -0,0 +1,27 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnMetricLogging()
{
ExecuteScript<MetricScript>([&](MetricScript* script)
{
script->OnMetricLogging();
});
}

View File

@@ -0,0 +1,184 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnItemCreate(Item* item, ItemTemplate const* itemProto, Player const* owner)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnItemCreate(item, itemProto, owner);
});
}
bool ScriptMgr::CanApplySoulboundFlag(Item* item, ItemTemplate const* proto)
{
auto ret = IsValidBoolScript<MiscScript>([&](MiscScript* script)
{
return !script->CanApplySoulboundFlag(item, proto);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnConstructObject(Object* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnConstructObject(origin);
});
}
void ScriptMgr::OnDestructObject(Object* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnDestructObject(origin);
});
}
void ScriptMgr::OnConstructPlayer(Player* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnConstructPlayer(origin);
});
}
void ScriptMgr::OnDestructPlayer(Player* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnDestructPlayer(origin);
});
}
void ScriptMgr::OnConstructGroup(Group* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnConstructGroup(origin);
});
}
void ScriptMgr::OnDestructGroup(Group* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnDestructGroup(origin);
});
}
void ScriptMgr::OnConstructInstanceSave(InstanceSave* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnConstructInstanceSave(origin);
});
}
void ScriptMgr::OnDestructInstanceSave(InstanceSave* origin)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnDestructInstanceSave(origin);
});
}
bool ScriptMgr::CanItemApplyEquipSpell(Player* player, Item* item)
{
auto ret = IsValidBoolScript<MiscScript>([&](MiscScript* script)
{
return !script->CanItemApplyEquipSpell(player, item);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::CanSendAuctionHello(WorldSession const* session, ObjectGuid guid, Creature* creature)
{
auto ret = IsValidBoolScript<MiscScript>([&](MiscScript* script)
{
return !script->CanSendAuctionHello(session, guid, creature);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::ValidateSpellAtCastSpell(Player* player, uint32& oldSpellId, uint32& spellId, uint8& castCount, uint8& castFlags)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->ValidateSpellAtCastSpell(player, oldSpellId, spellId, castCount, castFlags);
});
}
void ScriptMgr::ValidateSpellAtCastSpellResult(Player* player, Unit* mover, Spell* spell, uint32 oldSpellId, uint32 spellId)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->ValidateSpellAtCastSpellResult(player, mover, spell, oldSpellId, spellId);
});
}
void ScriptMgr::OnAfterLootTemplateProcess(Loot* loot, LootTemplate const* tab, LootStore const& store, Player* lootOwner, bool personal, bool noEmptyError, uint16 lootMode)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnAfterLootTemplateProcess(loot, tab, store, lootOwner, personal, noEmptyError, lootMode);
});
}
void ScriptMgr::OnInstanceSave(InstanceSave* instanceSave)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnInstanceSave(instanceSave);
});
}
void ScriptMgr::OnPlayerSetPhase(const AuraEffect* auraEff, AuraApplication const* aurApp, uint8 mode, bool apply, uint32& newPhase)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->OnPlayerSetPhase(auraEff, aurApp, mode, apply, newPhase);
});
}
void ScriptMgr::GetDialogStatus(Player* player, Object* questgiver)
{
ExecuteScript<MiscScript>([&](MiscScript* script)
{
script->GetDialogStatus(player, questgiver);
});
}

View File

@@ -0,0 +1,27 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnPlayerMove(Player* player, MovementInfo movementInfo, uint32 opcode)
{
ExecuteScript<MovementHandlerScript>([&](MovementHandlerScript* script)
{
script->OnPlayerMove(player, movementInfo, opcode);
});
}

View File

@@ -0,0 +1,27 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "OutdoorPvPMgr.h"
#include "ScriptMgr.h"
OutdoorPvP* ScriptMgr::CreateOutdoorPvP(OutdoorPvPData const* data)
{
ASSERT(data);
auto tempScript = ScriptRegistry<OutdoorPvPScript>::GetScriptById(data->ScriptId);
return tempScript ? tempScript->GetOutdoorPvP() : nullptr;
}

View File

@@ -0,0 +1,90 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnInitStatsForLevel(Guardian* guardian, uint8 petlevel)
{
ExecuteScript<PetScript>([&](PetScript* script)
{
script->OnInitStatsForLevel(guardian, petlevel);
});
}
void ScriptMgr::OnCalculateMaxTalentPointsForLevel(Pet* pet, uint8 level, uint8& points)
{
ExecuteScript<PetScript>([&](PetScript* script)
{
script->OnCalculateMaxTalentPointsForLevel(pet, level, points);
});
}
bool ScriptMgr::CanUnlearnSpellSet(Pet* pet, uint32 level, uint32 spell)
{
auto ret = IsValidBoolScript<PetScript>([&](PetScript* script)
{
return !script->CanUnlearnSpellSet(pet, level, spell);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::CanUnlearnSpellDefault(Pet* pet, SpellInfo const* spellEntry)
{
auto ret = IsValidBoolScript<PetScript>([&](PetScript* script)
{
return !script->CanUnlearnSpellDefault(pet, spellEntry);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::CanResetTalents(Pet* pet)
{
auto ret = IsValidBoolScript<PetScript>([&](PetScript* script)
{
return !script->CanResetTalents(pet);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnPetAddToWorld(Pet* pet)
{
ASSERT(pet);
ExecuteScript<PetScript>([&](PetScript* script)
{
script->OnPetAddToWorld(pet);
});
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,105 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
bool ScriptMgr::OnPlayerbotCheckLFGQueue(lfg::Lfg5Guids const& guidsList)
{
auto ret = IsValidBoolScript<PlayerbotScript>([&](PlayerbotScript* script)
{
return !script->OnPlayerbotCheckLFGQueue(guidsList);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnPlayerbotCheckKillTask(Player* player, Unit* victim)
{
ExecuteScript<PlayerbotScript>([&](PlayerbotScript* script)
{
script->OnPlayerbotCheckKillTask(player, victim);
});
}
void ScriptMgr::OnPlayerbotCheckPetitionAccount(Player* player, bool& found)
{
ExecuteScript<PlayerbotScript>([&](PlayerbotScript* script)
{
script->OnPlayerbotCheckPetitionAccount(player, found);
});
}
bool ScriptMgr::OnPlayerbotCheckUpdatesToSend(Player* player)
{
auto ret = IsValidBoolScript<PlayerbotScript>([&](PlayerbotScript* script)
{
return !script->OnPlayerbotCheckUpdatesToSend(player);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnPlayerbotPacketSent(Player* player, WorldPacket const* packet)
{
ExecuteScript<PlayerbotScript>([&](PlayerbotScript* script)
{
script->OnPlayerbotPacketSent(player, packet);
});
}
void ScriptMgr::OnPlayerbotUpdate(uint32 diff)
{
ExecuteScript<PlayerbotScript>([&](PlayerbotScript* script)
{
script->OnPlayerbotUpdate(diff);
});
}
void ScriptMgr::OnPlayerbotUpdateSessions(Player* player)
{
ExecuteScript<PlayerbotScript>([&](PlayerbotScript* script)
{
script->OnPlayerbotUpdateSessions(player);
});
}
void ScriptMgr::OnPlayerbotLogout(Player* player)
{
ExecuteScript<PlayerbotScript>([&](PlayerbotScript* script)
{
script->OnPlayerbotLogout(player);
});
}
void ScriptMgr::OnPlayerbotLogoutBots()
{
ExecuteScript<PlayerbotScript>([&](PlayerbotScript* script)
{
script->OnPlayerbotLogoutBots();
});
}

View File

@@ -0,0 +1,106 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnNetworkStart()
{
ExecuteScript<ServerScript>([&](ServerScript* script)
{
script->OnNetworkStart();
});
}
void ScriptMgr::OnNetworkStop()
{
ExecuteScript<ServerScript>([&](ServerScript* script)
{
script->OnNetworkStop();
});
}
void ScriptMgr::OnSocketOpen(std::shared_ptr<WorldSocket> socket)
{
ASSERT(socket);
ExecuteScript<ServerScript>([&](ServerScript* script)
{
script->OnSocketOpen(socket);
});
}
void ScriptMgr::OnSocketClose(std::shared_ptr<WorldSocket> socket)
{
ASSERT(socket);
ExecuteScript<ServerScript>([&](ServerScript* script)
{
script->OnSocketClose(socket);
});
}
bool ScriptMgr::CanPacketReceive(WorldSession* session, WorldPacket const& packet)
{
if (ScriptRegistry<ServerScript>::ScriptPointerList.empty())
return true;
WorldPacket copy(packet);
auto ret = IsValidBoolScript<ServerScript>([&](ServerScript* script)
{
return !script->CanPacketReceive(session, copy);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnPacketReceived(WorldSession* session, WorldPacket const& packet)
{
WorldPacket copy(packet);
ExecuteScript<ServerScript>([&](ServerScript* script)
{
script->OnPacketReceived(session, copy);
});
}
bool ScriptMgr::CanPacketSend(WorldSession* session, WorldPacket const& packet)
{
ASSERT(session);
if (ScriptRegistry<ServerScript>::ScriptPointerList.empty())
return true;
WorldPacket copy(packet);
auto ret = IsValidBoolScript<ServerScript>([&](ServerScript* script)
{
return !script->CanPacketSend(session, copy);
});
if (ret && *ret)
{
return false;
}
return true;
}

View File

@@ -0,0 +1,158 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnCalcMaxDuration(Aura const* aura, int32& maxDuration)
{
ExecuteScript<SpellSC>([&](SpellSC* script)
{
script->OnCalcMaxDuration(aura, maxDuration);
});
}
bool ScriptMgr::CanModAuraEffectDamageDone(AuraEffect const* auraEff, Unit* target, AuraApplication const* aurApp, uint8 mode, bool apply)
{
auto ret = IsValidBoolScript<SpellSC>([&](SpellSC* script)
{
return !script->CanModAuraEffectDamageDone(auraEff, target, aurApp, mode, apply);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::CanModAuraEffectModDamagePercentDone(AuraEffect const* auraEff, Unit* target, AuraApplication const* aurApp, uint8 mode, bool apply)
{
auto ret = IsValidBoolScript<SpellSC>([&](SpellSC* script)
{
return !script->CanModAuraEffectModDamagePercentDone(auraEff, target, aurApp, mode, apply);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnSpellCheckCast(Spell* spell, bool strict, SpellCastResult& res)
{
ExecuteScript<SpellSC>([&](SpellSC* script)
{
script->OnSpellCheckCast(spell, strict, res);
});
}
bool ScriptMgr::CanPrepare(Spell* spell, SpellCastTargets const* targets, AuraEffect const* triggeredByAura)
{
auto ret = IsValidBoolScript<SpellSC>([&](SpellSC* script)
{
return !script->CanPrepare(spell, targets, triggeredByAura);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::CanScalingEverything(Spell* spell)
{
auto ret = IsValidBoolScript<SpellSC>([&](SpellSC* script)
{
return script->CanScalingEverything(spell);
});
if (ret && *ret)
{
return true;
}
return false;
}
bool ScriptMgr::CanSelectSpecTalent(Spell* spell)
{
auto ret = IsValidBoolScript<SpellSC>([&](SpellSC* script)
{
return !script->CanSelectSpecTalent(spell);
});
if (ret && *ret)
{
return false;
}
return true;
}
void ScriptMgr::OnScaleAuraUnitAdd(Spell* spell, Unit* target, uint32 effectMask, bool checkIfValid, bool implicit, uint8 auraScaleMask, TargetInfo& targetInfo)
{
ExecuteScript<SpellSC>([&](SpellSC* script)
{
script->OnScaleAuraUnitAdd(spell, target, effectMask, checkIfValid, implicit, auraScaleMask, targetInfo);
});
}
void ScriptMgr::OnRemoveAuraScaleTargets(Spell* spell, TargetInfo& targetInfo, uint8 auraScaleMask, bool& needErase)
{
ExecuteScript<SpellSC>([&](SpellSC* script)
{
script->OnRemoveAuraScaleTargets(spell, targetInfo, auraScaleMask, needErase);
});
}
void ScriptMgr::OnBeforeAuraRankForLevel(SpellInfo const* spellInfo, SpellInfo const* latestSpellInfo, uint8 level)
{
ExecuteScript<SpellSC>([&](SpellSC* script)
{
script->OnBeforeAuraRankForLevel(spellInfo, latestSpellInfo, level);
});
}
void ScriptMgr::OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, GameObject* gameObjTarget)
{
ExecuteScript<SpellSC>([&](SpellSC* script)
{
script->OnDummyEffect(caster, spellID, effIndex, gameObjTarget);
});
}
void ScriptMgr::OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, Creature* creatureTarget)
{
ExecuteScript<SpellSC>([&](SpellSC* script)
{
script->OnDummyEffect(caster, spellID, effIndex, creatureTarget);
});
}
void ScriptMgr::OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, Item* itemTarget)
{
ExecuteScript<SpellSC>([&](SpellSC* script)
{
script->OnDummyEffect(caster, spellID, effIndex, itemTarget);
});
}

View File

@@ -0,0 +1,76 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "SpellScript.h"
void ScriptMgr::CreateSpellScripts(uint32 spellId, std::list<SpellScript*>& scriptVector)
{
SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId);
for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr)
{
SpellScriptLoader* tempScript = ScriptRegistry<SpellScriptLoader>::GetScriptById(itr->second);
if (!tempScript)
continue;
SpellScript* script = tempScript->GetSpellScript();
if (!script)
continue;
script->_Init(&tempScript->GetName(), spellId);
scriptVector.push_back(script);
}
}
void ScriptMgr::CreateAuraScripts(uint32 spellId, std::list<AuraScript*>& scriptVector)
{
SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId);
for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr)
{
SpellScriptLoader* tempScript = ScriptRegistry<SpellScriptLoader>::GetScriptById(itr->second);
if (!tempScript)
continue;
AuraScript* script = tempScript->GetAuraScript();
if (!script)
continue;
script->_Init(&tempScript->GetName(), spellId);
scriptVector.push_back(script);
}
}
void ScriptMgr::CreateSpellScriptLoaders(uint32 spellId, std::vector<std::pair<SpellScriptLoader*, SpellScriptsContainer::iterator>>& scriptVector)
{
SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spellId);
scriptVector.reserve(std::distance(bounds.first, bounds.second));
for (SpellScriptsContainer::iterator itr = bounds.first; itr != bounds.second; ++itr)
{
SpellScriptLoader* tempScript = ScriptRegistry<SpellScriptLoader>::GetScriptById(itr->second);
if (!tempScript)
continue;
scriptVector.emplace_back(tempScript, itr);
}
}

View File

@@ -0,0 +1,70 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "Transport.h"
void ScriptMgr::OnAddPassenger(Transport* transport, Player* player)
{
ASSERT(transport);
ASSERT(player);
if (auto tempScript = ScriptRegistry<TransportScript>::GetScriptById(transport->GetScriptId()))
{
tempScript->OnAddPassenger(transport, player);
}
}
void ScriptMgr::OnAddCreaturePassenger(Transport* transport, Creature* creature)
{
ASSERT(transport);
ASSERT(creature);
if (auto tempScript = ScriptRegistry<TransportScript>::GetScriptById(transport->GetScriptId()))
{
tempScript->OnAddCreaturePassenger(transport, creature);
}
}
void ScriptMgr::OnRemovePassenger(Transport* transport, Player* player)
{
ASSERT(transport);
ASSERT(player);
if (auto tempScript = ScriptRegistry<TransportScript>::GetScriptById(transport->GetScriptId()))
{
tempScript->OnRemovePassenger(transport, player);
}
}
void ScriptMgr::OnTransportUpdate(Transport* transport, uint32 diff)
{
ASSERT(transport);
if (auto tempScript = ScriptRegistry<TransportScript>::GetScriptById(transport->GetScriptId()))
{
tempScript->OnUpdate(transport, diff);
}
}
void ScriptMgr::OnRelocate(Transport* transport, uint32 waypointId, uint32 mapId, float x, float y, float z)
{
if (auto tempScript = ScriptRegistry<TransportScript>::GetScriptById(transport->GetScriptId()))
{
tempScript->OnRelocate(transport, waypointId, mapId, x, y, z);
}
}

View File

@@ -0,0 +1,212 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
uint32 ScriptMgr::DealDamage(Unit* AttackerUnit, Unit* pVictim, uint32 damage, DamageEffectType damagetype)
{
if (ScriptRegistry<UnitScript>::ScriptPointerList.empty())
{
return damage;
}
for (auto const& [scriptID, script] : ScriptRegistry<UnitScript>::ScriptPointerList)
{
auto const& dmg = script->DealDamage(AttackerUnit, pVictim, damage, damagetype);
if (dmg != damage)
{
return damage;
}
}
return damage;
}
void ScriptMgr::OnHeal(Unit* healer, Unit* reciever, uint32& gain)
{
ExecuteScript<UnitScript>([&](UnitScript* script)
{
script->OnHeal(healer, reciever, gain);
});
}
void ScriptMgr::OnDamage(Unit* attacker, Unit* victim, uint32& damage)
{
ExecuteScript<UnitScript>([&](UnitScript* script)
{
script->OnDamage(attacker, victim, damage);
});
}
void ScriptMgr::ModifyPeriodicDamageAurasTick(Unit* target, Unit* attacker, uint32& damage)
{
ExecuteScript<UnitScript>([&](UnitScript* script)
{
script->ModifyPeriodicDamageAurasTick(target, attacker, damage);
});
}
void ScriptMgr::ModifyMeleeDamage(Unit* target, Unit* attacker, uint32& damage)
{
ExecuteScript<UnitScript>([&](UnitScript* script)
{
script->ModifyMeleeDamage(target, attacker, damage);
});
}
void ScriptMgr::ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& damage)
{
ExecuteScript<UnitScript>([&](UnitScript* script)
{
script->ModifySpellDamageTaken(target, attacker, damage);
});
}
void ScriptMgr::ModifyHealRecieved(Unit* target, Unit* attacker, uint32& damage)
{
ExecuteScript<UnitScript>([&](UnitScript* script)
{
script->ModifyHealRecieved(target, attacker, damage);
});
}
void ScriptMgr::OnBeforeRollMeleeOutcomeAgainst(Unit const* attacker, Unit const* victim, WeaponAttackType attType, int32& attackerMaxSkillValueForLevel, int32& victimMaxSkillValueForLevel, int32& attackerWeaponSkill, int32& victimDefenseSkill, int32& crit_chance, int32& miss_chance, int32& dodge_chance, int32& parry_chance, int32& block_chance)
{
ExecuteScript<UnitScript>([&](UnitScript* script)
{
script->OnBeforeRollMeleeOutcomeAgainst(attacker, victim, attType, attackerMaxSkillValueForLevel, victimMaxSkillValueForLevel, attackerWeaponSkill, victimDefenseSkill, crit_chance, miss_chance, dodge_chance, parry_chance, block_chance);
});
}
void ScriptMgr::OnAuraRemove(Unit* unit, AuraApplication* aurApp, AuraRemoveMode mode)
{
ExecuteScript<UnitScript>([&](UnitScript* script)
{
script->OnAuraRemove(unit, aurApp, mode);
});
}
bool ScriptMgr::IfNormalReaction(Unit const* unit, Unit const* target, ReputationRank& repRank)
{
auto ret = IsValidBoolScript<UnitScript>([&](UnitScript* script)
{
return !script->IfNormalReaction(unit, target, repRank);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::IsNeedModSpellDamagePercent(Unit const* unit, AuraEffect* auraEff, float& doneTotalMod, SpellInfo const* spellProto)
{
auto ret = IsValidBoolScript<UnitScript>([&](UnitScript* script)
{
return !script->IsNeedModSpellDamagePercent(unit, auraEff, doneTotalMod, spellProto);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::IsNeedModMeleeDamagePercent(Unit const* unit, AuraEffect* auraEff, float& doneTotalMod, SpellInfo const* spellProto)
{
auto ret = IsValidBoolScript<UnitScript>([&](UnitScript* script)
{
return !script->IsNeedModMeleeDamagePercent(unit, auraEff, doneTotalMod, spellProto);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::IsNeedModHealPercent(Unit const* unit, AuraEffect* auraEff, float& doneTotalMod, SpellInfo const* spellProto)
{
auto ret = IsValidBoolScript<UnitScript>([&](UnitScript* script)
{
return !script->IsNeedModHealPercent(unit, auraEff, doneTotalMod, spellProto);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::CanSetPhaseMask(Unit const* unit, uint32 newPhaseMask, bool update)
{
auto ret = IsValidBoolScript<UnitScript>([&](UnitScript* script)
{
return !script->CanSetPhaseMask(unit, newPhaseMask, update);
});
if (ret && *ret)
{
return false;
}
return true;
}
bool ScriptMgr::IsCustomBuildValuesUpdate(Unit const* unit, uint8 updateType, ByteBuffer& fieldBuffer, Player const* target, uint16 index)
{
auto ret = IsValidBoolScript<UnitScript>([&](UnitScript* script)
{
return script->IsCustomBuildValuesUpdate(unit, updateType, fieldBuffer, target, index);
});
if (ret && *ret)
{
return true;
}
return false;
}
bool ScriptMgr::OnBuildValuesUpdate(Unit const* unit, uint8 updateType, ByteBuffer& fieldBuffer, Player* target, uint16 index)
{
auto ret = IsValidBoolScript<UnitScript>([&](UnitScript* script) { return script->OnBuildValuesUpdate(unit, updateType, fieldBuffer, target, index); });
if (ret && *ret)
{
return true;
}
return false;
}
void ScriptMgr::OnUnitUpdate(Unit* unit, uint32 diff)
{
ExecuteScript<UnitScript>([&](UnitScript* script)
{
script->OnUnitUpdate(unit, diff);
});
}

View File

@@ -0,0 +1,88 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "Vehicle.h"
void ScriptMgr::OnInstall(Vehicle* veh)
{
ASSERT(veh);
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
{
tempScript->OnInstall(veh);
}
}
void ScriptMgr::OnUninstall(Vehicle* veh)
{
ASSERT(veh);
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
{
tempScript->OnUninstall(veh);
}
}
void ScriptMgr::OnReset(Vehicle* veh)
{
ASSERT(veh);
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
{
tempScript->OnReset(veh);
}
}
void ScriptMgr::OnInstallAccessory(Vehicle* veh, Creature* accessory)
{
ASSERT(veh);
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
ASSERT(accessory);
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
{
tempScript->OnInstallAccessory(veh, accessory);
}
}
void ScriptMgr::OnAddPassenger(Vehicle* veh, Unit* passenger, int8 seatId)
{
ASSERT(veh);
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
ASSERT(passenger);
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
{
tempScript->OnAddPassenger(veh, passenger, seatId);
}
}
void ScriptMgr::OnRemovePassenger(Vehicle* veh, Unit* passenger)
{
ASSERT(veh);
ASSERT(veh->GetBase()->GetTypeId() == TYPEID_UNIT);
ASSERT(passenger);
if (auto tempScript = ScriptRegistry<VehicleScript>::GetScriptById(veh->GetBase()->ToCreature()->GetScriptId()))
{
tempScript->OnRemovePassenger(veh, passenger);
}
}

View File

@@ -0,0 +1,44 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnWeatherChange(Weather* weather, WeatherState state, float grade)
{
ASSERT(weather);
ExecuteScript<ElunaScript>([&](ElunaScript* script)
{
script->OnWeatherChange(weather, state, grade);
});
if (auto tempScript = ScriptRegistry<WeatherScript>::GetScriptById(weather->GetScriptId()))
{
tempScript->OnChange(weather, state, grade);
}
}
void ScriptMgr::OnWeatherUpdate(Weather* weather, uint32 diff)
{
ASSERT(weather);
if (auto tempScript = ScriptRegistry<WeatherScript>::GetScriptById(weather->GetScriptId()))
{
tempScript->OnUpdate(weather, diff);
}
}

View File

@@ -0,0 +1,69 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnWorldObjectDestroy(WorldObject* object)
{
ASSERT(object);
ExecuteScript<WorldObjectScript>([&](WorldObjectScript* script)
{
script->OnWorldObjectDestroy(object);
});
}
void ScriptMgr::OnWorldObjectCreate(WorldObject* object)
{
ASSERT(object);
ExecuteScript<WorldObjectScript>([&](WorldObjectScript* script)
{
script->OnWorldObjectCreate(object);
});
}
void ScriptMgr::OnWorldObjectSetMap(WorldObject* object, Map* map)
{
ASSERT(object);
ExecuteScript<WorldObjectScript>([&](WorldObjectScript* script)
{
script->OnWorldObjectSetMap(object, map);
});
}
void ScriptMgr::OnWorldObjectResetMap(WorldObject* object)
{
ASSERT(object);
ExecuteScript<WorldObjectScript>([&](WorldObjectScript* script)
{
script->OnWorldObjectResetMap(object);
});
}
void ScriptMgr::OnWorldObjectUpdate(WorldObject* object, uint32 diff)
{
ASSERT(object);
ExecuteScript<WorldObjectScript>([&](WorldObjectScript* script)
{
script->OnWorldObjectUpdate(object, diff);
});
}

View File

@@ -0,0 +1,123 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
void ScriptMgr::OnOpenStateChange(bool open)
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnOpenStateChange(open);
});
}
void ScriptMgr::OnLoadCustomDatabaseTable()
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnLoadCustomDatabaseTable();
});
}
void ScriptMgr::OnBeforeConfigLoad(bool reload)
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnBeforeConfigLoad(reload);
});
}
void ScriptMgr::OnAfterConfigLoad(bool reload)
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnAfterConfigLoad(reload);
});
}
void ScriptMgr::OnBeforeFinalizePlayerWorldSession(uint32& cacheVersion)
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnBeforeFinalizePlayerWorldSession(cacheVersion);
});
}
void ScriptMgr::OnMotdChange(std::string& newMotd)
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnMotdChange(newMotd);
});
}
void ScriptMgr::OnShutdownInitiate(ShutdownExitCode code, ShutdownMask mask)
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnShutdownInitiate(code, mask);
});
}
void ScriptMgr::OnShutdownCancel()
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnShutdownCancel();
});
}
void ScriptMgr::OnWorldUpdate(uint32 diff)
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnUpdate(diff);
});
}
void ScriptMgr::OnStartup()
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnStartup();
});
}
void ScriptMgr::OnShutdown()
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnShutdown();
});
}
void ScriptMgr::OnBeforeWorldInitialized()
{
ExecuteScript<WorldScript>([&](WorldScript* script)
{
script->OnBeforeWorldInitialized();
});
}
void ScriptMgr::OnAfterUnloadAllMaps()
{
ExecuteScript<WorldScript>([](WorldScript* script)
{
script->OnAfterUnloadAllMaps();
});
}

File diff suppressed because it is too large Load Diff

View File

@@ -82,6 +82,7 @@ struct GroupQueueInfo;
struct ItemTemplate;
struct OutdoorPvPData;
struct TargetInfo;
struct SpellModifier;
namespace Acore::ChatCommands
{
@@ -186,6 +187,7 @@ public:
* @return True if you want to continue receive the packet, false if you want to disallow receive the packet
*/
[[nodiscard]] virtual bool CanPacketReceive(WorldSession* /*session*/, WorldPacket& /*packet*/) { return true; }
virtual void OnPacketReceived(WorldSession* /*session*/, WorldPacket const& /*packet*/) { }
};
class WorldScript : public ScriptObject
@@ -224,6 +226,11 @@ public:
// Called when the world is actually shut down.
virtual void OnShutdown() { }
/**
* @brief Called after all maps are unloaded from core
*/
virtual void OnAfterUnloadAllMaps() { }
/**
* @brief This hook runs before finalizing the player world session. Can be also used to mutate the cache version of the Client.
*
@@ -288,7 +295,7 @@ public:
_mapEntry = sMapStore.LookupEntry(_mapId);
if (!_mapEntry)
LOG_ERROR("maps.script", "Invalid MapScript for %u; no such map ID.", _mapId);
LOG_ERROR("maps.script", "Invalid MapScript for {}; no such map ID.", _mapId);
}
// Gets the MapEntry structure associated with this script. Can return nullptr.
@@ -329,7 +336,7 @@ public:
checkMap();
if (GetEntry() && !GetEntry()->IsWorldMap())
LOG_ERROR("maps.script", "WorldMapScript for map %u is invalid.", GetEntry()->MapID);
LOG_ERROR("maps.script", "WorldMapScript for map {} is invalid.", GetEntry()->MapID);
}
};
@@ -346,7 +353,7 @@ public:
checkMap();
if (GetEntry() && !GetEntry()->IsDungeon())
LOG_ERROR("maps.script", "InstanceMapScript for map %u is invalid.", GetEntry()->MapID);
LOG_ERROR("maps.script", "InstanceMapScript for map {} is invalid.", GetEntry()->MapID);
}
// Gets an InstanceScript object for this instance.
@@ -366,7 +373,7 @@ public:
checkMap();
if (GetEntry() && !GetEntry()->IsBattleground())
LOG_ERROR("maps.script", "BattlegroundMapScript for map %u is invalid.", GetEntry()->MapID);
LOG_ERROR("maps.script", "BattlegroundMapScript for map {} is invalid.", GetEntry()->MapID);
}
};
@@ -428,7 +435,7 @@ public:
//Called when Damage is Dealt
virtual uint32 DealDamage(Unit* /*AttackerUnit*/, Unit* /*pVictim*/, uint32 damage, DamageEffectType /*damagetype*/) { return damage; }
virtual void OnBeforeRollMeleeOutcomeAgainst(const Unit* /*attacker*/, const Unit* /*victim*/, WeaponAttackType /*attType*/, int32& /*attackerMaxSkillValueForLevel*/, int32& /*victimMaxSkillValueForLevel*/, int32& /*attackerWeaponSkill*/, int32& /*victimDefenseSkill*/, int32& /*crit_chance*/, int32& /*miss_chance*/, int32& /*dodge_chance*/, int32& /*parry_chance*/, int32& /*block_chance*/ ) { };
virtual void OnBeforeRollMeleeOutcomeAgainst(Unit const* /*attacker*/, Unit const* /*victim*/, WeaponAttackType /*attType*/, int32& /*attackerMaxSkillValueForLevel*/, int32& /*victimMaxSkillValueForLevel*/, int32& /*attackerWeaponSkill*/, int32& /*victimDefenseSkill*/, int32& /*crit_chance*/, int32& /*miss_chance*/, int32& /*dodge_chance*/, int32& /*parry_chance*/, int32& /*block_chance*/ ) { };
virtual void OnAuraRemove(Unit* /*unit*/, AuraApplication* /*aurApp*/, AuraRemoveMode /*mode*/) { }
@@ -444,6 +451,8 @@ public:
[[nodiscard]] virtual bool IsCustomBuildValuesUpdate(Unit const* /*unit*/, uint8 /*updateType*/, ByteBuffer& /*fieldBuffer*/, Player const* /*target*/, uint16 /*index*/) { return false; }
[[nodiscard]] virtual bool OnBuildValuesUpdate(Unit const* /*unit*/, uint8 /*updateType*/, ByteBuffer& /*fieldBuffer*/, Player* /*target*/, uint16 /*index*/) { return false; }
/**
* @brief This hook runs in Unit::Update
*
@@ -989,6 +998,7 @@ public:
// Called for player::update
virtual void OnBeforeUpdate(Player* /*player*/, uint32 /*p_time*/) { }
virtual void OnUpdate(Player* /*player*/, uint32 /*p_time*/) { }
virtual void OnAfterUpdate(Player* /*player*/, uint32 /*diff*/) {}
// Called when a player's money is modified (before the modification is done)
virtual void OnMoneyChanged(Player* /*player*/, int32& /*amount*/) { }
@@ -997,7 +1007,7 @@ public:
virtual void OnGiveXP(Player* /*player*/, uint32& /*amount*/, Unit* /*victim*/) { }
// Called when a player's reputation changes (before it is actually changed)
virtual void OnReputationChange(Player* /*player*/, uint32 /*factionId*/, int32& /*standing*/, bool /*incremental*/) { }
virtual bool OnReputationChange(Player* /*player*/, uint32 /*factionID*/, int32& /*standing*/, bool /*incremental*/) { return true; }
// Called when a player's reputation rank changes (before it is actually changed)
virtual void OnReputationRankChange(Player* /*player*/, uint32 /*factionID*/, ReputationRank /*newRank*/, ReputationRank /*olRank*/, bool /*increased*/) { }
@@ -1129,13 +1139,13 @@ public:
virtual void OnPlayerJoinArena(Player* /*player*/) { }
//Called when trying to get a team ID of a slot > 2 (This is for custom teams created by modules)
virtual void GetCustomGetArenaTeamId(const Player* /*player*/, uint8 /*slot*/, uint32& /*teamID*/) const { }
virtual void GetCustomGetArenaTeamId(Player const* /*player*/, uint8 /*slot*/, uint32& /*teamID*/) const { }
//Called when trying to get players personal rating of an arena slot > 2 (This is for custom teams created by modules)
virtual void GetCustomArenaPersonalRating(const Player* /*player*/, uint8 /*slot*/, uint32& /*rating*/) const { }
virtual void GetCustomArenaPersonalRating(Player const* /*player*/, uint8 /*slot*/, uint32& /*rating*/) const { }
//Called after the normal slots (0..2) for arena have been evaluated so that custom arena teams could modify it if nececasry
virtual void OnGetMaxPersonalArenaRatingRequirement(const Player* /*player*/, uint32 /*minSlot*/, uint32& /*maxArenaRating*/) const {}
virtual void OnGetMaxPersonalArenaRatingRequirement(Player const* /*player*/, uint32 /*minSlot*/, uint32& /*maxArenaRating*/) const {}
//After looting item
virtual void OnLootItem(Player* /*player*/, Item* /*item*/, uint32 /*count*/, ObjectGuid /*lootguid*/) { }
@@ -1499,7 +1509,7 @@ protected:
public:
// items
virtual void OnItemDelFromDB(CharacterDatabaseTransaction /*trans*/, ObjectGuid::LowType /*itemGuid*/) { }
virtual void OnMirrorImageDisplayItem(const Item* /*item*/, uint32& /*display*/) { }
virtual void OnMirrorImageDisplayItem(Item const* /*item*/, uint32& /*display*/) { }
// loot
virtual void OnAfterRefCount(Player const* /*player*/, LootStoreItem* /*LootStoreItem*/, Loot& /*loot*/, bool /*canRate*/, uint16 /*lootMode*/, uint32& /*maxcount*/, LootStore const& /*store*/) { }
@@ -1517,6 +1527,15 @@ public:
// Called before the phase for a WorldObject is set
virtual void OnBeforeWorldObjectSetPhaseMask(WorldObject const* /*worldObject*/, uint32& /*oldPhaseMask*/, uint32& /*newPhaseMask*/, bool& /*useCombinedPhases*/, bool& /*update*/) { }
// Called when checking if an aura spell is affected by a mod
virtual bool OnIsAffectedBySpellModCheck(SpellInfo const* /*affectSpell*/, SpellInfo const* /*checkSpell*/, SpellModifier const* /*mod*/) { return true; };
// Called when checking for spell negative healing modifiers
virtual bool OnSpellHealingBonusTakenNegativeModifiers(Unit const* /*target*/, Unit const* /*caster*/, SpellInfo const* /*spellInfo*/, float& /*val*/) { return false; };
// Called after loading spell dbc corrections
virtual void OnLoadSpellCustomAttr(SpellInfo* /*spell*/) { }
};
class BGScript : public ScriptObject
@@ -1700,6 +1719,9 @@ public:
// Runs on stop event
virtual void OnStop(uint16 /*EventID*/) { }
// Runs on event check
virtual void OnEventCheck(uint16 /*EventID*/) { }
};
class MailScript : public ScriptObject
@@ -1720,14 +1742,14 @@ protected:
public:
bool IsDatabaseBound() const { return false; }
[[nodiscard]] bool IsDatabaseBound() const override { return false; }
// After complete global acvievement
virtual void SetRealmCompleted(AchievementEntry const* /*achievement*/) { }
[[nodiscard]] virtual bool IsCompletedCriteria(AchievementMgr* /*mgr*/, AchievementCriteriaEntry const* /*achievementCriteria*/, AchievementEntry const* /*achievement*/, CriteriaProgress const* /*progress*/) { return true; }
[[nodiscard]] virtual bool IsRealmCompleted(AchievementGlobalMgr const* /*globalmgr*/, AchievementEntry const* /*achievement*/, std::chrono::system_clock::time_point /*completionTime*/) { return true; }
[[nodiscard]] virtual bool IsRealmCompleted(AchievementGlobalMgr const* /*globalmgr*/, AchievementEntry const* /*achievement*/, SystemTimePoint /*completionTime*/) { return true; }
virtual void OnBeforeCheckCriteria(AchievementMgr* /*mgr*/, AchievementCriteriaEntryList const* /*achievementCriteriaList*/) { }
@@ -1742,7 +1764,7 @@ protected:
public:
bool IsDatabaseBound() const { return false; }
[[nodiscard]] bool IsDatabaseBound() const override { return false; }
virtual void OnInitStatsForLevel(Guardian* /*guardian*/, uint8 /*petlevel*/) { }
@@ -1770,7 +1792,7 @@ protected:
public:
bool IsDatabaseBound() const { return false; }
[[nodiscard]] bool IsDatabaseBound() const override { return false; }
[[nodiscard]] virtual bool CanAddMember(ArenaTeam* /*team*/, ObjectGuid /*PlayerGuid*/) { return true; }
@@ -1787,7 +1809,7 @@ protected:
public:
bool IsDatabaseBound() const { return false; }
[[nodiscard]] bool IsDatabaseBound() const override { return false; }
virtual void OnConstructObject(Object* /*origin*/) { }
@@ -1840,9 +1862,9 @@ protected:
public:
bool IsDatabaseBound() const { return false; }
[[nodiscard]] bool IsDatabaseBound() const override { return false; }
virtual void OnHandleDevCommand(Player* /*player*/, std::string& /*argstr*/) { }
virtual void OnHandleDevCommand(Player* /*player*/, bool& /*enable*/) { }
/**
* @brief This hook runs execute chat command
@@ -1861,9 +1883,15 @@ protected:
public:
bool IsDatabaseBound() const { return false; }
[[nodiscard]] bool IsDatabaseBound() const override { return false; }
[[nodiscard]] virtual bool OnDatabasesLoading() { return true; }
virtual void OnAfterDatabasesLoaded(uint32 /*updateFlags*/) { }
virtual void OnDatabasesKeepAlive() { }
virtual void OnDatabasesClosing() { }
virtual void OnDatabaseWarnAboutSyncQueries(bool /*apply*/) { }
virtual void OnDatabaseSelectIndexLogout(Player* /*player*/, uint32& /*statementIndex*/, uint32& /*statementParam*/) { }
virtual void OnDatabaseGetDBRevision(std::string& /*revision*/) { }
};
class WorldObjectScript : public ScriptObject
@@ -1874,7 +1902,7 @@ protected:
public:
bool IsDatabaseBound() const { return false; }
[[nodiscard]] bool IsDatabaseBound() const override { return false; }
/**
* @brief This hook called before destroy world object
@@ -1921,7 +1949,7 @@ protected:
public:
bool IsDatabaseBound() const { return false; }
[[nodiscard]] bool IsDatabaseBound() const override { return false; }
/**
* @brief This hook called before money loot
@@ -1952,6 +1980,37 @@ public:
[[nodiscard]] virtual bool CanAreaTrigger(Player* /*player*/, AreaTrigger const* /*trigger*/) { return false; }
};
class MetricScript : public ScriptObject
{
protected:
MetricScript(const char* name);
public:
bool IsDatabaseBound() const { return false; }
virtual void OnMetricLogging() { }
};
class PlayerbotScript : public ScriptObject
{
protected:
PlayerbotScript(const char* name);
public:
bool IsDatabaseBound() const { return false; }
[[nodiscard]] virtual bool OnPlayerbotCheckLFGQueue(lfg::Lfg5Guids const& /*guidsList*/) { return true; }
virtual void OnPlayerbotCheckKillTask(Player* /*player*/, Unit* /*victim*/) { }
virtual void OnPlayerbotCheckPetitionAccount(Player* /*player*/, bool& /*found*/) { }
[[nodiscard]] virtual bool OnPlayerbotCheckUpdatesToSend(Player* /*player*/) { return true; }
virtual void OnPlayerbotPacketSent(Player* /*player*/, WorldPacket const* /*packet*/) { }
virtual void OnPlayerbotUpdate(uint32 /*diff*/) { }
virtual void OnPlayerbotUpdateSessions(Player* /*player*/) { }
virtual void OnPlayerbotLogout(Player* /*player*/) { }
virtual void OnPlayerbotLogoutBots() { }
};
// Manages registration, loading, and execution of scripts.
class ScriptMgr
{
@@ -2004,6 +2063,7 @@ public: /* ServerScript */
void OnSocketOpen(std::shared_ptr<WorldSocket> socket);
void OnSocketClose(std::shared_ptr<WorldSocket> socket);
bool CanPacketReceive(WorldSession* session, WorldPacket const& packet);
void OnPacketReceived(WorldSession* session, WorldPacket const& packet);
bool CanPacketSend(WorldSession* session, WorldPacket const& packet);
public: /* WorldScript */
@@ -2019,6 +2079,7 @@ public: /* WorldScript */
void OnStartup();
void OnShutdown();
void OnBeforeWorldInitialized();
void OnAfterUnloadAllMaps();
public: /* FormulaScript */
void OnHonorCalculation(float& honor, uint8 level, float multiplier);
@@ -2138,6 +2199,7 @@ public: /* AchievementCriteriaScript */
public: /* PlayerScript */
void OnBeforePlayerUpdate(Player* player, uint32 p_time);
void OnPlayerUpdate(Player* player, uint32 p_time);
void OnAfterPlayerUpdate(Player* player, uint32 diff);
void OnSendInitialPacketsBeforeAddToMap(Player* player, WorldPacket& data);
void OnPlayerReleasedGhost(Player* player);
void OnPVPKill(Player* killer, Player* killed);
@@ -2150,7 +2212,7 @@ public: /* PlayerScript */
void OnPlayerTalentsReset(Player* player, bool noCost);
void OnPlayerMoneyChanged(Player* player, int32& amount);
void OnGivePlayerXP(Player* player, uint32& amount, Unit* victim);
void OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental);
bool OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental);
void OnPlayerReputationRankChange(Player* player, uint32 factionID, ReputationRank newRank, ReputationRank oldRank, bool increased);
void OnPlayerLearnSpell(Player* player, uint32 spellID);
void OnPlayerForgotSpell(Player* player, uint32 spellID);
@@ -2195,9 +2257,9 @@ public: /* PlayerScript */
void OnEquip(Player* player, Item* it, uint8 bag, uint8 slot, bool update);
void OnPlayerJoinBG(Player* player);
void OnPlayerJoinArena(Player* player);
void GetCustomGetArenaTeamId(const Player* player, uint8 slot, uint32& teamID) const;
void GetCustomArenaPersonalRating(const Player* player, uint8 slot, uint32& rating) const;
void OnGetMaxPersonalArenaRatingRequirement(const Player* player, uint32 minSlot, uint32& maxArenaRating) const;
void GetCustomGetArenaTeamId(Player const* player, uint8 slot, uint32& teamID) const;
void GetCustomArenaPersonalRating(Player const* player, uint8 slot, uint32& rating) const;
void OnGetMaxPersonalArenaRatingRequirement(Player const* player, uint32 minSlot, uint32& maxArenaRating) const;
void OnLootItem(Player* player, Item* item, uint32 count, ObjectGuid lootguid);
void OnCreateItem(Player* player, Item* item, uint32 count);
void OnQuestRewardItem(Player* player, Item* item, uint32 count);
@@ -2323,7 +2385,7 @@ public: /* GroupScript */
public: /* GlobalScript */
void OnGlobalItemDelFromDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid);
void OnGlobalMirrorImageDisplayItem(const Item* item, uint32& display);
void OnGlobalMirrorImageDisplayItem(Item const* item, uint32& display);
void OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map<ObjectGuid, uint32>& ap);
void OnAfterRefCount(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, uint32& maxcount, LootStore const& store);
void OnBeforeDropAddItem(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, LootStore const& store);
@@ -2333,6 +2395,9 @@ public: /* GlobalScript */
void OnAfterInitializeLockedDungeons(Player* player);
void OnAfterUpdateEncounterState(Map* map, EncounterCreditType type, uint32 creditEntry, Unit* source, Difficulty difficulty_fixed, DungeonEncounterList const* encounters, uint32 dungeonCompleted, bool updated);
void OnBeforeWorldObjectSetPhaseMask(WorldObject const* worldObject, uint32& oldPhaseMask, uint32& newPhaseMask, bool& useCombinedPhases, bool& update);
bool OnIsAffectedBySpellModCheck(SpellInfo const* affectSpell, SpellInfo const* checkSpell, SpellModifier const* mod);
bool OnSpellHealingBonusTakenNegativeModifiers(Unit const* target, Unit const* caster, SpellInfo const* spellInfo, float& val);
void OnLoadSpellCustomAttr(SpellInfo* spell);
public: /* Scheduled scripts */
uint32 IncreaseScheduledScriptsCount() { return ++_scheduledScripts; }
@@ -2348,7 +2413,7 @@ public: /* UnitScript */
void ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& damage);
void ModifyHealRecieved(Unit* target, Unit* attacker, uint32& addHealth);
uint32 DealDamage(Unit* AttackerUnit, Unit* pVictim, uint32 damage, DamageEffectType damagetype);
void OnBeforeRollMeleeOutcomeAgainst(const Unit* attacker, const Unit* victim, WeaponAttackType attType, int32& attackerMaxSkillValueForLevel, int32& victimMaxSkillValueForLevel, int32& attackerWeaponSkill, int32& victimDefenseSkill, int32& crit_chance, int32& miss_chance, int32& dodge_chance, int32& parry_chance, int32& block_chance);
void OnBeforeRollMeleeOutcomeAgainst(Unit const* attacker, Unit const* victim, WeaponAttackType attType, int32& attackerMaxSkillValueForLevel, int32& victimMaxSkillValueForLevel, int32& attackerWeaponSkill, int32& victimDefenseSkill, int32& crit_chance, int32& miss_chance, int32& dodge_chance, int32& parry_chance, int32& block_chance);
void OnAuraRemove(Unit* unit, AuraApplication* aurApp, AuraRemoveMode mode);
bool IfNormalReaction(Unit const* unit, Unit const* target, ReputationRank& repRank);
bool IsNeedModSpellDamagePercent(Unit const* unit, AuraEffect* auraEff, float& doneTotalMod, SpellInfo const* spellProto);
@@ -2356,6 +2421,7 @@ public: /* UnitScript */
bool IsNeedModHealPercent(Unit const* unit, AuraEffect* auraEff, float& doneTotalMod, SpellInfo const* spellProto);
bool CanSetPhaseMask(Unit const* unit, uint32 newPhaseMask, bool update);
bool IsCustomBuildValuesUpdate(Unit const* unit, uint8 updateType, ByteBuffer& fieldBuffer, Player const* target, uint16 index);
bool OnBuildValuesUpdate(Unit const* unit, uint8 updateType, ByteBuffer& fieldBuffer, Player* target, uint16 index);
void OnUnitUpdate(Unit* unit, uint32 diff);
public: /* MovementHandlerScript */
@@ -2415,6 +2481,7 @@ public: /* SpellSC */
public: /* GameEventScript */
void OnGameEventStart(uint16 EventID);
void OnGameEventStop(uint16 EventID);
void OnGameEventCheck(uint16 EventID);
public: /* MailScript */
void OnBeforeMailDraftSendMailTo(MailDraft* mailDraft, MailReceiver const& receiver, MailSender const& sender, MailCheckMask& checked, uint32& deliver_delay, uint32& custom_expiration, bool& deleteMailItemsFromDB, bool& sendMail);
@@ -2464,12 +2531,18 @@ public: /* MiscScript */
public: /* CommandSC */
void OnHandleDevCommand(Player* player, std::string& argstr);
void OnHandleDevCommand(Player* player, bool& enable);
bool CanExecuteCommand(ChatHandler& handler, std::string_view cmdStr);
public: /* DatabaseScript */
bool OnDatabasesLoading();
void OnAfterDatabasesLoaded(uint32 updateFlags);
void OnDatabasesKeepAlive();
void OnDatabasesClosing();
void OnDatabaseWarnAboutSyncQueries(bool apply);
void OnDatabaseSelectIndexLogout(Player* player, uint32& statementIndex, uint32& statementParam);
void OnDatabaseGetDBRevision(std::string& revision);
public: /* WorldObjectScript */
@@ -2487,6 +2560,21 @@ public: /* LootScript */
void OnLootMoney(Player* player, uint32 gold);
public: /* MetricScript */
void OnMetricLogging();
public: /* PlayerbotScript */
bool OnPlayerbotCheckLFGQueue(lfg::Lfg5Guids const& guidsList);
void OnPlayerbotCheckKillTask(Player* player, Unit* victim);
void OnPlayerbotCheckPetitionAccount(Player* player, bool& found);
bool OnPlayerbotCheckUpdatesToSend(Player* player);
void OnPlayerbotPacketSent(Player* player, WorldPacket const* packet);
void OnPlayerbotUpdate(uint32 diff);
void OnPlayerbotUpdateSessions(Player* player);
void OnPlayerbotLogout(Player* player);
void OnPlayerbotLogoutBots();
private:
uint32 _scriptCount;
@@ -2517,7 +2605,7 @@ public:
GenericSpellAndAuraScriptLoader(char const* name, ArgsType&& args) : SpellScriptLoader(name), _args(std::move(args)) { }
private:
SpellScript* GetSpellScript() const override
[[nodiscard]] SpellScript* GetSpellScript() const override
{
if constexpr (!std::is_same_v<SpellScriptType, Acore::find_type_end>)
{
@@ -2529,7 +2617,7 @@ private:
}
}
AuraScript* GetAuraScript() const override
[[nodiscard]] AuraScript* GetAuraScript() const override
{
if constexpr (!std::is_same_v<AuraScriptType, Acore::find_type_end>)
{
@@ -2677,8 +2765,8 @@ public:
{
// The script uses a script name from database, but isn't assigned to anything.
if (script->GetName().find("Smart") == std::string::npos)
LOG_ERROR("sql.sql", "Script named '%s' is not assigned in the database.",
script->GetName().c_str());
LOG_ERROR("sql.sql", "Script named '{}' is not assigned in the database.",
script->GetName());
}
}
else
@@ -2711,8 +2799,8 @@ private:
{
if (it->second == script)
{
LOG_ERROR("scripts", "Script '%s' has same memory pointer as '%s'.",
script->GetName().c_str(), it->second->GetName().c_str());
LOG_ERROR("scripts", "Script '{}' has same memory pointer as '{}'.",
script->GetName(), it->second->GetName());
return false;
}

View File

@@ -20,69 +20,48 @@
#include "ScriptMgr.h"
template<typename ScriptName, typename TCallBack>
inline bool GetReturnBoolScripts(bool ret, TCallBack&& callback)
template<typename ScriptName>
inline Optional<bool> IsValidBoolScript(std::function<bool(ScriptName*)> executeHook)
{
if (ScriptRegistry<ScriptName>::ScriptPointerList.empty())
return ret;
bool needReturn = !ret;
return {};
for (auto const& [scriptID, script] : ScriptRegistry<ScriptName>::ScriptPointerList)
{
if (callback(script))
return needReturn;
if (executeHook(script))
return true;
}
return ret;
return false;
}
template<class ScriptName, class T, typename TCallBack>
inline void GetReturnIndexScripts([[maybe_unused]] T* ret, TCallBack&& callback)
template<typename ScriptName, class T>
inline T* GetReturnAIScript(std::function<T*(ScriptName*)> executeHook)
{
if (ScriptRegistry<ScriptName>::ScriptPointerList.empty())
return;
return nullptr;
for (auto const& [scriptID, script] : ScriptRegistry<ScriptName>::ScriptPointerList)
{
if (T* scriptAI = callback(script))
if (T* scriptAI = executeHook(script))
{
ret = scriptAI;
break;
return scriptAI;
}
}
return nullptr;
}
// Utility macros to refer to the script registry.
#define SCR_REG_MAP(T) ScriptRegistry<T>::ScriptMap
#define SCR_REG_ITR(T) ScriptRegistry<T>::ScriptMapIterator
#define SCR_REG_LST(T) ScriptRegistry<T>::ScriptPointerList
// Utility macros for looping over scripts.
#define FOR_SCRIPTS(T, C, E) \
if (!SCR_REG_LST(T).empty()) \
for (SCR_REG_ITR(T) C = SCR_REG_LST(T).begin(); \
C != SCR_REG_LST(T).end(); ++C)
#define FOR_SCRIPTS_RET(T, C, E, R) \
if (SCR_REG_LST(T).empty()) \
return R; \
for (SCR_REG_ITR(T) C = SCR_REG_LST(T).begin(); \
C != SCR_REG_LST(T).end(); ++C)
#define FOREACH_SCRIPT(T) \
FOR_SCRIPTS(T, itr, end) \
itr->second
// Utility macros for finding specific scripts.
#define GET_SCRIPT(T, I, V) \
T* V = ScriptRegistry<T>::GetScriptById(I); \
if (!V) \
template<typename ScriptName>
inline void ExecuteScript(std::function<void(ScriptName*)> executeHook)
{
if (ScriptRegistry<ScriptName>::ScriptPointerList.empty())
return;
#define GET_SCRIPT_RET(T, I, V, R) \
T* V = ScriptRegistry<T>::GetScriptById(I); \
if (!V) \
return R;
for (auto const& [scriptID, script] : ScriptRegistry<ScriptName>::ScriptPointerList)
{
executeHook(script);
}
}
#endif // _SCRIPT_MGR_MACRO_H_

View File

@@ -18,7 +18,6 @@
#include "ScriptSystem.h"
#include "DatabaseEnv.h"
#include "ObjectMgr.h"
#include "ScriptMgr.h"
ScriptPointVector const SystemMgr::_empty;
@@ -42,7 +41,7 @@ void SystemMgr::LoadScriptWaypoints()
if (result)
uiCreatureCount = result->GetRowCount();
LOG_INFO("server.loading", "Loading Script Waypoints for " UI64FMTD " creature(s)...", uiCreatureCount);
LOG_INFO("server.loading", "Loading Script Waypoints for {} creature(s)...", uiCreatureCount);
// 0 1 2 3 4 5
result = WorldDatabase.Query("SELECT entry, pointid, location_x, location_y, location_z, waittime FROM script_waypoint ORDER BY pointid");
@@ -61,28 +60,28 @@ void SystemMgr::LoadScriptWaypoints()
Field* pFields = result->Fetch();
ScriptPointMove temp;
temp.uiCreatureEntry = pFields[0].GetUInt32();
temp.uiCreatureEntry = pFields[0].Get<uint32>();
uint32 uiEntry = temp.uiCreatureEntry;
temp.uiPointId = pFields[1].GetUInt32();
temp.fX = pFields[2].GetFloat();
temp.fY = pFields[3].GetFloat();
temp.fZ = pFields[4].GetFloat();
temp.uiWaitTime = pFields[5].GetUInt32();
temp.uiPointId = pFields[1].Get<uint32>();
temp.fX = pFields[2].Get<float>();
temp.fY = pFields[3].Get<float>();
temp.fZ = pFields[4].Get<float>();
temp.uiWaitTime = pFields[5].Get<uint32>();
CreatureTemplate const* pCInfo = sObjectMgr->GetCreatureTemplate(temp.uiCreatureEntry);
if (!pCInfo)
{
LOG_ERROR("sql.sql", "DB table script_waypoint has waypoint for non-existant creature entry %u", temp.uiCreatureEntry);
LOG_ERROR("sql.sql", "DB table script_waypoint has waypoint for non-existant creature entry {}", temp.uiCreatureEntry);
continue;
}
if (!pCInfo->ScriptID)
LOG_ERROR("sql.sql", "DB table script_waypoint has waypoint for creature entry %u, but creature does not have ScriptName defined and then useless.", temp.uiCreatureEntry);
LOG_ERROR("sql.sql", "DB table script_waypoint has waypoint for creature entry {}, but creature does not have ScriptName defined and then useless.", temp.uiCreatureEntry);
m_mPointMoveMap[uiEntry].push_back(temp);
++count;
} while (result->NextRow());
LOG_INFO("server.loading", ">> Loaded %u Script Waypoint nodes in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
LOG_INFO("server.loading", ">> Loaded {} Script Waypoint nodes in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
}