aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Creature/Trainer.cpp23
-rw-r--r--src/server/game/Entities/Creature/Trainer.h3
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp14
3 files changed, 22 insertions, 18 deletions
diff --git a/src/server/game/Entities/Creature/Trainer.cpp b/src/server/game/Entities/Creature/Trainer.cpp
index fb9f0af7f19..4f85599b74c 100644
--- a/src/server/game/Entities/Creature/Trainer.cpp
+++ b/src/server/game/Entities/Creature/Trainer.cpp
@@ -24,6 +24,10 @@
namespace Trainer
{
+ bool Spell::IsCastable() const
+ {
+ return sSpellMgr->AssertSpellInfo(SpellId)->HasEffect(SPELL_EFFECT_LEARN_SPELL);
+ }
Trainer::Trainer(uint32 id, Type type, std::string greeting, std::vector<Spell> spells) : _id(id), _type(type), _spells(std::move(spells))
{
@@ -136,9 +140,22 @@ namespace Trainer
return SpellState::Unavailable;
// check ranks
- if (uint32 previousRankSpellId = sSpellMgr->GetPrevSpellInChain(trainerSpell->LearnedSpellId))
- if (!player->HasSpell(previousRankSpellId))
- return SpellState::Unavailable;
+ bool hasLearnSpellEffect = false;
+ for (SpellEffectInfo const* spellEffect : sSpellMgr->AssertSpellInfo(trainerSpell->SpellId)->GetEffectsForDifficulty(DIFFICULTY_NONE))
+ {
+ if (!spellEffect || !spellEffect->IsEffect(SPELL_EFFECT_LEARN_SPELL))
+ continue;
+
+ hasLearnSpellEffect = true;
+ if (uint32 previousRankSpellId = sSpellMgr->GetPrevSpellInChain(spellEffect->TriggerSpell))
+ if (!player->HasSpell(previousRankSpellId))
+ return SpellState::Unavailable;
+ }
+
+ if (!hasLearnSpellEffect)
+ if (uint32 previousRankSpellId = sSpellMgr->GetPrevSpellInChain(trainerSpell->SpellId))
+ if (!player->HasSpell(previousRankSpellId))
+ return SpellState::Unavailable;
// check additional spell requirement
for (auto const& requirePair : sSpellMgr->GetSpellsRequiredForSpellBounds(trainerSpell->SpellId))
diff --git a/src/server/game/Entities/Creature/Trainer.h b/src/server/game/Entities/Creature/Trainer.h
index f7e9c51dba1..20ee7deb3f5 100644
--- a/src/server/game/Entities/Creature/Trainer.h
+++ b/src/server/game/Entities/Creature/Trainer.h
@@ -59,8 +59,7 @@ namespace Trainer
std::array<uint32, 3> ReqAbility = { };
uint8 ReqLevel = 0;
- uint32 LearnedSpellId = 0;
- bool IsCastable() const { return LearnedSpellId != SpellId; }
+ bool IsCastable() const;
};
class Trainer
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 804c0910f04..4b2d0ab6add 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -8667,18 +8667,6 @@ void ObjectMgr::LoadTrainers()
if (!allReqValid)
continue;
- spell.LearnedSpellId = spell.SpellId;
- for (SpellEffectInfo const* spellEffect : spellInfo->GetEffectsForDifficulty(DIFFICULTY_NONE))
- {
- if (spellEffect && spellEffect->IsEffect(SPELL_EFFECT_LEARN_SPELL))
- {
- 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;
- }
- }
-
spellsByTrainer[trainerId].push_back(spell);
} while (trainerSpellsResult->NextRow());
@@ -9280,7 +9268,7 @@ CreatureBaseStats const* ObjectMgr::GetCreatureBaseStats(uint8 level, uint8 unit
void ObjectMgr::LoadCreatureClassLevelStats()
{
uint32 oldMSTime = getMSTime();
- // 0 1 2 3 4 5
+ // 0 1 2 3 4 5
QueryResult result = WorldDatabase.Query("SELECT level, class, basemana, basearmor, attackpower, rangedattackpower FROM creature_classlevelstats");
if (!result)