aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Scripting
diff options
context:
space:
mode:
authorCarbenium <carbenium@outlook.com>2020-06-22 16:10:34 +0200
committerShauren <shauren.trinity@gmail.com>2022-01-07 00:20:57 +0100
commit49523a74a4c28e5ae17f9a8352aa8224b765b7d8 (patch)
tree829e998508b4320f305bc9e4891ec7116c4005fd /src/server/game/Scripting
parenta26cc135fa34e0e4aa0c244c4c4b4bec4c25d709 (diff)
Battlefields: Move BF scripts out of game
This commit introduces the usual script interface for battlefields. (cherry picked from commit f7faf20254a120a90b8ee8eb55a284a6351aabc3)
Diffstat (limited to 'src/server/game/Scripting')
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp22
-rw-r--r--src/server/game/Scripting/ScriptMgr.h16
2 files changed, 38 insertions, 0 deletions
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index 038aa13a952..6eb82ae349a 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -85,6 +85,10 @@ struct is_script_database_bound<AreaTriggerScript>
: std::true_type { };
template<>
+struct is_script_database_bound<BattlefieldScript>
+ : std::true_type { };
+
+template<>
struct is_script_database_bound<BattlegroundScript>
: std::true_type { };
@@ -724,6 +728,11 @@ class ScriptRegistrySwapHooks<AreaTriggerEntityScript, Base>
AreaTrigger, AreaTriggerEntityScript, Base
> { };
+/// This hook is responsible for swapping BattlefieldScripts
+template<typename Base>
+class ScriptRegistrySwapHooks<BattlefieldScript, Base>
+ : public UnsupportedScriptRegistrySwapHooks<Base> { };
+
/// This hook is responsible for swapping BattlegroundScript's
template<typename Base>
class ScriptRegistrySwapHooks<BattlegroundScript, Base>
@@ -1720,6 +1729,12 @@ bool ScriptMgr::OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger, b
return entered ? tmpscript->OnTrigger(player, trigger) : tmpscript->OnExit(player, trigger);
}
+Battlefield* ScriptMgr::CreateBattlefield(uint32 scriptId)
+{
+ GET_SCRIPT_RET(BattlefieldScript, scriptId, tmpscript, nullptr);
+ return tmpscript->GetBattlefield();
+}
+
Battleground* ScriptMgr::CreateBattleground(BattlegroundTypeId /*typeId*/)
{
/// @todo Implement script-side battlegrounds.
@@ -2437,6 +2452,12 @@ bool OnlyOnceAreaTriggerScript::OnTrigger(Player* player, AreaTriggerEntry const
void OnlyOnceAreaTriggerScript::ResetAreaTriggerDone(InstanceScript* script, uint32 triggerId) { script->ResetAreaTriggerDone(triggerId); }
void OnlyOnceAreaTriggerScript::ResetAreaTriggerDone(Player const* player, AreaTriggerEntry const* trigger) { if (InstanceScript* instance = player->GetInstanceScript()) ResetAreaTriggerDone(instance, trigger->ID); }
+BattlefieldScript::BattlefieldScript(char const* name)
+ : ScriptObject(name)
+{
+ ScriptRegistry<BattlefieldScript>::Instance()->AddScript(this);
+}
+
BattlegroundScript::BattlegroundScript(char const* name)
: ScriptObject(name)
{
@@ -2557,6 +2578,7 @@ template class TC_GAME_API ScriptRegistry<ItemScript>;
template class TC_GAME_API ScriptRegistry<CreatureScript>;
template class TC_GAME_API ScriptRegistry<GameObjectScript>;
template class TC_GAME_API ScriptRegistry<AreaTriggerScript>;
+template class TC_GAME_API ScriptRegistry<BattlefieldScript>;
template class TC_GAME_API ScriptRegistry<BattlegroundScript>;
template class TC_GAME_API ScriptRegistry<OutdoorPvPScript>;
template class TC_GAME_API ScriptRegistry<CommandScript>;
diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h
index 20f7ca37715..e8694f64f70 100644
--- a/src/server/game/Scripting/ScriptMgr.h
+++ b/src/server/game/Scripting/ScriptMgr.h
@@ -28,6 +28,7 @@ class AreaTriggerAI;
class AuctionHouseObject;
class Aura;
class AuraScript;
+class Battlefield;
class Battleground;
class BattlegroundMap;
class Channel;
@@ -470,6 +471,17 @@ class TC_GAME_API OnlyOnceAreaTriggerScript : public AreaTriggerScript
void ResetAreaTriggerDone(Player const* player, AreaTriggerEntry const* trigger);
};
+class TC_GAME_API BattlefieldScript : public ScriptObject
+{
+ protected:
+
+ BattlefieldScript(char const* name);
+
+ public:
+
+ virtual Battlefield* GetBattlefield() const = 0;
+};
+
class TC_GAME_API BattlegroundScript : public ScriptObject
{
protected:
@@ -1016,6 +1028,10 @@ class TC_GAME_API ScriptMgr
bool OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger, bool entered);
+ public: /* BattlefieldScript */
+
+ Battlefield* CreateBattlefield(uint32 scriptId);
+
public: /* BattlegroundScript */
Battleground* CreateBattleground(BattlegroundTypeId typeId);