mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 10:30:27 +00:00
refactor(Core/Game): restyle game lib with astyle (#3466)
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
|
||||
/// Put scripts in the execution queue
|
||||
void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, Object* target)
|
||||
{
|
||||
{
|
||||
///- Find the script map
|
||||
ScriptMapMap::const_iterator s = scripts.find(id);
|
||||
if (s == scripts.end())
|
||||
@@ -59,7 +59,7 @@ void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, O
|
||||
}
|
||||
|
||||
void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target)
|
||||
{
|
||||
{
|
||||
// NOTE: script record _must_ exist until command executed
|
||||
|
||||
// prepare static data
|
||||
@@ -88,7 +88,7 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou
|
||||
|
||||
// Helpers for ScriptProcess method.
|
||||
inline Player* Map::_GetScriptPlayerSourceOrTarget(Object* source, Object* target, const ScriptInfo* scriptInfo) const
|
||||
{
|
||||
{
|
||||
Player* player = nullptr;
|
||||
if (!source && !target)
|
||||
sLog->outError("%s source and target objects are NULL.", scriptInfo->GetDebugInfo().c_str());
|
||||
@@ -102,15 +102,15 @@ inline Player* Map::_GetScriptPlayerSourceOrTarget(Object* source, Object* targe
|
||||
|
||||
if (!player)
|
||||
sLog->outError("%s neither source nor target object is player (source: TypeId: %u, Entry: %u, GUID: %u; target: TypeId: %u, Entry: %u, GUID: %u), skipping.",
|
||||
scriptInfo->GetDebugInfo().c_str(),
|
||||
source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUIDLow() : 0,
|
||||
target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUIDLow() : 0);
|
||||
scriptInfo->GetDebugInfo().c_str(),
|
||||
source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUIDLow() : 0,
|
||||
target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUIDLow() : 0);
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
inline Creature* Map::_GetScriptCreatureSourceOrTarget(Object* source, Object* target, const ScriptInfo* scriptInfo, bool bReverse) const
|
||||
{
|
||||
{
|
||||
Creature* creature = nullptr;
|
||||
if (!source && !target)
|
||||
sLog->outError("%s source and target objects are NULL.", scriptInfo->GetDebugInfo().c_str());
|
||||
@@ -135,33 +135,33 @@ inline Creature* Map::_GetScriptCreatureSourceOrTarget(Object* source, Object* t
|
||||
|
||||
if (!creature)
|
||||
sLog->outError("%s neither source nor target are creatures (source: TypeId: %u, Entry: %u, GUID: %u; target: TypeId: %u, Entry: %u, GUID: %u), skipping.",
|
||||
scriptInfo->GetDebugInfo().c_str(),
|
||||
source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUIDLow() : 0,
|
||||
target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUIDLow() : 0);
|
||||
scriptInfo->GetDebugInfo().c_str(),
|
||||
source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUIDLow() : 0,
|
||||
target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUIDLow() : 0);
|
||||
}
|
||||
return creature;
|
||||
}
|
||||
|
||||
inline Unit* Map::_GetScriptUnit(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const
|
||||
{
|
||||
{
|
||||
Unit* unit = nullptr;
|
||||
if (!obj)
|
||||
sLog->outError("%s %s object is NULL.", scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
|
||||
else if (!obj->isType(TYPEMASK_UNIT))
|
||||
sLog->outError("%s %s object is not unit (TypeId: %u, Entry: %u, GUID: %u), skipping.",
|
||||
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUIDLow());
|
||||
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUIDLow());
|
||||
else
|
||||
{
|
||||
unit = obj->ToUnit();
|
||||
if (!unit)
|
||||
sLog->outError("%s %s object could not be casted to unit.",
|
||||
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
|
||||
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
|
||||
}
|
||||
return unit;
|
||||
}
|
||||
|
||||
inline Player* Map::_GetScriptPlayer(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const
|
||||
{
|
||||
{
|
||||
Player* player = nullptr;
|
||||
if (!obj)
|
||||
sLog->outError("%s %s object is NULL.", scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
|
||||
@@ -170,13 +170,13 @@ inline Player* Map::_GetScriptPlayer(Object* obj, bool isSource, const ScriptInf
|
||||
player = obj->ToPlayer();
|
||||
if (!player)
|
||||
sLog->outError("%s %s object is not a player (TypeId: %u, Entry: %u, GUID: %u).",
|
||||
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUIDLow());
|
||||
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUIDLow());
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
inline Creature* Map::_GetScriptCreature(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const
|
||||
{
|
||||
{
|
||||
Creature* creature = nullptr;
|
||||
if (!obj)
|
||||
sLog->outError("%s %s object is NULL.", scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
|
||||
@@ -185,36 +185,39 @@ inline Creature* Map::_GetScriptCreature(Object* obj, bool isSource, const Scrip
|
||||
creature = obj->ToCreature();
|
||||
if (!creature)
|
||||
sLog->outError("%s %s object is not a creature (TypeId: %u, Entry: %u, GUID: %u).", scriptInfo->GetDebugInfo().c_str(),
|
||||
isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUIDLow());
|
||||
isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUIDLow());
|
||||
}
|
||||
return creature;
|
||||
}
|
||||
|
||||
inline WorldObject* Map::_GetScriptWorldObject(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const
|
||||
{
|
||||
{
|
||||
WorldObject* pWorldObject = nullptr;
|
||||
if (!obj)
|
||||
sLog->outError("%s %s object is NULL.",
|
||||
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
|
||||
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
|
||||
else
|
||||
{
|
||||
pWorldObject = dynamic_cast<WorldObject*>(obj);
|
||||
if (!pWorldObject)
|
||||
sLog->outError("%s %s object is not a world object (TypeId: %u, Entry: %u, GUID: %u).",
|
||||
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUIDLow());
|
||||
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUIDLow());
|
||||
}
|
||||
return pWorldObject;
|
||||
}
|
||||
|
||||
inline void Map::_ScriptProcessDoor(Object* source, Object* target, const ScriptInfo* scriptInfo) const
|
||||
{
|
||||
{
|
||||
bool bOpen = false;
|
||||
uint32 guid = scriptInfo->ToggleDoor.GOGuid;
|
||||
int32 nTimeToToggle = std::max(15, int32(scriptInfo->ToggleDoor.ResetDelay));
|
||||
switch (scriptInfo->command)
|
||||
{
|
||||
case SCRIPT_COMMAND_OPEN_DOOR: bOpen = true; break;
|
||||
case SCRIPT_COMMAND_CLOSE_DOOR: break;
|
||||
case SCRIPT_COMMAND_OPEN_DOOR:
|
||||
bOpen = true;
|
||||
break;
|
||||
case SCRIPT_COMMAND_CLOSE_DOOR:
|
||||
break;
|
||||
default:
|
||||
sLog->outError("%s unknown command for _ScriptProcessDoor.", scriptInfo->GetDebugInfo().c_str());
|
||||
return;
|
||||
@@ -225,13 +228,13 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script
|
||||
sLog->outError("%s source object is NULL.", scriptInfo->GetDebugInfo().c_str());
|
||||
else if (!source->isType(TYPEMASK_UNIT))
|
||||
sLog->outError("%s source object is not unit (TypeId: %u, Entry: %u, GUID: %u), skipping.", scriptInfo->GetDebugInfo().c_str(),
|
||||
source->GetTypeId(), source->GetEntry(), source->GetGUIDLow());
|
||||
source->GetTypeId(), source->GetEntry(), source->GetGUIDLow());
|
||||
else
|
||||
{
|
||||
WorldObject* wSource = dynamic_cast <WorldObject*> (source);
|
||||
if (!wSource)
|
||||
sLog->outError("%s source object could not be casted to world object (TypeId: %u, Entry: %u, GUID: %u), skipping.",
|
||||
scriptInfo->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow());
|
||||
scriptInfo->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow());
|
||||
else
|
||||
{
|
||||
GameObject* pDoor = _FindGameObject(wSource, guid);
|
||||
@@ -239,7 +242,7 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script
|
||||
sLog->outError("%s gameobject was not found (guid: %u).", scriptInfo->GetDebugInfo().c_str(), guid);
|
||||
else if (pDoor->GetGoType() != GAMEOBJECT_TYPE_DOOR)
|
||||
sLog->outError("%s gameobject is not a door (GoType: %u, Entry: %u, GUID: %u).",
|
||||
scriptInfo->GetDebugInfo().c_str(), pDoor->GetGoType(), pDoor->GetEntry(), pDoor->GetGUIDLow());
|
||||
scriptInfo->GetDebugInfo().c_str(), pDoor->GetGoType(), pDoor->GetEntry(), pDoor->GetGUIDLow());
|
||||
else if (bOpen == (pDoor->GetGoState() == GO_STATE_READY))
|
||||
{
|
||||
pDoor->UseDoorOrButton(nTimeToToggle);
|
||||
@@ -256,7 +259,7 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script
|
||||
}
|
||||
|
||||
inline GameObject* Map::_FindGameObject(WorldObject* searchObject, uint32 guid) const
|
||||
{
|
||||
{
|
||||
GameObject* gameobject = nullptr;
|
||||
|
||||
CellCoord p(acore::ComputeCellCoord(searchObject->GetPositionX(), searchObject->GetPositionY()));
|
||||
@@ -273,7 +276,7 @@ inline GameObject* Map::_FindGameObject(WorldObject* searchObject, uint32 guid)
|
||||
|
||||
/// Process queued scripts
|
||||
void Map::ScriptsProcess()
|
||||
{
|
||||
{
|
||||
if (m_scriptSchedule.empty())
|
||||
return;
|
||||
|
||||
@@ -311,14 +314,14 @@ void Map::ScriptsProcess()
|
||||
source = GetCorpse(step.sourceGUID);
|
||||
break;
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
{
|
||||
GameObject* go = GetGameObject(step.sourceGUID);
|
||||
source = go ? go->ToTransport() : nullptr;
|
||||
break;
|
||||
}
|
||||
{
|
||||
GameObject* go = GetGameObject(step.sourceGUID);
|
||||
source = go ? go->ToTransport() : nullptr;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sLog->outError("%s source with unsupported high guid (GUID: " UI64FMTD ", high guid: %u).",
|
||||
step.script->GetDebugInfo().c_str(), step.sourceGUID, GUID_HIPART(step.sourceGUID));
|
||||
step.script->GetDebugInfo().c_str(), step.sourceGUID, GUID_HIPART(step.sourceGUID));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -346,14 +349,14 @@ void Map::ScriptsProcess()
|
||||
target = GetCorpse(step.targetGUID);
|
||||
break;
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
{
|
||||
GameObject* go = GetGameObject(step.targetGUID);
|
||||
target = go ? go->ToTransport() : nullptr;
|
||||
break;
|
||||
}
|
||||
{
|
||||
GameObject* go = GetGameObject(step.targetGUID);
|
||||
target = go ? go->ToTransport() : nullptr;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sLog->outError("%s target with unsupported high guid (GUID: " UI64FMTD ", high guid: %u).",
|
||||
step.script->GetDebugInfo().c_str(), step.targetGUID, GUID_HIPART(step.targetGUID));
|
||||
step.script->GetDebugInfo().c_str(), step.targetGUID, GUID_HIPART(step.targetGUID));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -388,14 +391,14 @@ void Map::ScriptsProcess()
|
||||
break;
|
||||
case CHAT_TYPE_WHISPER:
|
||||
case CHAT_MSG_RAID_BOSS_WHISPER:
|
||||
{
|
||||
uint64 targetGUID = target ? target->GetGUID() : 0;
|
||||
if (!targetGUID || !IS_PLAYER_GUID(targetGUID))
|
||||
sLog->outError("%s attempt to whisper to non-player unit, skipping.", step.script->GetDebugInfo().c_str());
|
||||
else
|
||||
player->Whisper(text, LANG_UNIVERSAL, targetGUID);
|
||||
break;
|
||||
}
|
||||
{
|
||||
uint64 targetGUID = target ? target->GetGUID() : 0;
|
||||
if (!targetGUID || !IS_PLAYER_GUID(targetGUID))
|
||||
sLog->outError("%s attempt to whisper to non-player unit, skipping.", step.script->GetDebugInfo().c_str());
|
||||
else
|
||||
player->Whisper(text, LANG_UNIVERSAL, targetGUID);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break; // must be already checked at load
|
||||
}
|
||||
@@ -458,8 +461,8 @@ void Map::ScriptsProcess()
|
||||
// Validate field number.
|
||||
if (step.script->FieldSet.FieldID <= OBJECT_FIELD_ENTRY || step.script->FieldSet.FieldID >= cSource->GetValuesCount())
|
||||
sLog->outError("%s wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, GUID: %u) specified, skipping.",
|
||||
step.script->GetDebugInfo().c_str(), step.script->FieldSet.FieldID,
|
||||
cSource->GetValuesCount(), cSource->GetTypeId(), cSource->GetEntry(), cSource->GetGUIDLow());
|
||||
step.script->GetDebugInfo().c_str(), step.script->FieldSet.FieldID,
|
||||
cSource->GetValuesCount(), cSource->GetTypeId(), cSource->GetEntry(), cSource->GetGUIDLow());
|
||||
else
|
||||
cSource->SetUInt32Value(step.script->FieldSet.FieldID, step.script->FieldSet.FieldValue);
|
||||
}
|
||||
@@ -469,7 +472,7 @@ void Map::ScriptsProcess()
|
||||
// Source or target must be Creature.
|
||||
if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
|
||||
{
|
||||
Unit * unit = (Unit*)cSource;
|
||||
Unit* unit = (Unit*)cSource;
|
||||
if (step.script->MoveTo.TravelTime != 0)
|
||||
{
|
||||
float speed = unit->GetDistance(step.script->MoveTo.DestX, step.script->MoveTo.DestY, step.script->MoveTo.DestZ) / ((float)step.script->MoveTo.TravelTime * 0.001f);
|
||||
@@ -487,8 +490,8 @@ void Map::ScriptsProcess()
|
||||
// Validate field number.
|
||||
if (step.script->FlagToggle.FieldID <= OBJECT_FIELD_ENTRY || step.script->FlagToggle.FieldID >= cSource->GetValuesCount())
|
||||
sLog->outError("%s wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, GUID: %u) specified, skipping.",
|
||||
step.script->GetDebugInfo().c_str(), step.script->FlagToggle.FieldID,
|
||||
cSource->GetValuesCount(), cSource->GetTypeId(), cSource->GetEntry(), cSource->GetGUIDLow());
|
||||
step.script->GetDebugInfo().c_str(), step.script->FlagToggle.FieldID,
|
||||
cSource->GetValuesCount(), cSource->GetTypeId(), cSource->GetEntry(), cSource->GetGUIDLow());
|
||||
else
|
||||
cSource->SetFlag(step.script->FlagToggle.FieldID, step.script->FlagToggle.FieldValue);
|
||||
}
|
||||
@@ -501,8 +504,8 @@ void Map::ScriptsProcess()
|
||||
// Validate field number.
|
||||
if (step.script->FlagToggle.FieldID <= OBJECT_FIELD_ENTRY || step.script->FlagToggle.FieldID >= cSource->GetValuesCount())
|
||||
sLog->outError("%s wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, GUID: %u) specified, skipping.",
|
||||
step.script->GetDebugInfo().c_str(), step.script->FlagToggle.FieldID,
|
||||
cSource->GetValuesCount(), cSource->GetTypeId(), cSource->GetEntry(), cSource->GetGUIDLow());
|
||||
step.script->GetDebugInfo().c_str(), step.script->FlagToggle.FieldID,
|
||||
cSource->GetValuesCount(), cSource->GetTypeId(), cSource->GetEntry(), cSource->GetGUIDLow());
|
||||
else
|
||||
cSource->RemoveFlag(step.script->FlagToggle.FieldID, step.script->FlagToggle.FieldValue);
|
||||
}
|
||||
@@ -524,63 +527,63 @@ void Map::ScriptsProcess()
|
||||
break;
|
||||
|
||||
case SCRIPT_COMMAND_QUEST_EXPLORED:
|
||||
{
|
||||
if (!source)
|
||||
{
|
||||
sLog->outError("%s source object is NULL.", step.script->GetDebugInfo().c_str());
|
||||
break;
|
||||
}
|
||||
if (!target)
|
||||
{
|
||||
sLog->outError("%s target object is NULL.", step.script->GetDebugInfo().c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
// when script called for item spell casting then target == (unit or GO) and source is player
|
||||
WorldObject* worldObject;
|
||||
Player* player = target->ToPlayer();
|
||||
if (player)
|
||||
{
|
||||
if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER)
|
||||
if (!source)
|
||||
{
|
||||
sLog->outError("%s source is not unit, gameobject or player (TypeId: %u, Entry: %u, GUID: %u), skipping.",
|
||||
step.script->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow());
|
||||
sLog->outError("%s source object is NULL.", step.script->GetDebugInfo().c_str());
|
||||
break;
|
||||
}
|
||||
worldObject = dynamic_cast<WorldObject*>(source);
|
||||
}
|
||||
else
|
||||
{
|
||||
player = source->ToPlayer();
|
||||
if (!target)
|
||||
{
|
||||
sLog->outError("%s target object is NULL.", step.script->GetDebugInfo().c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
// when script called for item spell casting then target == (unit or GO) and source is player
|
||||
WorldObject* worldObject;
|
||||
Player* player = target->ToPlayer();
|
||||
if (player)
|
||||
{
|
||||
if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER)
|
||||
if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER)
|
||||
{
|
||||
sLog->outError("%s target is not unit, gameobject or player (TypeId: %u, Entry: %u, GUID: %u), skipping.",
|
||||
step.script->GetDebugInfo().c_str(), target->GetTypeId(), target->GetEntry(), target->GetGUIDLow());
|
||||
sLog->outError("%s source is not unit, gameobject or player (TypeId: %u, Entry: %u, GUID: %u), skipping.",
|
||||
step.script->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow());
|
||||
break;
|
||||
}
|
||||
worldObject = dynamic_cast<WorldObject*>(target);
|
||||
worldObject = dynamic_cast<WorldObject*>(source);
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog->outError("%s neither source nor target is player (source: TypeId: %u, Entry: %u, GUID: %u; target: TypeId: %u, Entry: %u, GUID: %u), skipping.",
|
||||
step.script->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow(),
|
||||
target->GetTypeId(), target->GetEntry(), target->GetGUIDLow());
|
||||
break;
|
||||
player = source->ToPlayer();
|
||||
if (player)
|
||||
{
|
||||
if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER)
|
||||
{
|
||||
sLog->outError("%s target is not unit, gameobject or player (TypeId: %u, Entry: %u, GUID: %u), skipping.",
|
||||
step.script->GetDebugInfo().c_str(), target->GetTypeId(), target->GetEntry(), target->GetGUIDLow());
|
||||
break;
|
||||
}
|
||||
worldObject = dynamic_cast<WorldObject*>(target);
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog->outError("%s neither source nor target is player (source: TypeId: %u, Entry: %u, GUID: %u; target: TypeId: %u, Entry: %u, GUID: %u), skipping.",
|
||||
step.script->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUIDLow(),
|
||||
target->GetTypeId(), target->GetEntry(), target->GetGUIDLow());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// quest id and flags checked at script loading
|
||||
if ((worldObject->GetTypeId() != TYPEID_UNIT || ((Unit*)worldObject)->IsAlive()) &&
|
||||
(step.script->QuestExplored.Distance == 0 || worldObject->IsWithinDistInMap(player, float(step.script->QuestExplored.Distance))))
|
||||
player->AreaExploredOrEventHappens(step.script->QuestExplored.QuestID);
|
||||
else
|
||||
player->FailQuest(step.script->QuestExplored.QuestID);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// quest id and flags checked at script loading
|
||||
if ((worldObject->GetTypeId() != TYPEID_UNIT || ((Unit*)worldObject)->IsAlive()) &&
|
||||
(step.script->QuestExplored.Distance == 0 || worldObject->IsWithinDistInMap(player, float(step.script->QuestExplored.Distance))))
|
||||
player->AreaExploredOrEventHappens(step.script->QuestExplored.QuestID);
|
||||
else
|
||||
player->FailQuest(step.script->QuestExplored.QuestID);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case SCRIPT_COMMAND_KILL_CREDIT:
|
||||
// Source or target must be Player.
|
||||
if (Player* player = _GetScriptPlayerSourceOrTarget(source, target, step.script))
|
||||
@@ -610,12 +613,12 @@ void Map::ScriptsProcess()
|
||||
}
|
||||
|
||||
if (pGO->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE ||
|
||||
pGO->GetGoType() == GAMEOBJECT_TYPE_DOOR ||
|
||||
pGO->GetGoType() == GAMEOBJECT_TYPE_BUTTON ||
|
||||
pGO->GetGoType() == GAMEOBJECT_TYPE_TRAP)
|
||||
pGO->GetGoType() == GAMEOBJECT_TYPE_DOOR ||
|
||||
pGO->GetGoType() == GAMEOBJECT_TYPE_BUTTON ||
|
||||
pGO->GetGoType() == GAMEOBJECT_TYPE_TRAP)
|
||||
{
|
||||
sLog->outError("%s can not be used with gameobject of type %u (guid: %u).",
|
||||
step.script->GetDebugInfo().c_str(), uint32(pGO->GetGoType()), step.script->RespawnGameobject.GOGuid);
|
||||
step.script->GetDebugInfo().c_str(), uint32(pGO->GetGoType()), step.script->RespawnGameobject.GOGuid);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -632,32 +635,32 @@ void Map::ScriptsProcess()
|
||||
break;
|
||||
|
||||
case SCRIPT_COMMAND_TEMP_SUMMON_CREATURE:
|
||||
{
|
||||
// Source must be WorldObject.
|
||||
if (WorldObject* pSummoner = _GetScriptWorldObject(source, true, step.script))
|
||||
{
|
||||
if (!step.script->TempSummonCreature.CreatureEntry)
|
||||
sLog->outError("%s creature entry (datalong) is not specified.", step.script->GetDebugInfo().c_str());
|
||||
else
|
||||
// Source must be WorldObject.
|
||||
if (WorldObject* pSummoner = _GetScriptWorldObject(source, true, step.script))
|
||||
{
|
||||
uint32 entry = step.script->TempSummonCreature.CreatureEntry;
|
||||
if (!step.script->TempSummonCreature.CreatureEntry)
|
||||
sLog->outError("%s creature entry (datalong) is not specified.", step.script->GetDebugInfo().c_str());
|
||||
else
|
||||
{
|
||||
uint32 entry = step.script->TempSummonCreature.CreatureEntry;
|
||||
|
||||
float x = step.script->TempSummonCreature.PosX;
|
||||
float y = step.script->TempSummonCreature.PosY;
|
||||
float z = step.script->TempSummonCreature.PosZ;
|
||||
float o = step.script->TempSummonCreature.Orientation;
|
||||
float x = step.script->TempSummonCreature.PosX;
|
||||
float y = step.script->TempSummonCreature.PosY;
|
||||
float z = step.script->TempSummonCreature.PosZ;
|
||||
float o = step.script->TempSummonCreature.Orientation;
|
||||
|
||||
if (step.script->TempSummonCreature.CheckIfExists)
|
||||
if (Unit* trigger = pSummoner->SummonTrigger(x, y, z, o, 1))
|
||||
if (trigger->FindNearestCreature(entry, 60.0f))
|
||||
break;
|
||||
if (step.script->TempSummonCreature.CheckIfExists)
|
||||
if (Unit* trigger = pSummoner->SummonTrigger(x, y, z, o, 1))
|
||||
if (trigger->FindNearestCreature(entry, 60.0f))
|
||||
break;
|
||||
|
||||
if (!pSummoner->SummonCreature(entry, x, y, z, o, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, step.script->TempSummonCreature.DespawnDelay))
|
||||
sLog->outError("%s creature was not spawned (entry: %u).", step.script->GetDebugInfo().c_str(), step.script->TempSummonCreature.CreatureEntry);
|
||||
if (!pSummoner->SummonCreature(entry, x, y, z, o, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, step.script->TempSummonCreature.DespawnDelay))
|
||||
sLog->outError("%s creature was not spawned (entry: %u).", step.script->GetDebugInfo().c_str(), step.script->TempSummonCreature.CreatureEntry);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SCRIPT_COMMAND_OPEN_DOOR:
|
||||
case SCRIPT_COMMAND_CLOSE_DOOR:
|
||||
@@ -678,7 +681,7 @@ void Map::ScriptsProcess()
|
||||
if (target->GetTypeId() != TYPEID_GAMEOBJECT)
|
||||
{
|
||||
sLog->outError("%s target object is not gameobject (TypeId: %u, Entry: %u, GUID: %u), skipping.",
|
||||
step.script->GetDebugInfo().c_str(), target->GetTypeId(), target->GetEntry(), target->GetGUIDLow());
|
||||
step.script->GetDebugInfo().c_str(), target->GetTypeId(), target->GetEntry(), target->GetGUIDLow());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -688,69 +691,69 @@ void Map::ScriptsProcess()
|
||||
break;
|
||||
|
||||
case SCRIPT_COMMAND_REMOVE_AURA:
|
||||
{
|
||||
// Source (datalong2 != 0) or target (datalong2 == 0) must be Unit.
|
||||
bool bReverse = step.script->RemoveAura.Flags & SF_REMOVEAURA_REVERSE;
|
||||
if (Unit* unit = _GetScriptUnit(bReverse ? source : target, bReverse, step.script))
|
||||
unit->RemoveAurasDueToSpell(step.script->RemoveAura.SpellID);
|
||||
break;
|
||||
}
|
||||
{
|
||||
// Source (datalong2 != 0) or target (datalong2 == 0) must be Unit.
|
||||
bool bReverse = step.script->RemoveAura.Flags & SF_REMOVEAURA_REVERSE;
|
||||
if (Unit* unit = _GetScriptUnit(bReverse ? source : target, bReverse, step.script))
|
||||
unit->RemoveAurasDueToSpell(step.script->RemoveAura.SpellID);
|
||||
break;
|
||||
}
|
||||
|
||||
case SCRIPT_COMMAND_CAST_SPELL:
|
||||
{
|
||||
// TODO: Allow gameobjects to be targets and casters
|
||||
if (!source && !target)
|
||||
{
|
||||
sLog->outError("%s source and target objects are NULL.", step.script->GetDebugInfo().c_str());
|
||||
// TODO: Allow gameobjects to be targets and casters
|
||||
if (!source && !target)
|
||||
{
|
||||
sLog->outError("%s source and target objects are NULL.", step.script->GetDebugInfo().c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
Unit* uSource = nullptr;
|
||||
Unit* uTarget = nullptr;
|
||||
// source/target cast spell at target/source (script->datalong2: 0: s->t 1: s->s 2: t->t 3: t->s
|
||||
switch (step.script->CastSpell.Flags)
|
||||
{
|
||||
case SF_CASTSPELL_SOURCE_TO_TARGET: // source -> target
|
||||
uSource = source ? source->ToUnit() : nullptr;
|
||||
uTarget = target ? target->ToUnit() : nullptr;
|
||||
break;
|
||||
case SF_CASTSPELL_SOURCE_TO_SOURCE: // source -> source
|
||||
uSource = source ? source->ToUnit() : nullptr;
|
||||
uTarget = uSource;
|
||||
break;
|
||||
case SF_CASTSPELL_TARGET_TO_TARGET: // target -> target
|
||||
uSource = target ? target->ToUnit() : nullptr;
|
||||
uTarget = uSource;
|
||||
break;
|
||||
case SF_CASTSPELL_TARGET_TO_SOURCE: // target -> source
|
||||
uSource = target ? target->ToUnit() : nullptr;
|
||||
uTarget = source ? source->ToUnit() : nullptr;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!uSource || !uSource->isType(TYPEMASK_UNIT))
|
||||
{
|
||||
sLog->outError("%s no source unit found for spell %u", step.script->GetDebugInfo().c_str(), step.script->CastSpell.SpellID);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!uTarget || !uTarget->isType(TYPEMASK_UNIT))
|
||||
{
|
||||
sLog->outError("%s no target unit found for spell %u", step.script->GetDebugInfo().c_str(), step.script->CastSpell.SpellID);
|
||||
break;
|
||||
}
|
||||
|
||||
bool triggered = (step.script->CastSpell.Flags != 4) ?
|
||||
step.script->CastSpell.CreatureEntry & SF_CASTSPELL_TRIGGERED :
|
||||
step.script->CastSpell.CreatureEntry < 0;
|
||||
uSource->CastSpell(uTarget, step.script->CastSpell.SpellID, triggered);
|
||||
break;
|
||||
}
|
||||
|
||||
Unit* uSource = nullptr;
|
||||
Unit* uTarget = nullptr;
|
||||
// source/target cast spell at target/source (script->datalong2: 0: s->t 1: s->s 2: t->t 3: t->s
|
||||
switch (step.script->CastSpell.Flags)
|
||||
{
|
||||
case SF_CASTSPELL_SOURCE_TO_TARGET: // source -> target
|
||||
uSource = source ? source->ToUnit() : nullptr;
|
||||
uTarget = target ? target->ToUnit() : nullptr;
|
||||
break;
|
||||
case SF_CASTSPELL_SOURCE_TO_SOURCE: // source -> source
|
||||
uSource = source ? source->ToUnit() : nullptr;
|
||||
uTarget = uSource;
|
||||
break;
|
||||
case SF_CASTSPELL_TARGET_TO_TARGET: // target -> target
|
||||
uSource = target ? target->ToUnit() : nullptr;
|
||||
uTarget = uSource;
|
||||
break;
|
||||
case SF_CASTSPELL_TARGET_TO_SOURCE: // target -> source
|
||||
uSource = target ? target->ToUnit() : nullptr;
|
||||
uTarget = source ? source->ToUnit() : nullptr;
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!uSource || !uSource->isType(TYPEMASK_UNIT))
|
||||
{
|
||||
sLog->outError("%s no source unit found for spell %u", step.script->GetDebugInfo().c_str(), step.script->CastSpell.SpellID);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!uTarget || !uTarget->isType(TYPEMASK_UNIT))
|
||||
{
|
||||
sLog->outError("%s no target unit found for spell %u", step.script->GetDebugInfo().c_str(), step.script->CastSpell.SpellID);
|
||||
break;
|
||||
}
|
||||
|
||||
bool triggered = (step.script->CastSpell.Flags != 4) ?
|
||||
step.script->CastSpell.CreatureEntry & SF_CASTSPELL_TRIGGERED :
|
||||
step.script->CastSpell.CreatureEntry < 0;
|
||||
uSource->CastSpell(uTarget, step.script->CastSpell.SpellID, triggered);
|
||||
break;
|
||||
}
|
||||
|
||||
case SCRIPT_COMMAND_PLAY_SOUND:
|
||||
// Source must be WorldObject.
|
||||
if (WorldObject* object = _GetScriptWorldObject(source, true, step.script))
|
||||
@@ -807,56 +810,56 @@ void Map::ScriptsProcess()
|
||||
break;
|
||||
|
||||
case SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT:
|
||||
{
|
||||
if (!step.script->CallScript.CreatureEntry)
|
||||
{
|
||||
sLog->outError("%s creature entry is not specified, skipping.", step.script->GetDebugInfo().c_str());
|
||||
if (!step.script->CallScript.CreatureEntry)
|
||||
{
|
||||
sLog->outError("%s creature entry is not specified, skipping.", step.script->GetDebugInfo().c_str());
|
||||
break;
|
||||
}
|
||||
if (!step.script->CallScript.ScriptID)
|
||||
{
|
||||
sLog->outError("%s script id is not specified, skipping.", step.script->GetDebugInfo().c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
Creature* cTarget = nullptr;
|
||||
WorldObject* wSource = dynamic_cast <WorldObject*> (source);
|
||||
if (wSource) //using grid searcher
|
||||
{
|
||||
CellCoord p(acore::ComputeCellCoord(wSource->GetPositionX(), wSource->GetPositionY()));
|
||||
Cell cell(p);
|
||||
|
||||
acore::CreatureWithDbGUIDCheck target_check(step.script->CallScript.CreatureEntry);
|
||||
acore::CreatureSearcher<acore::CreatureWithDbGUIDCheck> checker(wSource, cTarget, target_check);
|
||||
|
||||
TypeContainerVisitor<acore::CreatureSearcher <acore::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker);
|
||||
cell.Visit(p, unit_checker, *wSource->GetMap(), *wSource, wSource->GetGridActivationRange());
|
||||
}
|
||||
else //check hashmap holders
|
||||
{
|
||||
if (CreatureData const* data = sObjectMgr->GetCreatureData(step.script->CallScript.CreatureEntry))
|
||||
cTarget = ObjectAccessor::GetObjectInWorld<Creature>(data->mapid, data->posX, data->posY, MAKE_NEW_GUID(step.script->CallScript.CreatureEntry, data->id, HIGHGUID_UNIT), cTarget);
|
||||
}
|
||||
|
||||
if (!cTarget)
|
||||
{
|
||||
sLog->outError("%s target was not found (entry: %u)", step.script->GetDebugInfo().c_str(), step.script->CallScript.CreatureEntry);
|
||||
break;
|
||||
}
|
||||
|
||||
//Lets choose our ScriptMap map
|
||||
ScriptMapMap* datamap = GetScriptsMapByType(ScriptsType(step.script->CallScript.ScriptType));
|
||||
//if no scriptmap present...
|
||||
if (!datamap)
|
||||
{
|
||||
sLog->outError("%s unknown scriptmap (%u) specified, skipping.", step.script->GetDebugInfo().c_str(), step.script->CallScript.ScriptType);
|
||||
break;
|
||||
}
|
||||
|
||||
// Insert script into schedule but do not start it
|
||||
ScriptsStart(*datamap, step.script->CallScript.ScriptID, cTarget, nullptr);
|
||||
break;
|
||||
}
|
||||
if (!step.script->CallScript.ScriptID)
|
||||
{
|
||||
sLog->outError("%s script id is not specified, skipping.", step.script->GetDebugInfo().c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
Creature* cTarget = nullptr;
|
||||
WorldObject* wSource = dynamic_cast <WorldObject*> (source);
|
||||
if (wSource) //using grid searcher
|
||||
{
|
||||
CellCoord p(acore::ComputeCellCoord(wSource->GetPositionX(), wSource->GetPositionY()));
|
||||
Cell cell(p);
|
||||
|
||||
acore::CreatureWithDbGUIDCheck target_check(step.script->CallScript.CreatureEntry);
|
||||
acore::CreatureSearcher<acore::CreatureWithDbGUIDCheck> checker(wSource, cTarget, target_check);
|
||||
|
||||
TypeContainerVisitor<acore::CreatureSearcher <acore::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker);
|
||||
cell.Visit(p, unit_checker, *wSource->GetMap(), *wSource, wSource->GetGridActivationRange());
|
||||
}
|
||||
else //check hashmap holders
|
||||
{
|
||||
if (CreatureData const* data = sObjectMgr->GetCreatureData(step.script->CallScript.CreatureEntry))
|
||||
cTarget = ObjectAccessor::GetObjectInWorld<Creature>(data->mapid, data->posX, data->posY, MAKE_NEW_GUID(step.script->CallScript.CreatureEntry, data->id, HIGHGUID_UNIT), cTarget);
|
||||
}
|
||||
|
||||
if (!cTarget)
|
||||
{
|
||||
sLog->outError("%s target was not found (entry: %u)", step.script->GetDebugInfo().c_str(), step.script->CallScript.CreatureEntry);
|
||||
break;
|
||||
}
|
||||
|
||||
//Lets choose our ScriptMap map
|
||||
ScriptMapMap* datamap = GetScriptsMapByType(ScriptsType(step.script->CallScript.ScriptType));
|
||||
//if no scriptmap present...
|
||||
if (!datamap)
|
||||
{
|
||||
sLog->outError("%s unknown scriptmap (%u) specified, skipping.", step.script->GetDebugInfo().c_str(), step.script->CallScript.ScriptType);
|
||||
break;
|
||||
}
|
||||
|
||||
// Insert script into schedule but do not start it
|
||||
ScriptsStart(*datamap, step.script->CallScript.ScriptID, cTarget, nullptr);
|
||||
break;
|
||||
}
|
||||
|
||||
case SCRIPT_COMMAND_KILL:
|
||||
// Source or target must be Creature.
|
||||
@@ -864,7 +867,7 @@ void Map::ScriptsProcess()
|
||||
{
|
||||
if (cSource->isDead())
|
||||
sLog->outError("%s creature is already dead (Entry: %u, GUID: %u)",
|
||||
step.script->GetDebugInfo().c_str(), cSource->GetEntry(), cSource->GetGUIDLow());
|
||||
step.script->GetDebugInfo().c_str(), cSource->GetEntry(), cSource->GetGUIDLow());
|
||||
else
|
||||
{
|
||||
cSource->setDeathState(JUST_DIED);
|
||||
|
||||
@@ -90,7 +90,7 @@ void ScriptMgr::Initialize()
|
||||
|
||||
void ScriptMgr::Unload()
|
||||
{
|
||||
#define SCR_CLEAR(T) \
|
||||
#define SCR_CLEAR(T) \
|
||||
for (SCR_REG_ITR(T) itr = SCR_REG_LST(T).begin(); itr != SCR_REG_LST(T).end(); ++itr) \
|
||||
delete itr->second; \
|
||||
SCR_REG_LST(T).clear();
|
||||
@@ -128,7 +128,7 @@ void ScriptMgr::Unload()
|
||||
SCR_CLEAR(GameEventScript);
|
||||
SCR_CLEAR(MailScript);
|
||||
|
||||
#undef SCR_CLEAR
|
||||
#undef SCR_CLEAR
|
||||
}
|
||||
|
||||
void ScriptMgr::LoadDatabase()
|
||||
@@ -165,7 +165,7 @@ struct TSpellSummary
|
||||
{
|
||||
uint8 Targets; // set of enum SelectTarget
|
||||
uint8 Effects; // set of enum SelectEffect
|
||||
} *SpellSummary;
|
||||
}* SpellSummary;
|
||||
|
||||
void ScriptMgr::CheckIfScriptsInDatabaseExist()
|
||||
{
|
||||
@@ -174,31 +174,31 @@ void ScriptMgr::CheckIfScriptsInDatabaseExist()
|
||||
if (uint32 sid = sObjectMgr->GetScriptId((*itr).c_str()))
|
||||
{
|
||||
if (!ScriptRegistry<SpellScriptLoader>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<ServerScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<WorldScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<FormulaScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<WorldMapScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<InstanceMapScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<BattlegroundMapScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<ItemScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<CreatureScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<GameObjectScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<AreaTriggerScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<BattlegroundScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<OutdoorPvPScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<CommandScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<WeatherScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<AuctionHouseScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<ConditionScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<VehicleScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<DynamicObjectScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<TransportScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<AchievementCriteriaScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<PlayerScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<GuildScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<BGScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<SpellSC>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<GroupScript>::GetScriptById(sid))
|
||||
!ScriptRegistry<ServerScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<WorldScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<FormulaScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<WorldMapScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<InstanceMapScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<BattlegroundMapScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<ItemScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<CreatureScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<GameObjectScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<AreaTriggerScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<BattlegroundScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<OutdoorPvPScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<CommandScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<WeatherScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<AuctionHouseScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<ConditionScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<VehicleScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<DynamicObjectScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<TransportScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<AchievementCriteriaScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<PlayerScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<GuildScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<BGScript>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<SpellSC>::GetScriptById(sid) &&
|
||||
!ScriptRegistry<GroupScript>::GetScriptById(sid))
|
||||
sLog->outErrorDb("Script named '%s' is assigned in the database, but has no code!", (*itr).c_str());
|
||||
}
|
||||
}
|
||||
@@ -223,67 +223,67 @@ void ScriptMgr::FillSpellSummary()
|
||||
{
|
||||
// Spell targets self.
|
||||
if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER)
|
||||
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SELF-1);
|
||||
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SELF - 1);
|
||||
|
||||
// Spell targets a single enemy.
|
||||
if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ENEMY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_TARGET_ENEMY)
|
||||
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_ENEMY-1);
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_TARGET_ENEMY)
|
||||
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_ENEMY - 1);
|
||||
|
||||
// Spell targets AoE at enemy.
|
||||
if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_SRC_AREA_ENEMY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_DEST_AREA_ENEMY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY)
|
||||
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_ENEMY-1);
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_DEST_AREA_ENEMY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY)
|
||||
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_ENEMY - 1);
|
||||
|
||||
// Spell targets an enemy.
|
||||
if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ENEMY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_TARGET_ENEMY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_SRC_AREA_ENEMY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_DEST_AREA_ENEMY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY)
|
||||
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_ENEMY-1);
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_TARGET_ENEMY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_SRC_AREA_ENEMY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_DEST_AREA_ENEMY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY)
|
||||
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_ENEMY - 1);
|
||||
|
||||
// Spell targets a single friend (or self).
|
||||
if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_PARTY)
|
||||
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_FRIEND-1);
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_PARTY)
|
||||
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_SINGLE_FRIEND - 1);
|
||||
|
||||
// Spell targets AoE friends.
|
||||
if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER_AREA_PARTY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_LASTTARGET_AREA_PARTY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER)
|
||||
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_FRIEND-1);
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_LASTTARGET_AREA_PARTY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER)
|
||||
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_FRIEND - 1);
|
||||
|
||||
// Spell targets any friend (or self).
|
||||
if (pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_PARTY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER_AREA_PARTY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_LASTTARGET_AREA_PARTY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER)
|
||||
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_FRIEND-1);
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_ALLY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_TARGET_PARTY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_CASTER_AREA_PARTY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_UNIT_LASTTARGET_AREA_PARTY ||
|
||||
pTempSpell->Effects[j].TargetA.GetTarget() == TARGET_SRC_CASTER)
|
||||
SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_FRIEND - 1);
|
||||
|
||||
// Make sure that this spell includes a damage effect.
|
||||
if (pTempSpell->Effects[j].Effect == SPELL_EFFECT_SCHOOL_DAMAGE ||
|
||||
pTempSpell->Effects[j].Effect == SPELL_EFFECT_INSTAKILL ||
|
||||
pTempSpell->Effects[j].Effect == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE ||
|
||||
pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH)
|
||||
SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_DAMAGE-1);
|
||||
pTempSpell->Effects[j].Effect == SPELL_EFFECT_INSTAKILL ||
|
||||
pTempSpell->Effects[j].Effect == SPELL_EFFECT_ENVIRONMENTAL_DAMAGE ||
|
||||
pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEALTH_LEECH)
|
||||
SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_DAMAGE - 1);
|
||||
|
||||
// Make sure that this spell includes a healing effect (or an apply aura with a periodic heal).
|
||||
if (pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEAL ||
|
||||
pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEAL_MAX_HEALTH ||
|
||||
pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEAL_MECHANICAL ||
|
||||
(pTempSpell->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA && pTempSpell->Effects[j].ApplyAuraName == 8))
|
||||
SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_HEALING-1);
|
||||
pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEAL_MAX_HEALTH ||
|
||||
pTempSpell->Effects[j].Effect == SPELL_EFFECT_HEAL_MECHANICAL ||
|
||||
(pTempSpell->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA && pTempSpell->Effects[j].ApplyAuraName == 8))
|
||||
SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_HEALING - 1);
|
||||
|
||||
// Make sure that this spell applies an aura.
|
||||
if (pTempSpell->Effects[j].Effect == SPELL_EFFECT_APPLY_AURA)
|
||||
SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_AURA-1);
|
||||
SpellSummary[i].Effects |= 1 << (SELECT_EFFECT_AURA - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -513,15 +513,15 @@ void ScriptMgr::OnCreateMap(Map* map)
|
||||
#endif
|
||||
|
||||
SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
|
||||
itr->second->OnCreate(map);
|
||||
itr->second->OnCreate(map);
|
||||
SCR_MAP_END;
|
||||
|
||||
SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon);
|
||||
itr->second->OnCreate((InstanceMap*)map);
|
||||
itr->second->OnCreate((InstanceMap*)map);
|
||||
SCR_MAP_END;
|
||||
|
||||
SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground);
|
||||
itr->second->OnCreate((BattlegroundMap*)map);
|
||||
itr->second->OnCreate((BattlegroundMap*)map);
|
||||
SCR_MAP_END;
|
||||
}
|
||||
|
||||
@@ -534,15 +534,15 @@ void ScriptMgr::OnDestroyMap(Map* map)
|
||||
#endif
|
||||
|
||||
SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
|
||||
itr->second->OnDestroy(map);
|
||||
itr->second->OnDestroy(map);
|
||||
SCR_MAP_END;
|
||||
|
||||
SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon);
|
||||
itr->second->OnDestroy((InstanceMap*)map);
|
||||
itr->second->OnDestroy((InstanceMap*)map);
|
||||
SCR_MAP_END;
|
||||
|
||||
SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground);
|
||||
itr->second->OnDestroy((BattlegroundMap*)map);
|
||||
itr->second->OnDestroy((BattlegroundMap*)map);
|
||||
SCR_MAP_END;
|
||||
}
|
||||
|
||||
@@ -552,15 +552,15 @@ void ScriptMgr::OnLoadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy)
|
||||
ASSERT(gmap);
|
||||
|
||||
SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
|
||||
itr->second->OnLoadGridMap(map, gmap, gx, gy);
|
||||
itr->second->OnLoadGridMap(map, gmap, gx, gy);
|
||||
SCR_MAP_END;
|
||||
|
||||
SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon);
|
||||
itr->second->OnLoadGridMap((InstanceMap*)map, gmap, gx, gy);
|
||||
itr->second->OnLoadGridMap((InstanceMap*)map, gmap, gx, gy);
|
||||
SCR_MAP_END;
|
||||
|
||||
SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground);
|
||||
itr->second->OnLoadGridMap((BattlegroundMap*)map, gmap, gx, gy);
|
||||
itr->second->OnLoadGridMap((BattlegroundMap*)map, gmap, gx, gy);
|
||||
SCR_MAP_END;
|
||||
}
|
||||
|
||||
@@ -570,15 +570,15 @@ void ScriptMgr::OnUnloadGridMap(Map* map, GridMap* gmap, uint32 gx, uint32 gy)
|
||||
ASSERT(gmap);
|
||||
|
||||
SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
|
||||
itr->second->OnUnloadGridMap(map, gmap, gx, gy);
|
||||
itr->second->OnUnloadGridMap(map, gmap, gx, gy);
|
||||
SCR_MAP_END;
|
||||
|
||||
SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon);
|
||||
itr->second->OnUnloadGridMap((InstanceMap*)map, gmap, gx, gy);
|
||||
itr->second->OnUnloadGridMap((InstanceMap*)map, gmap, gx, gy);
|
||||
SCR_MAP_END;
|
||||
|
||||
SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground);
|
||||
itr->second->OnUnloadGridMap((BattlegroundMap*)map, gmap, gx, gy);
|
||||
itr->second->OnUnloadGridMap((BattlegroundMap*)map, gmap, gx, gy);
|
||||
SCR_MAP_END;
|
||||
}
|
||||
|
||||
@@ -597,15 +597,15 @@ void ScriptMgr::OnPlayerEnterMap(Map* map, Player* player)
|
||||
FOREACH_SCRIPT(PlayerScript)->OnMapChanged(player);
|
||||
|
||||
SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
|
||||
itr->second->OnPlayerEnter(map, player);
|
||||
itr->second->OnPlayerEnter(map, player);
|
||||
SCR_MAP_END;
|
||||
|
||||
SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon);
|
||||
itr->second->OnPlayerEnter((InstanceMap*)map, player);
|
||||
itr->second->OnPlayerEnter((InstanceMap*)map, player);
|
||||
SCR_MAP_END;
|
||||
|
||||
SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground);
|
||||
itr->second->OnPlayerEnter((BattlegroundMap*)map, player);
|
||||
itr->second->OnPlayerEnter((BattlegroundMap*)map, player);
|
||||
SCR_MAP_END;
|
||||
}
|
||||
|
||||
@@ -621,15 +621,15 @@ void ScriptMgr::OnPlayerLeaveMap(Map* map, Player* player)
|
||||
FOREACH_SCRIPT(AllMapScript)->OnPlayerLeaveAll(map, player);
|
||||
|
||||
SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
|
||||
itr->second->OnPlayerLeave(map, player);
|
||||
itr->second->OnPlayerLeave(map, player);
|
||||
SCR_MAP_END;
|
||||
|
||||
SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon);
|
||||
itr->second->OnPlayerLeave((InstanceMap*)map, player);
|
||||
itr->second->OnPlayerLeave((InstanceMap*)map, player);
|
||||
SCR_MAP_END;
|
||||
|
||||
SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground);
|
||||
itr->second->OnPlayerLeave((BattlegroundMap*)map, player);
|
||||
itr->second->OnPlayerLeave((BattlegroundMap*)map, player);
|
||||
SCR_MAP_END;
|
||||
}
|
||||
|
||||
@@ -642,15 +642,15 @@ void ScriptMgr::OnMapUpdate(Map* map, uint32 diff)
|
||||
#endif
|
||||
|
||||
SCR_MAP_BGN(WorldMapScript, map, itr, end, entry, IsWorldMap);
|
||||
itr->second->OnUpdate(map, diff);
|
||||
itr->second->OnUpdate(map, diff);
|
||||
SCR_MAP_END;
|
||||
|
||||
SCR_MAP_BGN(InstanceMapScript, map, itr, end, entry, IsDungeon);
|
||||
itr->second->OnUpdate((InstanceMap*)map, diff);
|
||||
itr->second->OnUpdate((InstanceMap*)map, diff);
|
||||
SCR_MAP_END;
|
||||
|
||||
SCR_MAP_BGN(BattlegroundMapScript, map, itr, end, entry, IsBattleground);
|
||||
itr->second->OnUpdate((BattlegroundMap*)map, diff);
|
||||
itr->second->OnUpdate((BattlegroundMap*)map, diff);
|
||||
SCR_MAP_END;
|
||||
}
|
||||
|
||||
@@ -709,7 +709,7 @@ bool ScriptMgr::OnItemExpire(Player* player, ItemTemplate const* proto)
|
||||
return tmpscript->OnExpire(player, proto);
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnItemRemove(Player * player, Item * item)
|
||||
bool ScriptMgr::OnItemRemove(Player* player, Item* item)
|
||||
{
|
||||
ASSERT(player);
|
||||
ASSERT(item);
|
||||
@@ -1065,7 +1065,7 @@ std::vector<ChatCommand> ScriptMgr::GetChatCommands()
|
||||
}
|
||||
|
||||
// Sort commands in alphabetical order
|
||||
std::sort(table.begin(), table.end(), [](const ChatCommand& a, const ChatCommand&b)
|
||||
std::sort(table.begin(), table.end(), [](const ChatCommand & a, const ChatCommand & b)
|
||||
{
|
||||
return strcmp(a.Name, b.Name) < 0;
|
||||
});
|
||||
@@ -1266,7 +1266,7 @@ void ScriptMgr::OnDynamicObjectUpdate(DynamicObject* dynobj, uint32 diff)
|
||||
ASSERT(dynobj);
|
||||
|
||||
FOR_SCRIPTS(DynamicObjectScript, itr, end)
|
||||
itr->second->OnUpdate(dynobj, diff);
|
||||
itr->second->OnUpdate(dynobj, diff);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnAddPassenger(Transport* transport, Player* player)
|
||||
@@ -1550,7 +1550,7 @@ void ScriptMgr::OnPlayerCreate(Player* player)
|
||||
FOREACH_SCRIPT(PlayerScript)->OnCreate(player);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerSave(Player * player)
|
||||
void ScriptMgr::OnPlayerSave(Player* player)
|
||||
{
|
||||
#ifdef ELUNA
|
||||
sEluna->OnSave(player);
|
||||
@@ -1592,12 +1592,12 @@ void ScriptMgr::OnPlayerUpdateArea(Player* player, uint32 oldArea, uint32 newAre
|
||||
FOREACH_SCRIPT(PlayerScript)->OnUpdateArea(player, oldArea, newArea);
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnBeforePlayerTeleport(Player* player, uint32 mapid, float x, float y, float z, float orientation, uint32 options, Unit *target)
|
||||
bool ScriptMgr::OnBeforePlayerTeleport(Player* player, uint32 mapid, float x, float y, float z, float orientation, uint32 options, Unit* target)
|
||||
{
|
||||
bool ret=true;
|
||||
bool ret = true;
|
||||
FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts
|
||||
if (!itr->second->OnBeforeTeleport(player, mapid, x, y, z, orientation, options, target))
|
||||
ret=false; // we change ret value only when scripts return false
|
||||
if (!itr->second->OnBeforeTeleport(player, mapid, x, y, z, orientation, options, target))
|
||||
ret = false; // we change ret value only when scripts return false
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1607,7 +1607,7 @@ void ScriptMgr::OnPlayerUpdateFaction(Player* player)
|
||||
FOREACH_SCRIPT(PlayerScript)->OnUpdateFaction(player);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerAddToBattleground(Player* player, Battleground *bg)
|
||||
void ScriptMgr::OnPlayerAddToBattleground(Player* player, Battleground* bg)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnAddToBattleground(player, bg);
|
||||
}
|
||||
@@ -1642,9 +1642,9 @@ void ScriptMgr::OnPlayerBeingCharmed(Player* player, Unit* charmer, uint32 oldFa
|
||||
FOREACH_SCRIPT(PlayerScript)->OnBeingCharmed(player, charmer, oldFactionId, newFactionId);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnAfterPlayerSetVisibleItemSlot(Player* player, uint8 slot, Item *item)
|
||||
void ScriptMgr::OnAfterPlayerSetVisibleItemSlot(Player* player, uint8 slot, Item* item)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnAfterSetVisibleItemSlot(player, slot,item);
|
||||
FOREACH_SCRIPT(PlayerScript)->OnAfterSetVisibleItemSlot(player, slot, item);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnAfterPlayerMoveItemFromInventory(Player* player, Item* it, uint8 bag, uint8 slot, bool update)
|
||||
@@ -1695,8 +1695,8 @@ bool ScriptMgr::CanJoinInBattlegroundQueue(Player* player, uint64 BattlemasterGu
|
||||
bool ret = true;
|
||||
|
||||
FOR_SCRIPTS_RET(PlayerScript, itr, end, ret) // return true by default if not scripts
|
||||
if (!itr->second->CanJoinInBattlegroundQueue(player, BattlemasterGuid, BGTypeID, joinAsGroup, err))
|
||||
ret = false; // we change ret value only when scripts return false
|
||||
if (!itr->second->CanJoinInBattlegroundQueue(player, BattlemasterGuid, BGTypeID, joinAsGroup, err))
|
||||
ret = false; // we change ret value only when scripts return false
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1801,7 +1801,7 @@ void ScriptMgr::OnGuildDisband(Guild* guild)
|
||||
FOREACH_SCRIPT(GuildScript)->OnDisband(guild);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGuildMemberWitdrawMoney(Guild* guild, Player* player, uint32 &amount, bool isRepair)
|
||||
void ScriptMgr::OnGuildMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair)
|
||||
{
|
||||
#ifdef ELUNA
|
||||
sEluna->OnMemberWitdrawMoney(guild, player, amount, isRepair);
|
||||
@@ -1809,7 +1809,7 @@ void ScriptMgr::OnGuildMemberWitdrawMoney(Guild* guild, Player* player, uint32 &
|
||||
FOREACH_SCRIPT(GuildScript)->OnMemberWitdrawMoney(guild, player, amount, isRepair);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32 &amount)
|
||||
void ScriptMgr::OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32& amount)
|
||||
{
|
||||
#ifdef ELUNA
|
||||
sEluna->OnMemberDepositMoney(guild, player, amount);
|
||||
@@ -1818,7 +1818,7 @@ void ScriptMgr::OnGuildMemberDepositMoney(Guild* guild, Player* player, uint32 &
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGuildItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId,
|
||||
bool isDestBank, uint8 destContainer, uint8 destSlotId)
|
||||
bool isDestBank, uint8 destContainer, uint8 destSlotId)
|
||||
{
|
||||
#ifdef ELUNA
|
||||
sEluna->OnItemMove(guild, player, pItem, isSrcBank, srcContainer, srcSlotId, isDestBank, destContainer, destSlotId);
|
||||
@@ -1847,7 +1847,7 @@ void ScriptMgr::OnGroupAddMember(Group* group, uint64 guid)
|
||||
{
|
||||
ASSERT(group);
|
||||
#ifdef ELUNA
|
||||
sEluna->OnAddMember(group, guid);
|
||||
sEluna->OnAddMember(group, guid);
|
||||
#endif
|
||||
FOREACH_SCRIPT(GroupScript)->OnAddMember(group, guid);
|
||||
}
|
||||
@@ -1894,20 +1894,20 @@ void ScriptMgr::OnGlobalItemDelFromDB(SQLTransaction& trans, uint32 itemGuid)
|
||||
ASSERT(trans);
|
||||
ASSERT(itemGuid);
|
||||
|
||||
FOREACH_SCRIPT(GlobalScript)->OnItemDelFromDB(trans,itemGuid);
|
||||
FOREACH_SCRIPT(GlobalScript)->OnItemDelFromDB(trans, itemGuid);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGlobalMirrorImageDisplayItem(const Item *item, uint32 &display)
|
||||
void ScriptMgr::OnGlobalMirrorImageDisplayItem(const Item* item, uint32& display)
|
||||
{
|
||||
FOREACH_SCRIPT(GlobalScript)->OnMirrorImageDisplayItem(item,display);
|
||||
FOREACH_SCRIPT(GlobalScript)->OnMirrorImageDisplayItem(item, display);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map<uint32, uint32> &ap)
|
||||
void ScriptMgr::OnBeforeUpdateArenaPoints(ArenaTeam* at, std::map<uint32, uint32>& ap)
|
||||
{
|
||||
FOREACH_SCRIPT(GlobalScript)->OnBeforeUpdateArenaPoints(at,ap);
|
||||
FOREACH_SCRIPT(GlobalScript)->OnBeforeUpdateArenaPoints(at, ap);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnAfterRefCount(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, uint32 &maxcount, LootStore const& store)
|
||||
void ScriptMgr::OnAfterRefCount(Player const* player, Loot& loot, bool canRate, uint16 lootMode, LootStoreItem* LootStoreItem, uint32& maxcount, LootStore const& store)
|
||||
{
|
||||
FOREACH_SCRIPT(GlobalScript)->OnAfterRefCount(player, LootStoreItem, loot, canRate, lootMode, maxcount, store);
|
||||
}
|
||||
@@ -1917,7 +1917,8 @@ void ScriptMgr::OnBeforeDropAddItem(Player const* player, Loot& loot, bool canRa
|
||||
FOREACH_SCRIPT(GlobalScript)->OnBeforeDropAddItem(player, loot, canRate, lootMode, LootStoreItem, store);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnItemRoll(Player const* player, LootStoreItem const* LootStoreItem, float &chance, Loot& loot, LootStore const& store) {
|
||||
void ScriptMgr::OnItemRoll(Player const* player, LootStoreItem const* LootStoreItem, float& chance, Loot& loot, LootStore const& store)
|
||||
{
|
||||
FOREACH_SCRIPT(GlobalScript)->OnItemRoll(player, LootStoreItem, chance, loot, store);
|
||||
}
|
||||
|
||||
@@ -1942,13 +1943,13 @@ void ScriptMgr::OnBeforeWorldObjectSetPhaseMask(WorldObject const* worldObject,
|
||||
}
|
||||
|
||||
// Unit
|
||||
uint32 ScriptMgr::DealDamage(Unit* AttackerUnit, Unit *pVictim, uint32 damage, DamageEffectType damagetype)
|
||||
uint32 ScriptMgr::DealDamage(Unit* AttackerUnit, Unit* pVictim, uint32 damage, DamageEffectType damagetype)
|
||||
{
|
||||
FOR_SCRIPTS_RET(UnitScript, itr, end, damage)
|
||||
damage = itr->second->DealDamage(AttackerUnit, pVictim, damage, damagetype);
|
||||
damage = itr->second->DealDamage(AttackerUnit, pVictim, damage, damagetype);
|
||||
return damage;
|
||||
}
|
||||
void ScriptMgr::Creature_SelectLevel(const CreatureTemplate *cinfo, Creature* creature)
|
||||
void ScriptMgr::Creature_SelectLevel(const CreatureTemplate* cinfo, Creature* creature)
|
||||
{
|
||||
FOREACH_SCRIPT(AllCreatureScript)->Creature_SelectLevel(cinfo, creature);
|
||||
}
|
||||
@@ -1982,7 +1983,7 @@ void ScriptMgr::ModifyHealRecieved(Unit* target, Unit* attacker, uint32& damage)
|
||||
FOREACH_SCRIPT(UnitScript)->ModifyHealRecieved(target, attacker, damage);
|
||||
}
|
||||
|
||||
void ScriptMgr::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 ScriptMgr::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)
|
||||
{
|
||||
FOREACH_SCRIPT(UnitScript)->OnBeforeRollMeleeOutcomeAgainst(attacker, victim, attType, attackerMaxSkillValueForLevel, victimMaxSkillValueForLevel, attackerWeaponSkill, victimDefenseSkill, crit_chance, miss_chance, dodge_chance, parry_chance, block_chance);
|
||||
}
|
||||
@@ -1992,12 +1993,12 @@ void ScriptMgr::OnPlayerMove(Player* player, MovementInfo movementInfo, uint32 o
|
||||
FOREACH_SCRIPT(MovementHandlerScript)->OnPlayerMove(player, movementInfo, opcode);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnBeforeBuyItemFromVendor(Player* player, uint64 vendorguid, uint32 vendorslot, uint32 &item, uint8 count, uint8 bag, uint8 slot)
|
||||
void ScriptMgr::OnBeforeBuyItemFromVendor(Player* player, uint64 vendorguid, uint32 vendorslot, uint32& item, uint8 count, uint8 bag, uint8 slot)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnBeforeBuyItemFromVendor(player, vendorguid, vendorslot, item, count, bag, slot);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnAfterStoreOrEquipNewItem(Player* player, uint32 vendorslot, uint32 &item, uint8 count, uint8 bag, uint8 slot, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore)
|
||||
void ScriptMgr::OnAfterStoreOrEquipNewItem(Player* player, uint32 vendorslot, uint32& item, uint8 count, uint8 bag, uint8 slot, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnAfterStoreOrEquipNewItem(player, vendorslot, item, count, bag, slot, pProto, pVendor, crItem, bStore);
|
||||
}
|
||||
@@ -2027,7 +2028,7 @@ void ScriptMgr::OnBeforeInitTalentForLevel(Player* player, uint8& level, uint32&
|
||||
FOREACH_SCRIPT(PlayerScript)->OnBeforeInitTalentForLevel(player, level, talentPointsForLevel);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnAfterArenaRatingCalculation(Battleground *const bg, int32 &winnerMatchmakerChange, int32 &loserMatchmakerChange, int32 &winnerChange, int32 &loserChange)
|
||||
void ScriptMgr::OnAfterArenaRatingCalculation(Battleground* const bg, int32& winnerMatchmakerChange, int32& loserMatchmakerChange, int32& winnerChange, int32& loserChange)
|
||||
{
|
||||
FOREACH_SCRIPT(FormulaScript)->OnAfterArenaRatingCalculation(bg, winnerMatchmakerChange, loserMatchmakerChange, winnerChange, loserChange);
|
||||
}
|
||||
@@ -2073,20 +2074,20 @@ bool ScriptMgr::CanFillPlayersToBG(BattlegroundQueue* queue, Battleground* bg, c
|
||||
bool ret = true;
|
||||
|
||||
FOR_SCRIPTS_RET(BGScript, itr, end, ret) // return true by default if not scripts
|
||||
if (!itr->second->CanFillPlayersToBG(queue, bg, aliFree, hordeFree, bracket_id))
|
||||
ret = false; // we change ret value only when scripts return false
|
||||
if (!itr->second->CanFillPlayersToBG(queue, bg, aliFree, hordeFree, bracket_id))
|
||||
ret = false; // we change ret value only when scripts return false
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ScriptMgr::CanFillPlayersToBGWithSpecific(BattlegroundQueue* queue, Battleground* bg, const int32 aliFree, const int32 hordeFree,
|
||||
BattlegroundBracketId thisBracketId, BattlegroundQueue* specificQueue, BattlegroundBracketId specificBracketId)
|
||||
BattlegroundBracketId thisBracketId, BattlegroundQueue* specificQueue, BattlegroundBracketId specificBracketId)
|
||||
{
|
||||
bool ret = true;
|
||||
|
||||
FOR_SCRIPTS_RET(BGScript, itr, end, ret) // return true by default if not scripts
|
||||
if (!itr->second->CanFillPlayersToBGWithSpecific(queue, bg, aliFree, hordeFree, thisBracketId, specificQueue, specificBracketId))
|
||||
ret = false; // we change ret value only when scripts return false
|
||||
if (!itr->second->CanFillPlayersToBGWithSpecific(queue, bg, aliFree, hordeFree, thisBracketId, specificQueue, specificBracketId))
|
||||
ret = false; // we change ret value only when scripts return false
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -2101,8 +2102,8 @@ bool ScriptMgr::CanSendMessageQueue(BattlegroundQueue* queue, Player* leader, Ba
|
||||
bool ret = true;
|
||||
|
||||
FOR_SCRIPTS_RET(BGScript, itr, end, ret) // return true by default if not scripts
|
||||
if (!itr->second->CanSendMessageQueue(queue, leader, bg, bracketEntry))
|
||||
ret = false; // we change ret value only when scripts return false
|
||||
if (!itr->second->CanSendMessageQueue(queue, leader, bg, bracketEntry))
|
||||
ret = false; // we change ret value only when scripts return false
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -71,8 +71,7 @@ void SystemMgr::LoadScriptWaypoints()
|
||||
|
||||
m_mPointMoveMap[uiEntry].push_back(temp);
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
} while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u Script Waypoint nodes in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
|
||||
@@ -48,32 +48,32 @@ typedef std::vector<ScriptPointMove> ScriptPointVector;
|
||||
|
||||
class SystemMgr
|
||||
{
|
||||
SystemMgr() {}
|
||||
~SystemMgr() {}
|
||||
SystemMgr() {}
|
||||
~SystemMgr() {}
|
||||
|
||||
public:
|
||||
static SystemMgr* instance();
|
||||
public:
|
||||
static SystemMgr* instance();
|
||||
|
||||
typedef std::unordered_map<uint32, ScriptPointVector> PointMoveMap;
|
||||
typedef std::unordered_map<uint32, ScriptPointVector> PointMoveMap;
|
||||
|
||||
//Database
|
||||
void LoadScriptWaypoints();
|
||||
//Database
|
||||
void LoadScriptWaypoints();
|
||||
|
||||
ScriptPointVector const& GetPointMoveList(uint32 creatureEntry) const
|
||||
{
|
||||
PointMoveMap::const_iterator itr = m_mPointMoveMap.find(creatureEntry);
|
||||
ScriptPointVector const& GetPointMoveList(uint32 creatureEntry) const
|
||||
{
|
||||
PointMoveMap::const_iterator itr = m_mPointMoveMap.find(creatureEntry);
|
||||
|
||||
if (itr == m_mPointMoveMap.end())
|
||||
return _empty;
|
||||
if (itr == m_mPointMoveMap.end())
|
||||
return _empty;
|
||||
|
||||
return itr->second;
|
||||
}
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
protected:
|
||||
PointMoveMap m_mPointMoveMap; //coordinates for waypoints
|
||||
protected:
|
||||
PointMoveMap m_mPointMoveMap; //coordinates for waypoints
|
||||
|
||||
private:
|
||||
static ScriptPointVector const _empty;
|
||||
private:
|
||||
static ScriptPointVector const _empty;
|
||||
};
|
||||
|
||||
#define sScriptSystemMgr SystemMgr::instance()
|
||||
|
||||
Reference in New Issue
Block a user