Core/Spells: Fixed TARGET_UNIT_DRIVER selection and possible problems with Righteous Defense target count

This commit is contained in:
Shauren
2011-05-14 14:12:40 +02:00
parent 77a7d9a4df
commit a816cdd772
2 changed files with 5 additions and 4 deletions

View File

@@ -2370,7 +2370,7 @@ void Spell::SelectEffectTargets(uint32 i, uint32 cur)
break;
case TARGET_UNIT_DRIVER:
if (Unit * driver = m_targets.getUnitTarget())
if (driver->IsOnVehicle(driver))
if (driver->IsOnVehicle(m_caster))
AddUnitTarget(driver, i);
break;
default:

View File

@@ -1390,11 +1390,12 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
Unit::AttackerSet attackers = unitTarget->getAttackers();
// selected from list 3
for (uint32 i = 0; i < std::min(size_t(3), attackers.size()); ++i)
uint32 maxTargets = std::min<uint32>(3, attackers.size());
for (uint32 i = 0; i < maxTargets; ++i)
{
Unit::AttackerSet::iterator aItr = attackers.begin();
std::advance(aItr, rand() % attackers.size());
AddUnitTarget((*aItr), 1);
std::advance(aItr, urand(0, attackers.size() - 1));
AddUnitTarget(*aItr, 1);
attackers.erase(aItr);
}