TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
reset_commandscript Class Reference

Public Member Functions

 reset_commandscript ()
 
std::vector< ChatCommandGetCommands () const override
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Static Public Member Functions

static bool HandleResetAchievementsCommand (ChatHandler *handler, char const *args)
 
static bool HandleResetHonorCommand (ChatHandler *handler, char const *args)
 
static bool HandleResetStatsOrLevelHelper (Player *player)
 
static bool HandleResetLevelCommand (ChatHandler *handler, char const *args)
 
static bool HandleResetSpellsCommand (ChatHandler *handler, char const *args)
 
static bool HandleResetStatsCommand (ChatHandler *handler, char const *args)
 
static bool HandleResetTalentsCommand (ChatHandler *handler, char const *args)
 
static bool HandleResetAllCommand (ChatHandler *handler, char const *args)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Constructor & Destructor Documentation

reset_commandscript::reset_commandscript ( )
inline
36 : CommandScript("reset_commandscript") { }
CommandScript(const char *name)
Definition: ScriptMgr.cpp:1616

Member Function Documentation

std::vector<ChatCommand> reset_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

39  {
40  static std::vector<ChatCommand> resetCommandTable =
41  {
49  };
50  static std::vector<ChatCommand> commandTable =
51  {
52  { "reset", rbac::RBAC_PERM_COMMAND_RESET, true, NULL, "", resetCommandTable },
53  };
54  return commandTable;
55  }
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: RBAC.h:624
Definition: RBAC.h:617
static bool HandleResetAllCommand(ChatHandler *handler, char const *args)
Definition: cs_reset.cpp:265
static bool HandleResetAchievementsCommand(ChatHandler *handler, char const *args)
Definition: cs_reset.cpp:57
static bool HandleResetStatsCommand(ChatHandler *handler, char const *args)
Definition: cs_reset.cpp:181
static bool HandleResetTalentsCommand(ChatHandler *handler, char const *args)
Definition: cs_reset.cpp:199
static bool HandleResetHonorCommand(ChatHandler *handler, char const *args)
Definition: cs_reset.cpp:72
static bool HandleResetLevelCommand(ChatHandler *handler, char const *args)
Definition: cs_reset.cpp:116
static bool HandleResetSpellsCommand(ChatHandler *handler, char const *args)
Definition: cs_reset.cpp:152

+ Here is the call graph for this function:

static bool reset_commandscript::HandleResetAchievementsCommand ( ChatHandler handler,
char const args 
)
inlinestatic
58  {
59  Player* target;
60  ObjectGuid targetGuid;
61  if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid))
62  return false;
63 
64  if (target)
65  target->ResetAchievements();
66  else
68 
69  return true;
70  }
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
Definition: AchievementMgr.h:312
Definition: ObjectGuid.h:189

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool reset_commandscript::HandleResetAllCommand ( ChatHandler handler,
char const args 
)
inlinestatic
266  {
267  if (!*args)
268  return false;
269 
270  std::string caseName = args;
271 
272  AtLoginFlags atLogin;
273 
274  // Command specially created as single command to prevent using short case names
275  if (caseName == "spells")
276  {
277  atLogin = AT_LOGIN_RESET_SPELLS;
278  sWorld->SendWorldText(LANG_RESETALL_SPELLS);
279  if (!handler->GetSession())
281  }
282  else if (caseName == "talents")
283  {
284  atLogin = AtLoginFlags(AT_LOGIN_RESET_TALENTS | AT_LOGIN_RESET_PET_TALENTS);
285  sWorld->SendWorldText(LANG_RESETALL_TALENTS);
286  if (!handler->GetSession())
288  }
289  else
290  {
292  handler->SetSentErrorMessage(true);
293  return false;
294  }
295 
297  stmt->setUInt16(0, uint16(atLogin));
299 
300  boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
302  for (HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr)
303  itr->second->SetAtLoginFlag(atLogin);
304 
305  return true;
306  }
Definition: Language.h:244
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: Language.h:246
Definition: CharacterDatabase.h:324
Definition: Language.h:245
#define sWorld
Definition: World.h:887
uint16_t uint16
Definition: g3dmath.h:166
Definition: PreparedStatement.h:74
TC_GAME_API HashMapHolder< Player >::MapType const & GetPlayers()
Definition: ObjectAccessor.cpp:258
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
WorldSession * GetSession()
Definition: Chat.h:59
Definition: ObjectAccessor.h:45
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool reset_commandscript::HandleResetHonorCommand ( ChatHandler handler,
char const args 
)
inlinestatic
73  {
74  Player* target;
75  if (!handler->extractPlayerTarget((char*)args, &target))
76  return false;
77 
78  target->SetUInt32Value(PLAYER_FIELD_KILLS, 0);
79  target->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, 0);
80  target->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL);
81 
82  return true;
83  }
Definition: UpdateFields.h:272
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
Definition: UpdateFields.h:273

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool reset_commandscript::HandleResetLevelCommand ( ChatHandler handler,
char const args 
)
inlinestatic
117  {
118  Player* target;
119  if (!handler->extractPlayerTarget((char*)args, &target))
120  return false;
121 
122  if (!HandleResetStatsOrLevelHelper(target))
123  return false;
124 
125  uint8 oldLevel = target->getLevel();
126 
127  // set starting level
128  uint32 startLevel = target->getClass() != CLASS_DEATH_KNIGHT
129  ? sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL)
130  : sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL);
131 
132  target->_ApplyAllLevelScaleItemMods(false);
133  target->SetLevel(startLevel);
134  target->InitRunes();
135  target->InitStatsForLevel(true);
136  target->InitTaxiNodesForLevel();
137  target->InitGlyphsForLevel();
138  target->InitTalentForLevel();
139  target->SetUInt32Value(PLAYER_XP, 0);
140 
141  target->_ApplyAllLevelScaleItemMods(true);
142 
143  // reset level for pet
144  if (Pet* pet = target->GetPet())
145  pet->SynchronizeLevelWithOwner();
146 
147  sScriptMgr->OnPlayerLevelChanged(target, oldLevel);
148 
149  return true;
150  }
Definition: SharedDefines.h:172
Definition: UpdateFields.h:215
#define sWorld
Definition: World.h:887
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
uint32_t uint32
Definition: Define.h:150
static bool HandleResetStatsOrLevelHelper(Player *player)
Definition: cs_reset.cpp:85
Definition: World.h:237
Definition: World.h:238
uint8_t uint8
Definition: Define.h:152
#define sScriptMgr
Definition: ScriptMgr.h:837
Definition: Pet.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool reset_commandscript::HandleResetSpellsCommand ( ChatHandler handler,
char const args 
)
inlinestatic
153  {
154  Player* target;
155  ObjectGuid targetGuid;
156  std::string targetName;
157  if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
158  return false;
159 
160  if (target)
161  {
162  target->ResetSpells(/* bool myClassOnly */);
163 
164  ChatHandler(target->GetSession()).SendSysMessage(LANG_RESET_SPELLS);
165  if (!handler->GetSession() || handler->GetSession()->GetPlayer() != target)
166  handler->PSendSysMessage(LANG_RESET_SPELLS_ONLINE, handler->GetNameLink(target).c_str());
167  }
168  else
169  {
171  stmt->setUInt16(0, uint16(AT_LOGIN_RESET_SPELLS));
172  stmt->setUInt64(1, targetGuid.GetCounter());
174 
175  handler->PSendSysMessage(LANG_RESET_SPELLS_OFFLINE, targetName.c_str());
176  }
177 
178  return true;
179  }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: Language.h:241
Definition: Language.h:237
Player * GetPlayer() const
Definition: WorldSession.h:927
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
uint16_t uint16
Definition: g3dmath.h:166
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:322
virtual std::string GetNameLink() const
Definition: Chat.h:101
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: Chat.h:56
Definition: Language.h:238
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
WorldSession * GetSession()
Definition: Chat.h:59
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: ObjectGuid.h:189
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool reset_commandscript::HandleResetStatsCommand ( ChatHandler handler,
char const args 
)
inlinestatic
182  {
183  Player* target;
184  if (!handler->extractPlayerTarget((char*)args, &target))
185  return false;
186 
187  if (!HandleResetStatsOrLevelHelper(target))
188  return false;
189 
190  target->InitRunes();
191  target->InitStatsForLevel(true);
192  target->InitTaxiNodesForLevel();
193  target->InitGlyphsForLevel();
194  target->InitTalentForLevel();
195 
196  return true;
197  }
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
static bool HandleResetStatsOrLevelHelper(Player *player)
Definition: cs_reset.cpp:85

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool reset_commandscript::HandleResetStatsOrLevelHelper ( Player player)
inlinestatic
86  {
87  ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(player->getClass());
88  if (!classEntry)
89  {
90  TC_LOG_ERROR("misc", "Class %u not found in DBC (Wrong DBC files?)", player->getClass());
91  return false;
92  }
93 
94  uint8 powerType = classEntry->PowerType;
95 
96  // reset m_form if no aura
97  if (!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT))
98  player->SetShapeshiftForm(FORM_NONE);
99 
100  player->setFactionForRace(player->getRace());
101  player->SetUInt32Value(UNIT_FIELD_DISPLAY_POWER, powerType);
102 
103  // reset only if player not in some form;
104  if (player->GetShapeshiftForm() == FORM_NONE)
105  player->InitDisplayIds();
106 
107  player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP);
108 
109  player->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
110 
111  //-1 is default value
112  player->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1));
113  return true;
114  }
Definition: Unit.h:262
Definition: UpdateFields.h:146
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesfmt)
Definition: UpdateFields.h:274
Definition: UpdateFields.h:97
Definition: DBCStructure.h:181
uint32 PowerType
Definition: DBCStructure.h:184
Definition: Unit.h:308
Definition: Unit.h:676
Definition: UpdateFields.h:109
Definition: SpellAuraDefines.h:96
uint8_t uint8
Definition: Define.h:152
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the caller graph for this function:

static bool reset_commandscript::HandleResetTalentsCommand ( ChatHandler handler,
char const args 
)
inlinestatic
200  {
201  Player* target;
202  ObjectGuid targetGuid;
203  std::string targetName;
204 
205  if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
206  {
207  /* TODO: 6.x remove/update pet talents
208  // Try reset talents as Hunter Pet
209  Creature* creature = handler->getSelectedCreature();
210  if (!*args && creature && creature->IsPet())
211  {
212  Unit* owner = creature->GetOwner();
213  if (owner && owner->GetTypeId() == TYPEID_PLAYER && creature->ToPet()->IsPermanentPetFor(owner->ToPlayer()))
214  {
215  creature->ToPet()->resetTalents();
216  owner->ToPlayer()->SendTalentsInfoData(true);
217 
218  ChatHandler(owner->ToPlayer()->GetSession()).SendSysMessage(LANG_RESET_PET_TALENTS);
219  if (!handler->GetSession() || handler->GetSession()->GetPlayer() != owner->ToPlayer())
220  handler->PSendSysMessage(LANG_RESET_PET_TALENTS_ONLINE, handler->GetNameLink(owner->ToPlayer()).c_str());
221  }
222  return true;
223  }
224  */
225 
227  handler->SetSentErrorMessage(true);
228  return false;
229  }
230 
231  if (target)
232  {
233  target->ResetTalents(true);
234  target->ResetTalentSpecialization();
235  target->SendTalentsInfoData();
236  ChatHandler(target->GetSession()).SendSysMessage(LANG_RESET_TALENTS);
237  if (!handler->GetSession() || handler->GetSession()->GetPlayer() != target)
238  handler->PSendSysMessage(LANG_RESET_TALENTS_ONLINE, handler->GetNameLink(target).c_str());
239 
240  /* TODO: 6.x remove/update pet talents
241  Pet* pet = target->GetPet();
242  Pet::resetTalentsForAllPetsOf(target, pet);
243  if (pet)
244  target->SendTalentsInfoData(true);
245  */
246  return true;
247  }
248  else if (!targetGuid.IsEmpty())
249  {
251  stmt->setUInt16(0, uint16(AT_LOGIN_NONE | AT_LOGIN_RESET_PET_TALENTS));
252  stmt->setUInt64(1, targetGuid.GetCounter());
254 
255  std::string nameLink = handler->playerLink(targetName);
256  handler->PSendSysMessage(LANG_RESET_TALENTS_OFFLINE, nameLink.c_str());
257  return true;
258  }
259 
261  handler->SetSentErrorMessage(true);
262  return false;
263  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Language.h:140
bool extractPlayerTarget(char *args, Player **player, ObjectGuid *player_guid=NULL, std::string *player_name=NULL)
Definition: Chat.cpp:945
uint16_t uint16
Definition: g3dmath.h:166
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:322
Definition: Language.h:242
virtual std::string GetNameLink() const
Definition: Chat.h:101
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
Definition: Language.h:239
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: Chat.h:56
Definition: Language.h:240
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
WorldSession * GetSession()
Definition: Chat.h:59
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: ObjectGuid.h:189
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
std::string playerLink(std::string const &name) const
Definition: Chat.h:132
bool IsEmpty() const
Definition: ObjectGuid.h:242
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: