[8734] Re-implement talent 31789

* Allow apply to enemies of attacked party member
* Correctly apply effect to 3 attackers
This commit is contained in:
VladimirMangos 2009-10-25 10:16:31 +03:00
parent 9746a97174
commit 9e4b833054
2 changed files with 23 additions and 13 deletions

View file

@ -1760,13 +1760,25 @@ void Spell::EffectDummy(uint32 i)
}
case 31789: // Righteous Defense (step 1)
{
if (m_caster->GetTypeId() != TYPEID_PLAYER)
{
SendCastResult(SPELL_FAILED_TARGET_AFFECTING_COMBAT);
return;
}
// 31989 -> dummy effect (step 1) + dummy effect (step 2) -> 31709 (taunt like spell for each target)
Unit* friendTarget = !unitTarget || unitTarget->IsFriendlyTo(m_caster) ? unitTarget : unitTarget->getVictim();
if (friendTarget)
{
Player* player = friendTarget->GetCharmerOrOwnerPlayerOrPlayerItself();
if (!player || !player->IsInSameRaidWith((Player*)m_caster))
friendTarget = NULL;
}
// non-standard cast requirement check
if (!unitTarget || unitTarget->getAttackers().empty())
if (!friendTarget || friendTarget->getAttackers().empty())
{
if (m_caster->GetTypeId()==TYPEID_PLAYER)
((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->Id,true);
((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->Id,true);
SendCastResult(SPELL_FAILED_TARGET_AFFECTING_COMBAT);
return;
}
@ -1776,18 +1788,16 @@ void Spell::EffectDummy(uint32 i)
for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit)
ihit->effectMask &= ~(1<<1);
// not empty (checked)
Unit::AttackerSet const& attackers = unitTarget->getAttackers();
// not empty (checked), copy
Unit::AttackerSet attackers = friendTarget->getAttackers();
// chance to be selected from list
float chance = 100.0f/attackers.size();
uint32 count=0;
for(Unit::AttackerSet::const_iterator aItr = attackers.begin(); aItr != attackers.end() && count < 3; ++aItr)
// selected from list 3
for(int i = 0; i < std::min(size_t(3),attackers.size()); ++i)
{
if (!roll_chance_f(chance))
continue;
++count;
Unit::AttackerSet::iterator aItr = attackers.begin();
std::advance(aItr, rand() % attackers.size());
AddUnitTarget((*aItr), 1);
attackers.erase(aItr);
}
// now let next effect cast spell at each target.

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8733"
#define REVISION_NR "8734"
#endif // __REVISION_NR_H__