aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/Maps/Map.cpp8
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp50
2 files changed, 58 insertions, 0 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 04a5b102a6d..306af9c962a 100755
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -30,6 +30,7 @@
#include "MapManager.h"
#include "ObjectMgr.h"
#include "Group.h"
+#include "LFGMgr.h"
union u_map_magic
{
@@ -2318,6 +2319,13 @@ bool InstanceMap::AddPlayerToMap(Player* player)
ASSERT(playerBind->save == mapSave);
}
}
+
+ if (group && group->isLFGGroup())
+ if (uint32 dungeonId = sLFGMgr->GetDungeon(group->GetGUID(), true))
+ if (LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(dungeonId))
+ if (LFGDungeonEntry const* randomDungeon = sLFGDungeonStore.LookupEntry(*(sLFGMgr->GetSelectedDungeons(player->GetGUID()).begin())))
+ if (dungeon->map == GetId() && dungeon->difficulty == GetDifficulty() && randomDungeon->type == LFG_TYPE_RANDOM)
+ player->CastSpell(player, LFG_SPELL_LUCK_OF_THE_DRAW, true);
}
// for normal instances cancel the reset schedule when the
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp
index 260b0c57563..af558d479a5 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -26,6 +26,8 @@
#include "SpellAuraEffects.h"
#include "SkillDiscovery.h"
#include "GridNotifiers.h"
+#include "Group.h"
+#include "LFGMgr.h"
class spell_gen_absorb0_hitlimit1 : public SpellScriptLoader
{
@@ -1419,6 +1421,53 @@ public:
}
};
+class spell_gen_luck_of_the_draw : public SpellScriptLoader
+{
+ public:
+ spell_gen_luck_of_the_draw() : SpellScriptLoader("spell_gen_luck_of_the_draw") { }
+
+ class spell_gen_luck_of_the_draw_AuraScript : public AuraScript
+ {
+ PrepareAuraScript(spell_gen_luck_of_the_draw_AuraScript);
+
+ // cheap hax to make it have update calls
+ void CalcPeriodic(AuraEffect const* /*effect*/, bool& isPeriodic, int32& amplitude)
+ {
+ isPeriodic = true;
+ amplitude = 5 * IN_MILLISECONDS;
+ }
+
+ void Update(AuraEffect* /*effect*/)
+ {
+ if (GetUnitOwner()->GetTypeId() != TYPEID_PLAYER)
+ return;
+
+ LFGDungeonEntry const* randomDungeon = sLFGDungeonStore.LookupEntry(*(sLFGMgr->GetSelectedDungeons(GetUnitOwner()->GetGUID()).begin()));
+ Group* group = GetUnitOwner()->ToPlayer()->GetGroup();
+ Map const* map = GetUnitOwner()->GetMap();
+ if (group && group->isLFGGroup())
+ if (uint32 dungeonId = sLFGMgr->GetDungeon(group->GetGUID(), true))
+ if (LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(dungeonId))
+ if (dungeon->map == map->GetId() && dungeon->difficulty == map->GetDifficulty())
+ if (randomDungeon && randomDungeon->type == LFG_TYPE_RANDOM)
+ return; // in correct dungeon
+
+ Remove(AURA_REMOVE_BY_DEFAULT);
+ }
+
+ void Register()
+ {
+ DoEffectCalcPeriodic += AuraEffectCalcPeriodicFn(spell_gen_luck_of_the_draw_AuraScript::CalcPeriodic, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
+ OnEffectUpdatePeriodic += AuraEffectUpdatePeriodicFn(spell_gen_luck_of_the_draw_AuraScript::Update, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_DONE);
+ }
+ };
+
+ AuraScript* GetAuraScript() const
+ {
+ return new spell_gen_luck_of_the_draw_AuraScript();
+ }
+};
+
void AddSC_generic_spell_scripts()
{
new spell_gen_absorb0_hitlimit1();
@@ -1451,4 +1500,5 @@ void AddSC_generic_spell_scripts()
new spell_gen_vehicle_scaling();
new spell_gen_oracle_wolvar_reputation();
new spell_gen_damage_reduction_aura();
+ new spell_gen_luck_of_the_draw();
}