diff options
| author | Machiavelli <machiavelli.trinity@gmail.com> | 2011-12-19 11:14:26 +0100 | 
|---|---|---|
| committer | Machiavelli <machiavelli.trinity@gmail.com> | 2011-12-19 11:14:26 +0100 | 
| commit | 16df950fdb8e87a4cc931a68ca6e22c301e7e894 (patch) | |
| tree | a64d43c5a7d882d4257bcacdf457298c4fd43a71 /src/server/scripts/Spells | |
| parent | 829be0b82b2ecdb054e4059d0d2dc39f3df6ded6 (diff) | |
| parent | 40e235a2ccf3661a5cf18c6946ae95ba2e544771 (diff) | |
Merge branch 'master' of github.com:TrinityCore/TrinityCore
Diffstat (limited to 'src/server/scripts/Spells')
| -rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 50 | 
1 files changed, 50 insertions, 0 deletions
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();  }  | 
