From 41c58f3be9c4ff1427ae7be8efe1e58d3899c251 Mon Sep 17 00:00:00 2001 From: Laise Date: Wed, 12 May 2010 13:33:17 +0300 Subject: [PATCH] [9882] Add support for mounts dependent from riding skill and location --- sql/mangos_spell_check.sql | 19 +++++++++++++ src/game/Spell.cpp | 57 ++++++++++++++++++++++++++++++++++++++ src/game/Spell.h | 2 ++ src/game/SpellAuras.cpp | 12 ++++++++ src/shared/revision_nr.h | 2 +- 5 files changed, 91 insertions(+), 1 deletion(-) diff --git a/sql/mangos_spell_check.sql b/sql/mangos_spell_check.sql index 7eec1edcd..322bc7d86 100644 --- a/sql/mangos_spell_check.sql +++ b/sql/mangos_spell_check.sql @@ -314,6 +314,9 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas (47758,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Penance', 'Spell::EffectDummy'), (47897, 5,0x0001000000000000,0x00000000, -1, -1, -1, 2, -1,-1,'Shadowflame', 'Spell::EffectSchoolDMG'), (47960,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Shadowflame', 'Spell::EffectSchoolDMG'), +(48023,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Headless Horseman\'s Mount', 'Aura::HandleAuraDummy'), +(48024,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Headless Horseman\'s Mount', 'Aura::HandleAuraDummy'), +(48025,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Headless Horseman\'s Mount', 'Aura::HandleAuraDummy'), (48301,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Mind Trauma', 'Spell::EffectSchoolDMG'), (48542,-1, -1, -1, -1, -1, -1, 30, -1,-1,'Revitalize', 'Spell::EffectEnergize'), (48743,-1, -1, -1, -1, -1, -1, 10, -1,-1,'Death Pact', 'Spell::EffectHeal'), @@ -354,6 +357,8 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas (51582, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Rocket Boots Engaged', 'Spell::EffectDummy'), (51592, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Pickup Primordial Hatchling', 'Spell::EffectDummy'), (51593,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Pickup Primordial Hatchling', 'Spell::EffectDummy'), +(51617,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Headless Horseman\'s Mount', 'Aura::HandleAuraDummy'), +(51621,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Headless Horseman\'s Mount', 'Aura::HandleAuraDummy'), (51961, 0, -1, -1, -1, -1, -1, 3, -1,-1,'Captured Chicken Cover', 'Spell::EffectDummy'), (52025,-1, -1, -1, -1, -1, -1, -1, -1,-1,'Cleansing Totem Effect', 'Spell::EffectDummy'), (52032,-1, -1, -1, -1, -1, -1, 30, -1, 0,'Mana Spring Totem', 'Spell::EffectDummy'), @@ -458,10 +463,24 @@ INSERT INTO spell_check (spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMas (70937,-1, -1, -1, -1, -1, -1, -1, 4,-1,'Glyph of Eternal Water', 'Spell::EffectDummy'), (71021,-1, -1, -1, -1, -1, -1, 31, -1,-1,'Saber Lash', 'Spell::EffectWeaponDmg'), (71904, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Chaos Bane', 'Spell::EffectSchoolDMG'), +(72281, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Invincible', 'Aura::HandleAuraDummy'), +(72282, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Invincible', 'Aura::HandleAuraDummy'), +(72283, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Invincible', 'Aura::HandleAuraDummy'), +(72284, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Invincible', 'Aura::HandleAuraDummy'), +(72286, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Invincible', 'Aura::HandleAuraDummy'), (72505, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Ooze Eruption', 'Spell::EffectSchoolDMG'), (72624, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Ooze Eruption', 'Spell::EffectSchoolDMG'), (72625, 0, -1, -1, -1, -1, -1, 2, -1,-1,'Ooze Eruption', 'Spell::EffectSchoolDMG'), (73422, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Chaos Bane', 'Spell::cast'), +(74854, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Blazing Hippogryph', 'Aura::HandleAuraDummy'), +(74855, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Blazing Hippogryph', 'Aura::HandleAuraDummy'), +(74856, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Blazing Hippogryph', 'Aura::HandleAuraDummy'), +(75614, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Celestial Steed', 'Aura::HandleAuraDummy'), +(75617, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Celestial Steed', 'Aura::HandleAuraDummy'), +(75618, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Celestial Steed', 'Aura::HandleAuraDummy'), +(75619, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Celestial Steed', 'Aura::HandleAuraDummy'), +(75620, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Celestial Steed', 'Aura::HandleAuraDummy'), +(76153, 0, -1, -1, -1, -1, -1, -1, -1,-1,'Celestial Steed', 'Aura::HandleAuraDummy'), /*id fm familyMaskA fmMaskB icon vis cat eff aur ef name code */ diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 8920349f4..ec218d042 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -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; } \ No newline at end of file diff --git a/src/game/Spell.h b/src/game/Spell.h index 69c2dbcaf..5f48b1d31 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -497,6 +497,8 @@ class Spell void CastTriggerSpells(); void CleanupTargetList(); + + static void SelectMountByAreaAndSkill(Unit* target, uint32 spellId75, uint32 spellId150, uint32 spellId225, uint32 spellId300, uint32 spellIdSpecial); protected: void SendLoot(uint64 guid, LootType loottype); diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 54fcb1050..0b231c847 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -2290,6 +2290,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) // not use ammo and not allow use ((Player*)m_target)->RemoveAmmo(); return; + case 48025: // Headless Horseman's Mount + Spell::SelectMountByAreaAndSkill(m_target, 51621, 48024, 51617, 48023, NULL); + return; case 62061: // Festive Holiday Mount if (m_target->HasAuraType(SPELL_AURA_MOUNTED)) // Reindeer Transformation @@ -2305,6 +2308,15 @@ void Aura::HandleAuraDummy(bool apply, bool Real) if (m_target->GetTypeId() == TYPEID_PLAYER) ((Player*)m_target)->removeSpell(63680); return; + case 72286: // Invincible + Spell::SelectMountByAreaAndSkill(m_target, 72281, 72282, 72283, 72284, NULL); + return; + case 74856: // Blazing Hippogryph + Spell::SelectMountByAreaAndSkill(m_target, NULL, NULL, 74854, 74855, NULL); + return; + case 75614: // Celestial Steed + Spell::SelectMountByAreaAndSkill(m_target, 75619, 75620, 75617, 75618, 76153); + return; } break; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index ae1780dc8..d86e330b6 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9881" + #define REVISION_NR "9882" #endif // __REVISION_NR_H__