Battlefields: Move BF scripts out of game

This commit introduces the usual script interface
for battlefields.
This commit is contained in:
Carbenium authored and Ovahlord committed 2022-10-09 00:35:07 +02:00
1 parent d5f7d7b754
commit 0ef220fca0
17 files changed
+320 -206

No files matched your search

+22
View File
@@ -77,6 +77,10 @@ template<>
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 { };
@@ -603,6 +607,12 @@ class ScriptRegistrySwapHooks<GameObjectScript, Base>
GameObject, GameObjectScript, 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>
@@ -1564,6 +1574,12 @@ bool ScriptMgr::OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger)
return tmpscript->OnTrigger(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.
@@ -2193,6 +2209,11 @@ 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)
@@ -2298,6 +2319,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>;
+16
View File
@@ -28,6 +28,7 @@ class AccountMgr;
class AuctionHouseObject;
class Aura;
class AuraScript;
class Battlefield;
class Battleground;
class BattlegroundMap;
class Channel;
@@ -453,6 +454,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:
@@ -934,6 +946,10 @@ class TC_GAME_API ScriptMgr
bool OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger);
public: /* BattlefieldScript */
Battlefield* CreateBattlefield(uint32 scriptId);
public: /* BattlegroundScript */
Battleground* CreateBattleground(BattlegroundTypeId typeId);