mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Scripts/Commands: new command '.debug instancespawn'
This commit is contained in:
@@ -818,6 +818,7 @@ INSERT INTO `rbac_linked_permissions` VALUES
|
||||
(196,866),
|
||||
(196,867),
|
||||
(196,870),
|
||||
(196,871),
|
||||
(197,232),
|
||||
(197,236),
|
||||
(197,237),
|
||||
@@ -1709,7 +1710,8 @@ INSERT INTO `rbac_permissions` VALUES
|
||||
(865,'Command: npc showloot'),
|
||||
(866,'Command: list spawnpoints'),
|
||||
(867,'Command: reload quest_greeting_locale'),
|
||||
(870,'Command: debug threatinfo');
|
||||
(870,'Command: debug threatinfo'),
|
||||
(871,'Command: debug instancespawn');
|
||||
/*!40000 ALTER TABLE `rbac_permissions` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
@@ -1805,18 +1807,18 @@ INSERT INTO `updates` VALUES
|
||||
('2015_03_20_01_auth.sql','862961815354DA2746F5F71FBC8155F57CBE75AB','ARCHIVED','2015-03-21 21:44:12',0),
|
||||
('2015_03_20_02_auth.sql','33E4F94086590768EF5D4855DD43D7DE7C06ADA4','ARCHIVED','2015-03-21 21:44:51',0),
|
||||
('2015_08_21_00_auth.sql','C31A9E1D28E11B60BE8F8198637DD51F6D75123F','ARCHIVED','2015-10-05 23:16:19',0),
|
||||
('2015_11_07_00_auth.sql','0ACDD35EC9745231BCFA701B78056DEF94D0CC53','ARCHIVED','2016-04-11 00:42:36',92),
|
||||
('2015_11_07_00_auth.sql','0ACDD35EC9745231BCFA701B78056DEF94D0CC53','ARCHIVED','2016-04-11 00:42:36',0),
|
||||
('2016_01_13_00_auth.sql','24615CC69B3CD7BB4699874647C35BA86E8A93FD','ARCHIVED','2016-01-13 00:00:00',0),
|
||||
('2016_04_11_00_auth.sql','0ACDD35EC9745231BCFA701B78056DEF94D0CC53','ARCHIVED','2016-04-11 03:18:17',0),
|
||||
('2016_05_11_00_auth.sql','95B66235B8D67BF1CA216EB09F313C1F8F393B47','ARCHIVED','2016-04-16 13:17:11',0),
|
||||
('2016_06_06_00_auth.sql','A0A8D73A952D0618833416513D53F73A70E7EA25','ARCHIVED','2016-10-16 13:42:31',45),
|
||||
('2016_06_06_00_auth.sql','A0A8D73A952D0618833416513D53F73A70E7EA25','ARCHIVED','2016-10-16 13:42:31',0),
|
||||
('2016_09_22_00_auth.sql','70047954E3556BFA430ADD5680EF8797F74A4B9E','ARCHIVED','2016-09-22 00:00:00',0),
|
||||
('2016_10_16_00_auth.sql','0ACDD35EC9745231BCFA701B78056DEF94D0CC53','ARCHIVED','2016-10-16 14:02:49',31),
|
||||
('2016_10_16_00_auth.sql','0ACDD35EC9745231BCFA701B78056DEF94D0CC53','ARCHIVED','2016-10-16 14:02:49',0),
|
||||
('2017_01_06_00_auth.sql','6CCFE6A9774EC733C9863D36A0F15F3534189BBD','ARCHIVED','2017-01-06 05:34:00',0),
|
||||
('2017_01_08_00_auth.sql','A68511D0BF94C41F720A11B630CCB36BBEA6B17D','ARCHIVED','2017-01-08 03:21:00',0),
|
||||
('2017_02_06_00_auth_335.sql','612068198F744892ECC0ACFE3BDCB6D72995916E','ARCHIVED','2017-02-06 00:00:00',0),
|
||||
('2017_03_17_00_auth.sql','4902E9B1B063F399F928C2DD7AFD60427738E227','ARCHIVED','2017-03-17 18:58:01',0),
|
||||
('2017_04_19_00_auth.sql','EAE1C1D3AA752259785C056A8F18515E1EF32BC9','RELEASED','2017-04-19 00:07:40',32),
|
||||
('2017_04_19_00_auth.sql','EAE1C1D3AA752259785C056A8F18515E1EF32BC9','RELEASED','2017-04-19 00:07:40',0),
|
||||
('2017_05_29_00_auth.sql','74BBB703AABD8A6BCB905EA2F5C14A5E26124CDD','RELEASED','2017-05-29 23:16:20',0),
|
||||
('2017_06_12_00_auth.sql','176532AED785F1F759382C79A28E0FED92E99779','RELEASED','2017-06-12 14:46:29',0),
|
||||
('2017_06_12_01_auth.sql','6661B4935E101AF188BEBF43203144104E89F8C54','RELEASED','2017-06-12 15:10:00',0),
|
||||
@@ -1825,10 +1827,11 @@ INSERT INTO `updates` VALUES
|
||||
('2017_06_28_00_auth.sql','D32EF80F57F629C23395D80F06E91D7E40719F83','RELEASED','2017-06-28 15:23:34',0),
|
||||
('2017_08_01_00_auth.sql','6ECE808AF52345177189E962C0606B769B6806A6','RELEASED','2017-08-01 01:11:28',0),
|
||||
('2017_10_13_00_auth.sql','87674E0D166AC60E3725B445714427892E42C6FE','RELEASED','2017-10-13 22:00:22',0),
|
||||
('2017_10_29_00_auth.sql','0AF3E442B2F312D4F396EC07517B156EF2BFF0F4','RELEASED','2017-10-08 12:30:47',16),
|
||||
('2017_12_17_00_auth.sql','2CD99730D4D32DBF0584CD5B1AA6F8F4AE3DA975','RELEASED','2017-12-17 03:17:39',52),
|
||||
('2017_10_29_00_auth.sql','0AF3E442B2F312D4F396EC07517B156EF2BFF0F4','RELEASED','2017-10-08 12:30:47',0),
|
||||
('2017_12_17_00_auth.sql','2CD99730D4D32DBF0584CD5B1AA6F8F4AE3DA975','RELEASED','2017-12-17 03:17:39',0),
|
||||
('2018_01_03_00_auth_2018_01_02_00_auth.sql','08AF5DAB45515B681B738DA17FA414C7C7CCA44E','RELEASED','2018-01-02 20:40:37',0),
|
||||
('2018_01_09_00_auth.sql','A5D4EC8FCFAB4F2DCE70EDCAD1ACBFB484FD68D5','RELEASED','2018-01-09 00:00:00',0);
|
||||
('2018_01_09_00_auth.sql','A5D4EC8FCFAB4F2DCE70EDCAD1ACBFB484FD68D5','RELEASED','2018-01-09 00:00:00',0),
|
||||
('2018_01_24_00_auth.sql','167B17D8A253D62A8112F8A7EB21C6E99CAEF1E4','RELEASED','2018-01-24 00:00:00',0);
|
||||
/*!40000 ALTER TABLE `updates` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
|
||||
8
sql/updates/auth/3.3.5/2018_01_24_00_auth.sql
Normal file
8
sql/updates/auth/3.3.5/2018_01_24_00_auth.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
--
|
||||
DELETE FROM `rbac_permissions` WHERE `id`=871;
|
||||
INSERT INTO `rbac_permissions` (`id`,`name`) VALUES
|
||||
(871, 'Command: debug instancespawn');
|
||||
|
||||
DELETE FROM `rbac_linked_permissions` WHERE `linkedId`=871;
|
||||
INSERT INTO `rbac_linked_permissions` (`id`,`linkedId`) VALUES
|
||||
(196,871);
|
||||
6
sql/updates/world/3.3.5/2018_01_24_06_world.sql
Normal file
6
sql/updates/world/3.3.5/2018_01_24_06_world.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
--
|
||||
DELETE FROM `command` WHERE `name`="debug instancespawn";
|
||||
INSERT INTO `command`(`name`,`permission`,`help`) VALUES
|
||||
('debug instancespawn',871,'Syntax: .debug instancespawn [<groupID>/explain]
|
||||
|
||||
Displays information about the spawn groups being managed by the current instance script. If groupID is specified, additionally explains why that spawn group is in the listed state. If "explain" is specified, explains all spawn groups.');
|
||||
@@ -776,6 +776,7 @@ enum RBACPermissions
|
||||
RBAC_PERM_COMMAND_MODIFY_POWER = 868, // reserved
|
||||
RBAC_PERM_COMMAND_DEBUG_SEND_PLAYER_CHOICE = 869, // reserved
|
||||
RBAC_PERM_COMMAND_DEBUG_THREATINFO = 870,
|
||||
RBAC_PERM_COMMAND_DEBUG_INSTANCESPAWN = 871,
|
||||
//
|
||||
// IF YOU ADD NEW PERMISSIONS, ADD THEM IN MASTER BRANCH AS WELL!
|
||||
//
|
||||
|
||||
@@ -311,6 +311,8 @@ class TC_GAME_API InstanceScript : public ZoneScript
|
||||
// Strong reference to the associated script module
|
||||
std::shared_ptr<ModuleReference> module_reference;
|
||||
#endif // #ifndef TRINITY_API_USE_DYNAMIC_LINKING
|
||||
|
||||
friend class debug_commandscript;
|
||||
};
|
||||
|
||||
#endif // TRINITY_INSTANCE_DATA_H
|
||||
|
||||
@@ -103,6 +103,7 @@ public:
|
||||
{ "boundary", rbac::RBAC_PERM_COMMAND_DEBUG_BOUNDARY, false, &HandleDebugBoundaryCommand, "" },
|
||||
{ "raidreset", rbac::RBAC_PERM_COMMAND_INSTANCE_UNBIND, false, &HandleDebugRaidResetCommand, "" },
|
||||
{ "neargraveyard", rbac::RBAC_PERM_COMMAND_NEARGRAVEYARD, false, &HandleDebugNearGraveyard, "" },
|
||||
{ "instancespawn", rbac::RBAC_PERM_COMMAND_DEBUG_INSTANCESPAWN, false, &HandleDebugInstanceSpawns, "" },
|
||||
};
|
||||
static std::vector<ChatCommand> commandTable =
|
||||
{
|
||||
@@ -1718,6 +1719,115 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleDebugInstanceSpawns(ChatHandler* handler, char const* args)
|
||||
{
|
||||
Player const* const player = handler->GetSession()->GetPlayer();
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
bool explain = false;
|
||||
uint32 groupID = 0;
|
||||
if (!stricmp(args, "explain"))
|
||||
explain = true;
|
||||
else
|
||||
groupID = atoi(args);
|
||||
|
||||
if (groupID && !sObjectMgr->GetSpawnGroupData(groupID))
|
||||
{
|
||||
handler->PSendSysMessage("There is no spawn group with ID %u.", groupID);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Map const* const map = player->GetMap();
|
||||
char const* const mapName = map->GetMapName();
|
||||
InstanceScript const* const instance = player->GetInstanceScript();
|
||||
if (!instance)
|
||||
{
|
||||
handler->PSendSysMessage("%s has no instance script.", mapName);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
if (!instance->_instanceSpawnGroups || instance->_instanceSpawnGroups->empty())
|
||||
{
|
||||
handler->PSendSysMessage("%s's instance script does not manage any spawn groups.", mapName);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
auto const& spawnGroups = *instance->_instanceSpawnGroups;
|
||||
std::unordered_map<uint32, std::set<std::tuple<bool, uint8, uint8>>> store;
|
||||
for (InstanceSpawnGroupInfo const& info : spawnGroups)
|
||||
{
|
||||
if (groupID && info.SpawnGroupId != groupID)
|
||||
continue;
|
||||
|
||||
bool isSpawn;
|
||||
if (info.Flags & InstanceSpawnGroupInfo::FLAG_BLOCK_SPAWN)
|
||||
isSpawn = false;
|
||||
else if (info.Flags & InstanceSpawnGroupInfo::FLAG_ACTIVATE_SPAWN)
|
||||
isSpawn = true;
|
||||
else
|
||||
continue;
|
||||
|
||||
store[info.SpawnGroupId].emplace(isSpawn, info.BossStateId, info.BossStates);
|
||||
}
|
||||
|
||||
if (groupID && store.find(groupID) == store.end())
|
||||
{
|
||||
handler->PSendSysMessage("%s's instance script does not manage group '%s'.", mapName, sObjectMgr->GetSpawnGroupData(groupID)->name.c_str());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!groupID)
|
||||
handler->PSendSysMessage("Spawn groups managed by %s (%u):", mapName, map->GetId());
|
||||
|
||||
for (auto const& pair : store)
|
||||
{
|
||||
SpawnGroupTemplateData const* groupData = sObjectMgr->GetSpawnGroupData(pair.first);
|
||||
assert(groupData); // checked by objectmgr on load
|
||||
if (explain)
|
||||
{
|
||||
handler->PSendSysMessage(" |-- '%s' (%u)", groupData->name, pair.first);
|
||||
bool isBlocked = false, isSpawned = false;
|
||||
for (auto const& tuple : pair.second)
|
||||
{
|
||||
bool const isSpawn = std::get<0>(tuple);
|
||||
uint8 const bossStateId = std::get<1>(tuple);
|
||||
EncounterState const actualState = instance->GetBossState(bossStateId);
|
||||
if (std::get<2>(tuple) & (1 << actualState))
|
||||
{
|
||||
if (isSpawn)
|
||||
{
|
||||
isSpawned = true;
|
||||
if (isBlocked)
|
||||
handler->PSendSysMessage(" | |-- '%s' would be allowed to spawn by boss state %u being %s, but this is overruled", groupData->name, bossStateId, InstanceScript::GetBossStateName(actualState));
|
||||
else
|
||||
handler->PSendSysMessage(" | |-- '%s' is allowed to spawn because boss state %u is %s.", groupData->name, bossStateId, InstanceScript::GetBossStateName(bossStateId));
|
||||
}
|
||||
else
|
||||
{
|
||||
isBlocked = true;
|
||||
handler->PSendSysMessage(" | |-- '%s' is blocked from spawning because boss state %u is %s.", groupData->name, bossStateId, InstanceScript::GetBossStateName(bossStateId));
|
||||
}
|
||||
}
|
||||
else
|
||||
handler->PSendSysMessage(" | |-- '%s' could've been %s if boss state %u matched mask %u; but it is %s -> %u, which does not match.",
|
||||
groupData->name, isSpawn ? "allowed to spawn" : "blocked from spawning", bossStateId, std::get<2>(tuple), InstanceScript::GetBossStateName(actualState), (1 << actualState));
|
||||
}
|
||||
if (isBlocked)
|
||||
handler->PSendSysMessage(" | |=> '%s' is not active due to a blocking rule being matched", groupData->name);
|
||||
else if (isSpawned)
|
||||
handler->PSendSysMessage(" | |=> '%s' is active due to a spawn rule being matched", groupData->name);
|
||||
else
|
||||
handler->PSendSysMessage(" | |=> '%s' is not active due to none of its rules being matched", groupData->name);
|
||||
}
|
||||
else
|
||||
handler->PSendSysMessage(" - '%s' (%u) is %sactive", groupData->name, pair.first, map->IsSpawnGroupActive(pair.first) ? "" : "not ");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_debug_commandscript()
|
||||
|
||||
Reference in New Issue
Block a user