本文整理汇总了C++中P_PLAYER::addItem方法的典型用法代码示例。如果您正苦于以下问题:C++ P_PLAYER::addItem方法的具体用法?C++ P_PLAYER::addItem怎么用?C++ P_PLAYER::addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_PLAYER
的用法示例。
在下文中一共展示了P_PLAYER::addItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: grabItem
//.........这里部分代码省略.........
outmostCont->setMoreZ(0);
// sendtradestatus( tradeWindow, outmostCont );
}
}
// If the top-most container ( thats important ) is a corpse
// and looting is a crime, flag the character criminal.
if( !pChar->isGM() && outmostCont && outmostCont->corpse() )
{
// For each item we take out we loose carma
// if the corpse is innocent and not in our guild
bool sameGuild = ( GuildCompare( pChar, outmostCont->owner() ) != 0 );
if( ( outmostCont->more2() == 1 ) && !pChar->Owns( outmostCont ) && !sameGuild )
{
// pChar->karma -= 5;
pChar->setKarma( pChar->karma() - 5 );
pChar->setCriminalTime( uiCurrentTime + SrvParams->crimtime() * MY_CLOCKS_PER_SEC );
socket->sysMessage( tr("You lost some karma.") );
}
}
// Check if the item is too heavy
//if( !pc_currchar->isGMorCounselor() )
//{
//} << Deactivated (DarkStorm)
// ==== Grabbing the Item is allowed here ====
// Remove eventual item-bonusses if we're unequipping something
if( pItem->container() && pItem->container()->isChar() )
{
P_CHAR wearer = dynamic_cast<P_CHAR>( pItem->container() );
if( wearer )
wearer->removeItemBonus( pItem );
// resend the stat window
if( wearer && wearer->objectType() == enPlayer )
{
P_PLAYER pp = dynamic_cast<P_PLAYER>(wearer);
if( pp->socket() )
pp->socket()->sendStatWindow();
}
}
// Send the user a pickup sound if we're picking it up
// From a container/paperdoll
if( !pItem->isInWorld() )
socket->soundEffect( 0x57, pItem );
// If we're picking up a specific amount of what we got
// Take that into account
if( amount < pItem->amount() )
{
UI32 pickedAmount = QMIN( amount, pItem->amount() );
// We only have to split if we're not taking it all
if( pickedAmount != pItem->amount() )
{
P_ITEM splitItem = new cItem( *pItem ); // Create a new item to pick that up
splitItem->setSerial( World::instance()->findItemSerial() );
splitItem->setAmount( pItem->amount() - pickedAmount );
P_ITEM pContainer = dynamic_cast<P_ITEM>(pItem->container());
if ( pContainer )
pContainer->addItem( splitItem, false );
splitItem->SetOwnSerial( pItem->ownSerial() );
splitItem->SetSpawnSerial( pItem->spawnserial );
// He needs to see the new item
splitItem->update();
// If we're taking something out of a spawn-region it's spawning "flag" is removed isn't it?
pItem->SetSpawnSerial( INVALID_SERIAL );
pItem->setAmount( pickedAmount );
}
}
// *normally* we should exclude the dragging socket here. but it works so as well.
pItem->removeFromView( true );
// Remove it from the World if it is in world, otherwise remove it from it's current container
if( pItem->isInWorld() )
MapObjects::instance()->remove( pItem );
else
pItem->removeFromCont( true );
// The item was in a multi
if( pItem->multis() != INVALID_SERIAL )
{
cMulti* pMulti = dynamic_cast< cMulti* >( FindItemBySerial( pItem->multis() ) );
if( pMulti )
pMulti->removeItem( pItem );
}
pChar->addItem( cBaseChar::Dragging, pItem );
if( weight != pChar->weight() )
socket->sendStatWindow();
}
示例2: grabItem
//.........这里部分代码省略.........
P_ITEM outmostCont = pItem->getOutmostItem();
// If the top-most container ( thats important ) is a corpse
// and looting is a crime, flag the character criminal.
if ( !pChar->isGM() && outmostCont && outmostCont->corpse() )
{
// For each item we take out we loose carma
// if the corpse is innocent and not in our guild
bool sameGuild = true;//( GuildCompare( pChar, outmostCont->owner() ) != 0 );
if ( outmostCont->hasTag( "notoriety" ) && outmostCont->getTag( "notoriety" ).toInt() == 1 && !pChar->owns( outmostCont ) && !sameGuild )
{
// pChar->karma -= 5;
pChar->setKarma( pChar->karma() - 5 );
pChar->setCriminalTime( Server::instance()->time() + Config::instance()->crimtime() * MY_CLOCKS_PER_SEC );
socket->sysMessage( tr( "You lost some karma." ) );
}
}
// Check if the item is too heavy
//if( !pc_currchar->isGMorCounselor() )
//{
//} << Deactivated (DarkStorm)
// ==== Grabbing the Item is allowed here ====
// Send the user a pickup sound if we're picking it up
// From a container/paperdoll
if ( !pItem->isInWorld() )
socket->soundEffect( 0x57, pItem );
// If we're picking up a specific amount of what we got
// Take that into account
if ( amount < pItem->amount() )
{
UI32 pickedAmount = QMIN( amount, pItem->amount() );
// We only have to split if we're not taking it all
if ( pickedAmount != pItem->amount() )
{
P_ITEM splitItem = pItem->dupe(); // Create a new item to pick that up
splitItem->setAmount( pItem->amount() - pickedAmount );
// Add tags to the splitted item
QStringList keys = pItem->getTags();
QStringList::const_iterator it = keys.begin();
for ( ; it != keys.end(); ++it )
{
splitItem->setTag( *it, pItem->getTag( *it ) );
}
P_ITEM pContainer = dynamic_cast<P_ITEM>( pItem->container() );
if ( pContainer )
pContainer->addItem( splitItem, false );
splitItem->SetOwnSerial( pItem->ownSerial() );
splitItem->setSpawnregion( pItem->spawnregion() );
// He needs to see the new item
splitItem->update();
// If we're taking something out of a spawn-region it's spawning "flag" is removed isn't it?
pItem->setAmount( pickedAmount );
}
}
// *normally* we should exclude the dragging socket here. but it works so as well.
pItem->removeFromView( true );
// Remove from spawnregion
pItem->setSpawnregion( 0 );
// Remove it from the World if it is in world, otherwise remove it from it's current container
if ( pItem->isInWorld() )
MapObjects::instance()->remove( pItem );
else
pItem->removeFromCont( true );
// Remove eventual item-bonusses if we're unequipping something
if ( pItem->container() && pItem->container()->isChar() )
{
P_CHAR wearer = dynamic_cast<P_CHAR>( pItem->container() );
// resend the stat window
if ( wearer && wearer->objectType() == enPlayer )
{
P_PLAYER pp = dynamic_cast<P_PLAYER>( wearer );
if ( pp->socket() )
pp->socket()->sendStatWindow();
}
}
pChar->addItem( cBaseChar::Dragging, pItem );
if ( weight != pChar->weight() )
{
socket->sendStatWindow();
}
}