Scripts/Spells: Moved all special target filtering cases to scripts
This commit is contained in:
1 parent
c2690f748b
commit
5adf9c5d30
15 files changed
+957
-671
No files matched your search
@@ -352,6 +352,57 @@ class spell_bronjahm_soulstorm_visual : public SpellScriptLoader
|
||||
}
|
||||
};
|
||||
|
||||
class DistanceCheck
|
||||
{
|
||||
public:
|
||||
explicit DistanceCheck(Unit* _caster) : caster(_caster) { }
|
||||
|
||||
bool operator() (Unit* unit)
|
||||
{
|
||||
if (caster->GetExactDist2d(unit) <= 10.0f)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Unit* caster;
|
||||
};
|
||||
|
||||
class spell_bronjahm_soulstorm_targeting : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_bronjahm_soulstorm_targeting() : SpellScriptLoader("spell_bronjahm_soulstorm_targeting") { }
|
||||
|
||||
class spell_bronjahm_soulstorm_targeting_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_bronjahm_soulstorm_targeting_SpellScript);
|
||||
|
||||
void FilterTargetsInitial(std::list<Unit*>& unitList)
|
||||
{
|
||||
unitList.remove_if(DistanceCheck(GetCaster()));
|
||||
sharedUnitList = unitList;
|
||||
}
|
||||
|
||||
// use the same target for first and second effect
|
||||
void FilterTargetsSubsequent(std::list<Unit*>& unitList)
|
||||
{
|
||||
unitList = sharedUnitList;
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
OnUnitTargetSelect += SpellUnitTargetFn(spell_bronjahm_soulstorm_targeting_SpellScript::FilterTargetsInitial, EFFECT_1, TARGET_UNIT_AREA_ENEMY_DST);
|
||||
OnUnitTargetSelect += SpellUnitTargetFn(spell_bronjahm_soulstorm_targeting_SpellScript::FilterTargetsSubsequent, EFFECT_2, TARGET_UNIT_AREA_ENEMY_DST);
|
||||
}
|
||||
|
||||
std::list<Unit*> sharedUnitList;
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
return new spell_bronjahm_soulstorm_targeting_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_boss_bronjahm()
|
||||
{
|
||||
new boss_bronjahm();
|
||||
@@ -360,4 +411,5 @@ void AddSC_boss_bronjahm()
|
||||
new spell_bronjahm_consume_soul();
|
||||
new spell_bronjahm_soulstorm_channel();
|
||||
new spell_bronjahm_soulstorm_visual();
|
||||
new spell_bronjahm_soulstorm_targeting();
|
||||
}
|
||||
@@ -560,6 +560,63 @@ class spell_blood_queen_bloodbolt : public SpellScriptLoader
|
||||
}
|
||||
};
|
||||
|
||||
class PactOfTheDarkfallenChack
|
||||
{
|
||||
public:
|
||||
bool operator() (Unit* unit)
|
||||
{
|
||||
return !unit->HasAura(SPELL_PACT_OF_THE_DARKFALLEN);
|
||||
}
|
||||
};
|
||||
|
||||
class spell_blood_queen_pact_of_the_darkfallen : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_blood_queen_pact_of_the_darkfallen() : SpellScriptLoader("spell_blood_queen_pact_of_the_darkfallen") { }
|
||||
|
||||
class spell_blood_queen_pact_of_the_darkfallen_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_blood_queen_pact_of_the_darkfallen_SpellScript);
|
||||
|
||||
void FilterTargets(std::list<Unit*>& unitList)
|
||||
{
|
||||
unitList.remove_if(PactOfTheDarkfallenChack());
|
||||
|
||||
bool remove = true;
|
||||
std::list<Unit*>::const_iterator itrEnd = unitList.end(), itr, itr2;
|
||||
// we can do this, unitList is MAX 4 in size
|
||||
for (itr = unitList.begin(); itr != itrEnd && remove; ++itr)
|
||||
{
|
||||
if (!GetCaster()->IsWithinDist(*itr, 5.0f, false))
|
||||
remove = false;
|
||||
|
||||
for (itr2 = unitList.begin(); itr2 != itrEnd && remove; ++itr2)
|
||||
if (itr != itr2 && !(*itr2)->IsWithinDist(*itr, 5.0f, false))
|
||||
remove = false;
|
||||
}
|
||||
|
||||
if (remove)
|
||||
{
|
||||
if (InstanceScript* instance = GetCaster()->GetInstanceScript())
|
||||
{
|
||||
instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_PACT_OF_THE_DARKFALLEN);
|
||||
unitList.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
OnUnitTargetSelect += SpellUnitTargetFn(spell_blood_queen_pact_of_the_darkfallen_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_AREA_ALLY_SRC);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
return new spell_blood_queen_pact_of_the_darkfallen_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
class achievement_once_bitten_twice_shy_n : public AchievementCriteriaScript
|
||||
{
|
||||
public:
|
||||
@@ -598,6 +655,7 @@ void AddSC_boss_blood_queen_lana_thel()
|
||||
new spell_blood_queen_vampiric_bite();
|
||||
new spell_blood_queen_frenzied_bloodthirst();
|
||||
new spell_blood_queen_bloodbolt();
|
||||
new spell_blood_queen_pact_of_the_darkfallen();
|
||||
new achievement_once_bitten_twice_shy_n();
|
||||
new achievement_once_bitten_twice_shy_v();
|
||||
}
|
||||
@@ -1124,6 +1124,105 @@ class spell_deathbringer_blood_nova : public SpellScriptLoader
|
||||
}
|
||||
};
|
||||
|
||||
class spell_deathbringer_blood_nova_targeting : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_deathbringer_blood_nova_targeting() : SpellScriptLoader("spell_deathbringer_blood_nova_targeting") { }
|
||||
|
||||
class spell_deathbringer_blood_nova_targeting_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_deathbringer_blood_nova_targeting_SpellScript);
|
||||
|
||||
bool Load()
|
||||
{
|
||||
// initialize variable
|
||||
target = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
void FilterTargetsInitial(std::list<Unit*>& unitList)
|
||||
{
|
||||
// select one random target, with preference of ranged targets
|
||||
uint32 targetsAtRange = 0;
|
||||
uint32 const minTargets = GetCaster()->GetMap()->GetSpawnMode() & 1 ? 10 : 4;
|
||||
unitList.sort(Trinity::ObjectDistanceOrderPred(GetCaster(), false));
|
||||
|
||||
// get target count at range
|
||||
for (std::list<Unit*>::iterator itr = unitList.begin(); itr != unitList.end(); ++itr, ++targetsAtRange)
|
||||
if ((*itr)->GetDistance(GetCaster()) < 12.0f)
|
||||
break;
|
||||
|
||||
// set the upper cap
|
||||
if (targetsAtRange < minTargets)
|
||||
targetsAtRange = std::min<uint32>(unitList.size()-1, minTargets);
|
||||
|
||||
std::list<Unit*>::iterator itr = unitList.begin();
|
||||
std::advance(itr, urand(0, targetsAtRange));
|
||||
target = *itr;
|
||||
unitList.clear();
|
||||
unitList.push_back(target);
|
||||
}
|
||||
|
||||
// use the same target for first and second effect
|
||||
void FilterTargetsSubsequent(std::list<Unit*>& unitList)
|
||||
{
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
unitList.clear();
|
||||
unitList.push_back(target);
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
OnUnitTargetSelect += SpellUnitTargetFn(spell_deathbringer_blood_nova_targeting_SpellScript::FilterTargetsInitial, EFFECT_0, TARGET_UNIT_AREA_ENEMY_SRC);
|
||||
OnUnitTargetSelect += SpellUnitTargetFn(spell_deathbringer_blood_nova_targeting_SpellScript::FilterTargetsSubsequent, EFFECT_1, TARGET_UNIT_AREA_ENEMY_SRC);
|
||||
}
|
||||
|
||||
Unit* target;
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
return new spell_deathbringer_blood_nova_targeting_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
class MarkOfTheFallenChampionCheck
|
||||
{
|
||||
public:
|
||||
bool operator() (Unit* unit)
|
||||
{
|
||||
return !unit->HasAura(SPELL_MARK_OF_THE_FALLEN_CHAMPION);
|
||||
}
|
||||
};
|
||||
|
||||
class spell_deathbringer_mark_of_the_fallen_champion : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_deathbringer_mark_of_the_fallen_champion() : SpellScriptLoader("spell_deathbringer_mark_of_the_fallen_champion") { }
|
||||
|
||||
class spell_deathbringer_mark_of_the_fallen_champion_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_deathbringer_mark_of_the_fallen_champion_SpellScript);
|
||||
|
||||
void FilterTargets(std::list<Unit*>& unitList)
|
||||
{
|
||||
unitList.remove_if(MarkOfTheFallenChampionCheck());
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
OnUnitTargetSelect += SpellUnitTargetFn(spell_deathbringer_mark_of_the_fallen_champion_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_AREA_ENEMY_SRC);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
return new spell_deathbringer_mark_of_the_fallen_champion_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
class achievement_ive_gone_and_made_a_mess : public AchievementCriteriaScript
|
||||
{
|
||||
public:
|
||||
@@ -1151,5 +1250,7 @@ void AddSC_boss_deathbringer_saurfang()
|
||||
new spell_deathbringer_blood_power();
|
||||
new spell_deathbringer_rune_of_blood();
|
||||
new spell_deathbringer_blood_nova();
|
||||
new spell_deathbringer_blood_nova_targeting();
|
||||
new spell_deathbringer_mark_of_the_fallen_champion();
|
||||
new achievement_ive_gone_and_made_a_mess();
|
||||
}
|
||||
@@ -1270,6 +1270,33 @@ class spell_putricide_mutated_transformation : public SpellScriptLoader
|
||||
}
|
||||
};
|
||||
|
||||
class spell_putricide_mutated_transformation_dmg : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
spell_putricide_mutated_transformation_dmg() : SpellScriptLoader("spell_putricide_mutated_transformation_dmg") { }
|
||||
|
||||
class spell_putricide_mutated_transformation_dmg_SpellScript : public SpellScript
|
||||
{
|
||||
PrepareSpellScript(spell_putricide_mutated_transformation_dmg_SpellScript);
|
||||
|
||||
void FilterTargetsInitial(std::list<Unit*>& unitList)
|
||||
{
|
||||
if (Unit* owner = ObjectAccessor::GetUnit(*GetCaster(), GetCaster()->GetCreatorGUID()))
|
||||
unitList.remove(owner);
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
OnUnitTargetSelect += SpellUnitTargetFn(spell_putricide_mutated_transformation_dmg_SpellScript::FilterTargetsInitial, EFFECT_0, TARGET_UNIT_AREA_ALLY_SRC);
|
||||
}
|
||||
};
|
||||
|
||||
SpellScript* GetSpellScript() const
|
||||
{
|
||||
return new spell_putricide_mutated_transformation_dmg_SpellScript();
|
||||
}
|
||||
};
|
||||
|
||||
class spell_putricide_regurgitated_ooze : public SpellScriptLoader
|
||||
{
|
||||
public:
|
||||
@@ -1347,6 +1374,7 @@ void AddSC_boss_professor_putricide()
|
||||
new spell_putricide_mutation_init();
|
||||
new spell_putricide_mutated_transformation_dismiss();
|
||||
new spell_putricide_mutated_transformation();
|
||||
new spell_putricide_mutated_transformation_dmg();
|
||||
new spell_putricide_regurgitated_ooze();
|
||||
new spell_stinky_precious_decimate();
|
||||
}
|
||||
Reference in new issue
Block a user