[2008_10_29_04_mangos_mangos_string.sql 2008_10_29_05_mangos_command.sql] Added new command: .npc follow - Makes the selected NPC follow you around like a pet

Signed-off-by: dythzer <micke223@gmail.com>

* Also implement .npc unfollow for cancel following.
* Help and mangos strings.
* Unrelated small fixes in mangos.sql.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
dythzer 2008-10-26 18:54:07 +01:00 committed by VladimirMangos
parent affb0722d6
commit 569032d907
8 changed files with 95 additions and 4 deletions

View file

@ -42,6 +42,8 @@
#include <map>
#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<Creature> const* mgen
= static_cast<TargetedMovementGenerator<Creature> 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;
}