rendered paste bodybool ChatHandler::HandleMoveCreatureCommand(const char* args)
{
uint32 lowguid = 0;
Creature* pCreature = getSelectedCreature();
if(!pCreature)
{
// number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r
char* cId = strtok((char*)args, " ");
if (!cId)
return false;
uint32 lowguid = atoi(cId);
if(!lowguid)
return false;
if(!objmgr.GetCreatureData(lowguid))
{
PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowguid);
return true;
}
pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(),MAKE_GUID(lowguid,HIGHGUID_UNIT));
}
else
{
lowguid = pCreature->GetDBTableGUIDLow();
}
float x, y, z, o;
x = m_session->GetPlayer()->GetPositionX();
y = m_session->GetPlayer()->GetPositionY();
z = m_session->GetPlayer()->GetPositionZ();
o = m_session->GetPlayer()->GetOrientation();
if (pCreature)
{
pCreature->SetRespawnCoord(x, y, z);
MapManager::Instance().GetMap(pCreature->GetMapId(),pCreature)->CreatureRelocation(pCreature,x, y, z,o);
pCreature->GetMotionMaster()->Initialize();
if(pCreature->isAlive()) // dead creature will reset movement generator at respawn
{
pCreature->setDeathState(JUST_DIED);
pCreature->RemoveCorpse();
pCreature->Respawn();
}
}
WorldDatabase.PExecuteLog("UPDATE creature SET spawn_position_x = '%f', spawn_position_y = '%f', spawn_position_z = '%f', spawn_orientation = '%f',position_x = '%f', position_y = '%f', position_z = '%f', orientation = '%f' WHERE guid = '%u'", x, y, z, o, x, y, z, o, lowguid);
PSendSysMessage(LANG_COMMAND_CREATUREMOVED);
return true;
}