Skip to content

Commit

Permalink
[9710] Add gm possibilities reset talents for all specs.
Browse files Browse the repository at this point in the history
* At login reset '.reset all talents' will reset all spec talents.
* New command '.reset specs' will reset its online/offline.
* Command '.reset talents' now not support offline player case.
  • Loading branch information
VladimirMangos committed Apr 9, 2010
1 parent f72f447 commit 44d2a43
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 18 deletions.
5 changes: 3 additions & 2 deletions sql/mangos.sql
Expand Up @@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
`cache_id` int(10) default '0',
`required_9704_01_mangos_achievement_reward` bit(1) default NULL
`required_9710_01_mangos_command` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';

--
Expand Down Expand Up @@ -731,7 +731,8 @@ INSERT INTO `command` VALUES
('reset level',3,'Syntax: .reset level [Playername]\r\n Reset level to 1 including reset stats and talents. Equipped items with greater level requirement can be lost.'),
('reset spells',3,'Syntax: .reset spells [Playername]\r\n Removes all non-original spells from spellbook.\r\n. Playername can be name of offline character.'),
('reset stats',3,'Syntax: .reset stats [Playername]\r\n Resets(recalculate) all stats of the targeted player to their original VALUESat current level.'),
('reset talents',3,'Syntax: .reset talents [Playername]\r\n Removes all talents of the targeted player or pet or named player. Playername can be name of offline character. With player talents also will be reset talents for all character\'s pets if any.'),
('reset specs',3,'Syntax: .reset specs [Playername]\r\n Removes all talents (for all specs) of the targeted player or named player. Playername can be name of offline character. With player talents also will be reset talents for all character\'s pets if any.'),
('reset talents',3,'Syntax: .reset talents [Playername]\r\n Removes all talents (current spec) of the targeted player or pet or named player. With player talents also will be reset talents for all character\'s pets if any.'),
('respawn',3,'Syntax: .respawn\r\n\r\nRespawn selected creature or respawn all nearest creatures (if none selected) and GO without waiting respawn time expiration.'),
('revive',3,'Syntax: .revive\r\n\r\nRevive the selected player. If no player is selected, it will revive you.'),
('save',0,'Syntax: .save\r\n\r\nSaves your character.'),
Expand Down
6 changes: 6 additions & 0 deletions sql/updates/9710_01_mangos_command.sql
@@ -0,0 +1,6 @@
ALTER TABLE db_version CHANGE COLUMN required_9704_01_mangos_achievement_reward required_9710_01_mangos_command bit;

DELETE FROM command WHERE name IN ('reset specs','reset talents');
INSERT INTO command VALUES
('reset specs',3,'Syntax: .reset specs [Playername]\r\n Removes all talents (for all specs) of the targeted player or named player. Playername can be name of offline character. With player talents also will be reset talents for all character\'s pets if any.'),
('reset talents',3,'Syntax: .reset talents [Playername]\r\n Removes all talents (current spec) of the targeted player or pet or named player. With player talents also will be reset talents for all character\'s pets if any.');
2 changes: 2 additions & 0 deletions sql/updates/Makefile.am
Expand Up @@ -111,6 +111,7 @@ pkgdata_DATA = \
9692_03_mangos_spell_proc_event.sql \
9702_01_characters_item.sql \
9704_01_mangos_achievement_reward.sql \
9710_01_mangos_command.sql \
README

## Additional files to include when running 'make dist'
Expand Down Expand Up @@ -202,4 +203,5 @@ EXTRA_DIST = \
9692_03_mangos_spell_proc_event.sql \
9702_01_characters_item.sql \
9704_01_mangos_achievement_reward.sql \
9710_01_mangos_command.sql \
README
2 changes: 1 addition & 1 deletion src/game/CharacterHandler.cpp
Expand Up @@ -768,7 +768,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)

if(pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
{
pCurrChar->resetTalents(true);
pCurrChar->resetTalents(true,true);
pCurrChar->SendTalentsInfoData(false); // original talents send already in to SendInitialPacketsBeforeAddToMap, resend reset state
SendNotification(LANG_RESET_TALENTS); // we can use SMSG_TALENTS_INVOLUNTARILY_RESET here
}
Expand Down
1 change: 1 addition & 0 deletions src/game/Chat.cpp
Expand Up @@ -484,6 +484,7 @@ ChatCommand * ChatHandler::getCommandTable()
{ "achievements", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetAchievementsCommand, "", NULL },
{ "honor", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetHonorCommand, "", NULL },
{ "level", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetLevelCommand, "", NULL },
{ "specs", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetSpecsCommand, "", NULL },
{ "spells", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetSpellsCommand, "", NULL },
{ "stats", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetStatsCommand, "", NULL },
{ "talents", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetTalentsCommand, "", NULL },
Expand Down
1 change: 1 addition & 0 deletions src/game/Chat.h
Expand Up @@ -402,6 +402,7 @@ class ChatHandler
bool HandleResetAllCommand(const char * args);
bool HandleResetHonorCommand(const char * args);
bool HandleResetLevelCommand(const char * args);
bool HandleResetSpecsCommand(const char * args);
bool HandleResetSpellsCommand(const char * args);
bool HandleResetStatsCommand(const char * args);
bool HandleResetTalentsCommand(const char * args);
Expand Down
45 changes: 36 additions & 9 deletions src/game/Level3.cpp
Expand Up @@ -4534,12 +4534,47 @@ bool ChatHandler::HandleResetSpellsCommand(const char * args)
return true;
}

