本文整理汇总了C++中P_ITEM::amount方法的典型用法代码示例。如果您正苦于以下问题:C++ P_ITEM::amount方法的具体用法?C++ P_ITEM::amount怎么用?C++ P_ITEM::amount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_ITEM
的用法示例。
在下文中一共展示了P_ITEM::amount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecursePacks
//////////////////
// name: RecursePacks
// Purpose: recurses through the container given by bp to calculate the total weight
// History: Ison 2-20-99 - rewrote by Tauriel 3/20/99
// rewritten by Duke 4.11.2k
//
float cWeight::RecursePacks(P_ITEM bp)
{
float totalweight=0.0;
if (bp == NULL) return 0.0f;
unsigned int ci = 0;
vector<SERIAL> vecContainer = contsp.getData(bp->serial);
for ( ci = 0; ci < vecContainer.size(); ci++)
{
P_ITEM pi = FindItemBySerial(vecContainer[ci]);
if ( pi == NULL ) // Should never happen, but...
{
contsp.remove( bp->serial, vecContainer[ci]); // Remove the invalid Entrie.
continue; // let's pick up next.
}
int itemsweight=pi->getWeight();
if( pi->type() == 1 ) //item is another container
{
totalweight += (itemsweight/100.0f); // the weight of container itself
totalweight += RecursePacks(pi); //find the item's weight within this container
}
if (pi->id() == 0x0EED)
totalweight += ( pi->amount() * SrvParams->goldWeight() );
else
totalweight += (float)((itemsweight * pi->amount())/100.0f);
}
return totalweight;
}
示例2: 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();
}
示例3: 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 );
}
示例4: giveGold
void cPlayer::giveGold( quint32 amount, bool inBank )
{
P_ITEM pCont = NULL;
if ( !inBank )
pCont = getBackpack();
else
pCont = getBankbox();
if ( !pCont )
return;
// Begin Spawning
quint32 total = amount;
while ( total > 0 )
{
P_ITEM pile = cItem::createFromScript( "eed" );
pile->setAmount( wpMin<quint32>( total, static_cast<quint32>( 65535 ) ) );
total -= pile->amount();
pCont->addItem( pile );
if ( !pile->free )
{
pile->update();
}
}
goldSound( amount, false );
}
示例5: 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 );
}
示例6: dropItem
void cDragItems::dropItem( cUOSocket *socket, cUORxDropItem *packet )
{
P_PLAYER pChar = socket->player();
if( !pChar )
return;
// Get the data
SERIAL contId = packet->cont();
Coord_cl dropPos = pChar->pos(); // plane
dropPos.x = packet->x();
dropPos.y = packet->y();
dropPos.z = packet->z();
// Get possible containers
P_ITEM pItem = FindItemBySerial( packet->serial() );
if( !pItem )
return;
P_ITEM iCont = FindItemBySerial( packet->cont() );
P_CHAR cCont = FindCharBySerial( packet->cont() );
// >> SEE LORD BINARIES DROPFIX <<
// A completely invalid Drop packet
if( !iCont && !cCont && ( dropPos.x == 0xFFFF ) && ( dropPos.y == 0xFFFF ) && ( (unsigned char)dropPos.z == 0xFF ) )
{
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
UINT32 weight = pChar->weight();
// Item dropped on Ground
if( !iCont && !cCont )
dropOnGround( socket, pItem, dropPos );
// Item dropped on another item
else if( iCont )
dropOnItem( socket, pItem, iCont, dropPos );
// Item dropped on char
else if( cCont )
dropOnChar( socket, pItem, cCont );
// Handle the sound-effect
if( pItem->id() == 0xEED )
goldsfx( socket, pItem->amount(), true );
// Update our weight.
if( weight != pChar->weight() )
socket->sendStatWindow();
}
示例7: LockeddownWeight
// history: added containersearch Duke, 4.11.2k
float cWeight::LockeddownWeight(P_ITEM pItem, int *total, int *total2 )
{
float totalweight=0.0;
if (!pItem)
{
*total=0;
return 0.0;
}
unsigned int ci = 0;
P_ITEM pi;
vector<SERIAL> vecContainer = contsp.getData(pItem->serial);
for ( ci = 0; ci < vecContainer.size(); ci++)
{
pi = FindItemBySerial(vecContainer[ci]);
int itemsweight=pi->getWeight();
total2=total2+pi->amount();
*total=*total+1;
if( pi->type() == 1 || pi->type() == 63 || pi->type() == 65 || pi->type() == 87) //item is another container
{
totalweight+=(itemsweight/100.0f); //(pi->weight/100);
totalweight+=LockeddownWeight(pi, total, total2); //find the item's weight within this container
}
if ( pi->id() == 0x0EED )
totalweight+=(pi->amount()*SrvParams->goldWeight());
else
totalweight+=(float)((itemsweight*pi->amount())/100.0f); //((pi->weight*pi->amount)/100); // Ison 2-21-99
}
if (*total==0)
{
*total=pItem->amount();
*total=*total*-1; // Indicate that not a pack ! on osi servers in that case weigt/items count isnt shown
// thus i set it negative, if you want to show it anyway, add something like if (weight<0) weight*=-1;
return ((((float)pItem->getWeight())/100)*pItem->amount()); // if no pack return single item weight*/
}
else
return totalweight;
}
示例8: dropOnTrainer
void cDragItems::dropOnTrainer( P_CLIENT client, P_ITEM pItem, P_CHAR pTrainer )
{
P_CHAR pChar = client->player();
if( pItem->id() != 0xEED )
{
pTrainer->talk( "You need to give me gold if you want me to train you!" );
bounceItem( client, pItem );
return;
}
pTrainer->talk( "I thank thee for thy payment. That should give thee a good start on thy way. Farewell!" );
Q_UINT8 skill = pTrainer->trainingplayerin();
Q_INT32 skillSum = pChar->getSkillSum();
Q_INT32 skillDelta = pTrainer->getTeachingDelta( pChar, skill, skillSum );
goldsfx( client->socket(), pItem->amount() );
if( pItem->amount() > skillDelta )
{
pItem->ReduceAmount( skillDelta );
bounceItem( client, pItem );
}
else
{
skillDelta = pItem->amount();
Items->DeleItem( pItem );
}
pChar->setBaseSkill( skill, pChar->baseSkill( skill ) + skillDelta );
Skills->updateSkillLevel( pChar, skill );
updateskill( client->socket(), skill );
// we will not reset the trainer id here because he may want to give him more money
}
示例9: giveGold
void cNPC::giveGold( Q_UINT32 amount, bool inBank )
{
P_ITEM pCont = getBackpack();
if( !pCont )
return;
// Begin Spawning
Q_UINT32 total = amount;
while( total > 0 )
{
P_ITEM pile = cItem::createFromScript( "eed" );
pile->setAmount( QMIN( total, static_cast<Q_UINT32>(65535) ) );
pCont->addItem( pile );
total -= pile->amount();
}
}
示例10: 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 );
}
示例11: 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.") );
}
}
//.........这里部分代码省略.........
示例12: dropOnItem
//.........这里部分代码省略.........
{
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;
}
if( pBook->hasSpell( spellId ) )
{
socket->sysMessage( tr( "That spellbook already contains this spell" ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
if( pItem->amount() > 1 )
{
socket->sysMessage( tr( "You can only put 1 scroll into a spellbook at a time" ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
else
{
pBook->addSpell( spellId );
Items->DeleItem( pItem );
pBook->update( socket );
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;
示例13: 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
//.........这里部分代码省略.........
示例14: grabItem
// New Class implementation
void cDragItems::grabItem( P_CLIENT client )
{
// Get our character
P_CHAR pChar = client->player();
if( pChar == NULL )
return;
// Fetch the grab information
SERIAL iSerial = LongFromCharPtr( &buffer[ client->socket() ][ 1 ] );
UI16 amount = ShortFromCharPtr( &buffer[ client->socket() ][ 5 ] );
P_ITEM pItem = FindItemBySerial( iSerial );
if( !pItem )
return;
// Are we already dragging an item ?
// Bounce it and reject the move
// (Logged out while dragging an item)
if( client->dragging() )
{
bounceItem( client, client->dragging() );
bounceItem( client, pItem, true );
return;
}
// Do we really want to let him break his meditation
// When he picks up an item ?
// Maybe a meditation check here ?!?
pChar->disturbMed( client->socket() ); // Meditation
P_CHAR itemOwner = GetPackOwner( pItem, 64 );
// Try to pick something out of another characters posessions
if( itemOwner && ( itemOwner != pChar ) && ( !pChar->Owns( itemOwner ) ) )
{
client->sysMessage( QString( "You have to steal the %1 out of %2's posessions." ).arg( pItem->getName() ).arg( itemOwner->name.c_str() ) );
bounceItem( client, pItem, true );
return;
}
// Check if the user can grab the item
if( !pChar->canPickUp( pItem ) )
{
client->sysMessage( "You cannot pick that up." );
bounceItem( client, pItem, true );
return;
}
// The user can't see the item
// Basically thats impossible as the client should deny moving the item
// if it's not in line of sight but to prevent exploits
if( !line_of_sight( client->socket(), pChar->pos, pItem->pos, TREES_BUSHES|WALLS_CHIMNEYS|DOORS|ROOFING_SLANTED|FLOORS_FLAT_ROOFING|LAVA_WATER ) )
{
client->sysMessage( "You can't see the item." );
bounceItem( client, pItem, true );
return;
}
P_ITEM outmostCont = GetOutmostCont( pItem, 64 );
// If it's a trade-window, reset the ack-status
if( outmostCont && ( outmostCont->contserial == pChar->serial ) && ( 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->morez = 0;
outmostCont->morez = 0;
sendtradestatus( tradeWindow, outmostCont );
}
}
// If the top-most container ( thats important ) is a corpse
// and looting is a crime, flag the character criminal.
if( 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, FindCharBySerial( outmostCont->ownserial ) ) != 0 );
if( ( outmostCont->more2 == 1 ) && !pChar->Owns( outmostCont ) && !sameGuild )
{
pChar->karma -= 5;
criminal( pChar );
client->sysMessage( "You lost some karma." );
}
}
// Check if the item is too heavy
//if( !pc_currchar->isGMorCounselor() )
//{
//} << Deactivated (DarkStorm)
// ==== Grabbing the Item is allowed here ====
//.........这里部分代码省略.........
示例15: dropOnItem
//.........这里部分代码省略.........
client->sysMessage( "That spellbook already contains this spell" );
bounceItem( client, pItem );
return;
}
}
// We drop something on the belongings of one of our playervendors
if( ( packOwner != NULL ) && ( packOwner->npcaitype() == 17 ) && pChar->Owns( packOwner ) )
{
client->sysMessage( "You drop something into your playervendor" );
bounceItem( client, pItem );
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)
// Spellbooks are containers for us as well
if( pCont->type() == 9 || pCont->type() == 1 || pCont->type() == 8 || pCont->type() == 63 || pCont->type() == 65 || pCont->type() == 66 )
{
pItem->setContSerial( pCont->serial );
pItem->setLayer( 0 ); // Remove it from our drag-layer
// Huh ? - Make that random will you!
pItem->pos = dropPos;
SndRemoveitem( pItem->serial );
RefreshItem( pItem );
// Dropped on another Container/in another Container
soundeffect2( pChar, 0x57 );
return;
}
// Item matching needs to be extended !!! at least Color! (for certain types)
else if ( pCont->isPileable() && pItem->isPileable() && ( pCont->id() == pItem->id() ) )
{
if( pCont->amount() + pItem->amount() <= 65535 )
{
pCont->setAmount( pCont->amount() + pItem->amount() );
Items->DeleItem( pItem );
RefreshItem( pCont ); // Need to update the amount
return;
}
// We have to *keep* our current item
else
{
pCont->setAmount( 65535 ); // Max out the amount
RefreshItem( pCont );
// The delta between 65535 and pCont->amount() sub our Amount is the
// new amount
pItem->setAmount( pItem->amount() - ( 65535 - pCont->amount() ) );
}
}
// We dropped the item NOT on a container
// And were *un*able to stack it (!)
// >> Set it to the location of the item we dropped it on and stack it up by 1
pItem->moveTo( pCont->pos );
pItem->pos.z++; // Increase z by 1
pItem->pos.y++; // To get it visualized do that with y as well
pItem->setLayer( 0 );
pItem->setContSerial( pCont->contserial );
RefreshItem( pItem );
// This needs to be checked
// It annoyingly shows the spellbook
// whenever you add a scroll
if( pCont->type() == 9 )
Magic->openSpellBook( pChar, pCont );
// Glowing Objects moved between chars
if( pItem->glow != INVALID_SERIAL )
{
pChar->removeHalo( pItem );
if( packOwner != NULL )
{
packOwner->addHalo(pItem);
packOwner->glowHalo(pItem);
}
}
}