diff options
author | KingPin <none@none> | 2008-10-29 17:09:32 -0500 |
---|---|---|
committer | KingPin <none@none> | 2008-10-29 17:09:32 -0500 |
commit | ce2d63e4aeddca0781c2eef764a6df0154f561fc (patch) | |
tree | 1b4aeb6a43215b64214e044c791c0324ed0af467 /src/game/Level2.cpp | |
parent | febb2d61472bbce18e008967dad04d2eaaa063cf (diff) |
[svn] * Added npc follow, waterwalk, repairitems commands. Patch by dythzer
* Prevent adding more than 5 people to raid - Apoc
* fixed typo from one of our previous commits.
* Fixed two strings in core, thanx to warhead for patch.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Level2.cpp')
-rw-r--r-- | src/game/Level2.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 4164c5cde3c..f60b38b5522 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -44,6 +44,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, @@ -4052,3 +4054,79 @@ bool ChatHandler::HandleServerCorpsesCommand(const char* /*args*/) CorpsesErase(); return true; } + +bool ChatHandler::HandleRepairitemsCommand(const char* /*args*/) +{ + Player *target = getSelectedPlayer(); + + if(!target) + { + PSendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + // Repair items + target->DurabilityRepairAll(false, 0, false); + + PSendSysMessage(LANG_YOU_REPAIR_ITEMS, target->GetName()); + if(needReportToTarget(target)) + ChatHandler(target).PSendSysMessage(LANG_YOUR_ITEMS_REPAIRED, 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; +} |