bool ChatHandler::HandleResetTalentsCommand(const char * args)
bool ChatHandler::HandleResetSpecsCommand(const char * args)
{
Player* target;
uint64 target_guid;
std::string target_name;
if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
return false;

if (target)
{
target->resetTalents(true,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 (target_guid)
{
uint32 at_flags = AT_LOGIN_RESET_TALENTS | AT_LOGIN_RESET_PET_TALENTS;
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'", at_flags, GUID_LOPART(target_guid) );
std::string nameLink = playerLink(target_name);
PSendSysMessage(LANG_RESET_TALENTS_OFFLINE, nameLink.c_str());
return true;
}

SendSysMessage(LANG_NO_CHAR_SELECTED);
SetSentErrorMessage(true);
return false;
}

bool ChatHandler::HandleResetTalentsCommand(const char * args)
{
Player* target;
std::string target_name;
if (!extractPlayerTarget((char*)args, &target, NULL, &target_name))
{
// Try reset talents as Hunter Pet
Creature* creature = getSelectedCreature();
Expand Down Expand Up @@ -4577,14 +4612,6 @@ bool ChatHandler::HandleResetTalentsCommand(const char * args)
target->SendTalentsInfoData(true);
return true;
}
else if (target_guid)
{
uint32 at_flags = AT_LOGIN_RESET_PET_TALENTS;
CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'", at_flags, GUID_LOPART(target_guid) );
std::string nameLink = playerLink(target_name);
PSendSysMessage(LANG_RESET_TALENTS_OFFLINE, nameLink.c_str());
return true;
}

SendSysMessage(LANG_NO_CHAR_SELECTED);
SetSentErrorMessage(true);
Expand Down
33 changes: 30 additions & 3 deletions src/game/Player.cpp
Expand Up @@ -3666,13 +3666,13 @@ uint32 Player::resetTalentsCost() const
}
}

bool Player::resetTalents(bool no_cost)
bool Player::resetTalents(bool no_cost, bool all_specs)
{
// not need after this call
if(HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
if(HasAtLoginFlag(AT_LOGIN_RESET_TALENTS) && all_specs)
RemoveAtLoginFlag(AT_LOGIN_RESET_TALENTS,true);

if (m_usedTalentCount == 0)
if (m_usedTalentCount == 0 && !all_specs)
{
UpdateFreeTalentPoints(false); // for fix if need counter
return false;
Expand Down Expand Up @@ -3730,6 +3730,33 @@ bool Player::resetTalents(bool no_cost)
iter = m_talents[m_activeSpec].begin();
}

// for not current spec just mark removed all saved to DB case and drop not saved
if (all_specs)
{
for (uint8 spec = 0; spec < MAX_TALENT_SPEC_COUNT; ++spec)
{
if (spec == m_activeSpec)
continue;

for (PlayerTalentMap::iterator iter = m_talents[spec].begin(); iter != m_talents[spec].end();)
{
switch (iter->second.state)
{
case PLAYERSPELL_REMOVED:
++iter;
break;
case PLAYERSPELL_NEW:
m_talents[spec].erase(iter++);
break;
default:
iter->second.state = PLAYERSPELL_REMOVED;
++iter;
break;
}
}
}
}

UpdateFreeTalentPoints(false);

if(!no_cost)
Expand Down
2 changes: 1 addition & 1 deletion src/game/Player.h
Expand Up @@ -1570,7 +1570,7 @@ class MANGOS_DLL_SPEC Player : public Unit
uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); }
void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); }
void UpdateFreeTalentPoints(bool resetIfNeed = true);
bool resetTalents(bool no_cost = false);
bool resetTalents(bool no_cost = false, bool all_specs = false);
uint32 resetTalentsCost() const;
void InitTalentForLevel();
void BuildPlayerTalentsInfoData(WorldPacket *data);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9709"
#define REVISION_NR "9710"
#endif // __REVISION_NR_H__
2 changes: 1 addition & 1 deletion src/shared/revision_sql.h
@@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_9702_01_characters_item"
#define REVISION_DB_MANGOS "required_9704_01_mangos_achievement_reward"
#define REVISION_DB_MANGOS "required_9710_01_mangos_command"
#define REVISION_DB_REALMD "required_9010_01_realmd_realmlist"
#endif // __REVISION_SQL_H__

2 comments on commit 44d2a43

@luisalvarado
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent news.

@arjanwoldring
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did see a post from Vladimir that the reset of 'all' talents is important. But I did not expect he made a patch so soon. I think this a great job Vlad. Thanks!

Please sign in to comment.