mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Creatures: Trainer followup
* Drop unused columns * Send proper spellid in packets for profession ranks * Added missing rank check
This commit is contained in:
3
sql/updates/world/master/2017_07_31_00_world.sql
Normal file
3
sql/updates/world/master/2017_07_31_00_world.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE `creature_template`
|
||||
DROP `trainer_type`,
|
||||
DROP `trainer_race`;
|
||||
@@ -82,8 +82,8 @@ namespace Trainer
|
||||
player->SendPlaySpellVisualKit(362, 1, 0); // 113 EmoteSalute
|
||||
|
||||
// learn explicitly or cast explicitly
|
||||
if (trainerSpell->CastSpellId)
|
||||
player->CastSpell(player, trainerSpell->CastSpellId, true);
|
||||
if (trainerSpell->IsCastable())
|
||||
player->CastSpell(player, trainerSpell->SpellId, true);
|
||||
else
|
||||
player->LearnSpell(trainerSpell->SpellId, false);
|
||||
}
|
||||
@@ -135,6 +135,11 @@ namespace Trainer
|
||||
if (player->getLevel() < trainerSpell->ReqLevel)
|
||||
return SpellState::Unavailable;
|
||||
|
||||
// check ranks
|
||||
if (uint32 previousRankSpellId = sSpellMgr->GetPrevSpellInChain(trainerSpell->LearnedSpellId))
|
||||
if (!player->HasSpell(previousRankSpellId))
|
||||
return SpellState::Unavailable;
|
||||
|
||||
// check additional spell requirement
|
||||
for (auto const& requirePair : sSpellMgr->GetSpellsRequiredForSpellBounds(trainerSpell->SpellId))
|
||||
if (!player->HasSpell(requirePair.second))
|
||||
|
||||
@@ -59,7 +59,8 @@ namespace Trainer
|
||||
std::array<uint32, 3> ReqAbility = { };
|
||||
uint8 ReqLevel = 0;
|
||||
|
||||
uint32 CastSpellId = 0;
|
||||
uint32 LearnedSpellId = 0;
|
||||
bool IsCastable() const { return LearnedSpellId != SpellId; }
|
||||
};
|
||||
|
||||
class Trainer
|
||||
|
||||
@@ -8563,13 +8563,15 @@ void ObjectMgr::LoadTrainers()
|
||||
if (!allReqValid)
|
||||
continue;
|
||||
|
||||
spell.LearnedSpellId = spell.SpellId;
|
||||
for (SpellEffectInfo const* spellEffect : spellInfo->GetEffectsForDifficulty(DIFFICULTY_NONE))
|
||||
{
|
||||
if (spellEffect->IsEffect(SPELL_EFFECT_LEARN_SPELL))
|
||||
if (spellEffect && spellEffect->IsEffect(SPELL_EFFECT_LEARN_SPELL))
|
||||
{
|
||||
spell.CastSpellId = spell.SpellId;
|
||||
spell.SpellId = spellEffect->TriggerSpell;
|
||||
break;
|
||||
ASSERT(spell.LearnedSpellId == spell.SpellId,
|
||||
"Only one learned spell is currently supported - spell %u already teaches %u but it tried to overwrite it with %u",
|
||||
spell.SpellId, spell.LearnedSpellId, spellEffect->TriggerSpell);
|
||||
spell.LearnedSpellId = spellEffect->TriggerSpell;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user