Conflicts: sql/old/3.3.5a/TDB52_to_TDB53_updates/world/2013_07_24_00_world_spell_script_names.sql sql/updates/world/2013_07_24_00_world_spell_script_names.sql sql/updates/world/2013_07_24_00_world_spell_script_names_335.sql src/server/game/Achievements/AchievementMgr.cpp src/server/game/Achievements/AchievementMgr.h src/server/game/Battlegrounds/ArenaTeamMgr.cpp src/server/game/Chat/ChatLink.cpp src/server/game/DataStores/DBCStores.cpp src/server/game/DataStores/DBCStructure.h src/server/game/DataStores/DBCfmt.h src/server/game/Entities/DynamicObject/DynamicObject.h src/server/game/Entities/Object/Object.cpp src/server/game/Entities/Player/Player.cpp src/server/game/Entities/Unit/StatSystem.cpp src/server/game/Entities/Unit/Unit.cpp src/server/game/Entities/Unit/Unit.h src/server/game/Groups/Group.cpp src/server/game/Handlers/QuestHandler.cpp src/server/game/Miscellaneous/SharedDefines.h src/server/game/Spells/Auras/SpellAuraEffects.cpp src/server/game/Spells/Auras/SpellAuras.cpp src/server/game/World/World.h src/server/scripts/Commands/cs_character.cpp src/server/scripts/Commands/cs_lookup.cpp src/server/scripts/Commands/cs_titles.cpp src/server/scripts/EasternKingdoms/ZulAman/boss_halazzi.cpp src/server/scripts/EasternKingdoms/ZulAman/boss_zuljin.cpp src/server/scripts/EasternKingdoms/ZulGurub/boss_jeklik.cpp src/server/scripts/Kalimdor/zone_darkshore.cpp src/server/scripts/Kalimdor/zone_mulgore.cpp src/server/scripts/Kalimdor/zone_tanaris.cpp src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp src/server/scripts/Spells/spell_dk.cpp src/server/scripts/Spells/spell_mage.cpp src/server/scripts/Spells/spell_rogue.cpp src/server/shared/Database/Implementation/CharacterDatabase.cpp src/server/shared/Database/Implementation/CharacterDatabase.h src/tools/vmap4_extractor/mpq_libmpq04.h
249 lines
8.3 KiB
C++
249 lines
8.3 KiB
C++
/*
|
|
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
* option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/* ScriptData
|
|
Name: titles_commandscript
|
|
%Complete: 100
|
|
Comment: All titles related commands
|
|
Category: commandscripts
|
|
EndScriptData */
|
|
|
|
#include "Chat.h"
|
|
#include "Language.h"
|
|
#include "ObjectMgr.h"
|
|
#include "Player.h"
|
|
#include "ScriptMgr.h"
|
|
|
|
class titles_commandscript : public CommandScript
|
|
{
|
|
public:
|
|
titles_commandscript() : CommandScript("titles_commandscript") { }
|
|
|
|
ChatCommand* GetCommands() const OVERRIDE
|
|
{
|
|
static ChatCommand titlesSetCommandTable[] =
|
|
{
|
|
{ "mask", rbac::RBAC_PERM_COMMAND_TITLES_SET_MASK, false, &HandleTitlesSetMaskCommand, "", NULL },
|
|
{ NULL, 0, false, NULL, "", NULL }
|
|
};
|
|
static ChatCommand titlesCommandTable[] =
|
|
{
|
|
{ "add", rbac::RBAC_PERM_COMMAND_TITLES_ADD, false, &HandleTitlesAddCommand, "", NULL },
|
|
{ "current", rbac::RBAC_PERM_COMMAND_TITLES_CURRENT, false, &HandleTitlesCurrentCommand, "", NULL },
|
|
{ "remove", rbac::RBAC_PERM_COMMAND_TITLES_REMOVE, false, &HandleTitlesRemoveCommand, "", NULL },
|
|
{ "set", rbac::RBAC_PERM_COMMAND_TITLES_SET, false, NULL, "", titlesSetCommandTable },
|
|
{ NULL, 0, false, NULL, "", NULL }
|
|
};
|
|
static ChatCommand commandTable[] =
|
|
{
|
|
{ "titles", rbac::RBAC_PERM_COMMAND_TITLES, false, NULL, "", titlesCommandTable },
|
|
{ NULL, 0, false, NULL, "", NULL }
|
|
};
|
|
return commandTable;
|
|
}
|
|
|
|
static bool HandleTitlesCurrentCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
// number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
|
|
char* id_p = handler->extractKeyFromLink((char*)args, "Htitle");
|
|
if (!id_p)
|
|
return false;
|
|
|
|
int32 id = atoi(id_p);
|
|
if (id <= 0)
|
|
{
|
|
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
|
handler->SetSentErrorMessage(true);
|
|
return false;
|
|
}
|
|
|
|
Player* target = handler->getSelectedPlayer();
|
|
if (!target)
|
|
{
|
|
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
|
handler->SetSentErrorMessage(true);
|
|
return false;
|
|
}
|
|
|
|
// check online security
|
|
if (handler->HasLowerSecurity(target, 0))
|
|
return false;
|
|
|
|
CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
|
|
if (!titleInfo)
|
|
{
|
|
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
|
handler->SetSentErrorMessage(true);
|
|
return false;
|
|
}
|
|
|
|
std::string tNameLink = handler->GetNameLink(target);
|
|
|
|
target->SetTitle(titleInfo); // to be sure that title now known
|
|
target->SetUInt32Value(PLAYER_CHOSEN_TITLE, titleInfo->bit_index);
|
|
|
|
handler->PSendSysMessage(LANG_TITLE_CURRENT_RES, id, target->getGender() == GENDER_MALE ? titleInfo->nameMale : titleInfo->nameFemale, tNameLink.c_str());
|
|
return true;
|
|
}
|
|
|
|
static bool HandleTitlesAddCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
// number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
|
|
char* id_p = handler->extractKeyFromLink((char*)args, "Htitle");
|
|
if (!id_p)
|
|
return false;
|
|
|
|
int32 id = atoi(id_p);
|
|
if (id <= 0)
|
|
{
|
|
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
|
handler->SetSentErrorMessage(true);
|
|
return false;
|
|
}
|
|
|
|
Player* target = handler->getSelectedPlayer();
|
|
if (!target)
|
|
{
|
|
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
|
handler->SetSentErrorMessage(true);
|
|
return false;
|
|
}
|
|
|
|
// check online security
|
|
if (handler->HasLowerSecurity(target, 0))
|
|
return false;
|
|
|
|
CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
|
|
if (!titleInfo)
|
|
{
|
|
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
|
handler->SetSentErrorMessage(true);
|
|
return false;
|
|
}
|
|
|
|
std::string tNameLink = handler->GetNameLink(target);
|
|
|
|
char titleNameStr[80];
|
|
snprintf(titleNameStr, 80, target->getGender() == GENDER_MALE ? titleInfo->nameMale : titleInfo->nameFemale, target->GetName().c_str());
|
|
|
|
target->SetTitle(titleInfo);
|
|
handler->PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr, tNameLink.c_str());
|
|
|
|
return true;
|
|
}
|
|
|
|
static bool HandleTitlesRemoveCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
// number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
|
|
char* id_p = handler->extractKeyFromLink((char*)args, "Htitle");
|
|
if (!id_p)
|
|
return false;
|
|
|
|
int32 id = atoi(id_p);
|
|
if (id <= 0)
|
|
{
|
|
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
|
handler->SetSentErrorMessage(true);
|
|
return false;
|
|
}
|
|
|
|
Player* target = handler->getSelectedPlayer();
|
|
if (!target)
|
|
{
|
|
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
|
handler->SetSentErrorMessage(true);
|
|
return false;
|
|
}
|
|
|
|
// check online security
|
|
if (handler->HasLowerSecurity(target, 0))
|
|
return false;
|
|
|
|
CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
|
|
if (!titleInfo)
|
|
{
|
|
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
|
handler->SetSentErrorMessage(true);
|
|
return false;
|
|
}
|
|
|
|
target->SetTitle(titleInfo, true);
|
|
|
|
std::string tNameLink = handler->GetNameLink(target);
|
|
|
|
char titleNameStr[80];
|
|
snprintf(titleNameStr, 80, target->getGender() == GENDER_MALE ? titleInfo->nameMale : titleInfo->nameFemale, target->GetName().c_str());
|
|
|
|
handler->PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr, tNameLink.c_str());
|
|
|
|
if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE)))
|
|
{
|
|
target->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
|
|
handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET, tNameLink.c_str());
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
//Edit Player KnownTitles
|
|
static bool HandleTitlesSetMaskCommand(ChatHandler* handler, char const* args)
|
|
{
|
|
if (!*args)
|
|
return false;
|
|
|
|
uint64 titles = 0;
|
|
|
|
sscanf((char*)args, UI64FMTD, &titles);
|
|
|
|
Player* target = handler->getSelectedPlayer();
|
|
if (!target)
|
|
{
|
|
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
|
handler->SetSentErrorMessage(true);
|
|
return false;
|
|
}
|
|
|
|
// check online security
|
|
if (handler->HasLowerSecurity(target, 0))
|
|
return false;
|
|
|
|
uint64 titles2 = titles;
|
|
|
|
for (uint32 i = 1; i < sCharTitlesStore.GetNumRows(); ++i)
|
|
if (CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i))
|
|
titles2 &= ~(uint64(1) << tEntry->bit_index);
|
|
|
|
titles &= ~titles2; // remove not existed titles
|
|
|
|
target->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles);
|
|
handler->SendSysMessage(LANG_DONE);
|
|
|
|
if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE)))
|
|
{
|
|
target->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0);
|
|
handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET, handler->GetNameLink(target).c_str());
|
|
}
|
|
|
|
return true;
|
|
}
|
|
};
|
|
|
|
void AddSC_titles_commandscript()
|
|
{
|
|
new titles_commandscript();
|
|
}
|