本文整理汇总了C++中P_CHAR::hunger方法的典型用法代码示例。如果您正苦于以下问题:C++ P_CHAR::hunger方法的具体用法?C++ P_CHAR::hunger怎么用?C++ P_CHAR::hunger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_CHAR
的用法示例。
在下文中一共展示了P_CHAR::hunger方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dropOnBeggar
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: dropOnPet
// 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: dropFoodOnChar
// 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: dropOnBeggar
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 );
}