mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
CRLF to LF
Seriously....
This commit is contained in:
@@ -1,383 +1,383 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2015 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: rbac_commandscript
|
||||
%Complete: 100
|
||||
Comment: All role based access control related commands (including account related)
|
||||
Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "AccountMgr.h"
|
||||
#include "Config.h"
|
||||
#include "Chat.h"
|
||||
#include "Language.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
struct RBACCommandData
|
||||
{
|
||||
RBACCommandData(): id(0), realmId(0), rbac(NULL), needDelete(false) { }
|
||||
~RBACCommandData()
|
||||
{
|
||||
if (needDelete)
|
||||
delete rbac;
|
||||
}
|
||||
|
||||
uint32 id;
|
||||
int32 realmId;
|
||||
rbac::RBACData* rbac;
|
||||
bool needDelete;
|
||||
};
|
||||
|
||||
class rbac_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
rbac_commandscript() : CommandScript("rbac_commandscript") { }
|
||||
|
||||
ChatCommand* GetCommands() const
|
||||
{
|
||||
static ChatCommand rbacAccountCommandTable[] =
|
||||
{
|
||||
{ "list", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_LIST, true, &HandleRBACPermListCommand, "", NULL },
|
||||
{ "grant", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_GRANT, true, &HandleRBACPermGrantCommand, "", NULL },
|
||||
{ "deny", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_DENY, true, &HandleRBACPermDenyCommand, "", NULL },
|
||||
{ "revoke", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_REVOKE, true, &HandleRBACPermRevokeCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand rbacCommandTable[] =
|
||||
{
|
||||
{ "account", rbac::RBAC_PERM_COMMAND_RBAC_ACC, true, NULL, "", rbacAccountCommandTable },
|
||||
{ "list", rbac::RBAC_PERM_COMMAND_RBAC_LIST, true, &HandleRBACListPermissionsCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "rbac", rbac::RBAC_PERM_COMMAND_RBAC, true, NULL, "", rbacCommandTable },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static RBACCommandData* ReadParams(ChatHandler* handler, char const* args, bool checkParams = true)
|
||||
{
|
||||
if (!args)
|
||||
return NULL;
|
||||
|
||||
char* param1 = strtok((char*)args, " ");
|
||||
char* param2 = strtok(NULL, " ");
|
||||
char* param3 = strtok(NULL, " ");
|
||||
|
||||
int32 realmId = -1;
|
||||
uint32 accountId = 0;
|
||||
std::string accountName;
|
||||
uint32 id = 0;
|
||||
RBACCommandData* data = NULL;
|
||||
rbac::RBACData* rdata = NULL;
|
||||
bool useSelectedPlayer = false;
|
||||
|
||||
if (checkParams)
|
||||
{
|
||||
if (!param3)
|
||||
{
|
||||
if (param2)
|
||||
realmId = atoi(param2);
|
||||
|
||||
if (param1)
|
||||
id = atoi(param1);
|
||||
|
||||
useSelectedPlayer = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = atoi(param2);
|
||||
realmId = atoi(param3);
|
||||
}
|
||||
|
||||
if (!id)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (realmId < -1 || !realmId)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_REALM, realmId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if (!param1)
|
||||
useSelectedPlayer = true;
|
||||
|
||||
if (useSelectedPlayer)
|
||||
{
|
||||
Player* player = handler->getSelectedPlayer();
|
||||
if (!player)
|
||||
return NULL;
|
||||
|
||||
rdata = player->GetSession()->GetRBACData();
|
||||
accountId = rdata->GetId();
|
||||
AccountMgr::GetName(accountId, accountName);
|
||||
}
|
||||
else
|
||||
{
|
||||
accountName = param1;
|
||||
|
||||
if (AccountMgr::normalizeString(accountName))
|
||||
accountId = AccountMgr::GetId(accountName);
|
||||
|
||||
if (!accountId)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkParams && handler->HasLowerSecurityAccount(NULL, accountId, true))
|
||||
return NULL;
|
||||
|
||||
data = new RBACCommandData();
|
||||
|
||||
if (!rdata)
|
||||
{
|
||||
data->rbac = new rbac::RBACData(accountId, accountName, realmID, AccountMgr::GetSecurity(accountId, realmID));
|
||||
data->rbac->LoadFromDB();
|
||||
data->needDelete = true;
|
||||
}
|
||||
else
|
||||
data->rbac = rdata;
|
||||
|
||||
data->id = id;
|
||||
data->realmId = realmId;
|
||||
return data;
|
||||
}
|
||||
|
||||
static bool HandleRBACPermGrantCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
rbac::RBACCommandResult result = command->rbac->GrantPermission(command->id, command->realmId);
|
||||
rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(command->id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case rbac::RBAC_CANT_ADD_ALREADY_ADDED:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_GRANTED_IN_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_IN_DENIED_LIST:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_GRANTED_IN_DENIED_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_OK:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_GRANTED, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_ID_DOES_NOT_EXISTS:
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACPermDenyCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
rbac::RBACCommandResult result = command->rbac->DenyPermission(command->id, command->realmId);
|
||||
rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(command->id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case rbac::RBAC_CANT_ADD_ALREADY_ADDED:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_DENIED_IN_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_IN_GRANTED_LIST:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_DENIED_IN_GRANTED_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_OK:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_DENIED, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_ID_DOES_NOT_EXISTS:
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACPermRevokeCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
rbac::RBACCommandResult result = command->rbac->RevokePermission(command->id, command->realmId);
|
||||
rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(command->id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case rbac::RBAC_CANT_REVOKE_NOT_IN_LIST:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_REVOKED_NOT_IN_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_OK:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_REVOKED, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_ID_DOES_NOT_EXISTS:
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACPermListCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args, false);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_HEADER_GRANTED, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
rbac::RBACPermissionContainer const& granted = command->rbac->GetGrantedPermissions();
|
||||
if (granted.empty())
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
|
||||
else
|
||||
{
|
||||
for (rbac::RBACPermissionContainer::const_iterator itr = granted.begin(); itr != granted.end(); ++itr)
|
||||
{
|
||||
rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(*itr);
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_HEADER_DENIED, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
rbac::RBACPermissionContainer const& denied = command->rbac->GetDeniedPermissions();
|
||||
if (denied.empty())
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
|
||||
else
|
||||
{
|
||||
for (rbac::RBACPermissionContainer::const_iterator itr = denied.begin(); itr != denied.end(); ++itr)
|
||||
{
|
||||
rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(*itr);
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
}
|
||||
}
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_HEADER_BY_SEC_LEVEL, command->rbac->GetId(), command->rbac->GetName().c_str(), command->rbac->GetSecurityLevel());
|
||||
rbac::RBACPermissionContainer const& defaultPermissions = sAccountMgr->GetRBACDefaultPermissions(command->rbac->GetSecurityLevel());
|
||||
if (defaultPermissions.empty())
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
|
||||
else
|
||||
{
|
||||
for (rbac::RBACPermissionContainer::const_iterator itr = defaultPermissions.begin(); itr != defaultPermissions.end(); ++itr)
|
||||
{
|
||||
rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(*itr);
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACListPermissionsCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
uint32 id = 0;
|
||||
if (char* param1 = strtok((char*)args, " "))
|
||||
id = atoi(param1);
|
||||
|
||||
if (!id)
|
||||
{
|
||||
rbac::RBACPermissionsContainer const& permissions = sAccountMgr->GetRBACPermissionList();
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_PERMISSIONS_HEADER));
|
||||
for (rbac::RBACPermissionsContainer::const_iterator it = permissions.begin(); it != permissions.end(); ++it)
|
||||
{
|
||||
rbac::RBACPermission const* permission = it->second;
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(id);
|
||||
if (!permission)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_PERMISSIONS_HEADER));
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_PERMS_LINKED_HEADER));
|
||||
rbac::RBACPermissionContainer const& permissions = permission->GetLinkedPermissions();
|
||||
for (rbac::RBACPermissionContainer::const_iterator it = permissions.begin(); it != permissions.end(); ++it)
|
||||
if (rbac::RBACPermission const* rbacPermission = sAccountMgr->GetRBACPermission(*it))
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, rbacPermission->GetId(), rbacPermission->GetName().c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_rbac_commandscript()
|
||||
{
|
||||
new rbac_commandscript();
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2008-2015 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: rbac_commandscript
|
||||
%Complete: 100
|
||||
Comment: All role based access control related commands (including account related)
|
||||
Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "AccountMgr.h"
|
||||
#include "Config.h"
|
||||
#include "Chat.h"
|
||||
#include "Language.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
struct RBACCommandData
|
||||
{
|
||||
RBACCommandData(): id(0), realmId(0), rbac(NULL), needDelete(false) { }
|
||||
~RBACCommandData()
|
||||
{
|
||||
if (needDelete)
|
||||
delete rbac;
|
||||
}
|
||||
|
||||
uint32 id;
|
||||
int32 realmId;
|
||||
rbac::RBACData* rbac;
|
||||
bool needDelete;
|
||||
};
|
||||
|
||||
class rbac_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
rbac_commandscript() : CommandScript("rbac_commandscript") { }
|
||||
|
||||
ChatCommand* GetCommands() const
|
||||
{
|
||||
static ChatCommand rbacAccountCommandTable[] =
|
||||
{
|
||||
{ "list", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_LIST, true, &HandleRBACPermListCommand, "", NULL },
|
||||
{ "grant", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_GRANT, true, &HandleRBACPermGrantCommand, "", NULL },
|
||||
{ "deny", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_DENY, true, &HandleRBACPermDenyCommand, "", NULL },
|
||||
{ "revoke", rbac::RBAC_PERM_COMMAND_RBAC_ACC_PERM_REVOKE, true, &HandleRBACPermRevokeCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand rbacCommandTable[] =
|
||||
{
|
||||
{ "account", rbac::RBAC_PERM_COMMAND_RBAC_ACC, true, NULL, "", rbacAccountCommandTable },
|
||||
{ "list", rbac::RBAC_PERM_COMMAND_RBAC_LIST, true, &HandleRBACListPermissionsCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "rbac", rbac::RBAC_PERM_COMMAND_RBAC, true, NULL, "", rbacCommandTable },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static RBACCommandData* ReadParams(ChatHandler* handler, char const* args, bool checkParams = true)
|
||||
{
|
||||
if (!args)
|
||||
return NULL;
|
||||
|
||||
char* param1 = strtok((char*)args, " ");
|
||||
char* param2 = strtok(NULL, " ");
|
||||
char* param3 = strtok(NULL, " ");
|
||||
|
||||
int32 realmId = -1;
|
||||
uint32 accountId = 0;
|
||||
std::string accountName;
|
||||
uint32 id = 0;
|
||||
RBACCommandData* data = NULL;
|
||||
rbac::RBACData* rdata = NULL;
|
||||
bool useSelectedPlayer = false;
|
||||
|
||||
if (checkParams)
|
||||
{
|
||||
if (!param3)
|
||||
{
|
||||
if (param2)
|
||||
realmId = atoi(param2);
|
||||
|
||||
if (param1)
|
||||
id = atoi(param1);
|
||||
|
||||
useSelectedPlayer = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = atoi(param2);
|
||||
realmId = atoi(param3);
|
||||
}
|
||||
|
||||
if (!id)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (realmId < -1 || !realmId)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_REALM, realmId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if (!param1)
|
||||
useSelectedPlayer = true;
|
||||
|
||||
if (useSelectedPlayer)
|
||||
{
|
||||
Player* player = handler->getSelectedPlayer();
|
||||
if (!player)
|
||||
return NULL;
|
||||
|
||||
rdata = player->GetSession()->GetRBACData();
|
||||
accountId = rdata->GetId();
|
||||
AccountMgr::GetName(accountId, accountName);
|
||||
}
|
||||
else
|
||||
{
|
||||
accountName = param1;
|
||||
|
||||
if (AccountMgr::normalizeString(accountName))
|
||||
accountId = AccountMgr::GetId(accountName);
|
||||
|
||||
if (!accountId)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkParams && handler->HasLowerSecurityAccount(NULL, accountId, true))
|
||||
return NULL;
|
||||
|
||||
data = new RBACCommandData();
|
||||
|
||||
if (!rdata)
|
||||
{
|
||||
data->rbac = new rbac::RBACData(accountId, accountName, realmID, AccountMgr::GetSecurity(accountId, realmID));
|
||||
data->rbac->LoadFromDB();
|
||||
data->needDelete = true;
|
||||
}
|
||||
else
|
||||
data->rbac = rdata;
|
||||
|
||||
data->id = id;
|
||||
data->realmId = realmId;
|
||||
return data;
|
||||
}
|
||||
|
||||
static bool HandleRBACPermGrantCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
rbac::RBACCommandResult result = command->rbac->GrantPermission(command->id, command->realmId);
|
||||
rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(command->id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case rbac::RBAC_CANT_ADD_ALREADY_ADDED:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_GRANTED_IN_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_IN_DENIED_LIST:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_GRANTED_IN_DENIED_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_OK:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_GRANTED, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_ID_DOES_NOT_EXISTS:
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACPermDenyCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
rbac::RBACCommandResult result = command->rbac->DenyPermission(command->id, command->realmId);
|
||||
rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(command->id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case rbac::RBAC_CANT_ADD_ALREADY_ADDED:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_DENIED_IN_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_IN_GRANTED_LIST:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_DENIED_IN_GRANTED_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_OK:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_DENIED, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_ID_DOES_NOT_EXISTS:
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACPermRevokeCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
rbac::RBACCommandResult result = command->rbac->RevokePermission(command->id, command->realmId);
|
||||
rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(command->id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case rbac::RBAC_CANT_REVOKE_NOT_IN_LIST:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_REVOKED_NOT_IN_LIST, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_OK:
|
||||
handler->PSendSysMessage(LANG_RBAC_PERM_REVOKED, command->id, permission->GetName().c_str(),
|
||||
command->realmId, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
break;
|
||||
case rbac::RBAC_ID_DOES_NOT_EXISTS:
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, command->id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACPermListCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
RBACCommandData* command = ReadParams(handler, args, false);
|
||||
|
||||
if (!command)
|
||||
{
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_HEADER_GRANTED, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
rbac::RBACPermissionContainer const& granted = command->rbac->GetGrantedPermissions();
|
||||
if (granted.empty())
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
|
||||
else
|
||||
{
|
||||
for (rbac::RBACPermissionContainer::const_iterator itr = granted.begin(); itr != granted.end(); ++itr)
|
||||
{
|
||||
rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(*itr);
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_HEADER_DENIED, command->rbac->GetId(), command->rbac->GetName().c_str());
|
||||
rbac::RBACPermissionContainer const& denied = command->rbac->GetDeniedPermissions();
|
||||
if (denied.empty())
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
|
||||
else
|
||||
{
|
||||
for (rbac::RBACPermissionContainer::const_iterator itr = denied.begin(); itr != denied.end(); ++itr)
|
||||
{
|
||||
rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(*itr);
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
}
|
||||
}
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_HEADER_BY_SEC_LEVEL, command->rbac->GetId(), command->rbac->GetName().c_str(), command->rbac->GetSecurityLevel());
|
||||
rbac::RBACPermissionContainer const& defaultPermissions = sAccountMgr->GetRBACDefaultPermissions(command->rbac->GetSecurityLevel());
|
||||
if (defaultPermissions.empty())
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_EMPTY));
|
||||
else
|
||||
{
|
||||
for (rbac::RBACPermissionContainer::const_iterator itr = defaultPermissions.begin(); itr != defaultPermissions.end(); ++itr)
|
||||
{
|
||||
rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(*itr);
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
delete command;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleRBACListPermissionsCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
uint32 id = 0;
|
||||
if (char* param1 = strtok((char*)args, " "))
|
||||
id = atoi(param1);
|
||||
|
||||
if (!id)
|
||||
{
|
||||
rbac::RBACPermissionsContainer const& permissions = sAccountMgr->GetRBACPermissionList();
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_PERMISSIONS_HEADER));
|
||||
for (rbac::RBACPermissionsContainer::const_iterator it = permissions.begin(); it != permissions.end(); ++it)
|
||||
{
|
||||
rbac::RBACPermission const* permission = it->second;
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rbac::RBACPermission const* permission = sAccountMgr->GetRBACPermission(id);
|
||||
if (!permission)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_RBAC_WRONG_PARAMETER_ID, id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_PERMISSIONS_HEADER));
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, permission->GetId(), permission->GetName().c_str());
|
||||
handler->PSendSysMessage("%s", handler->GetTrinityString(LANG_RBAC_LIST_PERMS_LINKED_HEADER));
|
||||
rbac::RBACPermissionContainer const& permissions = permission->GetLinkedPermissions();
|
||||
for (rbac::RBACPermissionContainer::const_iterator it = permissions.begin(); it != permissions.end(); ++it)
|
||||
if (rbac::RBACPermission const* rbacPermission = sAccountMgr->GetRBACPermission(*it))
|
||||
handler->PSendSysMessage(LANG_RBAC_LIST_ELEMENT, rbacPermission->GetId(), rbacPermission->GetName().c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_rbac_commandscript()
|
||||
{
|
||||
new rbac_commandscript();
|
||||
}
|
||||
|
||||
@@ -1,215 +1,215 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2015 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/>.
|
||||
*/
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "ScriptedCreature.h"
|
||||
#include "black_temple.h"
|
||||
#include "Player.h"
|
||||
#include "SpellInfo.h"
|
||||
|
||||
enum Texts
|
||||
{
|
||||
SAY_AGGRO = 0,
|
||||
SAY_NEEDLE = 1,
|
||||
SAY_SLAY = 2,
|
||||
SAY_SPECIAL = 3,
|
||||
SAY_ENRAGE = 4,
|
||||
SAY_DEATH = 5
|
||||
};
|
||||
|
||||
enum Spells
|
||||
{
|
||||
SPELL_NEEDLE_SPINE = 39992,
|
||||
SPELL_TIDAL_BURST = 39878,
|
||||
SPELL_TIDAL_SHIELD = 39872,
|
||||
SPELL_IMPALING_SPINE = 39837,
|
||||
SPELL_CREATE_NAJENTUS_SPINE = 39956,
|
||||
SPELL_HURL_SPINE = 39948,
|
||||
SPELL_BERSERK = 26662
|
||||
|
||||
};
|
||||
|
||||
enum Events
|
||||
{
|
||||
EVENT_BERSERK = 1,
|
||||
EVENT_YELL = 2,
|
||||
EVENT_NEEDLE = 3,
|
||||
EVENT_SPINE = 4,
|
||||
EVENT_SHIELD = 5
|
||||
};
|
||||
|
||||
enum EventGroups
|
||||
{
|
||||
GCD_CAST = 1,
|
||||
GCD_YELL = 2
|
||||
};
|
||||
|
||||
class boss_najentus : public CreatureScript
|
||||
{
|
||||
public:
|
||||
boss_najentus() : CreatureScript("boss_najentus") { }
|
||||
|
||||
struct boss_najentusAI : public BossAI
|
||||
{
|
||||
boss_najentusAI(Creature* creature) : BossAI(creature, DATA_HIGH_WARLORD_NAJENTUS)
|
||||
{
|
||||
}
|
||||
|
||||
void Reset() override
|
||||
{
|
||||
_Reset();
|
||||
SpineTargetGUID.Clear();
|
||||
}
|
||||
|
||||
void KilledUnit(Unit* /*victim*/) override
|
||||
{
|
||||
Talk(SAY_SLAY);
|
||||
events.DelayEvents(5000, GCD_YELL);
|
||||
}
|
||||
|
||||
void JustDied(Unit* /*killer*/) override
|
||||
{
|
||||
_JustDied();
|
||||
Talk(SAY_DEATH);
|
||||
}
|
||||
|
||||
void SpellHit(Unit* /*caster*/, const SpellInfo* spell) override
|
||||
{
|
||||
if (spell->Id == SPELL_HURL_SPINE && me->HasAura(SPELL_TIDAL_SHIELD))
|
||||
{
|
||||
me->RemoveAurasDueToSpell(SPELL_TIDAL_SHIELD);
|
||||
DoCast(me, SPELL_TIDAL_BURST, true);
|
||||
ResetTimer();
|
||||
}
|
||||
}
|
||||
|
||||
void EnterCombat(Unit* /*who*/) override
|
||||
{
|
||||
_EnterCombat();
|
||||
Talk(SAY_AGGRO);
|
||||
events.ScheduleEvent(EVENT_BERSERK, 480000, GCD_CAST);
|
||||
events.ScheduleEvent(EVENT_YELL, 45000 + (rand32() % 76) * 1000, GCD_YELL);
|
||||
ResetTimer();
|
||||
}
|
||||
|
||||
bool RemoveImpalingSpine()
|
||||
{
|
||||
if (!SpineTargetGUID)
|
||||
return false;
|
||||
|
||||
Unit* target = ObjectAccessor::GetUnit(*me, SpineTargetGUID);
|
||||
if (target && target->HasAura(SPELL_IMPALING_SPINE))
|
||||
target->RemoveAurasDueToSpell(SPELL_IMPALING_SPINE);
|
||||
SpineTargetGUID.Clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ResetTimer(uint32 inc = 0)
|
||||
{
|
||||
events.RescheduleEvent(EVENT_NEEDLE, 10000 + inc, GCD_CAST);
|
||||
events.RescheduleEvent(EVENT_SPINE, 20000 + inc, GCD_CAST);
|
||||
events.RescheduleEvent(EVENT_SHIELD, 60000 + inc);
|
||||
}
|
||||
|
||||
void ExecuteEvent(uint32 eventId) override
|
||||
{
|
||||
switch (eventId)
|
||||
{
|
||||
case EVENT_SHIELD:
|
||||
DoCast(me, SPELL_TIDAL_SHIELD, true);
|
||||
ResetTimer(45000);
|
||||
break;
|
||||
case EVENT_BERSERK:
|
||||
Talk(SAY_ENRAGE);
|
||||
DoCast(me, SPELL_BERSERK, true);
|
||||
events.DelayEvents(15000, GCD_YELL);
|
||||
break;
|
||||
case EVENT_SPINE:
|
||||
{
|
||||
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1);
|
||||
|
||||
if (!target)
|
||||
target = me->GetVictim();
|
||||
|
||||
if (target)
|
||||
{
|
||||
DoCast(target, SPELL_IMPALING_SPINE, true);
|
||||
SpineTargetGUID = target->GetGUID();
|
||||
//must let target summon, otherwise you cannot click the spine
|
||||
target->SummonGameObject(GO_NAJENTUS_SPINE, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), me->GetOrientation(), 0, 0, 0, 0, 30);
|
||||
Talk(SAY_NEEDLE);
|
||||
events.DelayEvents(1500, GCD_CAST);
|
||||
events.DelayEvents(15000, GCD_YELL);
|
||||
}
|
||||
events.ScheduleEvent(EVENT_SPINE, 21000, GCD_CAST);
|
||||
return;
|
||||
}
|
||||
case EVENT_NEEDLE:
|
||||
{
|
||||
//DoCast(me, SPELL_NEEDLE_SPINE, true);
|
||||
std::list<Unit*> targets;
|
||||
SelectTargetList(targets, 3, SELECT_TARGET_RANDOM, 80, true);
|
||||
for (std::list<Unit*>::const_iterator i = targets.begin(); i != targets.end(); ++i)
|
||||
DoCast(*i, 39835, true);
|
||||
events.ScheduleEvent(EVENT_NEEDLE, urand(15000, 25000), GCD_CAST);
|
||||
events.DelayEvents(1500, GCD_CAST);
|
||||
return;
|
||||
}
|
||||
case EVENT_YELL:
|
||||
Talk(SAY_SPECIAL);
|
||||
events.ScheduleEvent(EVENT_YELL, urand(25000, 100000), GCD_YELL);
|
||||
events.DelayEvents(15000, GCD_YELL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid SpineTargetGUID;
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
{
|
||||
return GetBlackTempleAI<boss_najentusAI>(creature);
|
||||
}
|
||||
};
|
||||
|
||||
class go_najentus_spine : public GameObjectScript
|
||||
{
|
||||
public:
|
||||
go_najentus_spine() : GameObjectScript("go_najentus_spine") { }
|
||||
|
||||
bool OnGossipHello(Player* player, GameObject* go) override
|
||||
{
|
||||
if (InstanceScript* instance = go->GetInstanceScript())
|
||||
if (Creature* Najentus = ObjectAccessor::GetCreature(*go, instance->GetGuidData(DATA_HIGH_WARLORD_NAJENTUS)))
|
||||
if (ENSURE_AI(boss_najentus::boss_najentusAI, Najentus->AI())->RemoveImpalingSpine())
|
||||
{
|
||||
player->CastSpell(player, SPELL_CREATE_NAJENTUS_SPINE, true);
|
||||
go->Delete();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void AddSC_boss_najentus()
|
||||
{
|
||||
new boss_najentus();
|
||||
new go_najentus_spine();
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2008-2015 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/>.
|
||||
*/
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "ScriptedCreature.h"
|
||||
#include "black_temple.h"
|
||||
#include "Player.h"
|
||||
#include "SpellInfo.h"
|
||||
|
||||
enum Texts
|
||||
{
|
||||
SAY_AGGRO = 0,
|
||||
SAY_NEEDLE = 1,
|
||||
SAY_SLAY = 2,
|
||||
SAY_SPECIAL = 3,
|
||||
SAY_ENRAGE = 4,
|
||||
SAY_DEATH = 5
|
||||
};
|
||||
|
||||
enum Spells
|
||||
{
|
||||
SPELL_NEEDLE_SPINE = 39992,
|
||||
SPELL_TIDAL_BURST = 39878,
|
||||
SPELL_TIDAL_SHIELD = 39872,
|
||||
SPELL_IMPALING_SPINE = 39837,
|
||||
SPELL_CREATE_NAJENTUS_SPINE = 39956,
|
||||
SPELL_HURL_SPINE = 39948,
|
||||
SPELL_BERSERK = 26662
|
||||
|
||||
};
|
||||
|
||||
enum Events
|
||||
{
|
||||
EVENT_BERSERK = 1,
|
||||
EVENT_YELL = 2,
|
||||
EVENT_NEEDLE = 3,
|
||||
EVENT_SPINE = 4,
|
||||
EVENT_SHIELD = 5
|
||||
};
|
||||
|
||||
enum EventGroups
|
||||
{
|
||||
GCD_CAST = 1,
|
||||
GCD_YELL = 2
|
||||
};
|
||||
|
||||
class boss_najentus : public CreatureScript
|
||||
{
|
||||
public:
|
||||
boss_najentus() : CreatureScript("boss_najentus") { }
|
||||
|
||||
struct boss_najentusAI : public BossAI
|
||||
{
|
||||
boss_najentusAI(Creature* creature) : BossAI(creature, DATA_HIGH_WARLORD_NAJENTUS)
|
||||
{
|
||||
}
|
||||
|
||||
void Reset() override
|
||||
{
|
||||
_Reset();
|
||||
SpineTargetGUID.Clear();
|
||||
}
|
||||
|
||||
void KilledUnit(Unit* /*victim*/) override
|
||||
{
|
||||
Talk(SAY_SLAY);
|
||||
events.DelayEvents(5000, GCD_YELL);
|
||||
}
|
||||
|
||||
void JustDied(Unit* /*killer*/) override
|
||||
{
|
||||
_JustDied();
|
||||
Talk(SAY_DEATH);
|
||||
}
|
||||
|
||||
void SpellHit(Unit* /*caster*/, const SpellInfo* spell) override
|
||||
{
|
||||
if (spell->Id == SPELL_HURL_SPINE && me->HasAura(SPELL_TIDAL_SHIELD))
|
||||
{
|
||||
me->RemoveAurasDueToSpell(SPELL_TIDAL_SHIELD);
|
||||
DoCast(me, SPELL_TIDAL_BURST, true);
|
||||
ResetTimer();
|
||||
}
|
||||
}
|
||||
|
||||
void EnterCombat(Unit* /*who*/) override
|
||||
{
|
||||
_EnterCombat();
|
||||
Talk(SAY_AGGRO);
|
||||
events.ScheduleEvent(EVENT_BERSERK, 480000, GCD_CAST);
|
||||
events.ScheduleEvent(EVENT_YELL, 45000 + (rand32() % 76) * 1000, GCD_YELL);
|
||||
ResetTimer();
|
||||
}
|
||||
|
||||
bool RemoveImpalingSpine()
|
||||
{
|
||||
if (!SpineTargetGUID)
|
||||
return false;
|
||||
|
||||
Unit* target = ObjectAccessor::GetUnit(*me, SpineTargetGUID);
|
||||
if (target && target->HasAura(SPELL_IMPALING_SPINE))
|
||||
target->RemoveAurasDueToSpell(SPELL_IMPALING_SPINE);
|
||||
SpineTargetGUID.Clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ResetTimer(uint32 inc = 0)
|
||||
{
|
||||
events.RescheduleEvent(EVENT_NEEDLE, 10000 + inc, GCD_CAST);
|
||||
events.RescheduleEvent(EVENT_SPINE, 20000 + inc, GCD_CAST);
|
||||
events.RescheduleEvent(EVENT_SHIELD, 60000 + inc);
|
||||
}
|
||||
|
||||
void ExecuteEvent(uint32 eventId) override
|
||||
{
|
||||
switch (eventId)
|
||||
{
|
||||
case EVENT_SHIELD:
|
||||
DoCast(me, SPELL_TIDAL_SHIELD, true);
|
||||
ResetTimer(45000);
|
||||
break;
|
||||
case EVENT_BERSERK:
|
||||
Talk(SAY_ENRAGE);
|
||||
DoCast(me, SPELL_BERSERK, true);
|
||||
events.DelayEvents(15000, GCD_YELL);
|
||||
break;
|
||||
case EVENT_SPINE:
|
||||
{
|
||||
Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1);
|
||||
|
||||
if (!target)
|
||||
target = me->GetVictim();
|
||||
|
||||
if (target)
|
||||
{
|
||||
DoCast(target, SPELL_IMPALING_SPINE, true);
|
||||
SpineTargetGUID = target->GetGUID();
|
||||
//must let target summon, otherwise you cannot click the spine
|
||||
target->SummonGameObject(GO_NAJENTUS_SPINE, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), me->GetOrientation(), 0, 0, 0, 0, 30);
|
||||
Talk(SAY_NEEDLE);
|
||||
events.DelayEvents(1500, GCD_CAST);
|
||||
events.DelayEvents(15000, GCD_YELL);
|
||||
}
|
||||
events.ScheduleEvent(EVENT_SPINE, 21000, GCD_CAST);
|
||||
return;
|
||||
}
|
||||
case EVENT_NEEDLE:
|
||||
{
|
||||
//DoCast(me, SPELL_NEEDLE_SPINE, true);
|
||||
std::list<Unit*> targets;
|
||||
SelectTargetList(targets, 3, SELECT_TARGET_RANDOM, 80, true);
|
||||
for (std::list<Unit*>::const_iterator i = targets.begin(); i != targets.end(); ++i)
|
||||
DoCast(*i, 39835, true);
|
||||
events.ScheduleEvent(EVENT_NEEDLE, urand(15000, 25000), GCD_CAST);
|
||||
events.DelayEvents(1500, GCD_CAST);
|
||||
return;
|
||||
}
|
||||
case EVENT_YELL:
|
||||
Talk(SAY_SPECIAL);
|
||||
events.ScheduleEvent(EVENT_YELL, urand(25000, 100000), GCD_YELL);
|
||||
events.DelayEvents(15000, GCD_YELL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid SpineTargetGUID;
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
{
|
||||
return GetBlackTempleAI<boss_najentusAI>(creature);
|
||||
}
|
||||
};
|
||||
|
||||
class go_najentus_spine : public GameObjectScript
|
||||
{
|
||||
public:
|
||||
go_najentus_spine() : GameObjectScript("go_najentus_spine") { }
|
||||
|
||||
bool OnGossipHello(Player* player, GameObject* go) override
|
||||
{
|
||||
if (InstanceScript* instance = go->GetInstanceScript())
|
||||
if (Creature* Najentus = ObjectAccessor::GetCreature(*go, instance->GetGuidData(DATA_HIGH_WARLORD_NAJENTUS)))
|
||||
if (ENSURE_AI(boss_najentus::boss_najentusAI, Najentus->AI())->RemoveImpalingSpine())
|
||||
{
|
||||
player->CastSpell(player, SPELL_CREATE_NAJENTUS_SPINE, true);
|
||||
go->Delete();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void AddSC_boss_najentus()
|
||||
{
|
||||
new boss_najentus();
|
||||
new go_najentus_spine();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user