49 trainerList.
Greeting = GetGreeting(locale);
50 trainerList.
Spells.reserve(_spells.size());
51 for (
Spell const& trainerSpell : _spells)
56 if (!
sConditionMgr->IsObjectMeetingTrainerSpellConditions(_id, trainerSpell.SpellId, player))
58 TC_LOG_DEBUG(
"condition",
"SendSpells: conditions not met for trainer id {} spell {} player '{}' ({})", _id, trainerSpell.SpellId, player->
GetName(), player->
GetGUID().
ToString());
62 trainerList.
Spells.emplace_back();
64 trainerListSpell.
SpellID = trainerSpell.SpellId;
65 trainerListSpell.
MoneyCost =
int32(trainerSpell.MoneyCost * reputationDiscount);
66 trainerListSpell.
ReqSkillLine = trainerSpell.ReqSkillLine;
67 trainerListSpell.
ReqSkillRank = trainerSpell.ReqSkillRank;
68 std::copy(trainerSpell.ReqAbility.begin(), trainerSpell.ReqAbility.end(), trainerListSpell.
ReqAbility.begin());
70 trainerListSpell.
ReqLevel = trainerSpell.ReqLevel;
78 Spell const* trainerSpell = GetSpell(spellId);
79 if (!trainerSpell || !CanTeachSpell(player, trainerSpell))
85 bool sendSpellVisual =
true;
95 sendSpellVisual =
false;
121 bool dependent =
false;
138 auto itr = std::find_if(_spells.begin(), _spells.end(), [spellId](
Spell const& trainerSpell)
140 return trainerSpell.SpellId == spellId;
143 if (itr != _spells.end())
149 bool Trainer::CanTeachSpell(
Player const* player,
Spell const* trainerSpell)
const
151 SpellState state = GetSpellState(player, trainerSpell);
186 if (reqAbility && !player->
HasSpell(reqAbility))
194 bool hasLearnSpellEffect =
false;
195 bool knowsAllLearnedSpells =
true;
201 hasLearnSpellEffect =
true;
202 if (!player->
HasSpell(spellEffectInfo.TriggerSpell))
203 knowsAllLearnedSpells =
false;
206 if (hasLearnSpellEffect && knowsAllLearnedSpells)
216 trainerBuyFailed.
SpellID = spellId;
223 if (_greeting[locale].empty())
226 return _greeting[locale];
229 void Trainer::AddGreetingLocale(
LocaleConstant locale, std::string_view greeting)
231 _greeting[locale] = greeting;
#define TC_LOG_DEBUG(filterType__,...)
@ SPELL_EFFECT_LEARN_SPELL
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
static uint16 RollPetBreed(uint32 species)
static uint32 SelectPetDisplay(BattlePetSpeciesEntry const *speciesEntry)
static BattlePetSpeciesEntry const * GetBattlePetSpeciesBySpell(uint32 spellId)
void AddPet(uint32 species, uint32 display, uint16 breed, BattlePetBreedQuality quality, uint16 level=1)
bool HasMaxPetCount(BattlePetSpeciesEntry const *battlePetSpecies, ObjectGuid ownerGuid) const
static BattlePetBreedQuality GetDefaultPetQuality(uint32 species)
std::string ToString() const
static ObjectGuid GetGUID(Object const *o)
void LearnSpell(uint32 spell_id, bool dependent, int32 fromSkill=0, bool suppressMessaging=false, Optional< int32 > traitDefinitionId={})
bool ModifyMoney(int64 amount, bool sendError=true)
void SendDirectMessage(WorldPacket const *data) const
bool IsSpellFitByClassAndRace(uint32 spell_id) const
float GetReputationPriceDiscount(Creature const *creature) const
WorldSession * GetSession() const
uint16 GetBaseSkillValue(uint32 skill) const
bool HasSpell(uint32 spell) const override
uint32 GetFreePrimaryProfessionPoints() const
bool HasEnoughMoney(uint64 amount) const
std::vector< SpellEffectInfo > const & GetEffects() const
bool IsPrimaryProfessionFirstRank() const
void SendPlaySpellVisualKit(uint32 id, uint32 type, uint32 duration) const
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
std::string const & GetName() const
int32 TrainerFailedReason
WorldPacket const * Write() override
WorldPacket const * Write() override
std::vector< TrainerListSpell > Spells
BattlePets::BattlePetMgr * GetBattlePetMgr() const
std::array< uint32, 3 > ReqAbility
std::array< int32, 3 > ReqAbility