diff --git a/sql/mangos.sql b/sql/mangos.sql index 5048f54dc..c2331be8c 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -330,6 +330,7 @@ INSERT INTO `command` VALUES ('npc delitem',2,'Syntax: .npc delitem #itemId\r\n\r\nRemove item #itemid from item list of selected vendor.'), ('npc factionid',2,'Syntax: .npc factionid #factionid\r\n\r\nSet the faction of the selected creature to #factionid.'), ('npc flag',2,'Syntax: .npc flag #npcflag\r\n\r\nSet the NPC flags of creature template of the selected creature and selected creature to #npcflag. NPC flags will applied to all creatures of selected creature template after server restart or grid unload/load.'), +('npc follow',2,'Syntax: .npc follow\r\n\r\nSelected creature start follow you until death/fight/etc.'), ('npc info',3,'Syntax: .npc info\r\n\r\nDisplay a list of details for the selected creature.\r\n\r\nThe list includes:\r\n- GUID, Faction, NPC flags, Entry ID, Model ID,\r\n- Level,\r\n- Health (current/maximum),\r\n\r\n- Field flags, dynamic flags, faction template, \r\n- Position information,\r\n- and the creature type, e.g. if the creature is a vendor.'), ('npc move',2,'Syntax: .npc move [#creature_guid]\r\n\r\nMove the targeted creature spawn point to your coordinates.'), ('npc name',2,'Syntax: .npc name $name\r\n\r\nChange the name of the selected creature or character to $name.\r\n\r\nCommand disabled.'), @@ -341,6 +342,7 @@ INSERT INTO `command` VALUES ('npc subname',2,'Syntax: .npc subname $Name\r\n\r\nChange the subname of the selected creature or player to $Name.\r\n\r\nCommand disabled.'), ('npc textemote',3,'Syntax: .npc textemote #emoteid\r\n\r\nMake the selected creature to do textemote with an emote of id #emoteid.'), ('npc whisper',1,'Syntax: .npc whisper #playerguid #text\r\nMake the selected npc whisper #text to #playerguid.'), +('npc unfollow',2,'Syntax: .npc unfollow\r\n\r\nSelected creature (non pet) stop follow you.'), ('password',0,'Syntax: .password $old_password $new_password $new_password\r\n\r\nChange your account password.'), ('pdump write',3,'Syntax is: pdump write $filename $playerNameOrGUID\r\nWrite character dump with name/guid $playerNameOrGUID to file $filename.'), ('pdump load',3,'Syntax is: pdump load $filename $account [$newname] [$newguid]\r\nLoad character dump from dump file into character list of $account with saved or $newname, with saved (or first free) or $newguid guid.'), @@ -397,7 +399,7 @@ INSERT INTO `command` VALUES ('unban ip',3,'Syntax is: unban ip $Ip\r\nUnban accounts for IP pattern.'), ('unlearn',3,'Syntax: .unlearn #startspell #endspell\r\n\r\nUnlearn for selected player the range of spells between id #startspell and #endspell. If no #endspell is provided, just unlearn spell of id #startspell.'), ('unmute',1,'Syntax: .unmute $playerName\r\n\r\nRestore chat messaging for any character from account of character $playerName.'), -('waterwalk',3,'Syntax: .waterwalk on/off\r\n\r\nSet on/off waterwalk state for selected player.'), +('waterwalk',2,'Syntax: .waterwalk on/off\r\n\r\nSet on/off waterwalk state for selected player.'), ('wchange',3,'Syntax: .wchange #weathertype #status\r\n\r\nSet current weather to #weathertype with an intensity of #status.\r\n\r\n#weathertype can be 1 for rain, 2 for snow, and 3 for sand. #status can be 0 for disabled, and 1 for enabled.'), ('whispers',1,'Syntax: .whispers on|off\r\nEnable/disable accepting whispers by GM from players. By default use mangosd.conf setting.'), ('wp',2,'Using WP Command:\r\nEach Waypoint Command has it\'s own description!'), @@ -803,7 +805,7 @@ CREATE TABLE `db_version` ( LOCK TABLES `db_version` WRITE; /*!40000 ALTER TABLE `db_version` DISABLE KEYS */; INSERT INTO `db_version` VALUES -('Mangos default database.'); +('Mangos default database.',NULL); /*!40000 ALTER TABLE `db_version` ENABLE KEYS */; UNLOCK TABLES; @@ -2410,6 +2412,9 @@ INSERT INTO `mangos_string` VALUES (337,'All your items repaired by %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (338,'You set waterwalk mode %s for %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (339,'Your waterwalk mode %s by %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(340,'%s is now following you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(341,'%s is not following you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(342,'%s is now not following you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (400,'|cffff0000[System Message]:|rScripts reloaded',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (401,'You change security level of account %s to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (402,'%s changed your security level to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), diff --git a/sql/updates/2008_10_29_04_mangos_mangos_string.sql b/sql/updates/2008_10_29_04_mangos_mangos_string.sql new file mode 100644 index 000000000..8404c195d --- /dev/null +++ b/sql/updates/2008_10_29_04_mangos_mangos_string.sql @@ -0,0 +1,8 @@ +ALTER TABLE db_version CHANGE COLUMN required_2008_10_29_03_mangos_db_version required_2008_10_29_04_mangos_mangos_string bit; + +DELETE FROM mangos_string WHERE entry IN (340,341,342); + +INSERT INTO mangos_string VALUES +(340,'%s is now following you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(341,'%s is not following you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(342,'%s is now not following you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); diff --git a/sql/updates/2008_10_29_05_mangos_command.sql b/sql/updates/2008_10_29_05_mangos_command.sql new file mode 100644 index 000000000..2c60ba03f --- /dev/null +++ b/sql/updates/2008_10_29_05_mangos_command.sql @@ -0,0 +1,8 @@ +ALTER TABLE db_version CHANGE COLUMN required_2008_10_29_04_mangos_mangos_string required_2008_10_29_05_mangos_command bit; + +DELETE FROM command WHERE name IN ('npc follow','npc unfollow','waterwalk'); + +INSERT INTO command VALUES +('npc follow',2,'Syntax: .npc follow\r\n\r\nSelected creature start follow you until death/fight/etc.'), +('npc unfollow',2,'Syntax: .npc unfollow\r\n\r\nSelected creature (non pet) stop follow you.'), +('waterwalk',2,'Syntax: .waterwalk on/off\r\n\r\nSet on/off waterwalk state for selected player.'); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index a9dedb563..f030b0b19 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -116,6 +116,8 @@ pkgdata_DATA = \ 2008_10_29_01_mangos_mangos_string.sql \ 2008_10_29_02_mangos_command.sql \ 2008_10_29_03_mangos_db_version.sql \ + 2008_10_29_04_mangos_mangos_string.sql \ + 2008_10_29_05_mangos_command.sql \ README ## Additional files to include when running 'make dist' @@ -213,4 +215,6 @@ EXTRA_DIST = \ 2008_10_29_01_mangos_mangos_string.sql \ 2008_10_29_02_mangos_command.sql \ 2008_10_29_03_mangos_db_version.sql \ + 2008_10_29_04_mangos_mangos_string.sql \ + 2008_10_29_05_mangos_command.sql \ README diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 58ed497ee..b12bd3e0c 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -377,6 +377,8 @@ ChatCommand * ChatHandler::getCommandTable() { "changeentry", SEC_ADMINISTRATOR, false, &ChatHandler::HandleChangeEntryCommand, "", NULL }, { "info", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNpcInfoCommand, "", NULL }, { "playemote", SEC_ADMINISTRATOR, false, &ChatHandler::HandlePlayEmoteCommand, "", NULL }, + { "follow", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcFollowCommand, "", NULL }, + { "unfollow", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcUnFollowCommand, "", NULL }, //{ TODO: fix or remove this commands { "name", SEC_GAMEMASTER, false, &ChatHandler::HandleNameCommand, "", NULL }, diff --git a/src/game/Chat.h b/src/game/Chat.h index fdbe5651f..a5ded3c6c 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -149,6 +149,9 @@ class ChatHandler bool HandleModifyRepCommand(const char* args); bool HandleModifyArenaCommand(const char* args); + bool HandleNpcFollowCommand(const char* args); + bool HandleNpcUnFollowCommand(const char* args); + bool HandleReloadCommand(const char* args); bool HandleReloadAllCommand(const char* args); bool HandleReloadAllAreaCommand(const char* args); diff --git a/src/game/Language.h b/src/game/Language.h index aee0f9bd7..974b94ee0 100644 --- a/src/game/Language.h +++ b/src/game/Language.h @@ -321,7 +321,10 @@ enum MangosStrings LANG_YOUR_ITEMS_REPAIRED = 337, LANG_YOU_SET_WATERWALK = 338, LANG_YOUR_WATERWALK_SET = 339, - // Room for more level 2 340-399 not used + LANG_CREATURE_FOLLOW_YOU_NOW = 340, + LANG_CREATURE_NOT_FOLLOW_YOU = 341, + LANG_CREATURE_NOT_FOLLOW_YOU_NOW = 342, + // Room for more level 2 343-399 not used // level 3 chat LANG_SCRIPTS_RELOADED = 400, diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index fa26be329..2d9043bc4 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -42,6 +42,8 @@ #include #include "GlobalEvents.h" +#include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand + static uint32 ReputationRankStrIndex[MAX_REPUTATION_RANK] = { LANG_REP_HATED, LANG_REP_HOSTILE, LANG_REP_UNFRIENDLY, LANG_REP_NEUTRAL, @@ -4048,7 +4050,7 @@ bool ChatHandler::HandleServerCorpsesCommand(const char* /*args*/) return true; } -bool ChatHandler::HandleRepairitemsCommand(const char* args) +bool ChatHandler::HandleRepairitemsCommand(const char* /*args*/) { Player *target = getSelectedPlayer(); @@ -4097,3 +4099,59 @@ bool ChatHandler::HandleWaterwalkCommand(const char* args) ChatHandler(player).PSendSysMessage(LANG_YOUR_WATERWALK_SET, args, GetName()); return true; } + +bool ChatHandler::HandleNpcFollowCommand(const char* /*args*/) +{ + Player *player = m_session->GetPlayer(); + Creature *creature = getSelectedCreature(); + + if(!creature) + { + PSendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + // Follow player - Using pet's default dist and angle + creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + + PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName()); + return true; +} + +bool ChatHandler::HandleNpcUnFollowCommand(const char* /*args*/) +{ + Player *player = m_session->GetPlayer(); + Creature *creature = getSelectedCreature(); + + if(!creature) + { + PSendSysMessage(LANG_SELECT_CREATURE); + SetSentErrorMessage(true); + return false; + } + + if (creature->GetMotionMaster()->empty() || + creature->GetMotionMaster()->GetCurrentMovementGeneratorType ()!=TARGETED_MOTION_TYPE) + { + PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU); + SetSentErrorMessage(true); + return false; + } + + TargetedMovementGenerator const* mgen + = static_cast const*>((creature->GetMotionMaster()->top())); + + if(mgen->GetTarget()!=player) + { + PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU); + SetSentErrorMessage(true); + return false; + } + + // reset movement + creature->GetMotionMaster()->MovementExpired(true); + + PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName()); + return true; +}