feat(Scripts/Commands): Implement opendoor command (#21136)

This commit is contained in:
Andrew 2025-01-10 20:48:58 -03:00 committed by GitHub
parent 8b21b6150f
commit 07937d34da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 2 deletions

View File

@ -0,0 +1,9 @@
--
DELETE FROM `acore_string` WHERE `entry` IN (5086, 5087);
INSERT INTO `acore_string` (`entry`, `content_default`) VALUES
(5086, 'No doors found within range ({} yards).'),
(5087, 'Door {} (Entry: {}) opened!');
DELETE FROM `command` WHERE `name` = 'opendoor';
INSERT INTO `command` (`name`, `security`, `help`) VALUES
('opendoor', 1, 'Syntax: .opendoor [$range]\nOpens the nearest door within the range provided (default 5.0yd)');

View File

@ -1145,7 +1145,10 @@ enum AcoreStrings
LANG_CMD_GO_RESPAWN = 5085,
// Room for more strings 5086-9999
LANG_CMD_NO_DOOR_FOUND = 5086,
LANG_CMD_DOOR_OPENED = 5087,
// Room for more strings 5088-9999
// Level requirement notifications
LANG_SAY_REQ = 6604,

View File

@ -146,7 +146,8 @@ public:
{ "playall", HandlePlayAllCommand, SEC_GAMEMASTER, Console::No },
{ "skirmish", HandleSkirmishCommand, SEC_ADMINISTRATOR, Console::No },
{ "mailbox", HandleMailBoxCommand, SEC_MODERATOR, Console::No },
{ "string", HandleStringCommand, SEC_GAMEMASTER, Console::No }
{ "string", HandleStringCommand, SEC_GAMEMASTER, Console::No },
{ "opendoor", HandleOpenDoorCommand, SEC_GAMEMASTER, Console::No }
};
return commandTable;
@ -3034,6 +3035,19 @@ public:
return true;
}
}
static bool HandleOpenDoorCommand(ChatHandler* handler, Optional<float> range)
{
if (GameObject* go = handler->GetPlayer()->FindNearestGameObjectOfType(GAMEOBJECT_TYPE_DOOR, range ? *range : 5.0f))
{
go->SetGoState(GO_STATE_ACTIVE);
handler->PSendSysMessage(LANG_CMD_DOOR_OPENED, go->GetName(), go->GetEntry());
return true;
}
handler->SendErrorMessage(LANG_CMD_NO_DOOR_FOUND, range ? *range : 5.0f);
return false;
}
};
void AddSC_misc_commandscript()