Scripts/Commands: ".modify speed" targets current Player by default

Allow ".modify speed" command to target current Player if there is no target or if the selected Unit is a Creature.
This behavior could be extended to other commands that require target Players.
This commit is contained in:
jackpoz
2014-04-13 14:06:21 +02:00
parent a07e82530f
commit dc58ec0d6c
3 changed files with 25 additions and 5 deletions

View File

@@ -782,6 +782,24 @@ Creature* ChatHandler::getSelectedCreature()
return ObjectAccessor::GetCreatureOrPetOrVehicle(*m_session->GetPlayer(), m_session->GetPlayer()->GetTarget());
}
Player* ChatHandler::getSelectedPlayerOrSelf()
{
if (!m_session)
return NULL;
uint64 selected = m_session->GetPlayer()->GetTarget();
if (!selected)
return m_session->GetPlayer();
// first try with selected target
Player* targetPlayer = ObjectAccessor::FindPlayer(selected);
// if the target is not a player, then return self
if (!targetPlayer)
targetPlayer = m_session->GetPlayer();
return targetPlayer;
}
char* ChatHandler::extractKeyFromLink(char* text, char const* linkType, char** something1)
{
// skip empty