Core/Scripts: Convert more commands over to CommandScripts (moves gobject, honor, quest, reload, titles and wp commands to scripts) - Patch by Paradox
(Also fixes a minor visual error on GM-listings (gm ingame/gm list) when the respective user had an R in his/her name). Closes issue 4792. --HG-- branch : trunk
This commit is contained in:
@@ -160,22 +160,6 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand gobjectCommandTable[] =
|
||||
{
|
||||
{ "activate", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleActivateObjectCommand>, "", NULL },
|
||||
{ "add", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectAddCommand>, "", NULL },
|
||||
{ "delete", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectDeleteCommand>, "", NULL },
|
||||
{ "info", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectInfoCommand>, "", NULL },
|
||||
{ "move", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectMoveCommand>, "", NULL },
|
||||
{ "near", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectNearCommand>, "", NULL },
|
||||
{ "state", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectStateCommand>, "", NULL },
|
||||
{ "setphase", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectPhaseCommand>, "", NULL },
|
||||
{ "target", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectTargetCommand>, "", NULL },
|
||||
{ "tempadd", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleTempGameObjectCommand>, "", NULL },
|
||||
{ "turn", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleGameObjectTurnCommand>, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand groupCommandTable[] =
|
||||
{
|
||||
{ "leader", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleGroupLeaderCommand>, "", NULL },
|
||||
@@ -194,14 +178,6 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand honorCommandTable[] =
|
||||
{
|
||||
{ "add", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleHonorAddCommand>, "", NULL },
|
||||
{ "addkill", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleHonorAddKillCommand>, "", NULL },
|
||||
{ "update", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleHonorUpdateCommand>, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand instanceCommandTable[] =
|
||||
{
|
||||
{ "listbinds", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleInstanceListBindsCommand>, "", NULL },
|
||||
@@ -264,124 +240,6 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand questCommandTable[] =
|
||||
{
|
||||
{ "add", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleQuestAdd>, "", NULL },
|
||||
{ "complete", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleQuestComplete>, "", NULL },
|
||||
{ "remove", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleQuestRemove>, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand reloadCommandTable[] =
|
||||
{
|
||||
{ "all", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllCommand>, "", NULL },
|
||||
{ "all_achievement",SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllAchievementCommand>,"", NULL },
|
||||
{ "all_area", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllAreaCommand>, "", NULL },
|
||||
{ "all_eventai", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllEventAICommand>, "", NULL },
|
||||
{ "all_gossips", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllGossipsCommand>, "", NULL },
|
||||
{ "all_item", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllItemCommand>, "", NULL },
|
||||
{ "all_locales", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllLocalesCommand>, "", NULL },
|
||||
{ "all_loot", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllLootCommand>, "", NULL },
|
||||
{ "all_npc", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllNpcCommand>, "", NULL },
|
||||
{ "all_quest", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllQuestCommand>, "", NULL },
|
||||
{ "all_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllScriptsCommand>, "", NULL },
|
||||
{ "all_spell", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAllSpellCommand>, "", NULL },
|
||||
|
||||
{ "config", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadConfigCommand>, "", NULL },
|
||||
|
||||
{ "access_requirement", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAccessRequirementCommand>, "", NULL },
|
||||
{ "achievement_criteria_data", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAchievementCriteriaDataCommand>, "", NULL },
|
||||
{ "achievement_reward", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAchievementRewardCommand>, "", NULL },
|
||||
{ "areatrigger_involvedrelation", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadQuestAreaTriggersCommand>, "", NULL },
|
||||
{ "areatrigger_tavern", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAreaTriggerTavernCommand>, "", NULL },
|
||||
{ "areatrigger_teleport", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAreaTriggerTeleportCommand>, "", NULL },
|
||||
{ "autobroadcast", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAutobroadcastCommand>, "", NULL },
|
||||
{ "command", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadCommandCommand>, "", NULL },
|
||||
{ "conditions", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadConditions>, "", NULL },
|
||||
{ "creature_text", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadCreatureText>, "", NULL },
|
||||
{ "creature_ai_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadEventAIScriptsCommand>, "", NULL },
|
||||
{ "creature_ai_summons", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadEventAISummonsCommand>, "", NULL },
|
||||
{ "creature_ai_texts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadEventAITextsCommand>, "", NULL },
|
||||
{ "creature_involvedrelation", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadCreatureQuestInvRelationsCommand>,"",NULL },
|
||||
{ "creature_linked_respawn", SEC_GAMEMASTER, true, OldHandler<&ChatHandler::HandleReloadCreatureLinkedRespawnCommand>, "", NULL },
|
||||
{ "creature_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesCreatureCommand>, "", NULL },
|
||||
{ "creature_onkill_reputation", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadOnKillReputationCommand>, "", NULL },
|
||||
{ "creature_questrelation", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadCreatureQuestRelationsCommand>, "", NULL },
|
||||
{ "creature_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadCreatureTemplateCommand>, "", NULL },
|
||||
//{ "db_script_string", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadDbScriptStringCommand>, "", NULL },
|
||||
{ "disables", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadDisablesCommand>, "", NULL },
|
||||
{ "disenchant_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesDisenchantCommand>, "", NULL },
|
||||
{ "event_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadEventScriptsCommand>, "", NULL },
|
||||
{ "fishing_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesFishingCommand>, "", NULL },
|
||||
{ "game_graveyard_zone", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGameGraveyardZoneCommand>, "", NULL },
|
||||
{ "game_tele", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGameTeleCommand>, "", NULL },
|
||||
{ "gameobject_involvedrelation", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGOQuestInvRelationsCommand>, "", NULL },
|
||||
{ "gameobject_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesGameobjectCommand>, "", NULL },
|
||||
{ "gameobject_questrelation", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGOQuestRelationsCommand>, "", NULL },
|
||||
{ "gameobject_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGameObjectScriptsCommand>, "", NULL },
|
||||
{ "gossip_menu", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGossipMenuCommand>, "", NULL },
|
||||
{ "gossip_menu_option", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGossipMenuOptionCommand>, "", NULL },
|
||||
{ "gossip_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadGossipScriptsCommand>, "", NULL },
|
||||
{ "item_enchantment_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadItemEnchantementsCommand>, "", NULL },
|
||||
{ "item_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesItemCommand>, "", NULL },
|
||||
{ "item_set_names", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadItemSetNamesCommand>, "", NULL },
|
||||
{ "lfg_dungeon_encounters", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLfgEncountersCommand>, "", NULL },
|
||||
{ "lfg_dungeon_rewards", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLfgRewardsCommand>, "", NULL },
|
||||
{ "locales_achievement_reward", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesAchievementRewardCommand>,"", NULL },
|
||||
{ "locales_creature", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesCreatureCommand>, "", NULL },
|
||||
{ "locales_gameobject", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesGameobjectCommand>, "", NULL },
|
||||
{ "locales_gossip_menu_option", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesGossipMenuOptionCommand>, "", NULL },
|
||||
{ "locales_item", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesItemCommand>, "", NULL },
|
||||
{ "locales_item_set_name", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesItemSetNameCommand>, "", NULL },
|
||||
{ "locales_npc_text", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesNpcTextCommand>, "", NULL },
|
||||
{ "locales_page_text", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesPageTextCommand>, "", NULL },
|
||||
{ "locales_points_of_interest", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesPointsOfInterestCommand>, "", NULL },
|
||||
{ "locales_quest", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLocalesQuestCommand>, "", NULL },
|
||||
{ "mail_level_reward", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadMailLevelRewardCommand>, "", NULL },
|
||||
{ "mail_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesMailCommand>, "", NULL },
|
||||
{ "milling_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesMillingCommand>, "", NULL },
|
||||
{ "npc_gossip", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadNpcGossipCommand>, "", NULL },
|
||||
{ "npc_spellclick_spells", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellClickSpellsCommand>, "",NULL},
|
||||
{ "npc_trainer", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadNpcTrainerCommand>, "", NULL },
|
||||
{ "npc_vendor", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadNpcVendorCommand>, "", NULL },
|
||||
{ "page_text", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadPageTextsCommand>, "", NULL },
|
||||
{ "pickpocketing_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesPickpocketingCommand>,"",NULL},
|
||||
{ "points_of_interest", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadPointsOfInterestCommand>, "", NULL },
|
||||
{ "prospecting_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesProspectingCommand>,"", NULL },
|
||||
{ "quest_end_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadQuestEndScriptsCommand>, "", NULL },
|
||||
{ "quest_poi", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadQuestPOICommand>, "", NULL },
|
||||
{ "quest_start_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadQuestStartScriptsCommand>, "", NULL },
|
||||
{ "quest_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadQuestTemplateCommand>, "", NULL },
|
||||
{ "reference_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesReferenceCommand>, "", NULL },
|
||||
{ "reserved_name", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadReservedNameCommand>, "", NULL },
|
||||
{ "reputation_reward_rate", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadReputationRewardRateCommand>, "", NULL },
|
||||
{ "reputation_spillover_template",SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadReputationRewardRateCommand>, "", NULL },
|
||||
{ "smart_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSmartScripts>, "", NULL },
|
||||
{ "skill_discovery_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSkillDiscoveryTemplateCommand>, "", NULL },
|
||||
{ "skill_extra_item_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSkillExtraItemTemplateCommand>, "", NULL },
|
||||
{ "skill_fishing_base_level", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSkillFishingBaseLevelCommand>, "", NULL },
|
||||
{ "skinning_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesSkinningCommand>, "", NULL },
|
||||
{ "spell_required", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellRequiredCommand>, "", NULL },
|
||||
{ "spell_area", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellAreaCommand>, "", NULL },
|
||||
{ "spell_bonus_data", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellBonusesCommand>, "", NULL },
|
||||
{ "spell_group", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellGroupsCommand>, "", NULL },
|
||||
{ "spell_learn_spell", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellLearnSpellCommand>, "", NULL },
|
||||
{ "spell_loot_template", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadLootTemplatesSpellCommand>, "", NULL },
|
||||
{ "spell_linked_spell", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellLinkedSpellCommand>, "", NULL },
|
||||
{ "spell_pet_auras", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellPetAurasCommand>, "", NULL },
|
||||
{ "spell_proc_event", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellProcEventCommand>, "", NULL },
|
||||
{ "spell_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellScriptsCommand>, "", NULL },
|
||||
{ "spell_target_position", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellTargetPositionCommand>, "", NULL },
|
||||
{ "spell_threats", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellThreatsCommand>, "", NULL },
|
||||
{ "spell_group_stack_rules", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadSpellGroupStackRulesCommand>, "", NULL },
|
||||
{ "trinity_string", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadTrinityStringCommand>, "", NULL },
|
||||
{ "auctions", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadAuctionsCommand>, "", NULL },
|
||||
{ "waypoint_scripts", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleReloadWpScriptsCommand>, "", NULL },
|
||||
{ "gm_tickets", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleGMTicketReloadCommand>, "", NULL },
|
||||
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand resetCommandTable[] =
|
||||
{
|
||||
{ "achievements", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleResetAchievementsCommand>, "", NULL },
|
||||
@@ -456,15 +314,6 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand titlesCommandTable[] =
|
||||
{
|
||||
{ "add", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleTitlesAddCommand>, "", NULL },
|
||||
{ "current", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleTitlesCurrentCommand>, "", NULL },
|
||||
{ "remove", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleTitlesRemoveCommand>, "", NULL },
|
||||
{ "setmask", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleTitlesSetMaskCommand>, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand unbanCommandTable[] =
|
||||
{
|
||||
{ "account", SEC_ADMINISTRATOR, true, OldHandler<&ChatHandler::HandleUnBanAccountCommand>, "", NULL },
|
||||
@@ -474,17 +323,6 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand wpCommandTable[] =
|
||||
{
|
||||
{ "show", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleWpShowCommand>, "", NULL },
|
||||
{ "addwp", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleWpAddCommand>, "", NULL },
|
||||
{ "load", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleWpLoadPathCommand>, "", NULL },
|
||||
{ "modify", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleWpModifyCommand>, "", NULL },
|
||||
{ "event", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleWpEventCommand>, "", NULL },
|
||||
{ "unload", SEC_GAMEMASTER, false, OldHandler<&ChatHandler::HandleWpUnLoadPathCommand>, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand ticketResponseCommandTable[] =
|
||||
{
|
||||
{ "append", SEC_MODERATOR, false, OldHandler<&ChatHandler::HandleGMTicketResponseAppendCommand>, "", NULL },
|
||||
@@ -515,12 +353,6 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "character", SEC_GAMEMASTER, true, NULL, "", characterCommandTable},
|
||||
{ "gobject", SEC_GAMEMASTER, false, NULL, "", gobjectCommandTable },
|
||||
{ "honor", SEC_GAMEMASTER, false, NULL, "", honorCommandTable },
|
||||
{ "wp", SEC_GAMEMASTER, false, NULL, "", wpCommandTable },
|
||||
{ "titles", SEC_GAMEMASTER, false, NULL, "", titlesCommandTable },
|
||||
{ "quest", SEC_ADMINISTRATOR, false, NULL, "", questCommandTable },
|
||||
{ "reload", SEC_ADMINISTRATOR, true, NULL, "", reloadCommandTable },
|
||||
{ "list", SEC_ADMINISTRATOR, true, NULL, "", listCommandTable },
|
||||
{ "lookup", SEC_ADMINISTRATOR, true, NULL, "", lookupCommandTable },
|
||||
{ "pdump", SEC_ADMINISTRATOR, true, NULL, "", pdumpCommandTable },
|
||||
@@ -533,7 +365,6 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ "channel", SEC_ADMINISTRATOR, true, NULL, "", channelCommandTable },
|
||||
|
||||
{ "pet", SEC_GAMEMASTER, false, NULL, "", petCommandTable },
|
||||
{ "loadpath", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleReloadAllPaths>, "", NULL },
|
||||
{ "ticket", SEC_MODERATOR, false, NULL, "", ticketCommandTable },
|
||||
|
||||
{ "aura", SEC_ADMINISTRATOR, false, OldHandler<&ChatHandler::HandleAuraCommand>, "", NULL },
|
||||
@@ -613,9 +444,9 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
// can't use vector as vector storage is implementation-dependent, eg, there can be alignment gaps between elements
|
||||
static ChatCommand* commandTableCache = 0;
|
||||
|
||||
if (load_command_table)
|
||||
if (LoadCommandTable())
|
||||
{
|
||||
load_command_table = false;
|
||||
SetLoadCommandTable(false);
|
||||
|
||||
{
|
||||
// count total number of top-level commands
|
||||
@@ -891,7 +722,7 @@ bool ChatHandler::ExecuteCommandInTable(ChatCommand *table, const char* text, co
|
||||
}
|
||||
}
|
||||
// some commands have custom error messages. Don't send the default one in these cases.
|
||||
else if (!sentErrorMessage)
|
||||
else if (!HasSentErrorMessage())
|
||||
{
|
||||
if (!table[i].Help.empty())
|
||||
SendSysMessage(table[i].Help.c_str());
|
||||
|
||||
+3
-137
@@ -79,7 +79,6 @@ class ChatHandler
|
||||
static ChatCommand* getCommandTable();
|
||||
|
||||
bool isValidChatMessage(const char* msg);
|
||||
bool HasSentErrorMessage() { return sentErrorMessage;}
|
||||
void SendGlobalSysMessage(const char *str);
|
||||
|
||||
bool hasStringAbbr(const char* name, const char* part);
|
||||
@@ -120,7 +119,10 @@ class ChatHandler
|
||||
|
||||
GameObject* GetNearbyGameObject();
|
||||
GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry);
|
||||
bool HasSentErrorMessage() { return sentErrorMessage;}
|
||||
void SetSentErrorMessage(bool val){ sentErrorMessage = val;};
|
||||
static bool LoadCommandTable() { return load_command_table;}
|
||||
static void SetLoadCommandTable(bool val){ load_command_table = val;};
|
||||
|
||||
protected:
|
||||
explicit ChatHandler() : m_session(NULL) {} // for CLI subclass
|
||||
@@ -171,26 +173,12 @@ class ChatHandler
|
||||
bool HandleBindSightCommand(const char* args);
|
||||
bool HandleUnbindSightCommand(const char* args);
|
||||
|
||||
bool HandleGameObjectAddCommand(const char* args);
|
||||
bool HandleGameObjectDeleteCommand(const char* args);
|
||||
bool HandleGameObjectInfoCommand(const char* args);
|
||||
bool HandleGameObjectMoveCommand(const char* args);
|
||||
bool HandleGameObjectNearCommand(const char* args);
|
||||
bool HandleGameObjectPhaseCommand(const char* args);
|
||||
bool HandleGameObjectStateCommand(const char* args);
|
||||
bool HandleGameObjectTargetCommand(const char* args);
|
||||
bool HandleGameObjectTurnCommand(const char* args);
|
||||
|
||||
bool HandleGuildCreateCommand(const char* args);
|
||||
bool HandleGuildInviteCommand(const char* args);
|
||||
bool HandleGuildUninviteCommand(const char* args);
|
||||
bool HandleGuildRankCommand(const char* args);
|
||||
bool HandleGuildDeleteCommand(const char* args);
|
||||
|
||||
bool HandleHonorAddCommand(const char* args);
|
||||
bool HandleHonorAddKillCommand(const char* args);
|
||||
bool HandleHonorUpdateCommand(const char* args);
|
||||
|
||||
bool HandleInstanceListBindsCommand(const char* args);
|
||||
bool HandleInstanceUnbindCommand(const char* args);
|
||||
bool HandleInstanceStatsCommand(const char* args);
|
||||
@@ -222,115 +210,6 @@ class ChatHandler
|
||||
bool HandlePDumpLoadCommand(const char *args);
|
||||
bool HandlePDumpWriteCommand(const char *args);
|
||||
|
||||
bool HandleQuestAdd(const char * args);
|
||||
bool HandleQuestRemove(const char * args);
|
||||
bool HandleQuestComplete(const char * args);
|
||||
|
||||
bool HandleReloadAllCommand(const char* args);
|
||||
bool HandleReloadAllAchievementCommand(const char* args);
|
||||
bool HandleReloadAllAreaCommand(const char* args);
|
||||
bool HandleReloadAllGossipsCommand(const char* args);
|
||||
bool HandleReloadAllItemCommand(const char* args);
|
||||
bool HandleReloadAllLootCommand(const char* args);
|
||||
bool HandleReloadAllNpcCommand(const char* args);
|
||||
bool HandleReloadAllQuestCommand(const char* args);
|
||||
bool HandleReloadAllScriptsCommand(const char* args);
|
||||
bool HandleReloadAllEventAICommand(const char* args);
|
||||
bool HandleReloadAllSpellCommand(const char* args);
|
||||
bool HandleReloadAllLocalesCommand(const char* args);
|
||||
|
||||
bool HandleReloadConfigCommand(const char* args);
|
||||
|
||||
bool HandleReloadAccessRequirementCommand(const char* args);
|
||||
bool HandleReloadAchievementCriteriaDataCommand(const char* args);
|
||||
bool HandleReloadAchievementRewardCommand(const char* args);
|
||||
bool HandleReloadAreaTriggerTavernCommand(const char* args);
|
||||
bool HandleReloadAreaTriggerTeleportCommand(const char* args);
|
||||
bool HandleReloadAutobroadcastCommand(const char* args);
|
||||
bool HandleReloadEventScriptsCommand(const char* args);
|
||||
bool HandleReloadEventAITextsCommand(const char* args);
|
||||
bool HandleReloadEventAISummonsCommand(const char* args);
|
||||
bool HandleReloadEventAIScriptsCommand(const char* args);
|
||||
bool HandleReloadCommandCommand(const char* args);
|
||||
bool HandleReloadOnKillReputationCommand(const char* args);
|
||||
bool HandleReloadCreatureTemplateCommand(const char* args);
|
||||
bool HandleReloadCreatureQuestRelationsCommand(const char* args);
|
||||
bool HandleReloadCreatureQuestInvRelationsCommand(const char* args);
|
||||
bool HandleReloadCreatureLinkedRespawnCommand(const char* args);
|
||||
bool HandleReloadDbScriptStringCommand(const char* args);
|
||||
bool HandleReloadGameGraveyardZoneCommand(const char* args);
|
||||
bool HandleReloadGameObjectScriptsCommand(const char* args);
|
||||
bool HandleReloadGameTeleCommand(const char* args);
|
||||
bool HandleReloadGossipMenuCommand(const char* args);
|
||||
bool HandleReloadGossipMenuOptionCommand(const char* args);
|
||||
bool HandleReloadGossipScriptsCommand(const char* args);
|
||||
bool HandleReloadGOQuestRelationsCommand(const char* args);
|
||||
bool HandleReloadGOQuestInvRelationsCommand(const char* args);
|
||||
bool HandleReloadItemEnchantementsCommand(const char* args);
|
||||
bool HandleReloadItemSetNamesCommand(const char* args);
|
||||
bool HandleReloadLfgEncountersCommand(const char* args);
|
||||
bool HandleReloadLfgRewardsCommand(const char* args);
|
||||
bool HandleReloadLocalesAchievementRewardCommand(const char* args);
|
||||
bool HandleReloadLocalesCreatureCommand(const char* args);
|
||||
bool HandleReloadLocalesGameobjectCommand(const char* args);
|
||||
bool HandleReloadLocalesGossipMenuOptionCommand(const char* args);
|
||||
bool HandleReloadLocalesItemCommand(const char* args);
|
||||
bool HandleReloadLocalesItemSetNameCommand(const char* args);
|
||||
bool HandleReloadLocalesNpcTextCommand(const char* args);
|
||||
bool HandleReloadLocalesPageTextCommand(const char* args);
|
||||
bool HandleReloadLocalesPointsOfInterestCommand(const char* args);
|
||||
bool HandleReloadLocalesQuestCommand(const char* args);
|
||||
// bool HandleReloadAuctionsCommand(const char* args);
|
||||
bool HandleReloadLootTemplatesCreatureCommand(const char* args);
|
||||
bool HandleReloadLootTemplatesDisenchantCommand(const char* args);
|
||||
bool HandleReloadLootTemplatesFishingCommand(const char* args);
|
||||
bool HandleReloadLootTemplatesGameobjectCommand(const char* args);
|
||||
bool HandleReloadLootTemplatesItemCommand(const char* args);
|
||||
bool HandleReloadLootTemplatesMailCommand(const char* args);
|
||||
bool HandleReloadMailLevelRewardCommand(const char* args);
|
||||
bool HandleReloadLootTemplatesMillingCommand(const char* args);
|
||||
bool HandleReloadLootTemplatesPickpocketingCommand(const char* args);
|
||||
bool HandleReloadLootTemplatesProspectingCommand(const char* args);
|
||||
bool HandleReloadLootTemplatesReferenceCommand(const char* args);
|
||||
bool HandleReloadLootTemplatesSkinningCommand(const char* args);
|
||||
bool HandleReloadLootTemplatesSpellCommand(const char* args);
|
||||
bool HandleReloadTrinityStringCommand(const char* args);
|
||||
bool HandleReloadNpcGossipCommand(const char* args);
|
||||
bool HandleReloadNpcTrainerCommand(const char* args);
|
||||
bool HandleReloadNpcVendorCommand(const char* args);
|
||||
bool HandleReloadPageTextsCommand(const char* args);
|
||||
bool HandleReloadPointsOfInterestCommand(const char* args);
|
||||
bool HandleReloadSpellClickSpellsCommand(const char* args);
|
||||
bool HandleReloadQuestAreaTriggersCommand(const char* args);
|
||||
bool HandleReloadQuestEndScriptsCommand(const char* args);
|
||||
bool HandleReloadQuestPOICommand(const char* args);
|
||||
bool HandleReloadQuestStartScriptsCommand(const char* args);
|
||||
bool HandleReloadQuestTemplateCommand(const char* args);
|
||||
bool HandleReloadReservedNameCommand(const char*);
|
||||
bool HandleReloadReputationRewardRateCommand(const char* args);
|
||||
bool HandleReloadReputationSpilloverTemplateCommand(const char* args);
|
||||
bool HandleReloadSkillDiscoveryTemplateCommand(const char* args);
|
||||
bool HandleReloadSkillExtraItemTemplateCommand(const char* args);
|
||||
bool HandleReloadSkillFishingBaseLevelCommand(const char* args);
|
||||
bool HandleReloadSpellRequiredCommand(const char* args);
|
||||
bool HandleReloadSpellAreaCommand(const char* args);
|
||||
bool HandleReloadSpellGroupsCommand(const char* args);
|
||||
bool HandleReloadSpellLearnSpellCommand(const char* args);
|
||||
bool HandleReloadSpellLinkedSpellCommand(const char* args);
|
||||
bool HandleReloadSpellProcEventCommand(const char* args);
|
||||
bool HandleReloadSpellBonusesCommand(const char* args);
|
||||
bool HandleReloadSpellScriptsCommand(const char* args);
|
||||
bool HandleReloadSpellTargetPositionCommand(const char* args);
|
||||
bool HandleReloadSpellThreatsCommand(const char* args);
|
||||
bool HandleReloadSpellPetAurasCommand(const char* args);
|
||||
bool HandleReloadDisablesCommand(const char* args);
|
||||
bool HandleReloadSpellGroupStackRulesCommand(const char* args);
|
||||
bool HandleReloadAuctionsCommand(const char* args);
|
||||
bool HandleReloadWpScriptsCommand(const char* args);
|
||||
bool HandleReloadConditions(const char* args);
|
||||
bool HandleReloadCreatureText(const char* args);
|
||||
bool HandleReloadSmartScripts(const char* args);
|
||||
|
||||
bool HandleResetAchievementsCommand(const char * args);
|
||||
bool HandleResetAllCommand(const char * args);
|
||||
bool HandleResetHonorCommand(const char * args);
|
||||
@@ -361,24 +240,11 @@ class ChatHandler
|
||||
bool HandleServerSetLogFileLevelCommand(const char* args);
|
||||
bool HandleServerSetDiffTimeCommand(const char* args);
|
||||
|
||||
bool HandleTitlesAddCommand(const char* args);
|
||||
bool HandleTitlesCurrentCommand(const char* args);
|
||||
bool HandleTitlesRemoveCommand(const char* args);
|
||||
bool HandleTitlesSetMaskCommand(const char* args);
|
||||
|
||||
bool HandleUnBanAccountCommand(const char* args);
|
||||
bool HandleUnBanAccountByCharCommand(const char* args);
|
||||
bool HandleUnBanCharacterCommand(const char* args);
|
||||
bool HandleUnBanIPCommand(const char* args);
|
||||
|
||||
bool HandleWpAddCommand(const char* args);
|
||||
bool HandleWpLoadPathCommand(const char* args);
|
||||
bool HandleWpUnLoadPathCommand(const char* args);
|
||||
bool HandleWpModifyCommand(const char* args);
|
||||
bool HandleWpEventCommand(const char* args);
|
||||
bool HandleWpShowCommand(const char* args);
|
||||
bool HandleReloadAllPaths(const char *args);
|
||||
|
||||
bool HandleHelpCommand(const char* args);
|
||||
bool HandleCommandsCommand(const char* args);
|
||||
bool HandleStartCommand(const char* args);
|
||||
|
||||
@@ -16,25 +16,4 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Common.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "Vehicle.h"
|
||||
#include "Player.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Chat.h"
|
||||
#include "Log.h"
|
||||
#include "Unit.h"
|
||||
#include "GossipDef.h"
|
||||
#include "Language.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
#include <fstream>
|
||||
#include "ObjectMgr.h"
|
||||
#include "Cell.h"
|
||||
#include "CellImpl.h"
|
||||
#include "GridNotifiers.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
// This file is deprecated
|
||||
// This file is deprecated
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -427,12 +427,6 @@ bool ChatHandler::HandleGMTicketDeleteByIdCommand(const char* args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleGMTicketReloadCommand(const char* /* args */)
|
||||
{
|
||||
sTicketMgr.LoadGMTickets();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleToggleGMTicketSystem(const char* /* args */)
|
||||
{
|
||||
sTicketMgr.SetStatus(!sTicketMgr.GetStatus());
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ScriptPCH.h"
|
||||
#include "ScriptLoader.h"
|
||||
|
||||
|
||||
@@ -51,10 +50,16 @@ void AddSC_debug_commandscript();
|
||||
void AddSC_event_commandscript();
|
||||
void AddSC_gm_commandscript();
|
||||
void AddSC_go_commandscript();
|
||||
void AddSC_gobject_commandscript();
|
||||
void AddSC_honor_commandscript();
|
||||
void AddSC_learn_commandscript();
|
||||
void AddSC_modify_commandscript();
|
||||
void AddSC_npc_commandscript();
|
||||
void AddSC_quest_commandscript();
|
||||
void AddSC_reload_commandscript();
|
||||
void AddSC_tele_commandscript();
|
||||
void AddSC_titles_commandscript();
|
||||
void AddSC_wp_commandscript();
|
||||
|
||||
#ifdef SCRIPTS
|
||||
//world
|
||||
@@ -629,10 +634,16 @@ void AddCommandScripts()
|
||||
AddSC_event_commandscript();
|
||||
AddSC_gm_commandscript();
|
||||
AddSC_go_commandscript();
|
||||
AddSC_gobject_commandscript();
|
||||
AddSC_honor_commandscript();
|
||||
AddSC_learn_commandscript();
|
||||
AddSC_modify_commandscript();
|
||||
AddSC_npc_commandscript();
|
||||
AddSC_quest_commandscript();
|
||||
AddSC_reload_commandscript();
|
||||
AddSC_tele_commandscript();
|
||||
AddSC_titles_commandscript();
|
||||
AddSC_wp_commandscript();
|
||||
}
|
||||
|
||||
void AddWorldScripts()
|
||||
|
||||
@@ -81,6 +81,7 @@ include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/AI/CoreAI
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/AI/EventAI
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/AI/ScriptedAI
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/AI/SmartScripts
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/AuctionHouse
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Battlegrounds
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Battlegrounds/Zones
|
||||
|
||||
@@ -11,12 +11,12 @@ set(scripts_STAT_SRCS
|
||||
Commands/cs_tele.cpp
|
||||
# Commands/cs_character.cpp
|
||||
Commands/cs_event.cpp
|
||||
# Commands/cs_gobject.cpp
|
||||
# Commands/cs_honor.cpp
|
||||
# Commands/cs_wp.cpp
|
||||
# Commands/cs_titles.cpp
|
||||
# Commands/cs_quest.cpp
|
||||
# Commands/cs_reload.cpp
|
||||
Commands/cs_gobject.cpp
|
||||
Commands/cs_honor.cpp
|
||||
Commands/cs_wp.cpp
|
||||
Commands/cs_titles.cpp
|
||||
Commands/cs_quest.cpp
|
||||
Commands/cs_reload.cpp
|
||||
# Commands/cs_list.cpp
|
||||
# Commands/cs_lookup.cpp
|
||||
# Commands/cs_pdump.cpp
|
||||
@@ -27,7 +27,6 @@ set(scripts_STAT_SRCS
|
||||
# Commands/cs_server.cpp
|
||||
# Commands/cs_channel.cpp
|
||||
# Commands/cs_pet.cpp
|
||||
# Commands/cs_loadpath.cpp
|
||||
# Commands/cs_ticket.cpp
|
||||
# Commands/cs_aura.cpp
|
||||
# Commands/cs_unaura.cpp
|
||||
|
||||
@@ -133,10 +133,13 @@ class gm_commandscript : public CommandScript
|
||||
const char* name = itr->second->GetName();
|
||||
uint8 security = itr_sec;
|
||||
uint8 max = ((16 - strlen(name)) / 2);
|
||||
uint8 max2 = max;
|
||||
if (((max)+(max2)+(strlen(name))) == 16)
|
||||
max2 = ((max)-1);
|
||||
if (handler->GetSession())
|
||||
handler->PSendSysMessage("|%s GMLevel %u", name, security);
|
||||
handler->PSendSysMessage("| %s GMLevel %u", name, security);
|
||||
else
|
||||
handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max, " ", security);
|
||||
handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security);
|
||||
}
|
||||
}
|
||||
if (footer)
|
||||
@@ -162,10 +165,13 @@ class gm_commandscript : public CommandScript
|
||||
const char* name = fields[0].GetCString();
|
||||
uint8 security = fields[1].GetUInt8();
|
||||
uint8 max = ((16 - strlen(name)) / 2);
|
||||
uint8 max2 = max;
|
||||
if (((max)+(max2)+(strlen(name))) == 16)
|
||||
max2 = ((max)-1);
|
||||
if (handler->GetSession())
|
||||
handler->PSendSysMessage("|%s GMLevel %u", name, security);
|
||||
handler->PSendSysMessage("| %s GMLevel %u", name, security);
|
||||
else
|
||||
handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max, " ", security);
|
||||
handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security);
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
|
||||
@@ -0,0 +1,677 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2010 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: gobject_commandscript
|
||||
%Complete: 100
|
||||
Comment: All gobject related commands
|
||||
Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "GameEventMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "PoolMgr.h"
|
||||
#include "MapManager.h"
|
||||
#include "Chat.h"
|
||||
|
||||
class gobject_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
gobject_commandscript() : CommandScript("gobject_commandscript") { }
|
||||
|
||||
ChatCommand* GetCommands() const
|
||||
{
|
||||
static ChatCommand gobjectAddCommandTable[] =
|
||||
{
|
||||
{ "temp", SEC_GAMEMASTER, false, &HandleGameObjectAddTempCommand, "", NULL },
|
||||
{ "", SEC_GAMEMASTER, false, &HandleGameObjectAddCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
static ChatCommand gobjectSetCommandTable[] =
|
||||
{
|
||||
{ "phase", SEC_GAMEMASTER, false, &HandleGameObjectSetPhaseCommand, "", NULL },
|
||||
{ "state", SEC_GAMEMASTER, false, &HandleGameObjectSetStateCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
static ChatCommand gobjectCommandTable[] =
|
||||
{
|
||||
{ "activate", SEC_GAMEMASTER, false, &HandleGameObjectActivateCommand, "", NULL },
|
||||
{ "delete", SEC_GAMEMASTER, false, &HandleGameObjectDeleteCommand, "", NULL },
|
||||
{ "info", SEC_GAMEMASTER, false, &HandleGameObjectInfoCommand, "", NULL },
|
||||
{ "move", SEC_GAMEMASTER, false, &HandleGameObjectMoveCommand, "", NULL },
|
||||
{ "near", SEC_GAMEMASTER, false, &HandleGameObjectNearCommand, "", NULL },
|
||||
{ "target", SEC_GAMEMASTER, false, &HandleGameObjectTargetCommand, "", NULL },
|
||||
{ "turn", SEC_GAMEMASTER, false, &HandleGameObjectTurnCommand, "", NULL },
|
||||
{ "add", SEC_GAMEMASTER, false, NULL, "", gobjectAddCommandTable },
|
||||
{ "set", SEC_GAMEMASTER, false, NULL, "", gobjectSetCommandTable },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "gobject", SEC_GAMEMASTER, false, NULL, "", gobjectCommandTable },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static bool HandleGameObjectActivateCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 lowguid = atoi(cId);
|
||||
if (!lowguid)
|
||||
return false;
|
||||
|
||||
GameObject* obj = NULL;
|
||||
|
||||
// by DB guid
|
||||
if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid))
|
||||
obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
|
||||
|
||||
if (!obj)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Activate
|
||||
obj->SetLootState(GO_READY);
|
||||
obj->UseDoorOrButton(10000);
|
||||
|
||||
handler->PSendSysMessage("Object activated!");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//spawn go
|
||||
static bool HandleGameObjectAddCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
|
||||
char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject_entry");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 id = atol(cId);
|
||||
if (!id)
|
||||
return false;
|
||||
|
||||
char* spawntimeSecs = strtok(NULL, " ");
|
||||
|
||||
const GameObjectInfo *gInfo = sObjectMgr.GetGameObjectInfo(id);
|
||||
|
||||
if (!gInfo)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId))
|
||||
{
|
||||
// report to DB errors log as in loading case
|
||||
sLog.outErrorDb("Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.",id, gInfo->type, gInfo->displayId);
|
||||
handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA,id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player *chr = handler->GetSession()->GetPlayer();
|
||||
float x = float(chr->GetPositionX());
|
||||
float y = float(chr->GetPositionY());
|
||||
float z = float(chr->GetPositionZ());
|
||||
float o = float(chr->GetOrientation());
|
||||
Map *map = chr->GetMap();
|
||||
|
||||
GameObject* pGameObj = new GameObject;
|
||||
uint32 db_lowGUID = sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
|
||||
|
||||
if (!pGameObj->Create(db_lowGUID, gInfo->id, map, chr->GetPhaseMaskForSpawn(), x, y, z, o, 0.0f, 0.0f, 0.0f, 0.0f, 0, GO_STATE_READY))
|
||||
{
|
||||
delete pGameObj;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (spawntimeSecs)
|
||||
{
|
||||
uint32 value = atoi((char*)spawntimeSecs);
|
||||
pGameObj->SetRespawnTime(value);
|
||||
//sLog.outDebug("*** spawntimeSecs: %d", value);
|
||||
}
|
||||
|
||||
// fill the gameobject data and save to the db
|
||||
pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()),chr->GetPhaseMaskForSpawn());
|
||||
|
||||
// this will generate a new guid if the object is in an instance
|
||||
if (!pGameObj->LoadFromDB(db_lowGUID, map))
|
||||
{
|
||||
delete pGameObj;
|
||||
return false;
|
||||
}
|
||||
|
||||
sLog.outDebug(handler->GetTrinityString(LANG_GAMEOBJECT_CURRENT), gInfo->name, db_lowGUID, x, y, z, o);
|
||||
|
||||
map->Add(pGameObj);
|
||||
|
||||
// TODO: is it really necessary to add both the real and DB table guid here ?
|
||||
sObjectMgr.AddGameobjectToGrid(db_lowGUID, sObjectMgr.GetGOData(db_lowGUID));
|
||||
|
||||
handler->PSendSysMessage(LANG_GAMEOBJECT_ADD,id,gInfo->name,db_lowGUID,x,y,z);
|
||||
return true;
|
||||
}
|
||||
|
||||
// add go, temp only
|
||||
static bool HandleGameObjectAddTempCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
char* charID = strtok((char*)args, " ");
|
||||
if (!charID)
|
||||
return false;
|
||||
|
||||
Player *chr = handler->GetSession()->GetPlayer();
|
||||
|
||||
char* spawntime = strtok(NULL, " ");
|
||||
uint32 spawntm = 300;
|
||||
|
||||
if (spawntime)
|
||||
spawntm = atoi((char*)spawntime);
|
||||
|
||||
float x = chr->GetPositionX();
|
||||
float y = chr->GetPositionY();
|
||||
float z = chr->GetPositionZ();
|
||||
float ang = chr->GetOrientation();
|
||||
|
||||
float rot2 = sin(ang/2);
|
||||
float rot3 = cos(ang/2);
|
||||
|
||||
uint32 id = atoi(charID);
|
||||
|
||||
chr->SummonGameObject(id,x,y,z,ang,0,0,rot2,rot3,spawntm);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleGameObjectTargetCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
Player* pl = handler->GetSession()->GetPlayer();
|
||||
QueryResult result;
|
||||
GameEventMgr::ActiveEvents const& activeEventsList = sGameEventMgr.GetActiveEventList();
|
||||
if (*args)
|
||||
{
|
||||
// number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
|
||||
char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject_entry");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 id = atol(cId);
|
||||
|
||||
if (id)
|
||||
result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%i' AND id = '%u' ORDER BY order_ ASC LIMIT 1",
|
||||
pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),id);
|
||||
else
|
||||
{
|
||||
std::string name = cId;
|
||||
WorldDatabase.escape_string(name);
|
||||
result = WorldDatabase.PQuery(
|
||||
"SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ "
|
||||
"FROM gameobject,gameobject_template WHERE gameobject_template.entry = gameobject.id AND map = %i AND name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" ORDER BY order_ ASC LIMIT 1",
|
||||
pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),name.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream eventFilter;
|
||||
eventFilter << " AND (event IS NULL ";
|
||||
bool initString = true;
|
||||
|
||||
for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr)
|
||||
{
|
||||
if (initString)
|
||||
{
|
||||
eventFilter << "OR event IN (" <<*itr;
|
||||
initString =false;
|
||||
}
|
||||
else
|
||||
eventFilter << "," << *itr;
|
||||
}
|
||||
|
||||
if (!initString)
|
||||
eventFilter << "))";
|
||||
else
|
||||
eventFilter << ")";
|
||||
|
||||
result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, phaseMask, "
|
||||
"(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject "
|
||||
"LEFT OUTER JOIN game_event_gameobject on gameobject.guid=game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 10",
|
||||
handler->GetSession()->GetPlayer()->GetPositionX(), handler->GetSession()->GetPlayer()->GetPositionY(), handler->GetSession()->GetPlayer()->GetPositionZ(), handler->GetSession()->GetPlayer()->GetMapId(),eventFilter.str().c_str());
|
||||
}
|
||||
|
||||
if (!result)
|
||||
{
|
||||
handler->SendSysMessage(LANG_COMMAND_TARGETOBJNOTFOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
float x, y, z, o;
|
||||
uint32 lowguid, id;
|
||||
uint16 mapid, phase;
|
||||
uint32 pool_id;
|
||||
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
lowguid = fields[0].GetUInt32();
|
||||
id = fields[1].GetUInt32();
|
||||
x = fields[2].GetFloat();
|
||||
y = fields[3].GetFloat();
|
||||
z = fields[4].GetFloat();
|
||||
o = fields[5].GetFloat();
|
||||
mapid = fields[6].GetUInt16();
|
||||
phase = fields[7].GetUInt16();
|
||||
pool_id = sPoolMgr.IsPartOfAPool<GameObject>(lowguid);
|
||||
if (!pool_id || sPoolMgr.IsSpawnedObject<GameObject>(lowguid))
|
||||
found = true;
|
||||
} while (result->NextRow() && (!found));
|
||||
|
||||
if (!found)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id);
|
||||
return false;
|
||||
}
|
||||
|
||||
GameObjectInfo const* goI = sObjectMgr.GetGameObjectInfo(id);
|
||||
|
||||
if (!goI)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id);
|
||||
return false;
|
||||
}
|
||||
|
||||
GameObject* target = handler->GetSession()->GetPlayer()->GetMap()->GetGameObject(MAKE_NEW_GUID(lowguid,id,HIGHGUID_GAMEOBJECT));
|
||||
|
||||
handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, lowguid, goI->name, lowguid, id, x, y, z, mapid, o, phase);
|
||||
|
||||
if (target)
|
||||
{
|
||||
int32 curRespawnDelay = int32(target->GetRespawnTimeEx()-time(NULL));
|
||||
if (curRespawnDelay < 0)
|
||||
curRespawnDelay = 0;
|
||||
|
||||
std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true);
|
||||
std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true);
|
||||
|
||||
handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//delete object by selection or guid
|
||||
static bool HandleGameObjectDeleteCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
||||
char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 lowguid = atoi(cId);
|
||||
if (!lowguid)
|
||||
return false;
|
||||
|
||||
GameObject* obj = NULL;
|
||||
|
||||
// by DB guid
|
||||
if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid))
|
||||
obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
|
||||
|
||||
if (!obj)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64 owner_guid = obj->GetOwnerGUID();
|
||||
if (owner_guid)
|
||||
{
|
||||
Unit* owner = ObjectAccessor::GetUnit(*handler->GetSession()->GetPlayer(),owner_guid);
|
||||
if (!owner || !IS_PLAYER_GUID(owner_guid))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_DELOBJREFERCREATURE, GUID_LOPART(owner_guid), obj->GetGUIDLow());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
owner->RemoveGameObject(obj,false);
|
||||
}
|
||||
|
||||
obj->SetRespawnTime(0); // not save respawn time
|
||||
obj->Delete();
|
||||
obj->DeleteFromDB();
|
||||
|
||||
handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, obj->GetGUIDLow());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//turn selected object
|
||||
static bool HandleGameObjectTurnCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
// number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
|
||||
char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 lowguid = atoi(cId);
|
||||
if (!lowguid)
|
||||
return false;
|
||||
|
||||
GameObject* obj = NULL;
|
||||
|
||||
// by DB guid
|
||||
if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid))
|
||||
obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
|
||||
|
||||
if (!obj)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* po = strtok(NULL, " ");
|
||||
float o;
|
||||
|
||||
if (po)
|
||||
{
|
||||
o = (float)atof(po);
|
||||
}
|
||||
else
|
||||
{
|
||||
Player *chr = handler->GetSession()->GetPlayer();
|
||||
o = chr->GetOrientation();
|
||||
}
|
||||
|
||||
obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o);
|
||||
obj->UpdateRotationFields();
|
||||
obj->DestroyForNearbyPlayers();
|
||||
obj->UpdateObjectVisibility();
|
||||
|
||||
obj->SaveToDB();
|
||||
obj->Refresh();
|
||||
|
||||
handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow(), o);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//move selected object
|
||||
static bool HandleGameObjectMoveCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
||||
char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 lowguid = atoi(cId);
|
||||
if (!lowguid)
|
||||
return false;
|
||||
|
||||
GameObject* obj = NULL;
|
||||
|
||||
// by DB guid
|
||||
if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid))
|
||||
obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
|
||||
|
||||
if (!obj)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* px = strtok(NULL, " ");
|
||||
char* py = strtok(NULL, " ");
|
||||
char* pz = strtok(NULL, " ");
|
||||
|
||||
if (!px)
|
||||
{
|
||||
Player *chr = handler->GetSession()->GetPlayer();
|
||||
obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation());
|
||||
obj->DestroyForNearbyPlayers();
|
||||
obj->UpdateObjectVisibility();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!py || !pz)
|
||||
return false;
|
||||
|
||||
float x = (float)atof(px);
|
||||
float y = (float)atof(py);
|
||||
float z = (float)atof(pz);
|
||||
|
||||
if (!MapManager::IsValidMapCoord(obj->GetMapId(),x,y,z))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,obj->GetMapId());
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
obj->Relocate(x, y, z, obj->GetOrientation());
|
||||
obj->DestroyForNearbyPlayers();
|
||||
obj->UpdateObjectVisibility();
|
||||
}
|
||||
|
||||
obj->SaveToDB();
|
||||
obj->Refresh();
|
||||
|
||||
handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, obj->GetGUIDLow(), obj->GetGOInfo()->name, obj->GetGUIDLow());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//set pahsemask for selected object
|
||||
static bool HandleGameObjectSetPhaseCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
// number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
|
||||
char* cId = handler->extractKeyFromLink((char*)args,"Hgameobject");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 lowguid = atoi(cId);
|
||||
if (!lowguid)
|
||||
return false;
|
||||
|
||||
GameObject* obj = NULL;
|
||||
|
||||
// by DB guid
|
||||
if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid))
|
||||
obj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
|
||||
|
||||
if (!obj)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* phaseStr = strtok (NULL, " ");
|
||||
uint32 phasemask = phaseStr? atoi(phaseStr) : 0;
|
||||
if (phasemask == 0)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
obj->SetPhaseMask(phasemask,true);
|
||||
obj->SaveToDB();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleGameObjectNearCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
float distance = (!*args) ? 10.0f : (float)(atof(args));
|
||||
uint32 count = 0;
|
||||
|
||||
Player* pl = handler->GetSession()->GetPlayer();
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, "
|
||||
"(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ "
|
||||
"FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_",
|
||||
pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),
|
||||
pl->GetMapId(),pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),distance*distance);
|
||||
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
uint32 guid = fields[0].GetUInt32();
|
||||
uint32 entry = fields[1].GetUInt32();
|
||||
float x = fields[2].GetFloat();
|
||||
float y = fields[3].GetFloat();
|
||||
float z = fields[4].GetFloat();
|
||||
int mapid = fields[5].GetUInt16();
|
||||
|
||||
GameObjectInfo const * gInfo = sObjectMgr.GetGameObjectInfo(entry);
|
||||
|
||||
if (!gInfo)
|
||||
continue;
|
||||
|
||||
handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name, x, y, z, mapid);
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE,distance,count);
|
||||
return true;
|
||||
}
|
||||
|
||||
//show info of gameobject
|
||||
static bool HandleGameObjectInfoCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
uint32 entry = 0;
|
||||
uint32 type = 0;
|
||||
uint32 displayid = 0;
|
||||
std::string name;
|
||||
uint32 lootId = 0;
|
||||
|
||||
if (!*args)
|
||||
{
|
||||
if (WorldObject * obj = handler->getSelectedObject())
|
||||
entry = obj->GetEntry();
|
||||
}
|
||||
else
|
||||
entry = atoi((char*)args);
|
||||
|
||||
GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(entry);
|
||||
|
||||
if (!goinfo)
|
||||
return false;
|
||||
|
||||
type = goinfo->type;
|
||||
displayid = goinfo->displayId;
|
||||
name = goinfo->name;
|
||||
if (type == GAMEOBJECT_TYPE_CHEST)
|
||||
lootId = goinfo->chest.lootId;
|
||||
else if (type == GAMEOBJECT_TYPE_FISHINGHOLE)
|
||||
lootId = goinfo->fishinghole.lootId;
|
||||
|
||||
handler->PSendSysMessage(LANG_GOINFO_ENTRY, entry);
|
||||
handler->PSendSysMessage(LANG_GOINFO_TYPE, type);
|
||||
handler->PSendSysMessage(LANG_GOINFO_LOOTID, lootId);
|
||||
handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayid);
|
||||
handler->PSendSysMessage(LANG_GOINFO_NAME, name.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
static bool HandleGameObjectSetStateCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
// number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r
|
||||
char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 lowguid = atoi(cId);
|
||||
if (!lowguid)
|
||||
return false;
|
||||
|
||||
GameObject* gobj = NULL;
|
||||
|
||||
if (GameObjectData const* goData = sObjectMgr.GetGOData(lowguid))
|
||||
gobj = handler->GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid, goData->id);
|
||||
|
||||
if (!gobj)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char* ctype = strtok(NULL, " ");
|
||||
if (!ctype)
|
||||
return false;
|
||||
|
||||
int32 type = atoi(ctype);
|
||||
if (type < 0)
|
||||
{
|
||||
if (type == -1)
|
||||
gobj->SendObjectDeSpawnAnim(gobj->GetGUID());
|
||||
else if (type == -2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
char* cstate = strtok(NULL, " ");
|
||||
if (!cstate)
|
||||
return false;
|
||||
|
||||
int32 state = atoi(cstate);
|
||||
|
||||
if (type < 4)
|
||||
gobj->SetByteValue(GAMEOBJECT_BYTES_1, type, state);
|
||||
else if (type == 4)
|
||||
{
|
||||
WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM,8+4);
|
||||
data << gobj->GetGUID();
|
||||
data << (uint32)(state);
|
||||
gobj->SendMessageToSet(&data, true);
|
||||
}
|
||||
handler->PSendSysMessage("Set gobject type %d state %d", type, state);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void AddSC_gobject_commandscript()
|
||||
{
|
||||
new gobject_commandscript();
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2010 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: honor_commandscript
|
||||
%Complete: 100
|
||||
Comment: All honor related commands
|
||||
Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Chat.h"
|
||||
|
||||
class honor_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
honor_commandscript() : CommandScript("honor_commandscript") { }
|
||||
|
||||
ChatCommand* GetCommands() const
|
||||
{
|
||||
static ChatCommand honorAddCommandTable[] =
|
||||
{
|
||||
{ "kill", SEC_GAMEMASTER, false, &HandleHonorAddKillCommand, "", NULL },
|
||||
{ "", SEC_GAMEMASTER, false, &HandleHonorAddCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
static ChatCommand honorCommandTable[] =
|
||||
{
|
||||
{ "add", SEC_GAMEMASTER, false, NULL, "", honorAddCommandTable },
|
||||
{ "update", SEC_GAMEMASTER, false, &HandleHonorUpdateCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "honor", SEC_GAMEMASTER, false, NULL, "", honorCommandTable },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
|
||||
static bool HandleHonorAddCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player *target = handler->getSelectedPlayer();
|
||||
if (!target)
|
||||
{
|
||||
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check online security
|
||||
if (handler->HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
uint32 amount = (uint32)atoi(args);
|
||||
target->RewardHonor(NULL, 1, amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleHonorAddKillCommand(ChatHandler* handler, const char* /*args*/)
|
||||
{
|
||||
Unit *target = handler->getSelectedUnit();
|
||||
if (!target)
|
||||
{
|
||||
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check online security
|
||||
if (target->GetTypeId() == TYPEID_PLAYER && handler->HasLowerSecurity((Player*)target, 0))
|
||||
return false;
|
||||
|
||||
handler->GetSession()->GetPlayer()->RewardHonor(target, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleHonorUpdateCommand(ChatHandler* handler, const char* /*args*/)
|
||||
{
|
||||
Player *target = handler->getSelectedPlayer();
|
||||
if (!target)
|
||||
{
|
||||
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check online security
|
||||
if (handler->HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
target->UpdateHonorFields();
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void AddSC_honor_commandscript()
|
||||
{
|
||||
new honor_commandscript();
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2010 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: quest_commandscript
|
||||
%Complete: 100
|
||||
Comment: All quest related commands
|
||||
Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Chat.h"
|
||||
|
||||
class quest_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
quest_commandscript() : CommandScript("quest_commandscript") { }
|
||||
|
||||
ChatCommand* GetCommands() const
|
||||
{
|
||||
static ChatCommand questCommandTable[] =
|
||||
{
|
||||
{ "add", SEC_ADMINISTRATOR, false, &HandleQuestAdd, "", NULL },
|
||||
{ "complete", SEC_ADMINISTRATOR, false, &HandleQuestComplete, "", NULL },
|
||||
{ "remove", SEC_ADMINISTRATOR, false, &HandleQuestRemove, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "quest", SEC_ADMINISTRATOR, false, NULL, "", questCommandTable },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static bool HandleQuestAdd(ChatHandler* handler, const char* args)
|
||||
{
|
||||
Player* player = handler->getSelectedPlayer();
|
||||
if (!player)
|
||||
{
|
||||
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// .addquest #entry'
|
||||
// number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r
|
||||
char* cId = handler->extractKeyFromLink((char*)args,"Hquest");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 entry = atol(cId);
|
||||
|
||||
Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry);
|
||||
|
||||
if (!pQuest)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND,entry);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check item starting quest (it can work incorrectly if added without item in inventory)
|
||||
for (uint32 id = 0; id < sItemStorage.MaxEntry; id++)
|
||||
{
|
||||
ItemPrototype const *pProto = sItemStorage.LookupEntry<ItemPrototype>(id);
|
||||
if (!pProto)
|
||||
continue;
|
||||
|
||||
if (pProto->StartQuest == entry)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM, entry, pProto->ItemId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ok, normal (creature/GO starting) quest
|
||||
if (player->CanAddQuest(pQuest, true))
|
||||
{
|
||||
player->AddQuest(pQuest, NULL);
|
||||
|
||||
if (player->CanCompleteQuest(entry))
|
||||
player->CompleteQuest(entry);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleQuestRemove(ChatHandler* handler, const char* args)
|
||||
{
|
||||
Player* player = handler->getSelectedPlayer();
|
||||
if (!player)
|
||||
{
|
||||
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// .removequest #entry'
|
||||
// number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r
|
||||
char* cId = handler->extractKeyFromLink((char*)args,"Hquest");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 entry = atol(cId);
|
||||
|
||||
Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry);
|
||||
|
||||
if (!pQuest)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove all quest entries for 'entry' from quest log
|
||||
for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot)
|
||||
{
|
||||
uint32 quest = player->GetQuestSlotQuestId(slot);
|
||||
if (quest == entry)
|
||||
{
|
||||
player->SetQuestSlot(slot,0);
|
||||
|
||||
// we ignore unequippable quest items in this case, its' still be equipped
|
||||
player->TakeQuestSourceItem(quest, false);
|
||||
}
|
||||
}
|
||||
|
||||
// set quest status to not started (will updated in DB at next save)
|
||||
player->SetQuestStatus(entry, QUEST_STATUS_NONE);
|
||||
|
||||
// reset rewarded for restart repeatable quest
|
||||
player->getQuestStatusMap()[entry].m_rewarded = false;
|
||||
|
||||
handler->SendSysMessage(LANG_COMMAND_QUEST_REMOVED);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleQuestComplete(ChatHandler* handler, const char* args)
|
||||
{
|
||||
Player* player = handler->getSelectedPlayer();
|
||||
if (!player)
|
||||
{
|
||||
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// .quest complete #entry
|
||||
// number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r
|
||||
char* cId = handler->extractKeyFromLink((char*)args,"Hquest");
|
||||
if (!cId)
|
||||
return false;
|
||||
|
||||
uint32 entry = atol(cId);
|
||||
|
||||
Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry);
|
||||
|
||||
// If player doesn't have the quest
|
||||
if (!pQuest || player->GetQuestStatus(entry) == QUEST_STATUS_NONE)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add quest items for quests that require items
|
||||
for (uint8 x = 0; x < QUEST_ITEM_OBJECTIVES_COUNT; ++x)
|
||||
{
|
||||
uint32 id = pQuest->ReqItemId[x];
|
||||
uint32 count = pQuest->ReqItemCount[x];
|
||||
if (!id || !count)
|
||||
continue;
|
||||
|
||||
uint32 curItemCount = player->GetItemCount(id,true);
|
||||
|
||||
ItemPosCountVec dest;
|
||||
uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, id, count-curItemCount);
|
||||
if (msg == EQUIP_ERR_OK)
|
||||
{
|
||||
Item* item = player->StoreNewItem(dest, id, true);
|
||||
player->SendNewItem(item,count-curItemCount,true,false);
|
||||
}
|
||||
}
|
||||
|
||||
// All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10")
|
||||
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
|
||||
{
|
||||
int32 creature = pQuest->ReqCreatureOrGOId[i];
|
||||
uint32 creaturecount = pQuest->ReqCreatureOrGOCount[i];
|
||||
|
||||
if (uint32 spell_id = pQuest->ReqSpell[i])
|
||||
{
|
||||
for (uint16 z = 0; z < creaturecount; ++z)
|
||||
player->CastedCreatureOrGO(creature,0,spell_id);
|
||||
}
|
||||
else if (creature > 0)
|
||||
{
|
||||
if (CreatureInfo const* cInfo = sObjectMgr.GetCreatureTemplate(creature))
|
||||
for (uint16 z = 0; z < creaturecount; ++z)
|
||||
player->KilledMonster(cInfo,0);
|
||||
}
|
||||
else if (creature < 0)
|
||||
{
|
||||
for (uint16 z = 0; z < creaturecount; ++z)
|
||||
player->CastedCreatureOrGO(creature,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
// If the quest requires reputation to complete
|
||||
if (uint32 repFaction = pQuest->GetRepObjectiveFaction())
|
||||
{
|
||||
uint32 repValue = pQuest->GetRepObjectiveValue();
|
||||
uint32 curRep = player->GetReputationMgr().GetReputation(repFaction);
|
||||
if (curRep < repValue)
|
||||
if (FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction))
|
||||
player->GetReputationMgr().SetReputation(factionEntry,repValue);
|
||||
}
|
||||
|
||||
// If the quest requires a SECOND reputation to complete
|
||||
if (uint32 repFaction = pQuest->GetRepObjectiveFaction2())
|
||||
{
|
||||
uint32 repValue2 = pQuest->GetRepObjectiveValue2();
|
||||
uint32 curRep = player->GetReputationMgr().GetReputation(repFaction);
|
||||
if (curRep < repValue2)
|
||||
if (FactionEntry const *factionEntry = sFactionStore.LookupEntry(repFaction))
|
||||
player->GetReputationMgr().SetReputation(factionEntry,repValue2);
|
||||
}
|
||||
|
||||
// If the quest requires money
|
||||
int32 ReqOrRewMoney = pQuest->GetRewOrReqMoney();
|
||||
if (ReqOrRewMoney < 0)
|
||||
player->ModifyMoney(-ReqOrRewMoney);
|
||||
|
||||
player->CompleteQuest(entry);
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void AddSC_quest_commandscript()
|
||||
{
|
||||
new quest_commandscript();
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2010 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: titles_commandscript
|
||||
%Complete: 100
|
||||
Comment: All titles related commands
|
||||
Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Chat.h"
|
||||
|
||||
class titles_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
titles_commandscript() : CommandScript("titles_commandscript") { }
|
||||
|
||||
ChatCommand* GetCommands() const
|
||||
{
|
||||
static ChatCommand titlesSetCommandTable[] =
|
||||
{
|
||||
{ "mask", SEC_GAMEMASTER, false, &HandleTitlesSetMaskCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
static ChatCommand titlesCommandTable[] =
|
||||
{
|
||||
{ "add", SEC_GAMEMASTER, false, &HandleTitlesAddCommand, "", NULL },
|
||||
{ "current", SEC_GAMEMASTER, false, &HandleTitlesCurrentCommand, "", NULL },
|
||||
{ "remove", SEC_GAMEMASTER, false, &HandleTitlesRemoveCommand, "", NULL },
|
||||
{ "set", SEC_GAMEMASTER, false, NULL, "", titlesSetCommandTable },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "titles", SEC_GAMEMASTER, false, NULL, "", titlesCommandTable },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static bool HandleTitlesCurrentCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
// number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
|
||||
char* id_p = handler->extractKeyFromLink((char*)args,"Htitle");
|
||||
if (!id_p)
|
||||
return false;
|
||||
|
||||
int32 id = atoi(id_p);
|
||||
if (id <= 0)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player * target = handler->getSelectedPlayer();
|
||||
if (!target)
|
||||
{
|
||||
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check online security
|
||||
if (handler->HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
|
||||
if (!titleInfo)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string tNameLink = handler->GetNameLink(target);
|
||||
|
||||
target->SetTitle(titleInfo); // to be sure that title now known
|
||||
target->SetUInt32Value(PLAYER_CHOSEN_TITLE,titleInfo->bit_index);
|
||||
|
||||
handler->PSendSysMessage(LANG_TITLE_CURRENT_RES, id, titleInfo->name[handler->GetSessionDbcLocale()], tNameLink.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleTitlesAddCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
// number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
|
||||
char* id_p = handler->extractKeyFromLink((char*)args,"Htitle");
|
||||
if (!id_p)
|
||||
return false;
|
||||
|
||||
int32 id = atoi(id_p);
|
||||
if (id <= 0)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player * target = handler->getSelectedPlayer();
|
||||
if (!target)
|
||||
{
|
||||
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check online security
|
||||
if (handler->HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
|
||||
if (!titleInfo)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string tNameLink = handler->GetNameLink(target);
|
||||
|
||||
char const* targetName = target->GetName();
|
||||
char titleNameStr[80];
|
||||
snprintf(titleNameStr,80,titleInfo->name[handler->GetSessionDbcLocale()],targetName);
|
||||
|
||||
target->SetTitle(titleInfo);
|
||||
handler->PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr, tNameLink.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleTitlesRemoveCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
// number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r
|
||||
char* id_p = handler->extractKeyFromLink((char*)args,"Htitle");
|
||||
if (!id_p)
|
||||
return false;
|
||||
|
||||
int32 id = atoi(id_p);
|
||||
if (id <= 0)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player * target = handler->getSelectedPlayer();
|
||||
if (!target)
|
||||
{
|
||||
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check online security
|
||||
if (handler->HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id);
|
||||
if (!titleInfo)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_TITLE_ID, id);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
target->SetTitle(titleInfo,true);
|
||||
|
||||
std::string tNameLink = handler->GetNameLink(target);
|
||||
|
||||
char const* targetName = target->GetName();
|
||||
char titleNameStr[80];
|
||||
snprintf(titleNameStr,80,titleInfo->name[handler->GetSessionDbcLocale()],targetName);
|
||||
|
||||
handler->PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr, tNameLink.c_str());
|
||||
|
||||
if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE)))
|
||||
{
|
||||
target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0);
|
||||
handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET, tNameLink.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//Edit Player KnownTitles
|
||||
static bool HandleTitlesSetMaskCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
uint64 titles = 0;
|
||||
|
||||
sscanf((char*)args, UI64FMTD, &titles);
|
||||
|
||||
Player *target = handler->getSelectedPlayer();
|
||||
if (!target)
|
||||
{
|
||||
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check online security
|
||||
if (handler->HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
uint64 titles2 = titles;
|
||||
|
||||
for (uint32 i = 1; i < sCharTitlesStore.GetNumRows(); ++i)
|
||||
if (CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i))
|
||||
titles2 &= ~(uint64(1) << tEntry->bit_index);
|
||||
|
||||
titles &= ~titles2; // remove not existed titles
|
||||
|
||||
target->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles);
|
||||
handler->SendSysMessage(LANG_DONE);
|
||||
|
||||
if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE)))
|
||||
{
|
||||
target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0);
|
||||
handler->PSendSysMessage(LANG_CURRENT_TITLE_RESET,handler->GetNameLink(target).c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void AddSC_titles_commandscript()
|
||||
{
|
||||
new titles_commandscript();
|
||||
}
|
||||
@@ -0,0 +1,981 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2010 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: wp_commandscript
|
||||
%Complete: 100
|
||||
Comment: All wp related commands
|
||||
Category: commandscripts
|
||||
EndScriptData */
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "WaypointManager.h"
|
||||
#include "Chat.h"
|
||||
|
||||
class wp_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
wp_commandscript() : CommandScript("wp_commandscript") { }
|
||||
|
||||
ChatCommand* GetCommands() const
|
||||
{
|
||||
static ChatCommand wpCommandTable[] =
|
||||
{
|
||||
{ "add", SEC_GAMEMASTER, false, &HandleWpAddCommand, "", NULL },
|
||||
{ "event", SEC_GAMEMASTER, false, &HandleWpEventCommand, "", NULL },
|
||||
{ "load", SEC_GAMEMASTER, false, &HandleWpLoadCommand, "", NULL },
|
||||
{ "modify", SEC_GAMEMASTER, false, &HandleWpModifyCommand, "", NULL },
|
||||
{ "unload", SEC_GAMEMASTER, false, &HandleWpUnLoadCommand, "", NULL },
|
||||
{ "reload", SEC_ADMINISTRATOR, false, &HandleWpReloadCommand, "", NULL },
|
||||
{ "show", SEC_GAMEMASTER, false, &HandleWpShowCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
static ChatCommand commandTable[] =
|
||||
{
|
||||
{ "wp", SEC_GAMEMASTER, false, NULL, "", wpCommandTable },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a waypoint to a creature.
|
||||
*
|
||||
* The user can either select an npc or provide its GUID.
|
||||
*
|
||||
* The user can even select a visual waypoint - then the new waypoint
|
||||
* is placed *after* the selected one - this makes insertion of new
|
||||
* waypoints possible.
|
||||
*
|
||||
* eg:
|
||||
* .wp add 12345
|
||||
* -> adds a waypoint to the npc with the GUID 12345
|
||||
*
|
||||
* .wp add
|
||||
* -> adds a waypoint to the currently selected creature
|
||||
*
|
||||
*
|
||||
* @param args if the user did not provide a GUID, it is NULL
|
||||
*
|
||||
* @return true - command did succeed, false - something went wrong
|
||||
*/
|
||||
static bool HandleWpAddCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
sLog.outDebug("DEBUG: HandleWpAddCommand");
|
||||
|
||||
// optional
|
||||
char* path_number = NULL;
|
||||
uint32 pathid = 0;
|
||||
|
||||
if (*args)
|
||||
path_number = strtok((char*)args, " ");
|
||||
|
||||
uint32 point = 0;
|
||||
Creature* target = handler->getSelectedCreature();
|
||||
|
||||
if (!path_number)
|
||||
{
|
||||
if (target)
|
||||
pathid = target->GetWaypointPath();
|
||||
else
|
||||
{
|
||||
QueryResult result = WorldDatabase.Query("SELECT MAX(id) FROM waypoint_data");
|
||||
uint32 maxpathid = result->Fetch()->GetInt32();
|
||||
pathid = maxpathid+1;
|
||||
sLog.outDebug("DEBUG: HandleWpAddCommand - New path started.");
|
||||
handler->PSendSysMessage("%s%s|r", "|cff00ff00", "New path started.");
|
||||
}
|
||||
}
|
||||
else
|
||||
pathid = atoi(path_number);
|
||||
|
||||
// path_id -> ID of the Path
|
||||
// point -> number of the waypoint (if not 0)
|
||||
|
||||
if (!pathid)
|
||||
{
|
||||
sLog.outDebug("DEBUG: HandleWpAddCommand - Current creature haven't loaded path.");
|
||||
handler->PSendSysMessage("%s%s|r", "|cffff33ff", "Current creature haven't loaded path.");
|
||||
return true;
|
||||
}
|
||||
|
||||
sLog.outDebug("DEBUG: HandleWpAddCommand - point == 0");
|
||||
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'",pathid);
|
||||
|
||||
if (result)
|
||||
point = (*result)[0].GetUInt32();
|
||||
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
//Map *map = player->GetMap();
|
||||
|
||||
WorldDatabase.PExecute("INSERT INTO waypoint_data (id, point, position_x, position_y, position_z) VALUES ('%u','%u','%f', '%f', '%f')",
|
||||
pathid, point+1, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
|
||||
|
||||
handler->PSendSysMessage("%s%s%u%s%u%s|r", "|cff00ff00", "PathID: |r|cff00ffff", pathid, "|r|cff00ff00: Waypoint |r|cff00ffff", point+1,"|r|cff00ff00 created. ");
|
||||
return true;
|
||||
} // HandleWpAddCommand
|
||||
|
||||
static bool HandleWpLoadCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// optional
|
||||
char* path_number = NULL;
|
||||
|
||||
if (*args)
|
||||
path_number = strtok((char*)args, " ");
|
||||
|
||||
uint32 pathid = 0;
|
||||
uint32 guidlow = 0;
|
||||
Creature* target = handler->getSelectedCreature();
|
||||
|
||||
// Did player provide a path_id?
|
||||
if (!path_number)
|
||||
sLog.outDebug("DEBUG: HandleWpLoadPathCommand - No path number provided");
|
||||
|
||||
if (!target)
|
||||
{
|
||||
handler->SendSysMessage(LANG_SELECT_CREATURE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target->GetEntry() == 1)
|
||||
{
|
||||
handler->PSendSysMessage("%s%s|r", "|cffff33ff", "You want to load path to a waypoint? Aren't you?");
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
pathid = atoi(path_number);
|
||||
|
||||
if (!pathid)
|
||||
{
|
||||
handler->PSendSysMessage("%s%s|r", "|cffff33ff", "No vallid path number provided.");
|
||||
return true;
|
||||
}
|
||||
|
||||
guidlow = target->GetDBTableGUIDLow();
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature_addon WHERE guid = '%u'",guidlow);
|
||||
|
||||
if (result)
|
||||
WorldDatabase.PExecute("UPDATE creature_addon SET path_id = '%u' WHERE guid = '%u'", pathid, guidlow);
|
||||
else
|
||||
WorldDatabase.PExecute("INSERT INTO creature_addon(guid,path_id) VALUES ('%u','%u')", guidlow, pathid);
|
||||
|
||||
WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", WAYPOINT_MOTION_TYPE, guidlow);
|
||||
|
||||
target->LoadPath(pathid);
|
||||
target->SetDefaultMovementType(WAYPOINT_MOTION_TYPE);
|
||||
target->GetMotionMaster()->Initialize();
|
||||
target->MonsterSay("Path loaded.",0,0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleWpReloadCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
uint32 id = atoi(args);
|
||||
|
||||
if (!id)
|
||||
return false;
|
||||
|
||||
handler->PSendSysMessage("%s%s|r|cff00ffff%u|r", "|cff00ff00", "Loading Path: ", id);
|
||||
sWaypointMgr->UpdatePath(id);
|
||||
return true;
|
||||
}
|
||||
static bool HandleWpUnLoadCommand(ChatHandler* handler, const char* /*args*/)
|
||||
{
|
||||
uint32 guidlow = 0;
|
||||
Creature* target = handler->getSelectedCreature();
|
||||
|
||||
if (!target)
|
||||
{
|
||||
handler->PSendSysMessage("%s%s|r", "|cff33ffff", "You must select target.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target->GetCreatureAddon())
|
||||
{
|
||||
if (target->GetCreatureAddon()->path_id != 0)
|
||||
{
|
||||
WorldDatabase.PExecute("DELETE FROM creature_addon WHERE guid = %u", target->GetGUIDLow());
|
||||
target->UpdateWaypointID(0);
|
||||
WorldDatabase.PExecute("UPDATE creature SET MovementType = '%u' WHERE guid = '%u'", IDLE_MOTION_TYPE, guidlow);
|
||||
target->LoadPath(0);
|
||||
target->SetDefaultMovementType(IDLE_MOTION_TYPE);
|
||||
target->GetMotionMaster()->MoveTargetedHome();
|
||||
target->GetMotionMaster()->Initialize();
|
||||
target->MonsterSay("Path unloaded.",0,0);
|
||||
return true;
|
||||
}
|
||||
handler->PSendSysMessage("%s%s|r", "|cffff33ff", "Target have no loaded path.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleWpEventCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* show_str = strtok((char*)args, " ");
|
||||
std::string show = show_str;
|
||||
|
||||
// Check
|
||||
if ((show != "add") && (show != "mod") && (show != "del") && (show != "listid")) return false;
|
||||
|
||||
char* arg_id = strtok(NULL, " ");
|
||||
uint32 id = 0;
|
||||
|
||||
if (show == "add")
|
||||
{
|
||||
if (arg_id)
|
||||
id = atoi(arg_id);
|
||||
|
||||
if (id)
|
||||
{
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT id FROM waypoint_scripts WHERE guid = %u", id);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
WorldDatabase.PExecute("INSERT INTO waypoint_scripts(guid)VALUES(%u)", id);
|
||||
handler->PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: New waypoint event added: ", id);
|
||||
}
|
||||
else
|
||||
handler->PSendSysMessage("|cff00ff00Wp Event: You have choosed an existing waypoint script guid: %u|r", id);
|
||||
}
|
||||
else
|
||||
{
|
||||
QueryResult result = WorldDatabase.Query("SELECT MAX(guid) FROM waypoint_scripts");
|
||||
id = result->Fetch()->GetUInt32();
|
||||
WorldDatabase.PExecute("INSERT INTO waypoint_scripts(guid)VALUES(%u)", id+1);
|
||||
handler->PSendSysMessage("%s%s%u|r", "|cff00ff00","Wp Event: New waypoint event added: |r|cff00ffff", id+1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (show == "listid")
|
||||
{
|
||||
if (!arg_id)
|
||||
{
|
||||
handler->PSendSysMessage("%s%s|r", "|cff33ffff","Wp Event: You must provide waypoint script id.");
|
||||
return true;
|
||||
}
|
||||
|
||||
id = atoi(arg_id);
|
||||
|
||||
uint32 a2, a3, a4, a5, a6;
|
||||
float a8, a9, a10, a11;
|
||||
char const* a7;
|
||||
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = %u", id);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
handler->PSendSysMessage("%s%s%u|r", "|cff33ffff", "Wp Event: No waypoint scripts found on id: ", id);
|
||||
return true;
|
||||
}
|
||||
|
||||
Field *fields;
|
||||
|
||||
do
|
||||
{
|
||||
fields = result->Fetch();
|
||||
a2 = fields[0].GetUInt32();
|
||||
a3 = fields[1].GetUInt32();
|
||||
a4 = fields[2].GetUInt32();
|
||||
a5 = fields[3].GetUInt32();
|
||||
a6 = fields[4].GetUInt32();
|
||||
a7 = fields[5].GetCString();
|
||||
a8 = fields[6].GetFloat();
|
||||
a9 = fields[7].GetFloat();
|
||||
a10 = fields[8].GetFloat();
|
||||
a11 = fields[9].GetFloat();
|
||||
|
||||
handler->PSendSysMessage("|cffff33ffid:|r|cff00ffff %u|r|cff00ff00, guid: |r|cff00ffff%u|r|cff00ff00, delay: |r|cff00ffff%u|r|cff00ff00, command: |r|cff00ffff%u|r|cff00ff00, datalong: |r|cff00ffff%u|r|cff00ff00, datalong2: |r|cff00ffff%u|r|cff00ff00, datatext: |r|cff00ffff%s|r|cff00ff00, posx: |r|cff00ffff%f|r|cff00ff00, posy: |r|cff00ffff%f|r|cff00ff00, posz: |r|cff00ffff%f|r|cff00ff00, orientation: |r|cff00ffff%f|r", id, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
|
||||
}
|
||||
while (result->NextRow());
|
||||
}
|
||||
|
||||
if (show == "del")
|
||||
{
|
||||
id = atoi(arg_id);
|
||||
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT guid FROM waypoint_scripts WHERE guid = %u", id);
|
||||
|
||||
if (result)
|
||||
{
|
||||
WorldDatabase.PExecute("DELETE FROM waypoint_scripts WHERE guid = %u", id);
|
||||
handler->PSendSysMessage("%s%s%u|r","|cff00ff00","Wp Event: Waypoint script removed: ", id);
|
||||
}
|
||||
else
|
||||
handler->PSendSysMessage("|cffff33ffWp Event: ERROR: you have selected a non existing script: %u|r", id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (show == "mod")
|
||||
{
|
||||
if (!arg_id)
|
||||
{
|
||||
handler->SendSysMessage("|cffff33ffERROR: Waypoint script guid not present.|r");
|
||||
return true;
|
||||
}
|
||||
|
||||
id = atoi(arg_id);
|
||||
|
||||
if (!id)
|
||||
{
|
||||
handler->SendSysMessage("|cffff33ffERROR: No vallid waypoint script id not present.|r");
|
||||
return true;
|
||||
}
|
||||
|
||||
char* arg_2 = strtok(NULL," ");
|
||||
|
||||
if (!arg_2)
|
||||
{
|
||||
handler->SendSysMessage("|cffff33ffERROR: No argument present.|r");
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string arg_string = arg_2;
|
||||
|
||||
if ((arg_string != "setid") && (arg_string != "delay") && (arg_string != "command")
|
||||
&& (arg_string != "datalong") && (arg_string != "datalong2") && (arg_string != "dataint") && (arg_string != "posx")
|
||||
&& (arg_string != "posy") && (arg_string != "posz") && (arg_string != "orientation"))
|
||||
{
|
||||
handler->SendSysMessage("|cffff33ffERROR: No valid argument present.|r");
|
||||
return true;
|
||||
}
|
||||
|
||||
char* arg_3;
|
||||
std::string arg_str_2 = arg_2;
|
||||
arg_3 = strtok(NULL," ");
|
||||
|
||||
if (!arg_3)
|
||||
{
|
||||
handler->SendSysMessage("|cffff33ffERROR: No additional argument present.|r");
|
||||
return true;
|
||||
}
|
||||
|
||||
float coord;
|
||||
|
||||
if (arg_str_2 == "setid")
|
||||
{
|
||||
uint32 newid = atoi(arg_3);
|
||||
handler->PSendSysMessage("%s%s|r|cff00ffff%u|r|cff00ff00%s|r|cff00ffff%u|r","|cff00ff00","Wp Event: Wypoint scipt guid: ", newid," id changed: ", id);
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET id='%u' WHERE guid='%u'",
|
||||
newid, id); return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT id FROM waypoint_scripts WHERE guid='%u'",id);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
handler->SendSysMessage("|cffff33ffERROR: You have selected an non existing waypoint script guid.|r");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (arg_str_2 == "posx")
|
||||
{
|
||||
coord = (float)(atof(arg_3));
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET x='%f' WHERE guid='%u'",
|
||||
coord, id);
|
||||
handler->PSendSysMessage("|cff00ff00Waypoint script:|r|cff00ffff %u|r|cff00ff00 position_x updated.|r", id);
|
||||
return true;
|
||||
}
|
||||
else if (arg_str_2 == "posy")
|
||||
{
|
||||
coord = (float)(atof(arg_3));
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET y='%f' WHERE guid='%u'",
|
||||
coord, id);
|
||||
handler->PSendSysMessage("|cff00ff00Waypoint script: %u position_y updated.|r", id);
|
||||
return true;
|
||||
}
|
||||
else if (arg_str_2 == "posz")
|
||||
{
|
||||
coord = (float)(atof(arg_3));
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET z='%f' WHERE guid='%u'",
|
||||
coord, id);
|
||||
handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 position_z updated.|r", id);
|
||||
return true;
|
||||
}
|
||||
else if (arg_str_2 == "orientation")
|
||||
{
|
||||
coord = (float)(atof(arg_3));
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET o='%f' WHERE guid='%u'",
|
||||
coord, id);
|
||||
handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 orientation updated.|r", id);
|
||||
return true;
|
||||
}
|
||||
else if (arg_str_2 == "dataint")
|
||||
{
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'",
|
||||
arg_2, atoi(arg_3), id);
|
||||
handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 dataint updated.|r", id);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string arg_str_3 = arg_3;
|
||||
WorldDatabase.escape_string(arg_str_3);
|
||||
WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%s' WHERE guid='%u'",
|
||||
arg_2, arg_str_3.c_str(), id);
|
||||
}
|
||||
}
|
||||
handler->PSendSysMessage("%s%s|r|cff00ffff%u:|r|cff00ff00 %s %s|r","|cff00ff00","Waypoint script:", id, arg_2,"updated.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleWpModifyCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
sLog.outDebug("DEBUG: HandleWpModifyCommand");
|
||||
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// first arg: add del text emote spell waittime move
|
||||
char* show_str = strtok((char*)args, " ");
|
||||
if (!show_str)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string show = show_str;
|
||||
// Check
|
||||
// Remember: "show" must also be the name of a column!
|
||||
if ((show != "delay") && (show != "action") && (show != "action_chance")
|
||||
&& (show != "move_flag") && (show != "del") && (show != "move") && (show != "wpadd")
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Next arg is: <PATHID> <WPNUM> <ARGUMENT>
|
||||
char* arg_str = NULL;
|
||||
|
||||
// Did user provide a GUID
|
||||
// or did the user select a creature?
|
||||
// -> variable lowguid is filled with the GUID of the NPC
|
||||
uint32 pathid = 0;
|
||||
uint32 point = 0;
|
||||
uint32 wpGuid = 0;
|
||||
Creature* target = handler->getSelectedCreature();
|
||||
|
||||
if (!target || target->GetEntry() != VISUAL_WAYPOINT)
|
||||
{
|
||||
handler->SendSysMessage("|cffff33ffERROR: You must select a waypoint.|r");
|
||||
return false;
|
||||
}
|
||||
|
||||
sLog.outDebug("DEBUG: HandleWpModifyCommand - User did select an NPC");
|
||||
// The visual waypoint
|
||||
Creature* wpCreature = NULL;
|
||||
wpGuid = target->GetGUIDLow();
|
||||
|
||||
// Did the user select a visual spawnpoint?
|
||||
if (wpGuid)
|
||||
wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
|
||||
// attempt check creature existence by DB data
|
||||
else
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_CREATNOTFOUND, wpGuid);
|
||||
return false;
|
||||
}
|
||||
// User did select a visual waypoint?
|
||||
// Check the creature
|
||||
if (wpCreature->GetEntry() == VISUAL_WAYPOINT)
|
||||
{
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE wpguid = %u", wpGuid);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog.outDebug("DEBUG: HandleWpModifyCommand - No waypoint found - used 'wpguid'");
|
||||
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDSEARCH, target->GetGUIDLow());
|
||||
// Select waypoint number from database
|
||||
// Since we compare float values, we have to deal with
|
||||
// some difficulties.
|
||||
// Here we search for all waypoints that only differ in one from 1 thousand
|
||||
// (0.001) - There is no other way to compare C++ floats with mySQL floats
|
||||
// See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html
|
||||
const char* maxDIFF = "0.01";
|
||||
result = WorldDatabase.PQuery("SELECT id, point FROM waypoint_data WHERE (abs(position_x - %f) <= %s) and (abs(position_y - %f) <= %s) and (abs(position_z - %f) <= %s)",
|
||||
wpCreature->GetPositionX(), maxDIFF, wpCreature->GetPositionY(), maxDIFF, wpCreature->GetPositionZ(), maxDIFF);
|
||||
if (!result)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM, wpGuid);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
sLog.outDebug("DEBUG: HandleWpModifyCommand - After getting wpGuid");
|
||||
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
pathid = fields[0].GetUInt32();
|
||||
point = fields[1].GetUInt32();
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
// We have the waypoint number and the GUID of the "master npc"
|
||||
// Text is enclosed in "<>", all other arguments not
|
||||
arg_str = strtok((char*)NULL, " ");
|
||||
}
|
||||
|
||||
sLog.outDebug("DEBUG: HandleWpModifyCommand - Parameters parsed - now execute the command");
|
||||
|
||||
// Check for argument
|
||||
if (show != "del" && show != "move" && arg_str == NULL)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_ARGUMENTREQ, show_str);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (show == "del" && target)
|
||||
{
|
||||
handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid);
|
||||
|
||||
// wpCreature
|
||||
Creature* wpCreature = NULL;
|
||||
|
||||
if (wpGuid != 0)
|
||||
{
|
||||
wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
|
||||
wpCreature->CombatStop();
|
||||
wpCreature->DeleteFromDB();
|
||||
wpCreature->AddObjectToRemoveList();
|
||||
}
|
||||
|
||||
WorldDatabase.PExecute("DELETE FROM waypoint_data WHERE id='%u' AND point='%u'",
|
||||
pathid, point);
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET point=point-1 WHERE id='%u' AND point>'%u'",
|
||||
pathid, point);
|
||||
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_REMOVED);
|
||||
return true;
|
||||
} // del
|
||||
|
||||
if (show == "move" && target)
|
||||
{
|
||||
handler->PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff%u|r", pathid);
|
||||
|
||||
Player *chr = handler->GetSession()->GetPlayer();
|
||||
Map *map = chr->GetMap();
|
||||
{
|
||||
// wpCreature
|
||||
Creature* wpCreature = NULL;
|
||||
// What to do:
|
||||
// Move the visual spawnpoint
|
||||
// Respawn the owner of the waypoints
|
||||
if (wpGuid != 0)
|
||||
{
|
||||
wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpGuid, VISUAL_WAYPOINT, HIGHGUID_UNIT));
|
||||
wpCreature->CombatStop();
|
||||
wpCreature->DeleteFromDB();
|
||||
wpCreature->AddObjectToRemoveList();
|
||||
// re-create
|
||||
Creature* wpCreature2 = new Creature;
|
||||
if (!wpCreature2->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
|
||||
delete wpCreature2;
|
||||
return false;
|
||||
}
|
||||
|
||||
wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
|
||||
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
|
||||
wpCreature2->LoadFromDB(wpCreature2->GetDBTableGUIDLow(), map);
|
||||
map->Add(wpCreature2);
|
||||
//sMapMgr.GetMap(npcCreature->GetMapId())->Add(wpCreature2);
|
||||
}
|
||||
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET position_x = '%f',position_y = '%f',position_z = '%f' where id = '%u' AND point='%u'",
|
||||
chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), pathid, point);
|
||||
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_CHANGED);
|
||||
}
|
||||
return true;
|
||||
} // move
|
||||
|
||||
const char *text = arg_str;
|
||||
|
||||
if (text == 0)
|
||||
{
|
||||
// show_str check for present in list of correct values, no sql injection possible
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET %s=NULL WHERE id='%u' AND point='%u'",
|
||||
show_str, pathid, point);
|
||||
}
|
||||
else
|
||||
{
|
||||
// show_str check for present in list of correct values, no sql injection possible
|
||||
std::string text2 = text;
|
||||
WorldDatabase.escape_string(text2);
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET %s='%s' WHERE id='%u' AND point='%u'",
|
||||
show_str, text2.c_str(), pathid, point);
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleWpShowCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
sLog.outDebug("DEBUG: HandleWpShowCommand");
|
||||
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
// first arg: on, off, first, last
|
||||
char* show_str = strtok((char*)args, " ");
|
||||
if (!show_str)
|
||||
return false;
|
||||
|
||||
// second arg: GUID (optional, if a creature is selected)
|
||||
char* guid_str = strtok((char*)NULL, " ");
|
||||
sLog.outDebug("DEBUG: HandleWpShowCommand: show_str: %s guid_str: %s", show_str, guid_str);
|
||||
|
||||
uint32 pathid = 0;
|
||||
Creature* target = handler->getSelectedCreature();
|
||||
|
||||
// Did player provide a PathID?
|
||||
|
||||
if (!guid_str)
|
||||
{
|
||||
sLog.outDebug("DEBUG: HandleWpShowCommand: !guid_str");
|
||||
// No PathID provided
|
||||
// -> Player must have selected a creature
|
||||
|
||||
if (!target)
|
||||
{
|
||||
handler->SendSysMessage(LANG_SELECT_CREATURE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
pathid = target->GetWaypointPath();
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog.outDebug("|cff00ff00DEBUG: HandleWpShowCommand: PathID provided|r");
|
||||
// PathID provided
|
||||
// Warn if player also selected a creature
|
||||
// -> Creature selection is ignored <-
|
||||
if (target)
|
||||
handler->SendSysMessage(LANG_WAYPOINT_CREATSELECTED);
|
||||
|
||||
pathid = atoi((char*)guid_str);
|
||||
}
|
||||
|
||||
sLog.outDebug("DEBUG: HandleWpShowCommand: danach");
|
||||
|
||||
std::string show = show_str;
|
||||
uint32 Maxpoint;
|
||||
|
||||
sLog.outDebug("DEBUG: HandleWpShowCommand: PathID: %u", pathid);
|
||||
|
||||
//handler->PSendSysMessage("wpshow - show: %s", show);
|
||||
|
||||
// Show info for the selected waypoint
|
||||
if (show == "info")
|
||||
{
|
||||
// Check if the user did specify a visual waypoint
|
||||
if (target->GetEntry() != VISUAL_WAYPOINT)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_SELECT);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT id, point, delay, move_flag, action, action_chance FROM waypoint_data WHERE wpguid = %u", target->GetGUIDLow());
|
||||
|
||||
if (!result)
|
||||
{
|
||||
handler->SendSysMessage(LANG_WAYPOINT_NOTFOUNDDBPROBLEM);
|
||||
return true;
|
||||
}
|
||||
|
||||
handler->SendSysMessage("|cff00ffffDEBUG: wp show info:|r");
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
pathid = fields[0].GetUInt32();
|
||||
uint32 point = fields[1].GetUInt32();
|
||||
uint32 delay = fields[2].GetUInt32();
|
||||
uint32 flag = fields[3].GetUInt32();
|
||||
uint32 ev_id = fields[4].GetUInt32();
|
||||
uint32 ev_chance = fields[5].GetUInt32();
|
||||
|
||||
handler->PSendSysMessage("|cff00ff00Show info: for current point: |r|cff00ffff%u|r|cff00ff00, Path ID: |r|cff00ffff%u|r", point, pathid);
|
||||
handler->PSendSysMessage("|cff00ff00Show info: delay: |r|cff00ffff%u|r", delay);
|
||||
handler->PSendSysMessage("|cff00ff00Show info: Move flag: |r|cff00ffff%u|r", flag);
|
||||
handler->PSendSysMessage("|cff00ff00Show info: Waypoint event: |r|cff00ffff%u|r", ev_id);
|
||||
handler->PSendSysMessage("|cff00ff00Show info: Event chance: |r|cff00ffff%u|r", ev_chance);
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (show == "on")
|
||||
{
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT point, position_x,position_y,position_z FROM waypoint_data WHERE id = '%u'", pathid);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
handler->SendSysMessage("|cffff33ffPath no found.|r");
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("|cff00ff00DEBUG: wp on, PathID: |cff00ffff%u|r", pathid);
|
||||
|
||||
// Delete all visuals for this NPC
|
||||
QueryResult result2 = WorldDatabase.PQuery("SELECT wpguid FROM waypoint_data WHERE id = '%u' and wpguid <> 0", pathid);
|
||||
|
||||
if (result2)
|
||||
{
|
||||
bool hasError = false;
|
||||
do
|
||||
{
|
||||
Field *fields = result2->Fetch();
|
||||
uint32 wpguid = fields[0].GetUInt32();
|
||||
Creature* pCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(wpguid,VISUAL_WAYPOINT,HIGHGUID_UNIT));
|
||||
|
||||
if (!pCreature)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, wpguid);
|
||||
hasError = true;
|
||||
WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", wpguid);
|
||||
}
|
||||
else
|
||||
{
|
||||
pCreature->CombatStop();
|
||||
pCreature->DeleteFromDB();
|
||||
pCreature->AddObjectToRemoveList();
|
||||
}
|
||||
|
||||
}
|
||||
while (result2->NextRow());
|
||||
|
||||
if (hasError)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR1);
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR2);
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR3);
|
||||
}
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
uint32 point = fields[0].GetUInt32();
|
||||
float x = fields[1].GetFloat();
|
||||
float y = fields[2].GetFloat();
|
||||
float z = fields[3].GetFloat();
|
||||
|
||||
uint32 id = VISUAL_WAYPOINT;
|
||||
|
||||
Player *chr = handler->GetSession()->GetPlayer();
|
||||
Map *map = chr->GetMap();
|
||||
float o = chr->GetOrientation();
|
||||
|
||||
Creature* wpCreature = new Creature;
|
||||
if (!wpCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
|
||||
delete wpCreature;
|
||||
return false;
|
||||
}
|
||||
|
||||
sLog.outDebug("DEBUG: UPDATE waypoint_data SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), pathid, point);
|
||||
// set "wpguid" column to the visual waypoint
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '%u' WHERE id = '%u' and point = '%u'", wpCreature->GetGUIDLow(), pathid, point);
|
||||
|
||||
wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
|
||||
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
|
||||
wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(),map);
|
||||
map->Add(wpCreature);
|
||||
|
||||
if (target)
|
||||
{
|
||||
wpCreature->SetDisplayId(target->GetDisplayId());
|
||||
wpCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5);
|
||||
wpCreature->SetLevel(point > STRONG_MAX_LEVEL ? STRONG_MAX_LEVEL : point);
|
||||
}
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
handler->SendSysMessage("|cff00ff00Showing the current creature's path.|r");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (show == "first")
|
||||
{
|
||||
handler->PSendSysMessage("|cff00ff00DEBUG: wp first, GUID: %u|r", pathid);
|
||||
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z FROM waypoint_data WHERE point='1' AND id = '%u'",pathid);
|
||||
if (!result)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUND, pathid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
float x = fields[0].GetFloat();
|
||||
float y = fields[1].GetFloat();
|
||||
float z = fields[2].GetFloat();
|
||||
uint32 id = VISUAL_WAYPOINT;
|
||||
|
||||
Player *chr = handler->GetSession()->GetPlayer();
|
||||
float o = chr->GetOrientation();
|
||||
Map *map = chr->GetMap();
|
||||
|
||||
Creature* pCreature = new Creature;
|
||||
if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT),map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
|
||||
delete pCreature;
|
||||
return false;
|
||||
}
|
||||
|
||||
pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
|
||||
pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map);
|
||||
map->Add(pCreature);
|
||||
|
||||
if (target)
|
||||
{
|
||||
pCreature->SetDisplayId(target->GetDisplayId());
|
||||
pCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (show == "last")
|
||||
{
|
||||
handler->PSendSysMessage("|cff00ff00DEBUG: wp last, PathID: |r|cff00ffff%u|r", pathid);
|
||||
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT MAX(point) FROM waypoint_data WHERE id = '%u'",pathid);
|
||||
if (result)
|
||||
Maxpoint = (*result)[0].GetUInt32();
|
||||
else
|
||||
Maxpoint = 0;
|
||||
|
||||
result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z FROM waypoint_data WHERE point ='%u' AND id = '%u'",Maxpoint, pathid);
|
||||
if (!result)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTFOUNDLAST, pathid);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
Field *fields = result->Fetch();
|
||||
float x = fields[0].GetFloat();
|
||||
float y = fields[1].GetFloat();
|
||||
float z = fields[2].GetFloat();
|
||||
uint32 id = VISUAL_WAYPOINT;
|
||||
|
||||
Player *chr = handler->GetSession()->GetPlayer();
|
||||
float o = chr->GetOrientation();
|
||||
Map *map = chr->GetMap();
|
||||
|
||||
Creature* pCreature = new Creature;
|
||||
if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id);
|
||||
delete pCreature;
|
||||
return false;
|
||||
}
|
||||
|
||||
pCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
|
||||
pCreature->LoadFromDB(pCreature->GetDBTableGUIDLow(), map);
|
||||
map->Add(pCreature);
|
||||
|
||||
if (target)
|
||||
{
|
||||
pCreature->SetDisplayId(target->GetDisplayId());
|
||||
pCreature->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (show == "off")
|
||||
{
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT guid FROM creature WHERE id = '%u'", 1);
|
||||
if (!result)
|
||||
{
|
||||
handler->SendSysMessage(LANG_WAYPOINT_VP_NOTFOUND);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
bool hasError = false;
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
uint32 guid = fields[0].GetUInt32();
|
||||
Creature* pCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(guid,VISUAL_WAYPOINT,HIGHGUID_UNIT));
|
||||
if (!pCreature)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid);
|
||||
hasError = true;
|
||||
WorldDatabase.PExecute("DELETE FROM creature WHERE guid = '%u'", guid);
|
||||
}
|
||||
else
|
||||
{
|
||||
pCreature->CombatStop();
|
||||
pCreature->DeleteFromDB();
|
||||
pCreature->AddObjectToRemoveList();
|
||||
}
|
||||
}
|
||||
while (result->NextRow());
|
||||
// set "wpguid" column to "empty" - no visual waypoint spawned
|
||||
WorldDatabase.PExecute("UPDATE waypoint_data SET wpguid = '0'");
|
||||
//WorldDatabase.PExecute("UPDATE creature_movement SET wpguid = '0' WHERE wpguid <> '0'");
|
||||
|
||||
if (hasError)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR1);
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR2);
|
||||
handler->PSendSysMessage(LANG_WAYPOINT_TOOFAR3);
|
||||
}
|
||||
|
||||
handler->SendSysMessage(LANG_WAYPOINT_VP_ALLREMOVED);
|
||||
return true;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("|cffff33ffDEBUG: wpshow - no valid command found|r");
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void AddSC_wp_commandscript()
|
||||
{
|
||||
new wp_commandscript();
|
||||
}
|
||||
Reference in New Issue
Block a user