Core/Commands: Implement command for adding (completing) achievements

--HG--
branch : trunk
This commit is contained in:
Shocker
2010-09-21 03:51:14 +03:00
parent 7b3d573a16
commit 5ffaf0d84b
9 changed files with 50 additions and 6 deletions
+2
View File
@@ -327,6 +327,8 @@ INSERT INTO `command` VALUES
('account set addon',3,'Syntax: .account set addon [$account] #addon\r\n\r\nSet user (possible targeted) expansion addon level allowed. Addon values: 0 - normal, 1 - tbc, 2 - wotlk.'),
('account set gmlevel',4,'Syntax: .account set gmlevel [$account] #level [#realmid]\r\n\r\nSet the security level for targeted player (can''t be used at self) or for account $name to a level of #level on the realm #realmID.\r\n\r\n#level may range from 0 to 3.\r\n\r\n#reamID may be -1 for all realms.'),
('account set password',4,'Syntax: .account set password $account $password $password\r\n\r\nSet password for account.'),
('achievement',4,'Syntax: .achievement $subcommand\nType .achievement to see the list of possible subcommands or .help achievement $subcommand to see info on subcommands'),
('achievement add',4,'Syntax: .achievement add $achievement\nAdd an achievement to the targeted player.\n$achievement: can be either achievement id or achievement link'),
('additem',3,'Syntax: .additem #itemid/[#itemname]/#shift-click-item-link #itemcount\r\n\r\nAdds the specified number of items of id #itemid (or exact (!) name $itemname in brackets, or link created by shift-click at item in inventory or recipe) to your or selected character inventory. If #itemcount is omitted, only one item will be added.\r\n.'),
('additemset',3,'Syntax: .additemset #itemsetid\r\n\r\nAdd items from itemset of id #itemsetid to your or selected character inventory. Will add by one example each item from itemset.'),
('announce',1,'Syntax: .announce $MessageToBroadcast\r\n\r\nSend a global message to all players online in chat log.'),
+4
View File
@@ -0,0 +1,4 @@
DELETE FROM `command` WHERE `name` IN ('achievement add', 'achievement');
INSERT INTO `command` (`name`,`security`,`help`) VALUES
('achievement add',4,'Syntax: .achievement add $achievement\nAdd an achievement to the targeted player.\n$achievement: can be either achievement id or achievement link'),
('achievement',4,'Syntax: .achievement $subcommand\nType .achievement to see the list of possible subcommands or .help achievement $subcommand to see info on subcommands');
@@ -1900,11 +1900,11 @@ void AchievementMgr::RemoveTimedAchievement(AchievementCriteriaTimedTypes type,
}
}
void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement)
void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement, bool ignoreGMAllowAchievementConfig)
{
sLog.outDetail("AchievementMgr::CompletedAchievement(%u)", achievement->ID);
if (!sWorld.getBoolConfig(CONFIG_GM_ALLOW_ACHIEVEMENT_GAINS) && m_player->GetSession()->GetSecurity() > SEC_PLAYER)
if (!sWorld.getBoolConfig(CONFIG_GM_ALLOW_ACHIEVEMENT_GAINS) && m_player->GetSession()->GetSecurity() > SEC_PLAYER && !ignoreGMAllowAchievementConfig)
return;
if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER || HasAchieved(achievement))
@@ -247,7 +247,7 @@ class AchievementMgr
void SaveToDB(SQLTransaction& trans);
void ResetAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1 = 0, uint32 miscvalue2 = 0, bool evenIfCriteriaComplete = false);
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1 = 0, uint32 miscvalue2 = 0, Unit *unit = NULL, uint32 time = 0);
void CompletedAchievement(AchievementEntry const* entry);
void CompletedAchievement(AchievementEntry const* entry, bool ignoreGMAllowAchievementConfig = false);
void CheckAllAchievementCriteria();
void SendAllAchievementData();
void SendRespondInspectAchievements(Player* player);
+7
View File
@@ -692,9 +692,16 @@ ChatCommand * ChatHandler::getCommandTable()
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand achievementCommandTable[] =
{
{ "add", SEC_ADMINISTRATOR, false, &ChatHandler::HandleAchievementAddCommand, "", NULL},
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
{
{ "account", SEC_PLAYER, true, NULL, "", accountCommandTable },
{ "achievement", SEC_ADMINISTRATOR, false, NULL, "", achievementCommandTable},
{ "gm", SEC_MODERATOR, true, NULL, "", gmCommandTable },
{ "npc", SEC_MODERATOR, false, NULL, "", npcCommandTable },
{ "go", SEC_MODERATOR, false, NULL, "", goCommandTable },
+3
View File
@@ -568,6 +568,9 @@ class ChatHandler
bool HandleChangeWeather(const char* args);
bool HandleKickPlayerCommand(const char * args);
// Achievement commands
bool HandleAchievementAddCommand(const char* args);
// GM ticket command handlers
bool HandleGMTicketListCommand(const char* args);
bool HandleGMTicketListOnlineCommand(const char* args);
+28
View File
@@ -1408,6 +1408,34 @@ bool ChatHandler::HandleSetSkillCommand(const char *args)
return true;
}
bool ChatHandler::HandleAchievementAddCommand(const char *args)
{
if (!*args)
return false;
uint32 achievementId = atoi((char*)args);
if (!achievementId)
{
if (char* cId = extractKeyFromLink((char*)args, "Hachievement"))
achievementId = atoi(cId);
if (!achievementId)
return false;
}
Player* target = getSelectedPlayer();
if (!target)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
SetSentErrorMessage(true);
return false;
}
if (AchievementEntry const* pAE = GetAchievementStore()->LookupEntry(achievementId))
target->CompletedAchievement(pAE, true);
return true;
}
bool ChatHandler::HandleUnLearnCommand(const char *args)
{
if (!*args)
+2 -2
View File
@@ -23031,9 +23031,9 @@ void Player::UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 mis
GetAchievementMgr().UpdateAchievementCriteria(type, miscvalue1, miscvalue2, unit, time);
}
void Player::CompletedAchievement(AchievementEntry const* entry)
void Player::CompletedAchievement(AchievementEntry const* entry, bool ignoreGMAllowAchievementConfig)
{
GetAchievementMgr().CompletedAchievement(entry);
GetAchievementMgr().CompletedAchievement(entry, ignoreGMAllowAchievementConfig);
}
void Player::LearnTalent(uint32 talentId, uint32 talentRank)
+1 -1
View File
@@ -2362,7 +2362,7 @@ class Player : public Unit, public GridObject<Player>
AchievementMgr& GetAchievementMgr() { return m_achievementMgr; }
AchievementMgr const& GetAchievementMgr() const { return m_achievementMgr; }
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1 = 0, uint32 miscvalue2 = 0, Unit *unit = NULL, uint32 time = 0);
void CompletedAchievement(AchievementEntry const* entry);
void CompletedAchievement(AchievementEntry const* entry, bool ignoreGMAllowAchievementConfig = false);
bool HasTitle(uint32 bitIndex);
bool HasTitle(CharTitlesEntry const* title) { return HasTitle(title->bit_index); }