Example #1
0
void cSkills::SkillUse( cUOSocket* socket, quint16 id ) // Skill is clicked on the skill list
{
	P_PLAYER pChar = socket->player();

	// No Char no Skill use
	if ( !pChar )
		return;

	if ( pChar->isJailed() ) {
		socket->sysMessage( tr("You cannot use skills while you are in jail.") );
		return;
	}

	if ( pChar->isDead() )
	{
		socket->clilocMessage( 1019048 ); // I am dead and cannot do that.
		return;
	}

	/*
	if ( id != STEALTH )
		pChar->unhide(); // Don't unhide if we're trying to stealth
	*/

	pChar->disturbMed(); // Disturb meditation if we're using a skill

	if ( pChar->isCasting() )
	{
		socket->sysMessage( 1061131 ); // You cannot do that while casting a spell.
		return;
	}

	if ( pChar->skillDelay() > Server::instance()->time() && !pChar->isGM() )
	{
		socket->sysMessage( 500118 ); // You must wait a few moments to use another skill.
		return;
	}

	if ( pChar->onSkillUse( id ) )
		return;

	cTargetRequest* targetRequest = NULL;
	QString message;

	switch ( id )
	{
	case MEDITATION:
		Skills::instance()->Meditation( socket );
		break;
	default:
		socket->sysMessage( tr( "That skill has not been implemented yet." ) );
		return;
	}

	if ( targetRequest )
		socket->attachTarget( targetRequest );

	if ( !message.isEmpty() )
		pChar->message( message );

	pChar->setSkillDelay( Server::instance()->time() + Config::instance()->skillDelay() * MY_CLOCKS_PER_SEC );
}