Core/Creatures: Trainer followup

* Drop unused columns
* Send proper spellid in packets for profession ranks
* Added missing rank check
This commit is contained in:
Shauren
2017-07-31 19:53:02 +02:00
parent e7c22cbfb5
commit fac8ccf7e0
4 changed files with 18 additions and 7 deletions

View File

@@ -0,0 +1,3 @@
ALTER TABLE `creature_template`
DROP `trainer_type`,
DROP `trainer_race`;

View File

@@ -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))

View File

@@ -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

View File

@@ -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;
}
}