mirror of
https://github.com/mangosfour/server.git
synced 2025-12-27 01:37:04 +00:00
[2008_10_31_02_mangos_mangos_string.sql 2008_10_31_03_mangos_command.sql] Added new command: .npc tame - Creates a pet of the selected creature.
Works for all classes, not only hunter. Pet also saved in DB. Signed-off-by: dythzer <micke223@gmail.com> Command renamed to .npc tame and code updated to use common function with spell effect. Targeted creature not killed and tamed pet show up before player. Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
36508ba7ad
commit
eb97c9e717
8 changed files with 89 additions and 1 deletions
|
|
@ -379,6 +379,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
|||
{ "unfollow", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcUnFollowCommand, "", NULL },
|
||||
{ "whisper", SEC_MODERATOR, false, &ChatHandler::HandleNpcWhisperCommand, "", NULL },
|
||||
{ "yell", SEC_MODERATOR, false, &ChatHandler::HandleNpcYellCommand, "", NULL },
|
||||
{ "tame", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcTameCommand, "", NULL },
|
||||
|
||||
//{ TODO: fix or remove this commands
|
||||
{ "name", SEC_GAMEMASTER, false, &ChatHandler::HandleNameCommand, "", NULL },
|
||||
|
|
|
|||
|
|
@ -186,6 +186,7 @@ class ChatHandler
|
|||
bool HandleNpcSetMoveTypeCommand(const char* args);
|
||||
bool HandleNpcSpawnDistCommand(const char* args);
|
||||
bool HandleNpcSpawnTimeCommand(const char* args);
|
||||
bool HandleNpcTameCommand(const char* args);
|
||||
bool HandleNpcTextEmoteCommand(const char* args);
|
||||
bool HandleNpcUnFollowCommand(const char* args);
|
||||
bool HandleNpcWhisperCommand(const char* args);
|
||||
|
|
|
|||
|
|
@ -324,7 +324,9 @@ enum MangosStrings
|
|||
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
|
||||
LANG_CREATURE_NON_TAMEABLE = 343,
|
||||
LANG_YOU_ALREADY_HAVE_PET = 344,
|
||||
// Room for more level 2 345-399 not used
|
||||
|
||||
// level 3 chat
|
||||
LANG_SCRIPTS_RELOADED = 400,
|
||||
|
|
|
|||
|
|
@ -4156,3 +4156,67 @@ bool ChatHandler::HandleNpcUnFollowCommand(const char* /*args*/)
|
|||
PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleNpcTameCommand(const char* args)
|
||||
{
|
||||
Creature *creatureTarget = getSelectedCreature ();
|
||||
if (!creatureTarget || creatureTarget->isPet ())
|
||||
{
|
||||
PSendSysMessage (LANG_SELECT_CREATURE);
|
||||
SetSentErrorMessage (true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player *player = m_session->GetPlayer ();
|
||||
|
||||
if(player->GetPetGUID ())
|
||||
{
|
||||
SendSysMessage (LANG_YOU_ALREADY_HAVE_PET);
|
||||
SetSentErrorMessage (true);
|
||||
return false;
|
||||
}
|
||||
|
||||
CreatureInfo const* cInfo = creatureTarget->GetCreatureInfo();
|
||||
|
||||
if (!cInfo->isTameable ())
|
||||
{
|
||||
PSendSysMessage (LANG_CREATURE_NON_TAMEABLE,cInfo->Entry);
|
||||
SetSentErrorMessage (true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Everything looks OK, create new pet
|
||||
Pet* pet = player->CreateTamedPetFrom (creatureTarget);
|
||||
if (!pet)
|
||||
{
|
||||
PSendSysMessage (LANG_CREATURE_NON_TAMEABLE,cInfo->Entry);
|
||||
SetSentErrorMessage (true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// place pet before player
|
||||
float x,y,z;
|
||||
player->GetClosePoint (x,y,z,creatureTarget->GetObjectSize (),CONTACT_DISTANCE);
|
||||
pet->Relocate (x,y,z,M_PI-player->GetOrientation ());
|
||||
|
||||
// set pet to defensive mode by default (some classes can't control contolled pets in fact).
|
||||
pet->GetCharmInfo()->SetReactState(REACT_DEFENSIVE);
|
||||
|
||||
|
||||
// prepare visual effect for levelup
|
||||
pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()-1);
|
||||
|
||||
// add to world
|
||||
MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet);
|
||||
|
||||
// visual effect for levelup
|
||||
pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel());
|
||||
|
||||
// caster have pet now
|
||||
player->SetPet(pet);
|
||||
|
||||
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
|
||||
player->PetSpellInitialize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue