mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 18:15:31 +01:00
Scripts/Spells: Fixed crash in Druid T10 4P Restoration set bonus
Closes #1399 Closes #1507
This commit is contained in:
@@ -224,19 +224,38 @@ class spell_dru_t10_restoration_4p_bonus : public SpellScriptLoader
|
||||
{
|
||||
PrepareSpellScript(spell_dru_t10_restoration_4p_bonus_SpellScript);
|
||||
|
||||
bool Load()
|
||||
{
|
||||
return GetCaster()->GetTypeId() == TYPEID_PLAYER;
|
||||
}
|
||||
|
||||
void FilterTargets(std::list<Unit*>& unitList)
|
||||
{
|
||||
unitList.remove(GetTargetUnit());
|
||||
std::list<Unit*> tempTargets;
|
||||
std::list<Unit*>::iterator end = unitList.end(), itr = unitList.begin();
|
||||
for (; itr != end; ++itr)
|
||||
if (GetCaster()->IsInRaidWith(*itr))
|
||||
tempTargets.push_back(*itr);
|
||||
if (!GetCaster()->ToPlayer()->GetGroup())
|
||||
{
|
||||
unitList.clear();
|
||||
unitList.push_back(GetCaster());
|
||||
}
|
||||
else
|
||||
{
|
||||
unitList.remove(GetTargetUnit());
|
||||
std::list<Unit*> tempTargets;
|
||||
for (std::list<Unit*>::const_iterator itr = unitList.begin(); itr != unitList.end(); ++itr)
|
||||
if ((*itr)->GetTypeId() == TYPEID_PLAYER && GetCaster()->IsInRaidWith(*itr))
|
||||
tempTargets.push_back(*itr);
|
||||
|
||||
itr = tempTargets.begin();
|
||||
std::advance(itr, urand(0, tempTargets.size()-1));
|
||||
unitList.clear();
|
||||
unitList.push_back(*itr);
|
||||
if (tempTargets.empty())
|
||||
{
|
||||
unitList.clear();
|
||||
FinishCast(SPELL_FAILED_DONT_REPORT);
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<Unit*>::const_iterator it2 = tempTargets.begin();
|
||||
std::advance(it2, urand(0, tempTargets.size() - 1));
|
||||
unitList.clear();
|
||||
unitList.push_back(*it2);
|
||||
}
|
||||
}
|
||||
|
||||
void Register()
|
||||
|
||||
Reference in New Issue
Block a user