本文整理汇总了C++中P_ITEM::isMulti方法的典型用法代码示例。如果您正苦于以下问题:C++ P_ITEM::isMulti方法的具体用法?C++ P_ITEM::isMulti怎么用?C++ P_ITEM::isMulti使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_ITEM
的用法示例。
在下文中一共展示了P_ITEM::isMulti方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DynTile
Q_UINT16 DynTile( const Coord& pos )
{
MapItemsIterator ri = MapObjects::instance()->listItemsInCircle( pos, 18 );
for ( P_ITEM mapitem = ri.first(); mapitem; mapitem = ri.next() )
{
if ( mapitem->isMulti() )
{
MultiDefinition* def = MultiCache::instance()->getMulti( mapitem->id() - 0x4000 );
if ( !def )
return 0;
QValueVector<multiItem_st> multi = def->getEntries();
for ( Q_UINT32 j = 0; j < multi.size(); ++j )
{
if ( ( multi[j].visible && ( mapitem->pos().x + multi[j].x == pos.x ) && ( mapitem->pos().y + multi[j].y == pos.y ) && ( abs( mapitem->pos().z + multi[j].z - pos.z ) <= 1 ) ) )
{
return multi[j].tile;
}
}
}
else if ( mapitem->pos() == pos )
{
return mapitem->id();
}
}
return ( Q_UINT16 ) - 1;
}
示例2: findmulti
P_ITEM findmulti(Coord_cl pos) //Sortta like getboat() only more general... use this for other multi stuff!
{
int lastdist = 30;
P_ITEM multi = NULL;
int ret;
cRegion::RegionIterator4Items ri(pos);
for (ri.Begin(); !ri.atEnd(); ri++)
{
P_ITEM mapitem = ri.GetData();
if (mapitem != NULL)
{
if (mapitem->isMulti())
{
ret = pos.distance(mapitem->pos);
if (ret <= lastdist)
{
lastdist = ret;
if (inmulti(pos, mapitem))
multi = mapitem;
}
}
}
}
return multi;
}
示例3: DynTile
Q_UINT16 DynTile( const Coord_cl& pos )
{
RegionIterator4Items ri( pos );
for ( ri.Begin(); !ri.atEnd(); ri++ )
{
P_ITEM mapitem = ri.GetData();
if ( mapitem )
{
if ( mapitem->isMulti() )
{
MultiDefinition* def = MultiCache::instance()->getMulti( mapitem->id() - 0x4000 );
if ( !def )
return 0;
QValueVector<multiItem_st> multi = def->getEntries();
for ( Q_UINT32 j = 0; j < multi.size(); ++j )
{
if ( ( multi[j].visible && ( mapitem->pos().x + multi[j].x == pos.x ) && ( mapitem->pos().y + multi[j].y == pos.y ) && ( abs( mapitem->pos().z + multi[j].z - pos.z ) <= 1 ) ) )
{
return multi[j].tile;
}
}
}
else if ( mapitem->pos() == pos )
return mapitem->id();
}
}
return ( Q_UINT16 ) - 1;
}
示例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
void cDragItems::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;
}
// 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;
}
// 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;
}
// Required Strength
if( pItem->st() > pWearer->strength() )
{
if( pWearer == pChar )
socket->sysMessage( tr( "You cannot wear that item, you seem not strong enough" ) );
else
socket->sysMessage( tr( "This person can't wear that item, it seems not strong enough" ) );
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
// Required Dexterity
if( pItem->dx() > pWearer->dexterity() )
{
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;
//.........这里部分代码省略.........
示例6: findObjects
cSectorIterator* cSectorMaps::findObjects( MapType type, cSectorMap* sector, uint x1, uint y1, uint x2, uint y2 )
{
// First step: count how many items we are going to hold
unsigned int count = 0;
unsigned int xBlock, yBlock;
if ( x1 > x2 )
{
std::swap( x1, x2 );
std::swap( y1, y2 );
}
for ( xBlock = x1 / SECTOR_SIZE; xBlock <= x2 / SECTOR_SIZE; xBlock++ )
for ( yBlock = y1 / SECTOR_SIZE; yBlock <= y2 / SECTOR_SIZE; yBlock++ )
count += sector->countItems( ( xBlock * sector->gridHeight() ) + yBlock );
// Second step: actually "compile" our list of items
cUObject** items = ( cUObject** ) malloc( count * sizeof( cUObject* ) );
unsigned int offset = 0;
for ( xBlock = x1 / SECTOR_SIZE; xBlock <= x2 / SECTOR_SIZE; xBlock++ )
for ( yBlock = y1 / SECTOR_SIZE; yBlock <= y2 / SECTOR_SIZE; yBlock++ )
{
// We *do* know that we allocated more memory than we need, but the effect is minimal!
unsigned int block = ( xBlock * sector->gridHeight() ) + yBlock;
if ( block >= sector->gridWidth() * sector->gridHeight() )
continue;
if ( sector->grid[block] )
{
for ( unsigned int i = 0; i < sector->grid[block]->count; ++i )
{
cUObject* object = sector->grid[block]->data[i];
if ( object->pos().x >= x1 && object->pos().y >= y1 && object->pos().x <= x2 && object->pos().y <= y2 ) {
// This sucks but we don't have much choice
if (type == MT_CHARS) {
P_PLAYER player = dynamic_cast<P_PLAYER>(object);
// Exclude logged out players.
if (!player || player->socket() || player->logoutTime()) {
items[offset++] = object;
}
} else if (type == MT_MULTIS) {
P_ITEM item = dynamic_cast<P_ITEM>(object);
if (item && item->isMulti()) {
items[offset++] = object;
}
} else {
items[offset++] = object;
}
}
}
}
}
/*
NOTE:
Offset is our new count here. The count we measured previously
was just there to measure the amount of memory we had to allocate
for the list.
*/
switch ( type )
{
case MT_ITEMS:
case MT_MULTIS:
return new cItemSectorIterator( offset, items );
case MT_CHARS:
case MT_CHARSANDOFFLINE:
return new cCharSectorIterator( offset, items );
default:
return new cSectorIterator( offset, items );
};
}
示例7: getBlockingTiles
// Get blocking tiles at the given x,y,map coordinate
// Get floor tiles, that are not blocking, too
// we need these floor tiles to know, if the 'black map' tile is the only floor here
void getBlockingTiles( const Coord& pos, QList<stBlockingItem>& items )
{
stBlockingItem item;
// Maptiles first
Maps::instance()->mapTileSpan( pos, item.id, item.bottom, item.top );
item.maptile = true;
item.noblock = false;
// Only include this maptile if it's relevant for our line of sight
if ( item.id != 2 && item.id != 0x1DB && ( item.id <0x1AE || item.id> 0x1B5 ) )
{
items.append( item );
}
item.maptile = false;
// Search for statics at the same position
StaticsIterator statics = Maps::instance()->staticsIterator( pos, true );
// Find blocking statics
for ( ; !statics.atEnd(); ++statics )
{
const staticrecord &sitem = *statics;
tile_st tile = TileCache::instance()->getTile( sitem.itemid );
if ( tile.flag2 & 0x30 )
{
item.bottom = sitem.zoff;
// Bridges are only half as high
item.top = item.bottom + ( ( tile.flag2 & 0x04 ) ? ( tile.height / 2 ) : tile.height );
item.id = sitem.itemid;
item.noblock = false;
items.append( item );
}
// floor tiles that aren't blocking
else if ( tile.flag2 & 0x2 )
{
item.bottom = sitem.zoff;
// Bridges are only half as high
item.top = item.bottom + ( ( tile.flag2 & 0x04 ) ? ( tile.height / 2 ) : tile.height );
item.id = sitem.itemid;
item.noblock = true;
items.append( item );
}
}
// Search for items at the given location
MapItemsIterator itemIter = MapObjects::instance()->listItemsAtCoord( pos );
for ( P_ITEM pItem = itemIter.first(); pItem; pItem = itemIter.next() )
{
// If the item is invisible or a multi, skip past it.
if ( pItem->isMulti() )
continue;
tile_st tile = TileCache::instance()->getTile( pItem->id() );
// Window and noshoot tiles block
if ( tile.flag2 & 0x30 )
{
item.id = pItem->id();
item.bottom = pItem->pos().z;
// Bridges are only half as high
item.top = item.bottom + ( ( tile.flag2 & 0x04 ) ? ( tile.height / 2 ) : tile.height );
item.noblock = false;
items.append( item );
}
// floor tiles that aren't blocking
else if ( tile.flag2 & 0x2 )
{
item.id = pItem->id();
item.bottom = pItem->pos().z;
// Bridges are only half as high
item.top = item.bottom + ( ( tile.flag2 & 0x04 ) ? ( tile.height / 2 ) : tile.height );
item.noblock = true;
items.append( item );
}
}
// Check for multis around the area
MapMultisIterator multis = MapObjects::instance()->listMultisInCircle( pos, BUILDRANGE );
// Check if there is an intersecting item for this multi
for ( P_MULTI pMulti = multis.first(); pMulti; pMulti = multis.next() )
{
// Get all items for this multi
MultiDefinition *data = MultiCache::instance()->getMulti( pMulti->id() - 0x4000 );
if ( data )
{
QList<multiItem_st> mitems = data->getEntries();
QList<multiItem_st>::iterator it;
for ( it = mitems.begin(); it != mitems.end(); ++it )
{
multiItem_st mitem = *it;
//.........这里部分代码省略.........
示例8: dropOnItem
void cDragItems::dropOnItem( P_CLIENT client, P_ITEM pItem, P_ITEM pCont, const Coord_cl &dropPos )
{
P_CHAR pChar = client->player();
if( pItem->isMulti() )
{
client->sysMessage( "You cannot put houses in containers" );
bounceItem( client, pItem );
return;
}
// If the target belongs to another character
// It needs to be our vendor or else it's denied
P_CHAR packOwner = GetPackOwner( pCont );
if( ( packOwner != NULL ) && ( packOwner != pChar ) )
{
// For each item someone puts into there
// He needs to do a snoop-check
if( pChar->canSnoop() )
{
if( !Skills->CheckSkill( pChar, SNOOPING, 0, 1000 ) )
{
client->sysMessage( QString( "You fail to put that into %1's pack" ).arg( packOwner->name.c_str() ) );
bounceItem( client, pItem );
return;
}
}
if( !packOwner->isNpc() || ( packOwner->npcaitype() != 17 ) || !pChar->Owns( packOwner ) )
{
client->sysMessage( "You cannot put that into the belongings of another player" );
bounceItem( client, pItem );
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->morez = 0;
pCont->morez = 0;
sendtradestatus( tradeWindow, pCont );
}
}
if( !pChar->canPickUp( pItem ) )
{
bounceItem( client, pItem );
return;
}
// Trash can
if( pCont->type()==87 )
{
Items->DeleItem( pItem );
client->sysMessage( "As you let go of the item it disappears." );
return;
}
// Spell Book
if( pCont->type() == 9 )
{
UI08 spellId = Magic->calcSpellId( pItem->id() );
if( spellId < 0 )
{
client->sysMessage( "You can only put scrolls into a spellbook" );
bounceItem( client, pItem );
return;
}
if( Magic->hasSpell( pCont, spellId ) )
{
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 ) ) )
{
//.........这里部分代码省略.........
示例9: equipItem
void cDragItems::equipItem( P_CLIENT client )
{
// Get the packet information
SERIAL itemId = LongFromCharPtr( &buffer[ client->socket() ][ 1 ] );
SERIAL playerId = LongFromCharPtr( &buffer[ client->socket() ][ 6 ] );
P_ITEM pItem = FindItemBySerial( itemId );
P_CHAR pWearer = FindCharBySerial( playerId );
if( !pItem || !pWearer )
return;
P_CHAR pChar = client->player();
// We're dead and can't do that
if( pChar->dead )
{
client->sysMessage( "You are dead and can't do that." );
bounceItem( client, pItem );
return;
}
// Our target is dead
if( ( pWearer != pChar ) && pWearer->dead )
{
client->sysMessage( "You can't equip dead players." );
bounceItem( client, pItem );
return;
}
// Get our tile-information
tile_st pTile;
Map->SeekTile( pItem->id(), &pTile );
// 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() )
{
client->sysMessage( "This item cannot be equipped." );
bounceItem( client, pItem );
return;
}
// Required Strength
if( pItem->st > pWearer->st )
{
if( pWearer == pChar )
client->sysMessage( "You cannot wear that item, you seem not strong enough" );
else
client->sysMessage( "This person can't wear that armor, it seems not strong enough" );
bounceItem( client, pItem );
return;
}
// Required Dexterity
if( pItem->dx > pWearer->effDex() )
{
if( pWearer == pChar )
client->sysMessage( "You cannot wear that item, you seem not agile enough" );
else
client->sysMessage( "This person can't wear that armor, it seems not agile enough" );
bounceItem( client, pItem );
return;
}
// Required Intelligence
if( pItem->in > pWearer->in )
{
if( pWearer == pChar )
client->sysMessage( "You cannot wear that item, you seem not smart enough" );
else
client->sysMessage( "This person can't wear that armor, it seems not smart enough" );
bounceItem( client, pItem );
return;
}
// Males can't wear female armor
if( ( pChar->id() == 0x0190 ) && ( pItem->id() >= 0x1C00 ) && ( pItem->id() <= 0x1C0D ) )
{
client->sysMessage( "You cannot wear female armor." );
bounceItem( client, pItem );
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
UI08 layer = pItem->layer();
vector< SERIAL > equipment = contsp.getData( pWearer->serial );
for( UI32 i = 0; i < equipment.size(); i++ )
{
P_ITEM pEquip = FindItemBySerial( equipment[ i ] );
if( pEquip )
continue;
//.........这里部分代码省略.........
示例10: 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 );
}
//.........这里部分代码省略.........
示例11: 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;
//.........这里部分代码省略.........