Skip to content

Instantly share code, notes, and snippets.

@fredimachado
Created December 2, 2011 13:02
Show Gist options
  • Save fredimachado/1423174 to your computer and use it in GitHub Desktop.
Save fredimachado/1423174 to your computer and use it in GitHub Desktop.
Prevent player from accessing GM Island unless if summoned by a GM
diff --git a/sql/custom/gm_island_access.sql b/sql/custom/gm_island_access.sql
new file mode 100644
index 0000000..55be6b9
--- /dev/null
+++ b/sql/custom/gm_island_access.sql
@@ -0,0 +1,11 @@
+SET @NO_MANS_LAND := 42202;
+SET @EXCLUDE_PERSUADED := -73954;
+SET @GM_ISLAND := 876;
+
+-- Script
+DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_no_mans_land';
+INSERT INTO `spell_script_names` VALUES (@NO_MANS_LAND, 'spell_no_mans_land');
+
+-- Buff players with "No Man's Land" only if not with aura "Persuaded" (added when summoned by a GM)
+DELETE FROM `spell_area` WHERE `spell` = @NO_MANS_LAND AND `area` = @GM_ISLAND;
+INSERT INTO `spell_area` VALUES (@NO_MANS_LAND, @GM_ISLAND, 0, 0, 0, @EXCLUDE_PERSUADED, 1791, 2, 1);
diff --git a/src/server/game/Chat/Commands/Level1.cpp b/src/server/game/Chat/Commands/Level1.cpp
index f06f8a7..b0dae4a 100755
--- a/src/server/game/Chat/Commands/Level1.cpp
+++ b/src/server/game/Chat/Commands/Level1.cpp
@@ -208,6 +208,10 @@ bool ChatHandler::HandleSummonCommand(const char* args)
else
target->SaveRecallPosition();
+ // GM is summoning to GM Island, cast "Persuaded"
+ if (m_session->GetPlayer()->GetAreaId() == 876)
+ target->CastSpell(target, 73954, false);
+
// before GM
float x, y, z;
m_session->GetPlayer()->GetClosePoint(x, y, z, target->GetObjectSize());
@@ -405,6 +409,10 @@ bool ChatHandler::HandleRecallCommand(const char* args)
target->CleanupAfterTaxiFlight();
}
+ // Check for "Persuaded" aura and remove it
+ if (target->HasAura(73954))
+ target->RemoveAura(73954);
+
target->TeleportTo(target->m_recallMap, target->m_recallX, target->m_recallY, target->m_recallZ, target->m_recallO);
return true;
}
diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp
index 26d7034..ee41130 100755
--- a/src/server/game/Scripting/ScriptLoader.cpp
+++ b/src/server/game/Scripting/ScriptLoader.cpp
@@ -1226,13 +1226,13 @@ void AddBattlegroundScripts()
#ifdef SCRIPTS
/* This is where custom scripts' loading functions should be declared. */
-
+void AddSC_gm_island_access();
#endif
void AddCustomScripts()
{
#ifdef SCRIPTS
/* This is where custom scripts should be added. */
-
+ AddSC_gm_island_access();
#endif
}
diff --git a/src/server/scripts/Custom/CMakeLists.txt b/src/server/scripts/Custom/CMakeLists.txt
index 1570ca1..cdae894 100644
--- a/src/server/scripts/Custom/CMakeLists.txt
+++ b/src/server/scripts/Custom/CMakeLists.txt
@@ -10,6 +10,7 @@
set(scripts_STAT_SRCS
${scripts_STAT_SRCS}
+ Custom/gm_island_access.cpp
)
message(" -> Prepared: Custom")
diff --git a/src/server/scripts/Custom/gm_island_access.cpp b/src/server/scripts/Custom/gm_island_access.cpp
new file mode 100644
index 0000000..350cd04
--- /dev/null
+++ b/src/server/scripts/Custom/gm_island_access.cpp
@@ -0,0 +1,46 @@
+#include "ScriptPCH.h"
+#include "Log.h"
+
+class spell_no_mans_land : public SpellScriptLoader
+{
+ public:
+ spell_no_mans_land() : SpellScriptLoader("spell_no_mans_land") { }
+
+ class spell_no_mans_land_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_no_mans_land_AuraScript);
+
+ bool CheckAreaTarget(Unit* target)
+ {
+ if (Player* player = target->ToPlayer())
+ return !AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity());
+ return false;
+ }
+
+ void HandleEffectPeriodic(AuraEffect const* /*aurEff*/)
+ {
+ if (Player* player = GetTarget()->ToPlayer())
+ {
+ PreventDefaultAction();
+ sLog->outString("GM Island: Player %s (%u) was teleported out of the island.", player->GetName(), player->GetGUIDLow());
+ player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation());
+ }
+ }
+
+ void Register()
+ {
+ DoCheckAreaTarget += AuraCheckAreaTargetFn(spell_no_mans_land_AuraScript::CheckAreaTarget);
+ OnEffectPeriodic += AuraEffectPeriodicFn(spell_no_mans_land_AuraScript::HandleEffectPeriodic, EFFECT_0, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
+ }
+ };
+
+ AuraScript* GetAuraScript() const
+ {
+ return new spell_no_mans_land_AuraScript();
+ }
+};
+
+void AddSC_gm_island_access()
+{
+ new spell_no_mans_land();
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment