Merge pull request #6884 from Vincent-Michael/resetCommand
Core/Commands: Convert reset commands in commandscript
This commit is contained in:
@@ -165,18 +165,6 @@ ChatCommand* ChatHandler::getCommandTable()
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand resetCommandTable[] =
|
||||
{
|
||||
{ "achievements", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleResetAchievementsCommand>, "", NULL },
|
||||
{ "honor", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleResetHonorCommand>, "", NULL },
|
||||
{ "level", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleResetLevelCommand>, "", NULL },
|
||||
{ "spells", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleResetSpellsCommand>, "", NULL },
|
||||
{ "stats", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleResetStatsCommand>, "", NULL },
|
||||
{ "talents", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleResetTalentsCommand>, "", NULL },
|
||||
{ "all", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleResetAllCommand>, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand sendCommandTable[] =
|
||||
{
|
||||
{ "items", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleSendItemsCommand>, "", NULL },
|
||||
@@ -229,7 +217,6 @@ ChatCommand* ChatHandler::getCommandTable()
|
||||
{ "pdump", SEC_ADMINISTRATOR, true, NULL, "", pdumpCommandTable },
|
||||
{ "guild", SEC_ADMINISTRATOR, true, NULL, "", guildCommandTable },
|
||||
{ "group", SEC_ADMINISTRATOR, false, NULL, "", groupCommandTable },
|
||||
{ "reset", SEC_ADMINISTRATOR, true, NULL, "", resetCommandTable },
|
||||
|
||||
{ "channel", SEC_ADMINISTRATOR, true, NULL, "", channelCommandTable },
|
||||
|
||||
|
||||
@@ -184,14 +184,6 @@ class ChatHandler
|
||||
bool HandlePDumpLoadCommand(const char *args);
|
||||
bool HandlePDumpWriteCommand(const char *args);
|
||||
|
||||
bool HandleResetAchievementsCommand(const char * args);
|
||||
bool HandleResetAllCommand(const char * args);
|
||||
bool HandleResetHonorCommand(const char * args);
|
||||
bool HandleResetLevelCommand(const char * args);
|
||||
bool HandleResetSpellsCommand(const char* args);
|
||||
bool HandleResetStatsCommand(const char * args);
|
||||
bool HandleResetTalentsCommand(const char* args);
|
||||
|
||||
bool HandleSendItemsCommand(const char* args);
|
||||
bool HandleSendMailCommand(const char* args);
|
||||
bool HandleSendMessageCommand(const char * args);
|
||||
|
||||
@@ -1990,265 +1990,6 @@ bool ChatHandler::HandleChangeWeather(const char *args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleResetAchievementsCommand (const char * args)
|
||||
{
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
if (!extractPlayerTarget((char*)args, &target, &target_guid))
|
||||
return false;
|
||||
|
||||
if (target)
|
||||
target->GetAchievementMgr().Reset();
|
||||
else
|
||||
AchievementMgr::DeleteFromDB(GUID_LOPART(target_guid));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleResetHonorCommand (const char * args)
|
||||
{
|
||||
Player* target;
|
||||
if (!extractPlayerTarget((char*)args, &target))
|
||||
return false;
|
||||
|
||||
target->SetHonorPoints(0);
|
||||
target->SetUInt32Value(PLAYER_FIELD_KILLS, 0);
|
||||
target->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, 0);
|
||||
target->SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, 0);
|
||||
target->SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, 0);
|
||||
target->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleResetStatsOrLevelHelper(Player* player)
|
||||
{
|
||||
ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(player->getClass());
|
||||
if (!cEntry)
|
||||
{
|
||||
sLog->outError("Class %u not found in DBC (Wrong DBC files?)", player->getClass());
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8 powertype = cEntry->powerType;
|
||||
|
||||
// reset m_form if no aura
|
||||
if (!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT))
|
||||
player->SetShapeshiftForm(FORM_NONE);
|
||||
|
||||
player->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE);
|
||||
player->SetFloatValue(UNIT_FIELD_COMBATREACH, DEFAULT_COMBAT_REACH);
|
||||
|
||||
player->setFactionForRace(player->getRace());
|
||||
|
||||
player->SetUInt32Value(UNIT_FIELD_BYTES_0, ((player->getRace()) | (player->getClass() << 8) | (player->getGender() << 16) | (powertype << 24)));
|
||||
|
||||
// reset only if player not in some form;
|
||||
if (player->GetShapeshiftForm() == FORM_NONE)
|
||||
player->InitDisplayIds();
|
||||
|
||||
player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP);
|
||||
|
||||
player->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
|
||||
|
||||
//-1 is default value
|
||||
player->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1));
|
||||
|
||||
//player->SetUInt32Value(PLAYER_FIELD_BYTES, 0xEEE00000);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleResetLevelCommand(const char * args)
|
||||
{
|
||||
Player* target;
|
||||
if (!extractPlayerTarget((char*)args, &target))
|
||||
return false;
|
||||
|
||||
if (!HandleResetStatsOrLevelHelper(target))
|
||||
return false;
|
||||
|
||||
uint8 oldLevel = target->getLevel();
|
||||
|
||||
// set starting level
|
||||
uint32 start_level = target->getClass() != CLASS_DEATH_KNIGHT
|
||||
? sWorld->getIntConfig(CONFIG_START_PLAYER_LEVEL)
|
||||
: sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL);
|
||||
|
||||
target->_ApplyAllLevelScaleItemMods(false);
|
||||
target->SetLevel(start_level);
|
||||
target->InitRunes();
|
||||
target->InitStatsForLevel(true);
|
||||
target->InitTaxiNodesForLevel();
|
||||
target->InitGlyphsForLevel();
|
||||
target->InitTalentForLevel();
|
||||
target->SetUInt32Value(PLAYER_XP, 0);
|
||||
|
||||
target->_ApplyAllLevelScaleItemMods(true);
|
||||
|
||||
// reset level for pet
|
||||
if (Pet* pet = target->GetPet())
|
||||
pet->SynchronizeLevelWithOwner();
|
||||
|
||||
sScriptMgr->OnPlayerLevelChanged(target, oldLevel);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleResetStatsCommand(const char * args)
|
||||
{
|
||||
Player* target;
|
||||
if (!extractPlayerTarget((char*)args, &target))
|
||||
return false;
|
||||
|
||||
if (!HandleResetStatsOrLevelHelper(target))
|
||||
return false;
|
||||
|
||||
target->InitRunes();
|
||||
target->InitStatsForLevel(true);
|
||||
target->InitTaxiNodesForLevel();
|
||||
target->InitGlyphsForLevel();
|
||||
target->InitTalentForLevel();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleResetSpellsCommand(const char* args)
|
||||
{
|
||||
Player* target;
|
||||
uint64 targetGuid;
|
||||
std::string targetName;
|
||||
if (!extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
|
||||
return false;
|
||||
|
||||
if (target)
|
||||
{
|
||||
target->resetSpells(/* bool myClassOnly */);
|
||||
|
||||
ChatHandler(target).SendSysMessage(LANG_RESET_SPELLS);
|
||||
if (!m_session || m_session->GetPlayer() != target)
|
||||
PSendSysMessage(LANG_RESET_SPELLS_ONLINE, GetNameLink(target).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
|
||||
|
||||
stmt->setUInt16(0, uint16(AT_LOGIN_RESET_SPELLS));
|
||||
stmt->setUInt32(1, GUID_LOPART(targetGuid));
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
PSendSysMessage(LANG_RESET_SPELLS_OFFLINE, targetName.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleResetTalentsCommand(const char* args)
|
||||
{
|
||||
Player* target;
|
||||
uint64 targetGuid;
|
||||
std::string targetName;
|
||||
if (!extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
|
||||
{
|
||||
// Try reset talents as Hunter Pet
|
||||
Creature* creature = getSelectedCreature();
|
||||
if (!*args && creature && creature->isPet())
|
||||
{
|
||||
Unit* owner = creature->GetOwner();
|
||||
if (owner && owner->GetTypeId() == TYPEID_PLAYER && creature->ToPet()->IsPermanentPetFor(owner->ToPlayer()))
|
||||
{
|
||||
creature->ToPet()->resetTalents();
|
||||
owner->ToPlayer()->SendTalentsInfoData(true);
|
||||
|
||||
ChatHandler(owner->ToPlayer()).SendSysMessage(LANG_RESET_PET_TALENTS);
|
||||
if (!m_session || m_session->GetPlayer() != owner->ToPlayer())
|
||||
PSendSysMessage(LANG_RESET_PET_TALENTS_ONLINE, GetNameLink(owner->ToPlayer()).c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target)
|
||||
{
|
||||
target->resetTalents(true);
|
||||
target->SendTalentsInfoData(false);
|
||||
ChatHandler(target).SendSysMessage(LANG_RESET_TALENTS);
|
||||
if (!m_session || m_session->GetPlayer() != target)
|
||||
PSendSysMessage(LANG_RESET_TALENTS_ONLINE, GetNameLink(target).c_str());
|
||||
|
||||
Pet* pet = target->GetPet();
|
||||
Pet::resetTalentsForAllPetsOf(target, pet);
|
||||
if (pet)
|
||||
target->SendTalentsInfoData(true);
|
||||
return true;
|
||||
}
|
||||
else if (targetGuid)
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
|
||||
|
||||
stmt->setUInt16(0, uint16(AT_LOGIN_NONE | AT_LOGIN_RESET_PET_TALENTS));
|
||||
stmt->setUInt32(1, GUID_LOPART(targetGuid));
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
std::string nameLink = playerLink(targetName);
|
||||
PSendSysMessage(LANG_RESET_TALENTS_OFFLINE, nameLink.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleResetAllCommand(const char * args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
std::string casename = args;
|
||||
|
||||
AtLoginFlags atLogin;
|
||||
|
||||
// Command specially created as single command to prevent using short case names
|
||||
if (casename == "spells")
|
||||
{
|
||||
atLogin = AT_LOGIN_RESET_SPELLS;
|
||||
sWorld->SendWorldText(LANG_RESETALL_SPELLS);
|
||||
if (!m_session)
|
||||
SendSysMessage(LANG_RESETALL_SPELLS);
|
||||
}
|
||||
else if (casename == "talents")
|
||||
{
|
||||
atLogin = AtLoginFlags(AT_LOGIN_RESET_TALENTS | AT_LOGIN_RESET_PET_TALENTS);
|
||||
sWorld->SendWorldText(LANG_RESETALL_TALENTS);
|
||||
if (!m_session)
|
||||
SendSysMessage(LANG_RESETALL_TALENTS);
|
||||
}
|
||||
else
|
||||
{
|
||||
PSendSysMessage(LANG_RESETALL_UNKNOWN_CASE, args);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ALL_AT_LOGIN_FLAGS);
|
||||
|
||||
stmt->setUInt16(0, uint16(atLogin));
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType const& plist = sObjectAccessor->GetPlayers();
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = plist.begin(); itr != plist.end(); ++itr)
|
||||
itr->second->SetAtLoginFlag(atLogin);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleBanAccountCommand(const char *args)
|
||||
{
|
||||
|
||||
@@ -61,6 +61,7 @@ void AddSC_modify_commandscript();
|
||||
void AddSC_npc_commandscript();
|
||||
void AddSC_quest_commandscript();
|
||||
void AddSC_reload_commandscript();
|
||||
void AddSC_reset_commandscript();
|
||||
void AddSC_tele_commandscript();
|
||||
void AddSC_server_commandscript();
|
||||
void AddSC_titles_commandscript();
|
||||
@@ -668,6 +669,7 @@ void AddCommandScripts()
|
||||
AddSC_npc_commandscript();
|
||||
AddSC_quest_commandscript();
|
||||
AddSC_reload_commandscript();
|
||||
AddSC_reset_commandscript();
|
||||
AddSC_tele_commandscript();
|
||||
AddSC_server_commandscript();
|
||||
AddSC_titles_commandscript();
|
||||
|
||||
Reference in New Issue
Block a user