[11472] Implement spells 23184/25041 periodic trigger code.

Also implement classes PlayerListSearcher and AnyPlayerInObjectRangeWithAuraCheck

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
Xfurry 2011-05-12 00:07:18 +04:00 committed by VladimirMangos
parent 4bdf829064
commit 2355b0bfde
4 changed files with 67 additions and 6 deletions

View file

@ -469,6 +469,21 @@ namespace MaNGOS
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {} template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
}; };
template<class Check>
struct MANGOS_DLL_DECL PlayerListSearcher
{
uint32 i_phaseMask;
std::list<Player*> &i_objects;
Check& i_check;
PlayerListSearcher(std::list<Player*> &objects, Check & check)
: i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects),i_check(check) {}
void Visit(PlayerMapType &m);
template<class NOT_INTERESTED> void Visit(GridRefManager<NOT_INTERESTED> &) {}
};
template<class Do> template<class Do>
struct MANGOS_DLL_DECL PlayerWorker struct MANGOS_DLL_DECL PlayerWorker
{ {
@ -1137,6 +1152,8 @@ namespace MaNGOS
NearestCreatureEntryWithLiveStateInObjectRangeCheck(NearestCreatureEntryWithLiveStateInObjectRangeCheck const&); NearestCreatureEntryWithLiveStateInObjectRangeCheck(NearestCreatureEntryWithLiveStateInObjectRangeCheck const&);
}; };
// Player checks and do
class AnyPlayerInObjectRangeCheck class AnyPlayerInObjectRangeCheck
{ {
public: public:
@ -1154,7 +1171,23 @@ namespace MaNGOS
float i_range; float i_range;
}; };
// Player checks and do class AnyPlayerInObjectRangeWithAuraCheck
{
public:
AnyPlayerInObjectRangeWithAuraCheck(WorldObject const* obj, float range, uint32 spellId)
: i_obj(obj), i_range(range), i_spellId(spellId) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(Player* u)
{
return u->isAlive()
&& i_obj->IsWithinDistInMap(u, i_range)
&& u->HasAura(i_spellId);
}
private:
WorldObject const* i_obj;
float i_range;
uint32 i_spellId;
};
// Prepare using Builder localized packets with caching and send to player // Prepare using Builder localized packets with caching and send to player
template<class Builder> template<class Builder>

View file

@ -547,6 +547,15 @@ void MaNGOS::PlayerSearcher<Check>::Visit(PlayerMapType &m)
} }
} }
template<class Check>
void MaNGOS::PlayerListSearcher<Check>::Visit(PlayerMapType &m)
{
for(PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr)
if (itr->getSource()->InSamePhase(i_phaseMask))
if (i_check(itr->getSource()))
i_objects.push_back(itr->getSource());
}
template<class Builder> template<class Builder>
void MaNGOS::LocalizedPacketDo<Builder>::operator()( Player* p ) void MaNGOS::LocalizedPacketDo<Builder>::operator()( Player* p )
{ {

View file

@ -1112,8 +1112,29 @@ void Aura::TriggerSpell()
target->CastSpell(target, 23171, true, NULL, this); target->CastSpell(target, 23171, true, NULL, this);
return; return;
} }
// // Mark of Frost case 23184: // Mark of Frost
// case 23184: break; case 25041: // Mark of Nature
{
std::list<Player*> targets;
// spells existed in 1.x.x; 23183 - mark of frost; 25042 - mark of nature; both had radius of 100.0 yards in 1.x.x DBC
// spells are used by Azuregos and the Emerald dragons in order to put a stun debuff on the players which resurrect during the encounter
// in order to implement the missing spells we need to make a grid search for hostile players and check their auras; if they are marked apply debuff
// Mark of Frost or Mark of Nature
uint32 markSpellId = auraId == 23184 ? 23182 : 25040;
// Aura of Frost or Aura of Nature
uint32 debufSpellId = auraId == 23184 ? 23186 : 25043;
MaNGOS::AnyPlayerInObjectRangeWithAuraCheck u_check(GetTarget(), 100.0f, markSpellId);
MaNGOS::PlayerListSearcher<MaNGOS::AnyPlayerInObjectRangeWithAuraCheck > checker(targets, u_check);
Cell::VisitWorldObjects(GetTarget(), checker, 100.0f);
for (std::list<Player*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
(*itr)->CastSpell((*itr), debufSpellId, true, NULL, NULL, casterGUID);
return;
}
case 23493: // Restoration case 23493: // Restoration
{ {
uint32 heal = triggerTarget->GetMaxHealth() / 10; uint32 heal = triggerTarget->GetMaxHealth() / 10;
@ -1161,8 +1182,6 @@ void Aura::TriggerSpell()
} }
// // Stink Trap // // Stink Trap
// case 24918: break; // case 24918: break;
// // Mark of Nature
// case 25041: break;
// // Agro Drones // // Agro Drones
// case 25152: break; // case 25152: break;
case 25371: // Consume case 25371: // Consume

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11471" #define REVISION_NR "11472"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__