TrinityCore
Loading...
Searching...
No Matches
Trainer.h
Go to the documentation of this file.
1
/*
2
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3
*
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation; either version 2 of the License, or (at your
7
* option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef Trainer_h__
19
#define Trainer_h__
20
21
#include "
Common.h
"
22
#include <array>
23
#include <vector>
24
25
class
Creature
;
26
class
ObjectMgr
;
27
class
Player
;
28
29
namespace
Trainer
30
{
31
enum class
Type
:
uint32
32
{
33
Class
= 0,
34
Mount
= 1,
35
Tradeskill
= 2,
36
Pet
= 3
37
};
38
39
enum class
SpellState
:
uint8
40
{
41
Available
= 0,
42
Unavailable
= 1,
43
Known
= 2
44
};
45
46
enum class
FailReason
:
uint32
47
{
48
Unavailable
= 0,
49
NotEnoughMoney
= 1,
50
NotEnoughSkill
= 2
51
};
52
53
struct
TC_GAME_API
Spell
54
{
55
uint32
SpellId = 0;
56
uint32
MoneyCost = 0;
57
uint32
ReqSkillLine = 0;
58
uint32
ReqSkillRank = 0;
59
std::array<uint32, 3> ReqAbility = { };
60
uint8
ReqLevel = 0;
61
62
bool
IsCastable()
const
;
63
};
64
65
class
TC_GAME_API
Trainer
66
{
67
public
:
68
Trainer
(
uint32
trainerId,
Type
type,
uint32
requirement, std::string greeting, std::vector<Spell> spells);
69
70
Spell
const
* GetSpell(
uint32
spellId)
const
;
71
std::vector<Spell>
const
&
GetSpells
()
const
{
return
_spells; }
72
void
SendSpells(
Creature
const
* npc,
Player
const
* player,
LocaleConstant
locale)
const
;
73
bool
CanTeachSpell(
Player
const
* player,
Spell
const
* trainerSpell)
const
;
74
void
TeachSpell(
Creature
const
* npc,
Player
* player,
uint32
spellId)
const
;
75
76
Type
GetTrainerType
()
const
{
return
_type; }
77
uint32
GetTrainerRequirement
()
const
{
return
_requirement; }
78
bool
IsTrainerValidForPlayer(
Player
const
* player)
const
;
79
80
private
:
81
SpellState
GetSpellState(
Player
const
* player,
Spell
const
* trainerSpell)
const
;
82
void
SendTeachFailure(
Creature
const
* npc,
Player
const
* player,
uint32
spellId,
FailReason
reason)
const
;
83
void
SendTeachSucceeded(
Creature
const
* npc,
Player
const
* player,
uint32
spellId)
const
;
84
std::string
const
& GetGreeting(
LocaleConstant
locale)
const
;
85
86
friend
ObjectMgr
;
87
void
AddGreetingLocale(
LocaleConstant
locale, std::string greeting);
88
89
uint32
_trainerId
;
90
Type
_type
;
91
uint32
_requirement
;
92
std::vector<Spell>
_spells
;
93
std::array<std::string, TOTAL_LOCALES>
_greeting
;
94
};
95
}
96
97
#endif
// Trainer_h__
Common.h
LocaleConstant
LocaleConstant
Definition
Common.h:48
TC_GAME_API
#define TC_GAME_API
Definition
Define.h:114
uint8
uint8_t uint8
Definition
Define.h:135
uint32
uint32_t uint32
Definition
Define.h:133
Creature
Definition
Creature.h:62
ObjectMgr
Definition
ObjectMgr.h:930
Pet
Definition
Pet.h:40
Player
Definition
Player.h:924
Trainer::Trainer::_trainerId
uint32 _trainerId
Definition
Trainer.h:89
Trainer::Trainer::GetTrainerRequirement
uint32 GetTrainerRequirement() const
Definition
Trainer.h:77
Trainer::Trainer::_spells
std::vector< Spell > _spells
Definition
Trainer.h:92
Trainer::Trainer::_type
Type _type
Definition
Trainer.h:90
Trainer::Trainer::GetSpells
std::vector< Spell > const & GetSpells() const
Definition
Trainer.h:71
Trainer::Trainer::GetTrainerType
Type GetTrainerType() const
Definition
Trainer.h:76
Trainer::Trainer::ObjectMgr
friend ObjectMgr
Definition
Trainer.h:86
Trainer::Trainer::_greeting
std::array< std::string, TOTAL_LOCALES > _greeting
Definition
Trainer.h:93
Trainer::Trainer::_requirement
uint32 _requirement
Definition
Trainer.h:91
Trainer
Definition
Trainer.cpp:26
Trainer::SpellState
SpellState
Definition
Trainer.h:40
Trainer::SpellState::Known
@ Known
Trainer::SpellState::Unavailable
@ Unavailable
Trainer::SpellState::Available
@ Available
Trainer::Type
Type
Definition
Trainer.h:32
Trainer::Type::Tradeskill
@ Tradeskill
Trainer::Type::Class
@ Class
Trainer::Type::Mount
@ Mount
Trainer::FailReason
FailReason
Definition
Trainer.h:47
Trainer::FailReason::NotEnoughMoney
@ NotEnoughMoney
Trainer::FailReason::NotEnoughSkill
@ NotEnoughSkill
Trainer::Spell
Definition
Trainer.h:54
server
game
Entities
Creature
Trainer.h
Generated on Sun May 10 2026 02:30:14 for TrinityCore by
1.9.8