*Fix target selection for wild growth and circle of healing

--HG--
branch : trunk
This commit is contained in:
QAston
2009-05-03 00:02:02 +02:00
parent 823cb628be
commit abe9b27ee4
3 changed files with 99 additions and 6 deletions
+90 -2
View File
@@ -62,6 +62,54 @@ bool IsQuestTameSpell(uint32 spellId)
&& spellproto->Effect[1] == SPELL_EFFECT_APPLY_AURA && spellproto->EffectApplyAuraName[1] == SPELL_AURA_DUMMY;
}
class PrioritizeManaWraper
{
friend struct PrioritizeMana;
public:
explicit PrioritizeManaWraper(Unit * unit) : unit(unit)
{
uint32 maxmana = unit->GetMaxPower(POWER_MANA);
percentMana = maxmana ? unit->GetPower(POWER_MANA) * 100 / maxmana : 101;
}
Unit* getUnit() const { return unit; }
private:
Unit* unit;
uint32 percentMana;
};
struct PrioritizeMana
{
int operator()( PrioritizeManaWraper const& x, PrioritizeManaWraper const& y ) const
{
return x.percentMana < y.percentMana;
}
};
class PrioritizeHealthWraper
{
friend struct PrioritizeHealth;
public:
explicit PrioritizeHealthWraper(Unit * unit) : unit(unit)
{
uint32 maxhp = unit->GetMaxHealth();
percentHealth = maxhp ? unit->GetHealth() * 100 / maxhp : 101;
}
Unit* getUnit() const { return unit; }
private:
Unit* unit;
uint32 percentHealth;
};
struct PrioritizeHealth
{
int operator()( PrioritizeHealthWraper const& x, PrioritizeHealthWraper const& y ) const
{
return x.percentHealth < y.percentHealth;
}
};
SpellCastTargets::SpellCastTargets()
{
m_unitTarget = NULL;
@@ -1992,7 +2040,7 @@ void Spell::SetTargetMap(uint32 i, uint32 cur)
targetType = SPELL_TARGETS_NONE;
break;
}
if(modOwner)
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius, this);
radius *= m_spellValue->RadiusMod;
@@ -2082,8 +2130,48 @@ void Spell::SetTargetMap(uint32 i, uint32 cur)
if(m_spellInfo->Id == 5246) //Intimidating Shout
unitList.remove(m_targets.getUnitTarget());
else if (m_spellInfo->Id==57699) //Replenishment (special target selection) 10 targets with lowest mana
{
typedef std::priority_queue<PrioritizeManaWraper, std::vector<PrioritizeManaWraper>, PrioritizeMana> TopMana;
TopMana manaUsers;
for (std::list<Unit*>::iterator itr = unitList.begin() ; itr != unitList.end() && manaUsers.size() <=m_spellValue->MaxAffectedTargets;++itr)
{
if ((*itr)->getPowerType() == POWER_MANA)
{
PrioritizeManaWraper WTarget(*itr);
manaUsers.push(WTarget);
}
}
Trinity::RandomResizeList(unitList, maxTargets);
unitList.clear();
while(!manaUsers.empty())
{
unitList.push_back(manaUsers.top().getUnit());
manaUsers.pop();
}
}
else if (m_spellInfo->EffectImplicitTargetA[i] == TARGET_DEST_TARGET_ANY
&& m_spellInfo->EffectImplicitTargetB[i] == TARGET_UNIT_AREA_ALLY_DST)// Wild Growth, Circle of Healing target special selection
{
typedef std::priority_queue<PrioritizeHealthWraper, std::vector<PrioritizeHealthWraper>, PrioritizeHealth> TopHealth;
TopHealth healedMembers;
for (std::list<Unit*>::iterator itr = unitList.begin() ; itr != unitList.end() && healedMembers.size() <=m_spellValue->MaxAffectedTargets;++itr)
{
if ((*itr)->IsInRaidWith(m_targets.getUnitTarget()))
{
PrioritizeHealthWraper WTarget(*itr);
healedMembers.push(WTarget);
}
}
unitList.clear();
while(!healedMembers.empty())
{
unitList.push_back(healedMembers.top().getUnit());
healedMembers.pop();
}
}
Trinity::RandomResizeList(unitList, m_spellValue->MaxAffectedTargets);
}
for(std::list<Unit*>::iterator itr = unitList.begin(); itr != unitList.end(); ++itr)
+2 -2
View File
@@ -3199,7 +3199,7 @@ void AuraEffect::HandleAuraTransform(bool apply, bool Real)
m_target->SetDisplayId(modelid);
// Dragonmaw Illusion (set mount model also)
if(GetId()==42016 && m_target->GetMountID() && !m_target->GetAurasByType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED).empty())
if(GetId()==42016 && m_target->GetMountID() && !m_target->GetAurasByType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED).empty())
m_target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314);
}
}
@@ -4019,7 +4019,7 @@ void AuraEffect::HandleAuraModIncreaseFlightSpeed(bool apply, bool Real)
return;
// Enable Fly mode for flying mounts
if (m_auraName == SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED)
if (m_auraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED)
{
WorldPacket data;
if(apply)
+7 -2
View File
@@ -2374,7 +2374,7 @@ void SpellMgr::LoadSpellCustomAttr()
case TARGET_TYPE_DEST_TARGET:
spellInfo->Targets |= TARGET_FLAG_UNIT;
break;
}
}
}
for(uint32 j = 0; j < 3; ++j)
@@ -2442,12 +2442,14 @@ void SpellMgr::LoadSpellCustomAttr()
case 37676: //Insidious Whisper
case 46009: //Negative Energy
case 45641: //Fire Bloom
case 54937: //Glyph of Holy Light
spellInfo->MaxAffectedTargets = 5;
break;
case 40827: //Sinful Beam
case 40859: //Sinister Beam
case 40860: //Vile Beam
case 40861: //Wicked Beam
case 57669: // Replenishment
spellInfo->MaxAffectedTargets = 10;
break;
case 8122: case 8124: case 10888: case 10890: // Psychic Scream
@@ -2488,9 +2490,12 @@ void SpellMgr::LoadSpellCustomAttr()
switch(spellInfo->SpellFamilyName)
{
case SPELLFAMILY_DRUID:
//starfall
// starfall
if(spellInfo->SpellFamilyFlags[2] & 0x100)
spellInfo->MaxAffectedTargets = 2;
// Wild growth
else if(spellInfo->SpellFamilyFlags[1] & 0x4000000)
spellInfo->MaxAffectedTargets = 5;
break;
// circle of healing
case SPELLFAMILY_PRIEST: