Scripts/ICC: update Unchained Magic target selection

because we all love retri paladins and hate healers, right?, right?
This commit is contained in:
ccrs
2018-09-20 17:13:07 +02:00
parent 2a06923879
commit 2e4358f726

View File

@@ -15,15 +15,17 @@
* with this program. If not, see <http://www.gnu.org/licenses/>. * with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "ScriptMgr.h"
#include "GridNotifiers.h"
#include "icecrown_citadel.h" #include "icecrown_citadel.h"
#include "CommonHelpers.h"
#include "Containers.h"
#include "GridNotifiers.h"
#include "InstanceScript.h" #include "InstanceScript.h"
#include "Map.h" #include "Map.h"
#include "MotionMaster.h" #include "MotionMaster.h"
#include "ObjectAccessor.h" #include "ObjectAccessor.h"
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "ScriptedCreature.h" #include "ScriptedCreature.h"
#include "ScriptMgr.h"
#include "SpellAuraEffects.h" #include "SpellAuraEffects.h"
#include "SpellMgr.h" #include "SpellMgr.h"
#include "SpellScript.h" #include "SpellScript.h"
@@ -1152,46 +1154,74 @@ class spell_sindragosa_s_fury : public SpellScriptLoader
} }
}; };
class UnchainedMagicTargetSelector class spell_sindragosa_unchained_magic : public SpellScript
{ {
public: PrepareSpellScript(spell_sindragosa_unchained_magic);
UnchainedMagicTargetSelector() { }
bool operator()(WorldObject* object) const void FilterTargets(std::list<WorldObject*>& targets)
{
std::list<WorldObject*> healers;
std::list<WorldObject*> casters;
for (WorldObject* target : targets)
{ {
if (Unit* unit = object->ToUnit()) Player* player = target->ToPlayer();
return unit->GetPowerType() != POWER_MANA; if (!player || player->GetPowerType() != POWER_MANA)
return true; continue;
}
};
class spell_sindragosa_unchained_magic : public SpellScriptLoader if (Trinity::Helpers::Entity::IsPlayerHealer(player))
{
public:
spell_sindragosa_unchained_magic() : SpellScriptLoader("spell_sindragosa_unchained_magic") { }
class spell_sindragosa_unchained_magic_SpellScript : public SpellScript
{
PrepareSpellScript(spell_sindragosa_unchained_magic_SpellScript);
void FilterTargets(std::list<WorldObject*>& unitList)
{ {
unitList.remove_if(UnchainedMagicTargetSelector()); healers.push_back(target);
uint32 maxSize = uint32(GetCaster()->GetMap()->GetSpawnMode() & 1 ? 6 : 2); continue;
if (unitList.size() > maxSize)
Trinity::Containers::RandomResize(unitList, maxSize);
} }
void Register() override switch (player->getClass())
{ {
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_unchained_magic_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); case CLASS_PRIEST:
case CLASS_MAGE:
case CLASS_WARLOCK:
casters.push_back(target);
break;
case CLASS_SHAMAN:
if (Trinity::Helpers::Entity::GetPlayerSpecialization(player) != SPEC_SHAMAN_ENHANCEMENT)
casters.push_back(target);
break;
case CLASS_DRUID:
if (Trinity::Helpers::Entity::GetPlayerSpecialization(player) != SPEC_DRUID_FERAL)
casters.push_back(target);
break;
default:
break;
} }
};
SpellScript* GetSpellScript() const override
{
return new spell_sindragosa_unchained_magic_SpellScript();
} }
targets.clear();
bool const is25ManRaid = GetCaster()->GetMap()->Is25ManRaid();
if (!healers.empty())
{
Trinity::Containers::RandomResize(healers, size_t(is25ManRaid ? 3 : 1));
while (!healers.empty())
{
targets.push_back(healers.back());
healers.pop_back();
}
}
if (!casters.empty())
{
Trinity::Containers::RandomShuffle(casters);
size_t const maxSize = is25ManRaid ? 6 : 2;
while (!casters.empty() && targets.size() < maxSize)
{
targets.push_back(casters.back());
casters.pop_back();
}
}
}
void Register() override
{
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_unchained_magic::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
}
}; };
class spell_sindragosa_frost_breath : public SpellScriptLoader class spell_sindragosa_frost_breath : public SpellScriptLoader
@@ -1685,7 +1715,7 @@ void AddSC_boss_sindragosa()
new npc_rimefang(); new npc_rimefang();
new npc_sindragosa_trash(); new npc_sindragosa_trash();
new spell_sindragosa_s_fury(); new spell_sindragosa_s_fury();
new spell_sindragosa_unchained_magic(); RegisterSpellScript(spell_sindragosa_unchained_magic);
new spell_sindragosa_frost_breath(); new spell_sindragosa_frost_breath();
new spell_sindragosa_instability(); new spell_sindragosa_instability();
new spell_sindragosa_frost_beacon(); new spell_sindragosa_frost_beacon();