diff options
Diffstat (limited to 'src/server/game/Scripting')
| -rw-r--r-- | src/server/game/Scripting/ScriptMgr.cpp | 9 | ||||
| -rw-r--r-- | src/server/game/Scripting/ScriptMgr.h | 6 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 7c94aa3ed55..8ad749ef53a 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -1706,6 +1706,15 @@ uint32 ScriptMgr::GetDialogStatus(Player* player, Creature* creature) return tmpscript->GetDialogStatus(player, creature); } +bool ScriptMgr::CanSpawn(ObjectGuid::LowType spawnId, uint32 entry, CreatureTemplate const* actTemplate, CreatureData const* cData, Map const* map) +{ + ASSERT(actTemplate); + + CreatureTemplate const* baseTemplate = sObjectMgr->GetCreatureTemplate(entry); + GET_SCRIPT_RET(CreatureScript, baseTemplate->ScriptID, tmpscript, true); + return tmpscript->CanSpawn(spawnId, entry, baseTemplate, actTemplate, cData, map); +} + CreatureAI* ScriptMgr::GetCreatureAI(Creature* creature) { ASSERT(creature); diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 76a5f663f82..72b71651bd9 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -68,6 +68,8 @@ struct AreaTriggerEntry; struct AuctionEntry; struct ConditionSourceInfo; struct Condition; +struct CreatureTemplate; +struct CreatureData; struct ItemTemplate; struct MapEntry; struct OutdoorPvPData; @@ -436,6 +438,9 @@ class TC_GAME_API CreatureScript : public UnitScript, public UpdatableScript<Cre // Called when the dialog status between a player and the creature is requested. virtual uint32 GetDialogStatus(Player* /*player*/, Creature* /*creature*/) { return DIALOG_STATUS_SCRIPTED_NO_STATUS; } + // Called when the creature tries to spawn. Return false to block spawn and re-evaluate on next tick. + virtual bool CanSpawn(ObjectGuid::LowType /*spawnId*/, uint32 /*entry*/, CreatureTemplate const* /*baseTemplate*/, CreatureTemplate const* /*actTemplate*/, CreatureData const* /*cData*/, Map const* /*map*/) const { return true; } + // Called when a CreatureAI object is needed for the creature. virtual CreatureAI* GetAI(Creature* /*creature*/) const { return NULL; } }; @@ -1016,6 +1021,7 @@ class TC_GAME_API ScriptMgr bool OnQuestSelect(Player* player, Creature* creature, Quest const* quest); bool OnQuestReward(Player* player, Creature* creature, Quest const* quest, uint32 opt); uint32 GetDialogStatus(Player* player, Creature* creature); + bool CanSpawn(ObjectGuid::LowType spawnId, uint32 entry, CreatureTemplate const* actTemplate, CreatureData const* cData, Map const* map); CreatureAI* GetCreatureAI(Creature* creature); void OnCreatureUpdate(Creature* creature, uint32 diff); |
