本文整理汇总了C++中P_PLAYER::canPickUp方法的典型用法代码示例。如果您正苦于以下问题:C++ P_PLAYER::canPickUp方法的具体用法?C++ P_PLAYER::canPickUp怎么用?C++ P_PLAYER::canPickUp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_PLAYER
的用法示例。
在下文中一共展示了P_PLAYER::canPickUp方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dropOnGround
void DragAndDrop::dropOnGround( cUOSocket* socket, P_ITEM pItem, const Coord_cl& pos )
{
P_PLAYER pChar = socket->player();
// Check if the destination is in line of sight
if ( !pChar->lineOfSight( pos.losItemPoint(pItem->id()) ) )
{
socket->bounceItem( pItem, BR_OUT_OF_SIGHT );
return;
}
if ( !pChar->canPickUp( pItem ) )
{
socket->bounceItem( pItem, BR_CANNOT_PICK_THAT_UP );
return;
}
if ( pItem->onDropOnGround( pos ) )
{
// We're still dragging something
if ( socket->dragging() )
socket->bounceItem( socket->dragging(), BR_NO_REASON );
return;
}
pItem->removeFromCont();
pItem->moveTo( pos );
pItem->update();
// Play Sounds for non gold items
if (pItem->id() != 0xEED) {
pItem->soundEffect(0x42);
}
}
示例2: dropOnGround
void cDragItems::dropOnGround( cUOSocket *socket, P_ITEM pItem, const Coord_cl &pos )
{
P_PLAYER pChar = socket->player();
// Check if the destination is in line of sight
if( !lineOfSight( pChar->pos(), pos, WALLS_CHIMNEYS|DOORS|LAVA_WATER ) )
{
socket->bounceItem( pItem, BR_OUT_OF_SIGHT );
return;
}
if( !pChar->canPickUp( pItem ) )
{
socket->bounceItem( pItem, BR_CANNOT_PICK_THAT_UP );
return;
}
if( pItem->onDropOnGround( pos ) )
{
// We're still dragging something
if( socket->dragging() )
socket->bounceItem( socket->dragging(), BR_NO_REASON );
return;
}
pItem->removeFromCont();
pItem->moveTo( pos );
pItem->update();
if( pItem->priv() & 0x01 )
pItem->startDecay();
// Multi handling
// Has it been dropped into a multi
cMulti* pMulti = cMulti::findMulti( pos );
if( pMulti )
{
pMulti->addItem( pItem );
}
}
示例3: grabItem
// New Class implementation
void cDragItems::grabItem( cUOSocket *socket, cUORxDragItem *packet )
{
// Get our character
P_PLAYER pChar = socket->player();
if( !pChar )
return;
UINT32 weight = pChar->weight();
// Fetch the grab information
UI16 amount = packet->amount();
if( !amount )
amount = 1;
P_ITEM pItem = FindItemBySerial( packet->serial() );
// If it's an invalid pointer we can't even bounce
if( !pItem )
return;
// Are we already dragging an item ?
// Bounce it and reject the move
// (Logged out while dragging an item)
if( socket->dragging() )
{
socket->bounceItem( socket->dragging(), BR_ALREADY_DRAGGING );
return;
}
if( pItem->onPickup( pChar ) )
return;
if( pChar->onPickup( pItem ) )
return;
// Do we really want to let him break his meditation
// When he picks up an item ?
// Maybe a meditation check here ?!?
pChar->disturbMed(); // Meditation
P_CHAR itemOwner = pItem->getOutmostChar();
// Try to pick something out of another characters posessions
if( !pChar->isGM() && itemOwner && ( itemOwner != pChar ) && ( itemOwner->objectType() == enNPC && dynamic_cast<P_NPC>(itemOwner)->owner() != pChar ) )
{
socket->bounceItem( pItem, BR_BELONGS_TO_SOMEONE_ELSE );
return;
}
// Check if the user can grab the item
if( !pChar->canPickUp( pItem ) )
{
socket->bounceItem( pItem, BR_CANNOT_PICK_THAT_UP );
return;
}
// The user can't see the item
// Basically thats impossible as the socket should deny moving the item
// if it's not in line of sight but to prevent exploits
/*if( !line_of_sight( socket->socket(), pChar->pos, pItem->pos, TREES_BUSHES|WALLS_CHIMNEYS|DOORS|ROOFING_SLANTED|FLOORS_FLAT_ROOFING|LAVA_WATER ) )
{
socket->sysMessage( "You can't see the item." );
bounceItem( socket, pItem, true );
return;
}*/
P_ITEM outmostCont = pItem->getOutmostItem();
// If it's a trade-window, reset the ack-status
if( outmostCont && ( outmostCont->container() == pChar ) && ( outmostCont->layer() == 0 ) && ( outmostCont->id() == 0x1E5E ) )
{
// Get the other sides tradewindow
P_ITEM tradeWindow = FindItemBySerial( calcserial( outmostCont->moreb1(), outmostCont->moreb2(), outmostCont->moreb3(), outmostCont->moreb4() ) );
// If one of the trade-windows has the ack-status reset it
if( tradeWindow && ( tradeWindow->morez() || outmostCont->morez() ) )
{
tradeWindow->setMoreZ(0);
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.") );
}
}
//.........这里部分代码省略.........
示例4: dropOnItem
void cDragItems::dropOnItem( cUOSocket *socket, P_ITEM pItem, P_ITEM pCont, const Coord_cl &dropPos )
{
P_PLAYER pChar = socket->player();
if( pItem->isMulti() )
{
socket->sysMessage( tr( "You cannot put houses in containers" ) );
cUOTxBounceItem bounce;
bounce.setReason( BR_NO_REASON );
socket->send( &bounce );
Items->DeleItem( pItem );
return;
}
if( pItem->onDropOnItem( pCont ) )
{
if( socket->dragging() )
socket->bounceItem( socket->dragging(), BR_NO_REASON );
return;
}
else if( pCont->onDropOnItem( pItem ) )
{
if( socket->dragging() )
socket->bounceItem( socket->dragging(), BR_NO_REASON );
return;
}
// If the target belongs to another character
// It needs to be our vendor or else it's denied
P_CHAR packOwner = pCont->getOutmostChar();
if( ( packOwner ) && ( packOwner != pChar ) && !pChar->isGM() )
{
// For each item someone puts into there
// He needs to do a snoop-check
if( pChar->maySnoop() )
{
if( !pChar->checkSkill( SNOOPING, 0, 1000 ) )
{
socket->sysMessage( tr( "You fail to put that into %1's pack" ).arg( packOwner->name() ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
}
if( packOwner->objectType() == enPlayer ||
( packOwner->objectType() == enNPC && dynamic_cast<P_NPC>(packOwner)->owner() != pChar ) )
{
socket->sysMessage( tr("You cannot put that into the belongings of another player") );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
}
// If we put the item into a trade-window
// Reset the trade-status for both players
if( pCont->layer() == 0 && pCont->id() == 0x1E5E && pChar->Wears( pCont ) )
{
// Trade window???
P_ITEM tradeWindow = FindItemBySerial( calcserial( pCont->moreb1(), pCont->moreb2(), pCont->moreb3(), pCont->moreb4() ) );
// If it *IS* a trade-window, replace the status
if( tradeWindow && ( pCont->morez() || tradeWindow->morez() ) )
{
tradeWindow->setMoreZ(0);
pCont->setMoreZ(0);
// sendtradestatus( tradeWindow, pCont );
}
}
if( !pChar->canPickUp( pItem ) )
{
socket->bounceItem( pItem, BR_CANNOT_PICK_THAT_UP );
return;
}
// Trash can
if( pCont->type()==87 )
{
Items->DeleItem( pItem );
socket->sysMessage( tr( "As you let go of the item it disappears." ) );
return;
}
// Spell Book
cSpellBook *pBook = dynamic_cast< cSpellBook* >( pCont );
if( pBook )
{
SI08 spellId = NewMagic->calcSpellId( pItem->id() );
if( pItem->type() != 1105 || spellId < 0 )
{
socket->sysMessage( tr( "You can only put scrolls into a spellbook" ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
//.........这里部分代码省略.........
示例5: equipItem
//.........这里部分代码省略.........
{
if( pWearer == pChar )
socket->sysMessage( tr( "You cannot wear that item, you seem not agile enough" ) );
else
socket->sysMessage( tr( "This person can't wear that item, it seems not agile enough" ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
// Required Intelligence
if( pItem->in() > pWearer->intelligence() )
{
if( pWearer == pChar )
socket->sysMessage( tr( "You cannot wear that item, you seem not smart enough" ) );
else
socket->sysMessage( tr( "This person can't wear that item, it seems not smart enough" ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
// Males can't wear female armor
if( ( pChar->bodyID() == 0x0190 ) && ( pItem->id() >= 0x1C00 ) && ( pItem->id() <= 0x1C0D ) )
{
socket->sysMessage( tr( "You cannot wear female armor." ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
// Needs a check (!)
// Checks for equipment on the same layer
// If there is any it tries to unequip it
// If that fails it cancels
// we also need to check if there is a twohanded weapon if we want to equip another weapon.
UI08 layer = pTile.layer;
bool twohanded = false;
P_ITEM equippedLayerItem = pWearer->atLayer( static_cast<cBaseChar::enLayer>(layer) );
if ( equippedLayerItem )
twohanded = equippedLayerItem->twohanded();
if( twohanded && ( layer == 1 || layer == 2 ) )
{
socket->sysMessage( tr("You can't hold another item while wearing a twohanded weapon!") );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
// we're equipping so we do the check
if( equippedLayerItem )
{
if( pChar->canPickUp( equippedLayerItem ) )
{
equippedLayerItem->toBackpack( pWearer );
}
else
{
socket->sysMessage( tr( "You can't wear another item there!" ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
}
// At this point we're certain that we can wear the item
pWearer->addItem( static_cast<cBaseChar::enLayer>(pTile.layer), pItem );
// Apply the bonuses
pWearer->giveItemBonus( pItem );
if( pWearer->objectType() == enPlayer )
{
P_PLAYER pp = dynamic_cast<P_PLAYER>(pWearer);
if( pp->socket() )
pp->socket()->sendStatWindow();
}
// I don't think we need to remove the item
// as it's only visible to the current char
// And he looses contact anyway
// Build our packets
cUOTxCharEquipment wearItem;
wearItem.fromItem( pItem );
cUOTxSoundEffect soundEffect;
soundEffect.setSound( 0x57 );
soundEffect.setCoord( pWearer->pos() );
// Send to all sockets in range
// ONLY the new equipped item and the sound-effect
for( cUOSocket *mSock = cNetwork::instance()->first(); mSock; mSock = cNetwork::instance()->next() )
{
if( mSock->player() && ( mSock->player()->dist( pWearer ) <= mSock->player()->visualRange() ) )
{
mSock->send( &wearItem );
mSock->send( &soundEffect );
}
}
}
示例6: dropOnItem
void DragAndDrop::dropOnItem( cUOSocket* socket, P_ITEM pItem, P_ITEM pCont, const Coord_cl& dropPos )
{
P_PLAYER pChar = socket->player();
if ( pItem->isMulti() )
{
socket->sysMessage( tr( "You cannot put houses in containers" ) );
cUOTxBounceItem bounce;
bounce.setReason( BR_NO_REASON );
socket->send( &bounce );
pItem->remove();
return;
}
if ( pItem->onDropOnItem( pCont ) )
{
if ( pItem->free )
return;
if ( socket->dragging() )
socket->bounceItem( socket->dragging(), BR_NO_REASON );
return;
}
else if ( pCont->onDropOnItem( pItem ) )
{
if ( pItem->free )
return;
if ( socket->dragging() )
socket->bounceItem( socket->dragging(), BR_NO_REASON );
return;
}
// If the target belongs to another character
// It needs to be our vendor or else it's denied
P_CHAR packOwner = pCont->getOutmostChar();
if ( ( packOwner ) && ( packOwner != pChar ) && !pChar->isGM() )
{
// For each item someone puts into there
// He needs to do a snoop-check
if ( pChar->maySnoop() )
{
if ( !pChar->checkSkill( SNOOPING, 0, 1000 ) )
{
socket->sysMessage( tr( "You fail to put that into %1's pack" ).arg( packOwner->name() ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
}
if ( packOwner->objectType() == enPlayer || ( packOwner->objectType() == enNPC && dynamic_cast<P_NPC>( packOwner )->owner() != pChar ) )
{
socket->sysMessage( tr( "You cannot put that into the belongings of another player" ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
}
if ( !pChar->canPickUp( pItem ) )
{
socket->bounceItem( pItem, BR_CANNOT_PICK_THAT_UP );
return;
}
// We drop something on the belongings of one of our playervendors
/* if( ( packOwner != NULL ) && ( packOwner->npcaitype() == 17 ) && packOwner->owner() == pChar )
{
socket->sysMessage( tr( "You drop something into your playervendor (unimplemented)" ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}*/
// Playervendors (chest equipped by the vendor - opened to the client)
/*if( !( pCont->pileable() && pItem->pileable() && pCont->id() == pItem->id() || ( pCont->type() != 1 && pCont->type() != 9 ) ) )
{
P_CHAR pc_j = GetPackOwner(pCont);
if (pc_j != NULL)
{
if (pc_j->npcaitype() == 17 && pc_j->isNpc() && pChar->Owns(pc_j))
{
pChar->inputitem = pItem->serial;
pChar->inputmode = cChar::enPricing;
sysmessage(s, "Set a price for this item.");
}
}
*/
// We may also drop into *any* locked chest
// So we can have post-boxes ;o)
if ( pCont->type() == 1 )
{
// If we're dropping it onto the closed container
if ( dropPos.x == 0xFFFF && dropPos.y == 0xFFFF )
{
pCont->addItem( pItem );
}
//.........这里部分代码省略.........
示例7: grabItem
// New Class implementation
void DragAndDrop::grabItem( cUOSocket* socket, cUORxDragItem* packet )
{
// Get our character
P_PLAYER pChar = socket->player();
if ( !pChar )
return;
float weight = pChar->weight();
// Fetch the grab information
UI16 amount = packet->amount();
if ( !amount )
amount = 1;
P_ITEM pItem = FindItemBySerial( packet->serial() );
// If it's an invalid pointer we can't even bounce
if ( !pItem )
return;
// Are we already dragging an item ?
// Bounce it and reject the move
// (Logged out while dragging an item)
if ( socket->dragging() )
{
socket->bounceItem( socket->dragging(), BR_ALREADY_DRAGGING );
return;
}
// Check if the item can be reached
if (pItem->getOutmostChar() != pChar && !pChar->lineOfSight(pItem)) {
socket->bounceItem( pItem, BR_OUT_OF_REACH );
return;
}
if ( pItem->onPickup( pChar ) )
return;
if ( pChar->onPickup( pItem ) )
return;
// Do we really want to let him break his meditation
// When he picks up an item ?
// Maybe a meditation check here ?!?
pChar->disturbMed(); // Meditation
P_CHAR itemOwner = pItem->getOutmostChar();
// Try to pick something out of another characters posessions
if ( !pChar->isGM() && itemOwner && ( itemOwner != pChar ) && ( itemOwner->objectType() == enNPC && dynamic_cast<P_NPC>( itemOwner )->owner() != pChar ) )
{
socket->bounceItem( pItem, BR_BELONGS_TO_SOMEONE_ELSE );
return;
}
// Check if the user can grab the item
if ( !pChar->canPickUp( pItem ) )
{
socket->bounceItem( pItem, BR_CANNOT_PICK_THAT_UP );
return;
}
// The user can't see the item
// Basically thats impossible as the socket should deny moving the item
// if it's not in line of sight but to prevent exploits
/*if( !line_of_sight( socket->socket(), pChar->pos, pItem->pos, TREES_BUSHES|WALLS_CHIMNEYS|DOORS|ROOFING_SLANTED|FLOORS_FLAT_ROOFING|LAVA_WATER ) )
{
socket->sysMessage( "You can't see the item." );
bounceItem( socket, pItem, true );
return;
}*/
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
//.........这里部分代码省略.........
示例8: equipItem
void DragAndDrop::equipItem( cUOSocket* socket, cUORxWearItem* packet )
{
P_ITEM pItem = FindItemBySerial( packet->serial() );
P_CHAR pWearer = FindCharBySerial( packet->wearer() );
if ( !pItem || !pWearer )
return;
P_PLAYER pChar = socket->player();
// We're dead and can't do that
if ( pChar->isDead() )
{
socket->clilocMessage( 0x7A4D5, "", 0x3b2 ); // You can't do that when you're dead.
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
// No Special Layer Equipping
if ( ( packet->layer() > cBaseChar::InnerLegs || packet->layer() <= cBaseChar::TradeWindow ) && !pChar->isGM() )
{
socket->sysMessage( tr( "You can't equip on that layer." ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
// Our target is dead
if ( ( pWearer != pChar ) && pWearer->isDead() )
{
socket->sysMessage( tr( "You can't equip dead players." ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
// Only GM's can equip other People
if ( pWearer != pChar && !pChar->isGM() )
{
P_NPC pNpc = dynamic_cast<P_NPC>( pWearer );
// But we are allowed to equip our own humans
if ( !pNpc || ( pNpc->owner() != pChar && pWearer->isHuman() ) )
socket->sysMessage( tr( "You can't equip other players." ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
// Get our tile-information
tile_st pTile = TileCache::instance()->getTile( pItem->id() );
// Is the item wearable ? ( layer == 0 | equip-flag not set )
// Multis are not wearable are they :o)
if ( pTile.layer == 0 || !( pTile.flag3 & 0x40 ) || pItem->isMulti() )
{
socket->sysMessage( tr( "This item cannot be equipped." ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
// Check the Script for it
if ( pItem->onWearItem( pChar, pWearer, packet->layer() ) )
{
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
// Males can't wear female armor
if ( ( pChar->body() == 0x0190 ) && ( pItem->id() >= 0x1C00 ) && ( pItem->id() <= 0x1C0D ) )
{
socket->sysMessage( tr( "You cannot wear female armor." ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
// Needs a check (!)
// Checks for equipment on the same layer
// If there is any it tries to unequip it
// If that fails it cancels
// we also need to check if there is a twohanded weapon if we want to equip another weapon.
UI08 layer = pTile.layer;
P_ITEM equippedLayerItem = pWearer->atLayer( static_cast<cBaseChar::enLayer>( layer ) );
// we're equipping so we do the check
if ( equippedLayerItem )
{
if ( pChar->canPickUp( equippedLayerItem ) )
{
equippedLayerItem->toBackpack( pWearer );
}
else
{
socket->sysMessage( tr( "You can't wear another item there!" ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
}
// Check other layers if neccesary
bool occupied = false;
//.........这里部分代码省略.........