Scripts/Commands: Add tele and event commands to commandscripts system and streamlining the command selection process to ensure the correct command is run when using abbreviations
Patch by Paradox (some cleanups was needed) --HG-- branch : trunk
This commit is contained in:
@@ -759,171 +759,6 @@ bool ChatHandler::HandleSendMailCommand(const char* args)
|
||||
return true;
|
||||
}
|
||||
|
||||
// teleport player to given game_tele.entry
|
||||
bool ChatHandler::HandleTeleNameCommand(const char * args)
|
||||
{
|
||||
char* nameStr;
|
||||
char* teleStr;
|
||||
extractOptFirstArg((char*)args,&nameStr,&teleStr);
|
||||
if (!teleStr)
|
||||
return false;
|
||||
|
||||
Player* target;
|
||||
uint64 target_guid;
|
||||
std::string target_name;
|
||||
if (!extractPlayerTarget(nameStr,&target,&target_guid,&target_name))
|
||||
return false;
|
||||
|
||||
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
|
||||
GameTele const* tele = extractGameTeleFromLink(teleStr);
|
||||
if (!tele)
|
||||
{
|
||||
SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* MapEntry const * me = sMapStore.LookupEntry(tele->mapId);
|
||||
if (!me || me->IsBattlegroundOrArena())
|
||||
{
|
||||
SendSysMessage(LANG_CANNOT_TELE_TO_BG);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Player *chr = sObjectMgr.GetPlayer(name.c_str());*/
|
||||
|
||||
if (target)
|
||||
{
|
||||
// check online security
|
||||
if (HasLowerSecurity(target, 0))
|
||||
return false;
|
||||
|
||||
std::string chrNameLink = playerLink(target_name);
|
||||
|
||||
if (target->IsBeingTeleported() == true)
|
||||
{
|
||||
PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink.c_str(),"", tele->name.c_str());
|
||||
if (needReportToTarget(target))
|
||||
ChatHandler(target).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetNameLink().c_str());
|
||||
|
||||
// stop flight if need
|
||||
if (target->isInFlight())
|
||||
{
|
||||
target->GetMotionMaster()->MovementExpired();
|
||||
target->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
target->SaveRecallPosition();
|
||||
|
||||
target->TeleportTo(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation);
|
||||
}
|
||||
else
|
||||
{
|
||||
// check offline security
|
||||
if (HasLowerSecurity(NULL, target_guid))
|
||||
return false;
|
||||
|
||||
std::string nameLink = playerLink(target_name);
|
||||
|
||||
PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), GetTrinityString(LANG_OFFLINE), tele->name.c_str());
|
||||
Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation,
|
||||
sMapMgr.GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z),target_guid);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//Teleport group to given game_tele.entry
|
||||
bool ChatHandler::HandleTeleGroupCommand(const char * args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player *player = getSelectedPlayer();
|
||||
if (!player)
|
||||
{
|
||||
SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// check online security
|
||||
if (HasLowerSecurity(player, 0))
|
||||
return false;
|
||||
|
||||
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
|
||||
GameTele const* tele = extractGameTeleFromLink((char*)args);
|
||||
if (!tele)
|
||||
{
|
||||
SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
MapEntry const * me = sMapStore.LookupEntry(tele->mapId);
|
||||
if (!me || me->IsBattlegroundOrArena())
|
||||
{
|
||||
SendSysMessage(LANG_CANNOT_TELE_TO_BG);
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string nameLink = GetNameLink(player);
|
||||
|
||||
Group *grp = player->GetGroup();
|
||||
if (!grp)
|
||||
{
|
||||
PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str());
|
||||
SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
Player *pl = itr->getSource();
|
||||
|
||||
if (!pl || !pl->GetSession())
|
||||
continue;
|
||||
|
||||
// check online security
|
||||
if (HasLowerSecurity(pl, 0))
|
||||
return false;
|
||||
|
||||
std::string plNameLink = GetNameLink(pl);
|
||||
|
||||
if (pl->IsBeingTeleported())
|
||||
{
|
||||
PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(),"", tele->name.c_str());
|
||||
if (needReportToTarget(pl))
|
||||
ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str());
|
||||
|
||||
// stop flight if need
|
||||
if (pl->isInFlight())
|
||||
{
|
||||
pl->GetMotionMaster()->MovementExpired();
|
||||
pl->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
pl->SaveRecallPosition();
|
||||
|
||||
pl->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//Summon group of player
|
||||
bool ChatHandler::HandleGroupSummonCommand(const char* args)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user