void OnActivate(PlayerPointer pPlayer) { if(!pPlayer) return; QuestLogEntry *qle = pPlayer->GetQuestLogForEntry(9582); if(qle == NULL) return; // What is this ? :O To remove ? CreaturePointer reaver = pPlayer->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), 17556); if(reaver) { CreaturePointer reaver2 = pPlayer->GetMapMgr()->GetInterface()->SpawnCreature(17556, reaver->GetPositionX(), reaver->GetPositionY(), reaver->GetPositionZ(), reaver->GetOrientation(), true, false, 0, 0); reaver2->Despawn(5*60*1000, 0); reaver->Despawn(1, 5*60*1000); } }
bool ChatHandler::HandleDeleteCommand(const char* args, WorldSession *m_session) { uint64 guid = m_session->GetPlayer()->GetSelection(); if (guid == 0) { SystemMessage(m_session, "No selection."); return true; } CreaturePointer unit = m_session->GetPlayer()->GetMapMgr()->GetCreature(GET_LOWGUID_PART(guid)); if(!unit) { SystemMessage(m_session, "You should select a creature."); return true; } if( unit->m_spawn != NULL && !m_session->CanUseCommand('z') ) { SystemMessage(m_session, "You do not have permission to do that. Please contact higher staff for removing of saved spawns."); return true; } sGMLog.writefromsession(m_session, "used npc delete, sqlid %u, creature %s, pos %f %f %f", unit->m_spawn ? unit->m_spawn : 0, unit->GetCreatureName() ? unit->GetCreatureName()->Name : "wtfbbqhax", unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ()); BlueSystemMessage(m_session, "Deleted creature ID %u", unit->spawnid); MapMgrPointer unitMgr = unit->GetMapMgr(); if(unit->IsInWorld()) { unit->RemoveFromWorld(false,true); } if(unit->m_spawn == NULL) return true; unit->DeleteFromDB(); if(unit->m_spawn) { uint32 cellx=float2int32(((_maxX-unit->m_spawn->x)/_cellSize)); uint32 celly=float2int32(((_maxY-unit->m_spawn->y)/_cellSize)); if(cellx <= _sizeX && celly <= _sizeY && unitMgr != NULL) { CellSpawns * c = unitMgr->GetBaseMap()->GetSpawnsList(cellx, celly); if( c != NULL ) { for(CreatureSpawnList::iterator itr = c->CreatureSpawns.begin(); itr != c->CreatureSpawns.end(); ++itr) { if((*itr) == unit->m_spawn) { c->CreatureSpawns.erase(itr); delete unit->m_spawn; break; } } } } } unit->Destructor(); unit = NULLCREATURE; return true; }