mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-29 13:22:48 +01:00
Core/Commands: Add level 3 command for setting npc data. used for testing scripts.
This commit is contained in:
8
sql/updates/world/2012_05_09_01_world_commands.sql
Normal file
8
sql/updates/world/2012_05_09_01_world_commands.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
DELETE FROM `trinity_string` WHERE `entry` = 555;
|
||||
INSERT INTO `trinity_string` (`entry`,`content_default`) VALUES
|
||||
(555,"SetData performed on [GUID: %u, entry: %u, name: %s] Field: %u, Data: %u, with %s");
|
||||
|
||||
DELETE FROM `command` WHERE `name` = "npc set data";
|
||||
INSERT INTO `command` (`name`,`security`,`help`) VALUES
|
||||
("npc set data", 3, "Syntax: .npc set data $field $data
|
||||
Sets data for the selected creature. Used for testing Scripting");
|
||||
@@ -522,8 +522,9 @@ enum TrinityStrings
|
||||
LANG_YOURS_EXPLORE_SET_ALL = 553,
|
||||
LANG_YOURS_EXPLORE_SET_NOTHING = 554,
|
||||
|
||||
LANG_NPC_SETDATA = 555,
|
||||
|
||||
//! Old ones now free:
|
||||
// LANG_HOVER_ENABLED = 555,
|
||||
// LANG_HOVER_DISABLED = 556,
|
||||
|
||||
LANG_YOURS_LEVEL_UP = 557,
|
||||
|
||||
@@ -73,6 +73,7 @@ public:
|
||||
{ "phase", SEC_GAMEMASTER, false, &HandleNpcSetPhaseCommand, "", NULL },
|
||||
{ "spawndist", SEC_GAMEMASTER, false, &HandleNpcSetSpawnDistCommand, "", NULL },
|
||||
{ "spawntime", SEC_GAMEMASTER, false, &HandleNpcSetSpawnTimeCommand, "", NULL },
|
||||
{ "data", SEC_ADMINISTRATOR, false, &HandleNpcSetDataCommand, "", NULL },
|
||||
//{ TODO: fix or remove these commands
|
||||
{ "name", SEC_GAMEMASTER, false, &HandleNpcSetNameCommand, "", NULL },
|
||||
{ "subname", SEC_GAMEMASTER, false, &HandleNpcSetSubNameCommand, "", NULL },
|
||||
@@ -524,6 +525,39 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
//set data of creature for testing scripting
|
||||
static bool HandleNpcSetDataCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* arg1 = strtok((char*)args, " ");
|
||||
char* arg2 = strtok((char*)NULL, "");
|
||||
|
||||
if (!arg1 || !arg2)
|
||||
return false;
|
||||
|
||||
uint32 data_1 = (uint32)atoi(arg1);
|
||||
uint32 data_2 = (uint32)atoi(arg2);
|
||||
|
||||
if (!data_1 || !data_2)
|
||||
return false;
|
||||
|
||||
Creature* creature = handler->getSelectedCreature();
|
||||
|
||||
if (!creature)
|
||||
{
|
||||
handler->SendSysMessage(LANG_SELECT_CREATURE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
creature->AI()->SetData(data_1, data_2);
|
||||
std::string AIorScript = creature->GetAIName() != "" ? "AI type: " + creature->GetAIName() : (creature->GetScriptName() != "" ? "Script Name: " + creature->GetScriptName() : "No AI or Script Name Set");
|
||||
handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID(), creature->GetEntry(), creature->GetName(), data_1, data_2, AIorScript);
|
||||
return true;
|
||||
}
|
||||
|
||||
//npc follow handling
|
||||
static bool HandleNpcFollowCommand(ChatHandler* handler, const char* /*args*/)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user