aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Creature
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2018-11-13 17:49:36 +0100
committerShauren <shauren.trinity@gmail.com>2018-11-13 17:49:36 +0100
commit1423d3e7f36d9601060c1cc89171801609aad352 (patch)
treee3cb746686b9a775bce6712a78a4ac80dfb9d1ea /src/server/game/Entities/Creature
parent5bfb1cc960edd74716d3d0c65dd5aaf1ce34aa43 (diff)
Core/Creatures: Allow multiple SPELL_EFFECT_LEARN_SPELL effects on trainer spells
Closes #22787
Diffstat (limited to 'src/server/game/Entities/Creature')
-rw-r--r--src/server/game/Entities/Creature/Trainer.cpp23
-rw-r--r--src/server/game/Entities/Creature/Trainer.h3
2 files changed, 21 insertions, 5 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