コード例 #1
0
void DragAndDrop::dropOnBeggar( cUOSocket* socket, P_ITEM pItem, P_CHAR pBeggar )
{
	int tempint;

	if( ( pBeggar->hunger() < 6 ) && pItem->type() == 14 )
	{
		pBeggar->talk( tr("*cough* Thank thee!") );
		pBeggar->soundEffect( 0x3A + RandomNum( 1, 3 ) );

		// *You see Snowwhite eating some poisoned apples*
		// Color: 0x0026
		pBeggar->emote( tr( "*You see %1 eating %2*" ).arg( pBeggar->name() ).arg( pItem->getName() ) );

		// We try to feed it more than it needs
		if( pBeggar->hunger() + pItem->amount() > 6 )
		{

//			client->player()->karma += ( 6 - pBeggar->hunger() ) * 10;
			tempint = ( 6 - pBeggar->hunger() ) * 10;
			socket->player()->setKarma( socket->player()->karma() + tempint );

			pItem->setAmount( pItem->amount() - ( 6 - pBeggar->hunger() ) );
			pBeggar->setHunger( 6 );

			// Pack the rest into his backpack
			bounceItem( socket, pItem );
			return;
		}

		pBeggar->setHunger( pBeggar->hunger() + pItem->amount() );
//		client->player()->karma += pItem->amount() * 10;
		tempint = pItem->amount() * 10;
		socket->player()->setKarma( socket->player()->karma() + tempint );

		pItem->remove();
		return;
	}

	// No Food? Then it has to be Gold
	if( pItem->id() != 0xEED )
	{
		pBeggar->talk( tr("Sorry, but i can only use gold.") );
		bounceItem( socket, pItem );
		return;
	}

	pBeggar->talk( tr( "Thank you %1 for the %2 gold!" ).arg( socket->player()->name() ).arg( pItem->amount() ) );
	socket->sysMessage( tr("You have gained some karma!") );

	if( pItem->amount() <= 100 )
		socket->player()->setKarma( socket->player()->karma() + 10 );
	else
		socket->player()->setKarma( socket->player()->karma() + 50 );

	pItem->remove();
}
コード例 #2
0
// Item was dropped on a pet
void cDragItems::dropOnPet( P_CLIENT client, P_ITEM pItem, P_CHAR pPet )
{
	// Feed our pets
	if( ( pPet->hunger() >= 6 ) || pItem->type() != 14 )
	{
		client->sysMessage( "It doesn't seem to want your item" );
		bounceItem( client, pItem );
		return;
	}

	// We have three different eating-sounds (I don't like the idea as they sound too human)
	pPet->soundEffect( 0x3A + RandomNum( 1, 3 ) );

	// If you want to poison a pet... Why not
	if( pItem->poisoned && pPet->poisoned() < pItem->poisoned )
	{
		pPet->soundEffect( 0x246 );
		pPet->setPoisoned( pItem->poisoned );
		
		// a lev.1 poison takes effect after 40 secs, a deadly pois.(lev.4) takes 40/4 secs - AntiChrist
		pPet->setPoisontime( uiCurrentTime + ( MY_CLOCKS_PER_SEC * ( 40 / pPet->poisoned() ) ) );
		
		//wear off starts after poison takes effect - AntiChrist
		pPet->setPoisonwearofftime(pPet->poisontime() + ( MY_CLOCKS_PER_SEC * SrvParams->poisonTimer() ) );
		
		// Refresh the health-bar of our target
		impowncreate( client->socket(), pPet, 1 );
	}

	// *You see Snowwhite eating some poisoned apples*
	// Color: 0x0026
	QString emote = QString( "*You see %1 eating %2*" ).arg( pPet->name.c_str() ).arg( pItem->getName() );
	pPet->emote( emote );

	// We try to feed it more than it needs
	if( pPet->hunger() + pItem->amount() > 6 )
	{
		pItem->setAmount( pItem->amount() - ( 6 - pPet->hunger() ) );
		pPet->setHunger( 6 );

		// Pack the rest into his backpack
		bounceItem( client, pItem );
		return;
	}

	pPet->setHunger( pPet->hunger() + pItem->amount() );
	Items->DeleItem( pItem );
}
コード例 #3
0
// Food was dropped on a pet
void cDragItems::dropFoodOnChar( cUOSocket* socket, P_ITEM pItem, P_CHAR pChar )
{
	// Feed our pets
	if( pChar->hunger() >= 6 || pItem->type2() == 0 || !( pChar->nutriment() & ( 1 << (pItem->type2()-1) ) ) )
	{
		socket->sysMessage( tr("It doesn't seem to want your item") );
		bounceItem( socket, pItem );
		return;
	}

	// We have three different eating-sounds (I don't like the idea as they sound too human)
	pChar->soundEffect( 0x3A + RandomNum( 1, 3 ) );

	// If you want to poison a pet... Why not
	if( pItem->poisoned() && pChar->poisoned() < pItem->poisoned() )
	{
		pChar->soundEffect( 0x246 );
		pChar->setPoisoned( pItem->poisoned() );
		
		// a lev.1 poison takes effect after 40 secs, a deadly pois.(lev.4) takes 40/4 secs - AntiChrist
		pChar->setPoisonTime( uiCurrentTime + ( MY_CLOCKS_PER_SEC * ( 40 / pChar->poisoned() ) ) );
		
		//wear off starts after poison takes effect - AntiChrist
		pChar->setPoisonWearOffTime(pChar->poisonTime() + ( MY_CLOCKS_PER_SEC * SrvParams->poisonTimer() ) );
		
		// Refresh the health-bar of our target
		pChar->resend( false );
	}

	// *You see Snowwhite eating some poisoned apples*
	// Color: 0x0026
	pChar->emote( tr( "*You see %1 eating %2*" ).arg( pChar->name() ).arg( pItem->getName() ) );

	// We try to feed it more than it needs
	if( pChar->hunger() + pItem->amount() > 6 )
	{
		pItem->setAmount( pItem->amount() - ( 6 - pChar->hunger() ) );
		pChar->setHunger( 6 );

		// Pack the rest into his backpack
		bounceItem( socket, pItem );
		return;
	}

	pChar->setHunger( pChar->hunger() + pItem->amount() );
	Items->DeleItem( pItem );
}
コード例 #4
0
void cDragItems::dropOnBeggar( cUOSocket* socket, P_ITEM pItem, P_CHAR pBeggar )
{
	int tempint;
	
	if( ( pBeggar->hunger() < 6 ) && pItem->type() == 14 )
	{
		pBeggar->talk( tr("*cough* Thank thee!") );
		pBeggar->soundEffect( 0x3A + RandomNum( 1, 3 ) );

		// If you want to poison a pet... Why not
		if( pItem->poisoned() && pBeggar->poisoned() < pItem->poisoned() )
		{
			pBeggar->soundEffect( 0x246 );
			pBeggar->setPoisoned( pItem->poisoned() );
			
			// a lev.1 poison takes effect after 40 secs, a deadly pois.(lev.4) takes 40/4 secs - AntiChrist
			pBeggar->setPoisonTime( uiCurrentTime + ( MY_CLOCKS_PER_SEC * ( 40 / pBeggar->poisoned() ) ) );
			
			//wear off starts after poison takes effect - AntiChrist
			pBeggar->setPoisonWearOffTime( pBeggar->poisonTime() + ( MY_CLOCKS_PER_SEC * SrvParams->poisonTimer() ) );
			
			// Refresh the health-bar of our target
			pBeggar->resend( false );
		}


		// *You see Snowwhite eating some poisoned apples*
		// Color: 0x0026
		pBeggar->emote( tr( "*You see %1 eating %2*" ).arg( pBeggar->name() ).arg( pItem->getName() ) );

		// We try to feed it more than it needs
		if( pBeggar->hunger() + pItem->amount() > 6 )
		{
			
//			client->player()->karma += ( 6 - pBeggar->hunger() ) * 10;
			tempint = ( 6 - pBeggar->hunger() ) * 10;
			socket->player()->setKarma( socket->player()->karma() + tempint );

			pItem->setAmount( pItem->amount() - ( 6 - pBeggar->hunger() ) );
			pBeggar->setHunger( 6 );

			// Pack the rest into his backpack
			bounceItem( socket, pItem );
			return;
		}

		pBeggar->setHunger( pBeggar->hunger() + pItem->amount() );
//		client->player()->karma += pItem->amount() * 10;
		tempint = pItem->amount() * 10;
		socket->player()->setKarma( socket->player()->karma() + tempint );

		Items->DeleItem( pItem );
		return;
	}

	// No Food? Then it has to be Gold
	if( pItem->id() != 0xEED )
	{
		pBeggar->talk( tr("Sorry, but i can only use gold.") );
		bounceItem( socket, pItem );
		return;
	}

	pBeggar->talk( tr( "Thank you %1 for the %2 gold!" ).arg( socket->player()->name() ).arg( pItem->amount() ) );
	socket->sysMessage( tr("You have gained some karma!") );
	
	if( pItem->amount() <= 100 )
		socket->player()->setKarma( socket->player()->karma() + 10 );
	else
		socket->player()->setKarma( socket->player()->karma() + 50 );
	
	Items->DeleItem( pItem );
}