CRLF to LF

Seriously....
This commit is contained in:
DDuarte committed 2015-07-10 20:16:55 +01:00
1 parent a6f7bb029c
commit 57091cc5f1
19 files changed
+77574 -77574

No files matched your search

+1235 -1235
View File
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -1,3 +1,3 @@
DELETE FROM `spell_script_names` WHERE `spell_id` = 38194;
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(38194, 'spell_talon_king_ikiss_blink');
DELETE FROM `spell_script_names` WHERE `spell_id` = 38194;
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(38194, 'spell_talon_king_ikiss_blink');
@@ -1,18 +1,18 @@
-- SWP: Move Muru summons to database
SET @MURU := 25741;
DELETE FROM `creature_summon_groups` WHERE `summonerId` = @MURU AND `entry` IN (25798, 25799, 25744);
INSERT INTO `creature_summon_groups` (`summonerId`, `summonerType`, `groupId`, `entry`, `position_x`, `position_y`, `position_z`, `orientation`, `summonType`, `summonTime`) VALUES
(@MURU, 0, 0, 25799, 1780.16, 666.83, 71.19, 5.21, 5, 0), -- Shadowsword Fury Mage
(@MURU, 0, 0, 25799, 1847.93, 600.30, 71.30, 2.57, 5, 0),
(@MURU, 0, 0, 25798, 1779.97, 660.64, 71.19, 5.28, 5, 0), -- Shadowsword Berserker
(@MURU, 0, 0, 25798, 1786.20, 661.01, 71.19, 4.51, 5, 0),
(@MURU, 0, 0, 25798, 1845.17, 602.63, 71.28, 2.43, 5, 0),
(@MURU, 0, 0, 25798, 1842.91, 599.93, 71.23, 2.44, 5, 0),
(@MURU, 0, 1, 25744, 1819.90, 609.80, 69.74, 1.94, 5, 0), -- Darkfiend
(@MURU, 0, 1, 25744, 1829.39, 617.89, 69.73, 2.61, 5, 0),
(@MURU, 0, 1, 25744, 1801.98, 633.62, 69.74, 5.71, 5, 0),
(@MURU, 0, 1, 25744, 1830.88, 629.99, 69.73, 3.52, 5, 0),
(@MURU, 0, 1, 25744, 1800.38, 621.41, 69.74, 0.22, 5, 0),
(@MURU, 0, 1, 25744, 1808.30, 612.45, 69.73, 1.02, 5, 0),
(@MURU, 0, 1, 25744, 1823.90, 639.69, 69.74, 4.12, 5, 0),
(@MURU, 0, 1, 25744, 1811.85, 640.46, 69.73, 4.97, 5, 0);
-- SWP: Move Muru summons to database
SET @MURU := 25741;
DELETE FROM `creature_summon_groups` WHERE `summonerId` = @MURU AND `entry` IN (25798, 25799, 25744);
INSERT INTO `creature_summon_groups` (`summonerId`, `summonerType`, `groupId`, `entry`, `position_x`, `position_y`, `position_z`, `orientation`, `summonType`, `summonTime`) VALUES
(@MURU, 0, 0, 25799, 1780.16, 666.83, 71.19, 5.21, 5, 0), -- Shadowsword Fury Mage
(@MURU, 0, 0, 25799, 1847.93, 600.30, 71.30, 2.57, 5, 0),
(@MURU, 0, 0, 25798, 1779.97, 660.64, 71.19, 5.28, 5, 0), -- Shadowsword Berserker
(@MURU, 0, 0, 25798, 1786.20, 661.01, 71.19, 4.51, 5, 0),
(@MURU, 0, 0, 25798, 1845.17, 602.63, 71.28, 2.43, 5, 0),
(@MURU, 0, 0, 25798, 1842.91, 599.93, 71.23, 2.44, 5, 0),
(@MURU, 0, 1, 25744, 1819.90, 609.80, 69.74, 1.94, 5, 0), -- Darkfiend
(@MURU, 0, 1, 25744, 1829.39, 617.89, 69.73, 2.61, 5, 0),
(@MURU, 0, 1, 25744, 1801.98, 633.62, 69.74, 5.71, 5, 0),
(@MURU, 0, 1, 25744, 1830.88, 629.99, 69.73, 3.52, 5, 0),
(@MURU, 0, 1, 25744, 1800.38, 621.41, 69.74, 0.22, 5, 0),
(@MURU, 0, 1, 25744, 1808.30, 612.45, 69.73, 1.02, 5, 0),
(@MURU, 0, 1, 25744, 1823.90, 639.69, 69.74, 4.12, 5, 0),
(@MURU, 0, 1, 25744, 1811.85, 640.46, 69.73, 4.97, 5, 0);
@@ -1 +1 @@
UPDATE `creature_loot_template` SET `ChanceOrQuestChance`=6 WHERE `entry` IN (34566, 35216, 35268, 35269, 35347, 35348, 35349, 35350, 35351, 35352, 35447, 35448, 35449, 35615, 35616) AND `item`=3;
UPDATE `creature_loot_template` SET `ChanceOrQuestChance`=6 WHERE `entry` IN (34566, 35216, 35268, 35269, 35347, 35348, 35349, 35350, 35351, 35352, 35447, 35448, 35449, 35615, 35616) AND `item`=3;
@@ -1,2 +1,2 @@
-- Remove no longer used script
UPDATE `creature_template` SET `ScriptName` = '' WHERE `entry` = 17662; -- Broggok Poison Cloud
-- Remove no longer used script
UPDATE `creature_template` SET `ScriptName` = '' WHERE `entry` = 17662; -- Broggok Poison Cloud
@@ -1,6 +1,6 @@
-- Corrects unit_flags and sets AI for Illusion of Jandice Barov (11439)
SET @ENTRY := 11439;
UPDATE `creature_template` SET `ScriptName` = '', `AIName` = 'SmartAI', `unit_flags` = `unit_flags` &~4194304 WHERE `entry` = @ENTRY;
DELETE FROM `smart_scripts` WHERE `entryorguid` = @ENTRY AND `source_type` = 0;
INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES
(@ENTRY, 0, 0, 0, 0, 0, 100, 2, 2000, 8000, 5000, 8000, 11, 15284, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, "Illusion of Jandice Barov - In Combat - Cast 'Cleave' (Normal Dungeon)");
-- Corrects unit_flags and sets AI for Illusion of Jandice Barov (11439)
SET @ENTRY := 11439;
UPDATE `creature_template` SET `ScriptName` = '', `AIName` = 'SmartAI', `unit_flags` = `unit_flags` &~4194304 WHERE `entry` = @ENTRY;
DELETE FROM `smart_scripts` WHERE `entryorguid` = @ENTRY AND `source_type` = 0;
INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES
(@ENTRY, 0, 0, 0, 0, 0, 100, 2, 2000, 8000, 5000, 8000, 11, 15284, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, "Illusion of Jandice Barov - In Combat - Cast 'Cleave' (Normal Dungeon)");
@@ -1,4 +1,4 @@
DELETE FROM `spell_script_names` WHERE `spell_id` IN (27695, 27687);
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(27695, 'spell_kormok_summon_bone_mages'),
(27687, 'spell_kormok_summon_bone_minions');
DELETE FROM `spell_script_names` WHERE `spell_id` IN (27695, 27687);
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(27695, 'spell_kormok_summon_bone_mages'),
(27687, 'spell_kormok_summon_bone_minions');
@@ -1,5 +1,5 @@
SET @ENTRY := 11136; -- Freed Soul
UPDATE `creature_template` SET `AIName` = 'SmartAI', `ScriptName` = '' WHERE `entry` = @ENTRY;
DELETE FROM `smart_scripts` WHERE `entryorguid` = @ENTRY AND `source_type` = 0;
INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
(@ENTRY, 0, 0, 0, 11, 0, 100, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Freed Soul - On Respawn - Say Line 0');
SET @ENTRY := 11136; -- Freed Soul
UPDATE `creature_template` SET `AIName` = 'SmartAI', `ScriptName` = '' WHERE `entry` = @ENTRY;
DELETE FROM `smart_scripts` WHERE `entryorguid` = @ENTRY AND `source_type` = 0;
INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
(@ENTRY, 0, 0, 0, 11, 0, 100, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Freed Soul - On Respawn - Say Line 0');
@@ -1,6 +1,6 @@
SET @ENTRY := 25040; -- Greater Water Elemental
UPDATE `creature_template` SET `AIName` = 'SmartAI', `ScriptName` = '' WHERE `entry` = @ENTRY;
DELETE FROM `smart_scripts` WHERE `entryorguid` = @ENTRY AND `source_type` = 0;
INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
(@ENTRY, 0, 1, 0, 0, 0, 100, 0, 3000, 3000, 5000, 5000, 11, 46983, 64, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 'Greater Water Elemental - In Combat CMC - Cast Waterbolt');
SET @ENTRY := 25040; -- Greater Water Elemental
UPDATE `creature_template` SET `AIName` = 'SmartAI', `ScriptName` = '' WHERE `entry` = @ENTRY;
DELETE FROM `smart_scripts` WHERE `entryorguid` = @ENTRY AND `source_type` = 0;
INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES
(@ENTRY, 0, 1, 0, 0, 0, 100, 0, 3000, 3000, 5000, 5000, 11, 46983, 64, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 'Greater Water Elemental - In Combat CMC - Cast Waterbolt');
@@ -1 +1 @@
UPDATE `conditions` SET `ConditionValue1` = 46 WHERE `SourceEntry` IN (63989, 63997, 63998) AND `SourceTypeOrReferenceId` = 18;
UPDATE `conditions` SET `ConditionValue1` = 46 WHERE `SourceEntry` IN (63989, 63997, 63998) AND `SourceTypeOrReferenceId` = 18;
@@ -1 +1 @@
UPDATE `creature_template` SET `ScriptName` = '' WHERE `entry` = 29920;
UPDATE `creature_template` SET `ScriptName` = '' WHERE `entry` = 29920;
@@ -1,3 +1,3 @@
DELETE FROM `spell_script_names` WHERE `spell_id` = 48292;
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(48292, 'spell_gen_50pct_count_pct_from_max_hp');
DELETE FROM `spell_script_names` WHERE `spell_id` = 48292;
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(48292, 'spell_gen_50pct_count_pct_from_max_hp');
@@ -1,3 +1,3 @@
DELETE FROM `achievement_criteria_data` WHERE `criteria_id` = 7361 AND `type` = 12;
INSERT INTO `achievement_criteria_data`(`criteria_id`, `type`, `value1`, `value2`, `ScriptName`) VALUES
(7361, 12, 1, 0, '');
DELETE FROM `achievement_criteria_data` WHERE `criteria_id` = 7361 AND `type` = 12;
INSERT INTO `achievement_criteria_data`(`criteria_id`, `type`, `value1`, `value2`, `ScriptName`) VALUES
(7361, 12, 1, 0, '');
@@ -1,4 +1,4 @@
--
DELETE FROM `spell_script_names` WHERE `spell_id` = 39238;
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(39238, 'spell_q10929_fumping');
--
DELETE FROM `spell_script_names` WHERE `spell_id` = 39238;
INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES
(39238, 'spell_q10929_fumping');
+265 -265
View File
@@ -1,265 +1,265 @@
/*
* 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 "RBAC.h"
#include "AccountMgr.h"
#include "DatabaseEnv.h"
#include "Log.h"
namespace rbac
{
std::string GetDebugPermissionString(RBACPermissionContainer const& perms)
{
std::string str = "";
if (!perms.empty())
{
std::ostringstream o;
RBACPermissionContainer::const_iterator itr = perms.begin();
o << (*itr);
for (++itr; itr != perms.end(); ++itr)
o << ", " << uint32(*itr);
str = o.str();
}
return str;
}
RBACCommandResult RBACData::GrantPermission(uint32 permissionId, int32 realmId /* = 0*/)
{
// Check if permission Id exists
RBACPermission const* perm = sAccountMgr->GetRBACPermission(permissionId);
if (!perm)
{
TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission does not exists",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_ID_DOES_NOT_EXISTS;
}
// Check if already added in denied list
if (HasDeniedPermission(permissionId))
{
TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission in deny list",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_IN_DENIED_LIST;
}
// Already added?
if (HasGrantedPermission(permissionId))
{
TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission already granted",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_CANT_ADD_ALREADY_ADDED;
}
AddGrantedPermission(permissionId);
// Do not save to db when loading data from DB (realmId = 0)
if (realmId)
{
TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok and DB updated",
GetId(), GetName().c_str(), permissionId, realmId);
SavePermission(permissionId, true, realmId);
CalculateNewPermissions();
}
else
TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_OK;
}
RBACCommandResult RBACData::DenyPermission(uint32 permissionId, int32 realmId /* = 0*/)
{
// Check if permission Id exists
RBACPermission const* perm = sAccountMgr->GetRBACPermission(permissionId);
if (!perm)
{
TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission does not exists",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_ID_DOES_NOT_EXISTS;
}
// Check if already added in granted list
if (HasGrantedPermission(permissionId))
{
TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission in grant list",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_IN_GRANTED_LIST;
}
// Already added?
if (HasDeniedPermission(permissionId))
{
TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission already denied",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_CANT_ADD_ALREADY_ADDED;
}
AddDeniedPermission(permissionId);
// Do not save to db when loading data from DB (realmId = 0)
if (realmId)
{
TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok and DB updated",
GetId(), GetName().c_str(), permissionId, realmId);
SavePermission(permissionId, false, realmId);
CalculateNewPermissions();
}
else
TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_OK;
}
void RBACData::SavePermission(uint32 permission, bool granted, int32 realmId)
{
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_RBAC_ACCOUNT_PERMISSION);
stmt->setUInt32(0, GetId());
stmt->setUInt32(1, permission);
stmt->setBool(2, granted);
stmt->setInt32(3, realmId);
LoginDatabase.Execute(stmt);
}
RBACCommandResult RBACData::RevokePermission(uint32 permissionId, int32 realmId /* = 0*/)
{
// Check if it's present in any list
if (!HasGrantedPermission(permissionId) && !HasDeniedPermission(permissionId))
{
TC_LOG_TRACE("rbac", "RBACData::RevokePermission [Id: %u Name: %s] (Permission %u, RealmId %d). Not granted or revoked",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_CANT_REVOKE_NOT_IN_LIST;
}
RemoveGrantedPermission(permissionId);
RemoveDeniedPermission(permissionId);
// Do not save to db when loading data from DB (realmId = 0)
if (realmId)
{
TC_LOG_TRACE("rbac", "RBACData::RevokePermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok and DB updated",
GetId(), GetName().c_str(), permissionId, realmId);
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_RBAC_ACCOUNT_PERMISSION);
stmt->setUInt32(0, GetId());
stmt->setUInt32(1, permissionId);
stmt->setInt32(2, realmId);
LoginDatabase.Execute(stmt);
CalculateNewPermissions();
}
else
TC_LOG_TRACE("rbac", "RBACData::RevokePermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_OK;
}
void RBACData::LoadFromDB()
{
ClearData();
TC_LOG_DEBUG("rbac", "RBACData::LoadFromDB [Id: %u Name: %s]: Loading permissions", GetId(), GetName().c_str());
// Load account permissions (granted and denied) that affect current realm
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_RBAC_ACCOUNT_PERMISSIONS);
stmt->setUInt32(0, GetId());
stmt->setInt32(1, GetRealmId());
PreparedQueryResult result = LoginDatabase.Query(stmt);
if (result)
{
do
{
Field* fields = result->Fetch();
if (fields[1].GetBool())
GrantPermission(fields[0].GetUInt32());
else
DenyPermission(fields[0].GetUInt32());
}
while (result->NextRow());
}
// Add default permissions
RBACPermissionContainer const& permissions = sAccountMgr->GetRBACDefaultPermissions(_secLevel);
for (RBACPermissionContainer::const_iterator itr = permissions.begin(); itr != permissions.end(); ++itr)
GrantPermission(*itr);
// Force calculation of permissions
CalculateNewPermissions();
}
void RBACData::CalculateNewPermissions()
{
TC_LOG_TRACE("rbac", "RBACData::CalculateNewPermissions [Id: %u Name: %s]", GetId(), GetName().c_str());
// Get the list of granted permissions
_globalPerms = GetGrantedPermissions();
ExpandPermissions(_globalPerms);
RBACPermissionContainer revoked = GetDeniedPermissions();
ExpandPermissions(revoked);
RemovePermissions(_globalPerms, revoked);
}
void RBACData::AddPermissions(RBACPermissionContainer const& permsFrom, RBACPermissionContainer& permsTo)
{
for (RBACPermissionContainer::const_iterator itr = permsFrom.begin(); itr != permsFrom.end(); ++itr)
permsTo.insert(*itr);
}
void RBACData::RemovePermissions(RBACPermissionContainer const& permsFrom, RBACPermissionContainer& permsTo)
{
for (RBACPermissionContainer::const_iterator itr = permsFrom.begin(); itr != permsFrom.end(); ++itr)
permsTo.erase(*itr);
}
void RBACData::ExpandPermissions(RBACPermissionContainer& permissions)
{
RBACPermissionContainer toCheck = permissions;
permissions.clear();
while (!toCheck.empty())
{
// remove the permission from original list
uint32 permissionId = *toCheck.begin();
toCheck.erase(toCheck.begin());
RBACPermission const* permission = sAccountMgr->GetRBACPermission(permissionId);
if (!permission)
continue;
// insert into the final list (expanded list)
permissions.insert(permissionId);
// add all linked permissions (that are not already expanded) to the list of permissions to be checked
RBACPermissionContainer const& linkedPerms = permission->GetLinkedPermissions();
for (RBACPermissionContainer::const_iterator itr = linkedPerms.begin(); itr != linkedPerms.end(); ++itr)
if (permissions.find(*itr) == permissions.end())
toCheck.insert(*itr);
}
TC_LOG_DEBUG("rbac", "RBACData::ExpandPermissions: Expanded: %s", GetDebugPermissionString(permissions).c_str());
}
void RBACData::ClearData()
{
_grantedPerms.clear();
_deniedPerms.clear();
_globalPerms.clear();
}
}
/*
* 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 "RBAC.h"
#include "AccountMgr.h"
#include "DatabaseEnv.h"
#include "Log.h"
namespace rbac
{
std::string GetDebugPermissionString(RBACPermissionContainer const& perms)
{
std::string str = "";
if (!perms.empty())
{
std::ostringstream o;
RBACPermissionContainer::const_iterator itr = perms.begin();
o << (*itr);
for (++itr; itr != perms.end(); ++itr)
o << ", " << uint32(*itr);
str = o.str();
}
return str;
}
RBACCommandResult RBACData::GrantPermission(uint32 permissionId, int32 realmId /* = 0*/)
{
// Check if permission Id exists
RBACPermission const* perm = sAccountMgr->GetRBACPermission(permissionId);
if (!perm)
{
TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission does not exists",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_ID_DOES_NOT_EXISTS;
}
// Check if already added in denied list
if (HasDeniedPermission(permissionId))
{
TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission in deny list",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_IN_DENIED_LIST;
}
// Already added?
if (HasGrantedPermission(permissionId))
{
TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission already granted",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_CANT_ADD_ALREADY_ADDED;
}
AddGrantedPermission(permissionId);
// Do not save to db when loading data from DB (realmId = 0)
if (realmId)
{
TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok and DB updated",
GetId(), GetName().c_str(), permissionId, realmId);
SavePermission(permissionId, true, realmId);
CalculateNewPermissions();
}
else
TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_OK;
}
RBACCommandResult RBACData::DenyPermission(uint32 permissionId, int32 realmId /* = 0*/)
{
// Check if permission Id exists
RBACPermission const* perm = sAccountMgr->GetRBACPermission(permissionId);
if (!perm)
{
TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission does not exists",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_ID_DOES_NOT_EXISTS;
}
// Check if already added in granted list
if (HasGrantedPermission(permissionId))
{
TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission in grant list",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_IN_GRANTED_LIST;
}
// Already added?
if (HasDeniedPermission(permissionId))
{
TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission already denied",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_CANT_ADD_ALREADY_ADDED;
}
AddDeniedPermission(permissionId);
// Do not save to db when loading data from DB (realmId = 0)
if (realmId)
{
TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok and DB updated",
GetId(), GetName().c_str(), permissionId, realmId);
SavePermission(permissionId, false, realmId);
CalculateNewPermissions();
}
else
TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_OK;
}
void RBACData::SavePermission(uint32 permission, bool granted, int32 realmId)
{
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_RBAC_ACCOUNT_PERMISSION);
stmt->setUInt32(0, GetId());
stmt->setUInt32(1, permission);
stmt->setBool(2, granted);
stmt->setInt32(3, realmId);
LoginDatabase.Execute(stmt);
}
RBACCommandResult RBACData::RevokePermission(uint32 permissionId, int32 realmId /* = 0*/)
{
// Check if it's present in any list
if (!HasGrantedPermission(permissionId) && !HasDeniedPermission(permissionId))
{
TC_LOG_TRACE("rbac", "RBACData::RevokePermission [Id: %u Name: %s] (Permission %u, RealmId %d). Not granted or revoked",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_CANT_REVOKE_NOT_IN_LIST;
}
RemoveGrantedPermission(permissionId);
RemoveDeniedPermission(permissionId);
// Do not save to db when loading data from DB (realmId = 0)
if (realmId)
{
TC_LOG_TRACE("rbac", "RBACData::RevokePermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok and DB updated",
GetId(), GetName().c_str(), permissionId, realmId);
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_RBAC_ACCOUNT_PERMISSION);
stmt->setUInt32(0, GetId());
stmt->setUInt32(1, permissionId);
stmt->setInt32(2, realmId);
LoginDatabase.Execute(stmt);
CalculateNewPermissions();
}
else
TC_LOG_TRACE("rbac", "RBACData::RevokePermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_OK;
}
void RBACData::LoadFromDB()
{
ClearData();
TC_LOG_DEBUG("rbac", "RBACData::LoadFromDB [Id: %u Name: %s]: Loading permissions", GetId(), GetName().c_str());
// Load account permissions (granted and denied) that affect current realm
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_RBAC_ACCOUNT_PERMISSIONS);
stmt->setUInt32(0, GetId());
stmt->setInt32(1, GetRealmId());
PreparedQueryResult result = LoginDatabase.Query(stmt);
if (result)
{
do
{
Field* fields = result->Fetch();
if (fields[1].GetBool())
GrantPermission(fields[0].GetUInt32());
else
DenyPermission(fields[0].GetUInt32());
}
while (result->NextRow());
}
// Add default permissions
RBACPermissionContainer const& permissions = sAccountMgr->GetRBACDefaultPermissions(_secLevel);
for (RBACPermissionContainer::const_iterator itr = permissions.begin(); itr != permissions.end(); ++itr)
GrantPermission(*itr);
// Force calculation of permissions
CalculateNewPermissions();
}
void RBACData::CalculateNewPermissions()
{
TC_LOG_TRACE("rbac", "RBACData::CalculateNewPermissions [Id: %u Name: %s]", GetId(), GetName().c_str());
// Get the list of granted permissions
_globalPerms = GetGrantedPermissions();
ExpandPermissions(_globalPerms);
RBACPermissionContainer revoked = GetDeniedPermissions();
ExpandPermissions(revoked);
RemovePermissions(_globalPerms, revoked);
}
void RBACData::AddPermissions(RBACPermissionContainer const& permsFrom, RBACPermissionContainer& permsTo)
{
for (RBACPermissionContainer::const_iterator itr = permsFrom.begin(); itr != permsFrom.end(); ++itr)
permsTo.insert(*itr);
}
void RBACData::RemovePermissions(RBACPermissionContainer const& permsFrom, RBACPermissionContainer& permsTo)
{
for (RBACPermissionContainer::const_iterator itr = permsFrom.begin(); itr != permsFrom.end(); ++itr)
permsTo.erase(*itr);
}
void RBACData::ExpandPermissions(RBACPermissionContainer& permissions)
{
RBACPermissionContainer toCheck = permissions;
permissions.clear();
while (!toCheck.empty())
{
// remove the permission from original list
uint32 permissionId = *toCheck.begin();
toCheck.erase(toCheck.begin());
RBACPermission const* permission = sAccountMgr->GetRBACPermission(permissionId);
if (!permission)
continue;
// insert into the final list (expanded list)
permissions.insert(permissionId);
// add all linked permissions (that are not already expanded) to the list of permissions to be checked
RBACPermissionContainer const& linkedPerms = permission->GetLinkedPermissions();
for (RBACPermissionContainer::const_iterator itr = linkedPerms.begin(); itr != linkedPerms.end(); ++itr)
if (permissions.find(*itr) == permissions.end())
toCheck.insert(*itr);
}
TC_LOG_DEBUG("rbac", "RBACData::ExpandPermissions: Expanded: %s", GetDebugPermissionString(permissions).c_str());
}
void RBACData::ClearData()
{
_grantedPerms.clear();
_deniedPerms.clear();
_globalPerms.clear();
}
}
@@ -1757,9 +1757,9 @@ void GameObject::Use(Unit* user)
return;
}
if (Player* player = user->ToPlayer())
sOutdoorPvPMgr->HandleCustomSpell(player, spellId, this);
if (Player* player = user->ToPlayer())
sOutdoorPvPMgr->HandleCustomSpell(player, spellId, this);
if (spellCaster)
spellCaster->CastSpell(user, spellInfo, triggered);
else
+383 -383
View File
@@ -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();
}