mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +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
|
|
@ -340,6 +340,7 @@ INSERT INTO `command` VALUES
|
||||||
('npc spawndist',2,'Syntax: .npc spawndist #dist\r\n\r\nAdjust spawndistance of selected creature to dist.'),
|
('npc spawndist',2,'Syntax: .npc spawndist #dist\r\n\r\nAdjust spawndistance of selected creature to dist.'),
|
||||||
('npc spawntime',2,'Syntax: .npc spawntime #time \r\n\r\nAdjust spawntime of selected creature to time.'),
|
('npc spawntime',2,'Syntax: .npc spawntime #time \r\n\r\nAdjust spawntime of selected creature to time.'),
|
||||||
('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 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 tame',2,'Syntax: .npc tame\r\n\r\nTame selected creature (tameable non pet creature). You don''t must have pet.'),
|
||||||
('npc textemote',3,'Syntax: .npc textemote #emoteid\r\n\r\nMake the selected creature to do textemote with an emote of id #emoteid.'),
|
('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 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.'),
|
('npc unfollow',2,'Syntax: .npc unfollow\r\n\r\nSelected creature (non pet) stop follow you.'),
|
||||||
|
|
@ -2415,6 +2416,8 @@ INSERT INTO `mangos_string` VALUES
|
||||||
(340,'%s is now following you.',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),
|
(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),
|
(342,'%s is now not following you.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
|
||||||
|
(343,'Creature (Entry: %u) cannot be tamed.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
|
||||||
|
(344,'You already have pet.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
|
||||||
(400,'|cffff0000[System Message]:|rScripts reloaded',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),
|
(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),
|
(402,'%s changed your security level to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
|
||||||
|
|
|
||||||
7
sql/updates/2008_10_31_02_mangos_mangos_string.sql
Normal file
7
sql/updates/2008_10_31_02_mangos_mangos_string.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
ALTER TABLE db_version CHANGE COLUMN required_2008_10_31_01_mangos_creature_template required_2008_10_31_02_mangos_mangos_string bit;
|
||||||
|
|
||||||
|
DELETE FROM mangos_string WHERE entry IN (343,344);
|
||||||
|
|
||||||
|
INSERT INTO mangos_string VALUES
|
||||||
|
(343,'Creature (Entry: %u) cannot be tamed.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
|
||||||
|
(344,'You already have pet.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
|
||||||
6
sql/updates/2008_10_31_03_mangos_command.sql
Normal file
6
sql/updates/2008_10_31_03_mangos_command.sql
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
ALTER TABLE db_version CHANGE COLUMN required_2008_10_31_02_mangos_mangos_string required_2008_10_31_03_mangos_command bit;
|
||||||
|
|
||||||
|
DELETE FROM command WHERE name IN ('npc tame');
|
||||||
|
|
||||||
|
INSERT INTO command VALUES
|
||||||
|
('npc tame',2,'Syntax: .npc tame\r\n\r\nTame selected creature (tameable non pet creature). You don''t must have pet.');
|
||||||
|
|
@ -119,6 +119,8 @@ pkgdata_DATA = \
|
||||||
2008_10_29_04_mangos_mangos_string.sql \
|
2008_10_29_04_mangos_mangos_string.sql \
|
||||||
2008_10_29_05_mangos_command.sql \
|
2008_10_29_05_mangos_command.sql \
|
||||||
2008_10_31_01_mangos_creature_template.sql \
|
2008_10_31_01_mangos_creature_template.sql \
|
||||||
|
2008_10_31_02_mangos_mangos_string.sql \
|
||||||
|
2008_10_31_03_mangos_command.sql \
|
||||||
README
|
README
|
||||||
|
|
||||||
## Additional files to include when running 'make dist'
|
## Additional files to include when running 'make dist'
|
||||||
|
|
@ -219,4 +221,6 @@ EXTRA_DIST = \
|
||||||
2008_10_29_04_mangos_mangos_string.sql \
|
2008_10_29_04_mangos_mangos_string.sql \
|
||||||
2008_10_29_05_mangos_command.sql \
|
2008_10_29_05_mangos_command.sql \
|
||||||
2008_10_31_01_mangos_creature_template.sql \
|
2008_10_31_01_mangos_creature_template.sql \
|
||||||
|
2008_10_31_02_mangos_mangos_string.sql \
|
||||||
|
2008_10_31_03_mangos_command.sql \
|
||||||
README
|
README
|
||||||
|
|
|
||||||
|
|
@ -379,6 +379,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||||
{ "unfollow", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcUnFollowCommand, "", NULL },
|
{ "unfollow", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcUnFollowCommand, "", NULL },
|
||||||
{ "whisper", SEC_MODERATOR, false, &ChatHandler::HandleNpcWhisperCommand, "", NULL },
|
{ "whisper", SEC_MODERATOR, false, &ChatHandler::HandleNpcWhisperCommand, "", NULL },
|
||||||
{ "yell", SEC_MODERATOR, false, &ChatHandler::HandleNpcYellCommand, "", NULL },
|
{ "yell", SEC_MODERATOR, false, &ChatHandler::HandleNpcYellCommand, "", NULL },
|
||||||
|
{ "tame", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcTameCommand, "", NULL },
|
||||||
|
|
||||||
//{ TODO: fix or remove this commands
|
//{ TODO: fix or remove this commands
|
||||||
{ "name", SEC_GAMEMASTER, false, &ChatHandler::HandleNameCommand, "", NULL },
|
{ "name", SEC_GAMEMASTER, false, &ChatHandler::HandleNameCommand, "", NULL },
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,7 @@ class ChatHandler
|
||||||
bool HandleNpcSetMoveTypeCommand(const char* args);
|
bool HandleNpcSetMoveTypeCommand(const char* args);
|
||||||
bool HandleNpcSpawnDistCommand(const char* args);
|
bool HandleNpcSpawnDistCommand(const char* args);
|
||||||
bool HandleNpcSpawnTimeCommand(const char* args);
|
bool HandleNpcSpawnTimeCommand(const char* args);
|
||||||
|
bool HandleNpcTameCommand(const char* args);
|
||||||
bool HandleNpcTextEmoteCommand(const char* args);
|
bool HandleNpcTextEmoteCommand(const char* args);
|
||||||
bool HandleNpcUnFollowCommand(const char* args);
|
bool HandleNpcUnFollowCommand(const char* args);
|
||||||
bool HandleNpcWhisperCommand(const char* args);
|
bool HandleNpcWhisperCommand(const char* args);
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,9 @@ enum MangosStrings
|
||||||
LANG_CREATURE_FOLLOW_YOU_NOW = 340,
|
LANG_CREATURE_FOLLOW_YOU_NOW = 340,
|
||||||
LANG_CREATURE_NOT_FOLLOW_YOU = 341,
|
LANG_CREATURE_NOT_FOLLOW_YOU = 341,
|
||||||
LANG_CREATURE_NOT_FOLLOW_YOU_NOW = 342,
|
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
|
// level 3 chat
|
||||||
LANG_SCRIPTS_RELOADED = 400,
|
LANG_SCRIPTS_RELOADED = 400,
|
||||||
|
|
|
||||||
|
|
@ -4156,3 +4156,67 @@ bool ChatHandler::HandleNpcUnFollowCommand(const char* /*args*/)
|
||||||
PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName());
|
PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName());
|
||||||
return true;
|
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