[svn] added commands : pet create, tp, learn, unlearn. gobject activate and playall. thanx to dythzer.
--HG-- branch : trunk
This commit is contained in:
@@ -102,6 +102,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ "drunk", SEC_MODERATOR, false, &ChatHandler::HandleDrunkCommand, "", NULL },
|
||||
{ "standstate", SEC_GAMEMASTER, false, &ChatHandler::HandleStandStateCommand, "", NULL },
|
||||
{ "morph", SEC_GAMEMASTER, false, &ChatHandler::HandleMorphCommand, "", NULL },
|
||||
{ "gender", SEC_ADMINISTRATOR, false, &ChatHandler::HandleModifyGenderCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
@@ -283,6 +284,16 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ "rank", SEC_GAMEMASTER, true, &ChatHandler::HandleGuildRankCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
static ChatCommand petCommandTable[] =
|
||||
{
|
||||
{ "create", SEC_GAMEMASTER, false, &ChatHandler::HandleCreatePetCommand, "", NULL },
|
||||
{ "learn", SEC_GAMEMASTER, false, &ChatHandler::HandlePetLearnCommand, "", NULL },
|
||||
{ "unlearn", SEC_GAMEMASTER, false, &ChatHandler::HandlePetUnlearnCommand, "", NULL },
|
||||
{ "tp", SEC_GAMEMASTER, false, &ChatHandler::HandlePetTpCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
|
||||
static ChatCommand groupCommandTable[] =
|
||||
{
|
||||
@@ -420,6 +431,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ "turn", SEC_GAMEMASTER, false, &ChatHandler::HandleTurnObjectCommand, "", NULL },
|
||||
{ "move", SEC_GAMEMASTER, false, &ChatHandler::HandleMoveObjectCommand, "", NULL },
|
||||
{ "near", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNearObjectCommand, "", NULL },
|
||||
{ "activate", SEC_GAMEMASTER, false, &ChatHandler::HandleActivateObjectCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
@@ -475,6 +487,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ "reset", SEC_ADMINISTRATOR, false, NULL, "", resetCommandTable },
|
||||
{ "instance", SEC_ADMINISTRATOR, true, NULL, "", instanceCommandTable },
|
||||
{ "server", SEC_ADMINISTRATOR, true, NULL, "", serverCommandTable },
|
||||
{ "pet", SEC_GAMEMASTER, false, NULL, "", petCommandTable },
|
||||
|
||||
{ "aura", SEC_ADMINISTRATOR, false, &ChatHandler::HandleAuraCommand, "", NULL },
|
||||
{ "unaura", SEC_ADMINISTRATOR, false, &ChatHandler::HandleUnAuraCommand, "", NULL },
|
||||
@@ -540,6 +553,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
||||
{ "combatstop", SEC_GAMEMASTER, false, &ChatHandler::HandleCombatStopCommand, "", NULL },
|
||||
{ "chardelete", SEC_CONSOLE, true, &ChatHandler::HandleCharacterDeleteCommand, "", NULL },
|
||||
{ "sendmessage", SEC_ADMINISTRATOR, true, &ChatHandler::HandleSendMessageCommand, "", NULL },
|
||||
{ "playall", SEC_ADMINISTRATOR, false, &ChatHandler::HandlePlayAllCommand, "", NULL },
|
||||
{ "repairitems", SEC_GAMEMASTER, false, &ChatHandler::HandleRepairitemsCommand, "", NULL },
|
||||
{ "freeze", SEC_ADMINISTRATOR, false, &ChatHandler::HandleFreezeCommand, "", NULL },
|
||||
{ "unfreeze", SEC_ADMINISTRATOR, false, &ChatHandler::HandleUnFreezeCommand, "", NULL },
|
||||
|
||||
@@ -349,6 +349,7 @@ class ChatHandler
|
||||
bool HandleUnAuraCommand(const char* args);
|
||||
bool HandleLinkGraveCommand(const char* args);
|
||||
bool HandleNearGraveCommand(const char* args);
|
||||
bool HandleActivateObjectCommand(const char* args);
|
||||
bool HandleSpawnTransportCommand(const char* args);
|
||||
bool HandleExploreCheatCommand(const char* args);
|
||||
bool HandleTextEmoteCommand(const char* args);
|
||||
@@ -360,6 +361,11 @@ class ChatHandler
|
||||
bool HandleHideAreaCommand(const char* args);
|
||||
bool HandleAddItemCommand(const char* args);
|
||||
bool HandleAddItemSetCommand(const char* args);
|
||||
bool HandleModifyGenderCommand(const char* args);
|
||||
bool HandlePetTpCommand(const char* args);
|
||||
bool HandlePetUnlearnCommand(const char* args);
|
||||
bool HandlePetLearnCommand(const char* args);
|
||||
bool HandleCreatePetCommand(const char* args);
|
||||
|
||||
bool HandleGroupLeaderCommand(const char* args);
|
||||
bool HandleGroupDisbandCommand(const char* args);
|
||||
@@ -424,6 +430,7 @@ class ChatHandler
|
||||
bool HandleCombatStopCommand(const char *args);
|
||||
bool HandleCharDeleteCommand(const char *args);
|
||||
bool HandleSendMessageCommand(const char * args);
|
||||
bool HandlePlayAllCommand(const char* args);
|
||||
bool HandleRepairitemsCommand(const char* args);
|
||||
bool HandleFlushArenaPointsCommand(const char *args);
|
||||
|
||||
|
||||
@@ -728,6 +728,7 @@ enum TrinityStrings
|
||||
LANG_COMMAND_FROZEN_PLAYERS = 5006,
|
||||
LANG_INSTANCE_MUST_RAID_GRP = 5007,
|
||||
LANG_INSTANCE_NOT_AS_GHOST = 5008,
|
||||
LANG_COMMAND_PLAYED_TO_ALL = 5009,
|
||||
// Room for more Trinity strings 5009-9999
|
||||
|
||||
// Use for not-in-svn patches 10000-10999
|
||||
|
||||
@@ -4127,3 +4127,203 @@ bool ChatHandler::HandleNpcUnFollowCommand(const char* /*args*/)
|
||||
PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleCreatePetCommand(const char* args)
|
||||
{
|
||||
Player *player = m_session->GetPlayer();
|
||||
Creature *creatureTarget = getSelectedCreature();
|
||||
|
||||
CreatureInfo const* cInfo = objmgr.GetCreatureTemplate(creatureTarget->GetEntry());
|
||||
// Creatures with family 0 crashes the server
|
||||
if(cInfo->family == 0)
|
||||
{
|
||||
PSendSysMessage("This creature cannot be tamed. (family id: 0).");
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(player->GetPetGUID())
|
||||
{
|
||||
PSendSysMessage("You already have a pet");
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!creatureTarget || creatureTarget->isPet() || creatureTarget->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
PSendSysMessage(LANG_SELECT_CREATURE);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Everything looks OK, create new pet
|
||||
Pet* pet = new Pet(HUNTER_PET);
|
||||
|
||||
if(!pet->CreateBaseAtCreature(creatureTarget))
|
||||
{
|
||||
delete pet;
|
||||
PSendSysMessage("Error 1");
|
||||
return false;
|
||||
}
|
||||
|
||||
creatureTarget->setDeathState(JUST_DIED);
|
||||
creatureTarget->RemoveCorpse();
|
||||
creatureTarget->SetHealth(0); // just for nice GM-mode view
|
||||
|
||||
pet->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, player->GetGUID());
|
||||
pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID());
|
||||
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction());
|
||||
|
||||
if(!pet->InitStatsForLevel(creatureTarget->getLevel()))
|
||||
{
|
||||
sLog.outError("ERROR: InitStatsForLevel() in EffectTameCreature failed! Pet deleted.");
|
||||
PSendSysMessage("Error 2");
|
||||
return false;
|
||||
}
|
||||
|
||||
// prepare visual effect for levelup
|
||||
pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()-1);
|
||||
|
||||
pet->GetCharmInfo()->SetPetNumber(objmgr.GeneratePetNumber(), true);
|
||||
// this enables pet details window (Shift+P)
|
||||
pet->AIM_Initialize();
|
||||
pet->InitPetCreateSpells();
|
||||
pet->SetHealth(pet->GetMaxHealth());
|
||||
|
||||
MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet);
|
||||
|
||||
// visual effect for levelup
|
||||
pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel());
|
||||
|
||||
player->SetPet(pet);
|
||||
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
|
||||
player->PetSpellInitialize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandlePetLearnCommand(const char* args)
|
||||
{
|
||||
if(!*args)
|
||||
return false;
|
||||
|
||||
Player *plr = m_session->GetPlayer();
|
||||
Pet *pet = plr->GetPet();
|
||||
|
||||
if(!pet)
|
||||
{
|
||||
PSendSysMessage("You have no pet");
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 spellId = extractSpellIdFromLink((char*)args);
|
||||
|
||||
if(!spellId || !sSpellStore.LookupEntry(spellId))
|
||||
return false;
|
||||
|
||||
// Check if pet already has it
|
||||
if(pet->HasSpell(spellId))
|
||||
{
|
||||
PSendSysMessage("Pet already has spell: %u", spellId);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if spell is valid
|
||||
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
|
||||
if(!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spellId);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
pet->learnSpell(spellId);
|
||||
|
||||
PSendSysMessage("Pet has learned spell %u", spellId);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandlePetUnlearnCommand(const char *args)
|
||||
{
|
||||
if(!*args)
|
||||
return false;
|
||||
|
||||
Player *plr = m_session->GetPlayer();
|
||||
Pet *pet = plr->GetPet();
|
||||
|
||||
if(!pet)
|
||||
{
|
||||
PSendSysMessage("You have no pet");
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 spellId = extractSpellIdFromLink((char*)args);
|
||||
|
||||
if(pet->HasSpell(spellId))
|
||||
pet->removeSpell(spellId);
|
||||
else
|
||||
PSendSysMessage("Pet doesn't have that spell");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandlePetTpCommand(const char *args)
|
||||
{
|
||||
if(!*args)
|
||||
return false;
|
||||
|
||||
Player *plr = m_session->GetPlayer();
|
||||
Pet *pet = plr->GetPet();
|
||||
|
||||
if(!pet)
|
||||
{
|
||||
PSendSysMessage("You have no pet");
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 tp = atol(args);
|
||||
|
||||
pet->SetTP(tp);
|
||||
|
||||
PSendSysMessage("Pet's tp changed to %u", tp);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleActivateObjectCommand(const char *args)
|
||||
{
|
||||
if(!*args)
|
||||
return false;
|
||||
|
||||
char* cId = extractKeyFromLink((char*)args,"Hgameobject");
|
||||
if(!cId)
|
||||
return false;
|
||||
|
||||
uint32 lowguid = atoi(cId);
|
||||
if(!lowguid)
|
||||
return false;
|
||||
|
||||
GameObject* obj = NULL;
|
||||
|
||||
// by DB guid
|
||||
if (GameObjectData const* go_data = objmgr.GetGOData(lowguid))
|
||||
obj = GetObjectGlobalyWithGuidOrNearWithDbGuid(lowguid,go_data->id);
|
||||
|
||||
if(!obj)
|
||||
{
|
||||
PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, lowguid);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Activate
|
||||
obj->SetLootState(GO_READY);
|
||||
obj->UseDoorOrButton(10000);
|
||||
|
||||
PSendSysMessage("Object activated!");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -6226,6 +6226,91 @@ bool ChatHandler::HandleSendMessageCommand(const char* args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandlePlayAllCommand(const char* args)
|
||||
{
|
||||
if(!*args)
|
||||
return false;
|
||||
|
||||
uint32 soundId = atoi((char*)args);
|
||||
|
||||
if(!sSoundEntriesStore.LookupEntry(soundId))
|
||||
{
|
||||
PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
WorldPacket data(SMSG_PLAY_SOUND, 4);
|
||||
data << uint32(soundId) << m_session->GetPlayer()->GetGUID();
|
||||
sWorld.SendGlobalMessage(&data);
|
||||
|
||||
PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleModifyGenderCommand(const char *args)
|
||||
{
|
||||
if(!*args) return false;
|
||||
Player *player = getSelectedPlayer();
|
||||
|
||||
if(!player)
|
||||
{
|
||||
PSendSysMessage(LANG_NO_PLAYER);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string gender = (char*)args;
|
||||
uint32 displayId = player->GetNativeDisplayId();
|
||||
|
||||
if(gender == "male") // MALE
|
||||
{
|
||||
if(player->getGender() == GENDER_MALE)
|
||||
{
|
||||
PSendSysMessage("%s is already male", player->GetName());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set gender
|
||||
player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_MALE);
|
||||
// Change display ID
|
||||
player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1);
|
||||
player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId+1 : displayId-1);
|
||||
|
||||
ChatHandler(player).PSendSysMessage("Gender changed. You are now a man!");
|
||||
PSendSysMessage("Gender changed for %s", player->GetName());
|
||||
return true;
|
||||
}
|
||||
else if(gender == "female") // FEMALE
|
||||
{
|
||||
if(player->getGender() == GENDER_FEMALE)
|
||||
{
|
||||
PSendSysMessage("%s is already female", player->GetName());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set gender
|
||||
player->SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_FEMALE);
|
||||
// Change display ID
|
||||
player->SetDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1);
|
||||
player->SetNativeDisplayId(player->getRace() == RACE_BLOODELF ? displayId-1 : displayId+1);
|
||||
|
||||
ChatHandler(player).PSendSysMessage("Gender changed. You are now a woman!");
|
||||
PSendSysMessage("Gender changed for %s", player->GetName());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PSendSysMessage("You must use male or female as gender.");
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatHandler::HandleFreezeCommand(const char *args)
|
||||
{
|
||||
std::string name;
|
||||
|
||||
Reference in New Issue
Block a user