コード例 #1
0
ファイル: cmd_modify.cpp プロジェクト: lev1976g/NoxicCore
bool ChatHandler::HandleModifyLevelCommand(const char* args, WorldSession* m_session)
{
	Player* plr = getSelectedChar(m_session, true);
	if(!plr)
		return true;

	uint32 Level = args ? atol(args) : 0;
	if(!Level || Level > sWorld.m_levelCap)
	{
		RedSystemMessage(m_session, "A level (numeric) is required to be specified after this command.");
		return false;
	}

	// Set level message
	BlueSystemMessage(m_session, "Setting the level of %s to %u.", plr->GetName(), Level);
	GreenSystemMessageToPlr(plr, "%s set your level to %u.", m_session->GetPlayer()->GetName(), Level);

	sGMLog.writefromsession(m_session, "used modify level on %s, level %u", plr->GetName(), Level);

	// lookup level information
	LevelInfo* Info = objmgr.GetLevelInfo(plr->getRace(), plr->getClass(), Level);
	if(!Info)
	{
		RedSystemMessage(m_session, "Levelup information not found.");
		return false;
	}

	plr->ApplyLevelInfo(Info, Level);
	if(plr->getClass() == WARLOCK)
	{
		std::list<Pet*> summons = plr->GetSummons();
		for(std::list<Pet*>::iterator itr = summons.begin(); itr != summons.end(); ++itr)
		{
			Pet* summon = *itr;
			if(summon->IsInWorld() && summon->isAlive())
			{
				summon->setLevel(Level);
				summon->ApplyStatsForLevel();
				summon->UpdateSpellList();
			}
		}
	}

	return true;
}