[9882] Add support for mounts dependent from riding skill and location

This commit is contained in:
Laise 2010-05-12 13:33:17 +03:00
parent faf3e287c7
commit 41c58f3be9
5 changed files with 91 additions and 1 deletions

View file

@ -6526,4 +6526,61 @@ void Spell::ResetEffectDamageAndHeal()
{
m_damage = 0;
m_healing = 0;
}
void Spell::SelectMountByAreaAndSkill(Unit* target, uint32 spellId75, uint32 spellId150, uint32 spellId225, uint32 spellId300, uint32 spellIdSpecial)
{
if (!target || target->GetTypeId() != TYPEID_PLAYER)
return;
// Prevent stacking of mounts
target->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
uint16 skillval = ((Player*)target)->GetSkillValue(SKILL_RIDING);
if (!skillval)
return;
if (skillval >= 225 && (spellId300 > 0 || spellId225 > 0))
{
uint32 spellid = skillval >= 300 ? spellId300 : spellId225;
SpellEntry const *pSpell = sSpellStore.LookupEntry(spellid);
// zone check
uint32 zone, area;
target->GetZoneAndAreaId(zone, area);
SpellCastResult locRes= sSpellMgr.GetSpellAllowedInLocationError(pSpell, target->GetMapId(), zone, area, target->GetCharmerOrOwnerPlayerOrPlayerItself());
if (locRes != SPELL_CAST_OK || !((Player*)target)->IsKnowHowFlyIn(target->GetMapId(),zone))
target->CastSpell(target, spellId150, true);
else if (spellIdSpecial > 0)
{
for (PlayerSpellMap::const_iterator iter = ((Player*)target)->GetSpellMap().begin(); iter != ((Player*)target)->GetSpellMap().end(); ++iter)
{
if (iter->second.state != PLAYERSPELL_REMOVED)
{
bool changedSpeed = false;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(iter->first);
for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
{
if(spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED)
{
int32 mountSpeed = spellInfo->CalculateSimpleValue(SpellEffectIndex(i));
// speed higher than 300 replace it
if (mountSpeed > 300)
target->CastSpell(target, spellIdSpecial, true);
return;
}
}
}
}
target->CastSpell(target, pSpell, true);
}
else
target->CastSpell(target, pSpell, true);
}
else if (skillval >= 150 && spellId150 > 0)
target->CastSpell(target, spellId150, true);
else if (spellId75 > 0)
target->CastSpell(target, spellId75, true);
return;
}