本文整理汇总了C++中P_ITEM::id方法的典型用法代码示例。如果您正苦于以下问题:C++ P_ITEM::id方法的具体用法?C++ P_ITEM::id怎么用?C++ P_ITEM::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_ITEM
的用法示例。
在下文中一共展示了P_ITEM::id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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);
}
}
示例4: items_match
// this is a q&d fix for 'sell price higher than buy price' bug (Duke, 30.3.2001)
static bool items_match(P_ITEM pi1, P_ITEM pi2)
{
if (pi1 && pi2 && pi1->id()==pi2->id() &&
pi1->type==pi2->type &&
!(pi1->id()==0x14F0 && (pi1->morex!=pi2->morex)) && // house deeds only differ by morex
!(IsShield(pi1->id()) && pi1->name2 == pi2->name2) && // magic shields only differ by name2
!(IsMetalArmour(pi1->id()) && pi1->color != pi2->color) ) // color checking for armour
return true;
return false;
}
示例5: ItemDroppedOnTrainer
static bool ItemDroppedOnTrainer(P_CLIENT ps, PKGx08 *pp, P_ITEM pi)
{
UOXSOCKET s=ps->GetSocket();
CHARACTER cc=ps->GetCurrChar();
P_CHAR pc_currchar = MAKE_CHARREF_LRV(cc,true);
int t=calcCharFromSer(pp->Tserial);
if( pi->id() ==0x0EED )
{ // They gave the NPC gold
char sk=chars[t].trainingplayerin;
npctalk(s, t, "I thank thee for thy payment. That should give thee a good start on thy way. Farewell!",0);
int sum = pc_currchar->getSkillSum();
int delta = chars[t].getTeachingDelta(pc_currchar, sk, sum);
if(pi->amount>delta) // Paid too much
{
pi->amount-=delta;
Sndbounce5(s);
if (ps->IsDragging())
{
ps->ResetDragging();
item_bounce5(s,pi);
}
}
else
{
if(pi->amount < delta) // Gave less gold
delta = pi->amount; // so adjust skillgain
Items->DeleItem(pi);
}
pc_currchar->baseskill[sk]+=delta;
Skills->updateSkillLevel(DEREF_P_CHAR(pc_currchar), sk);
updateskill(s,sk);
pc_currchar->trainer=-1;
chars[t].trainingplayerin='\xFF';
itemsfx(s, pi->id());//AntiChrist - do the gold sound
return true;
}
else // Did not give gold
{
npctalk(s, t, "I am sorry, but I can only accept gold.",0);
Sndbounce5(s);
if (ps->IsDragging())
{
ps->ResetDragging();
item_bounce5(s,pi);
return true;
}
else
return true;
}//if items[i]=gold
return true;
}
示例6: losTargetPoint
Coord Coord::losTargetPoint( cUORxTarget* target, unsigned char map )
{
SERIAL serial = target->serial();
P_ITEM pItem = World::instance()->findItem( serial );
P_CHAR pChar = World::instance()->findChar( serial );
if ( pItem )
{
pItem = pItem->getOutmostItem();
if ( pItem->container() && pItem->container()->isChar() )
{
return pItem->container()->pos().losCharPoint();
}
else
{
return pItem->pos().losItemPoint( pItem->id() );
}
}
else if ( pChar )
{
return pChar->pos().losCharPoint();
}
else
{
return Coord( target->x(), target->y(), target->z(), map );
}
}
示例7: ItemDroppedOnBeggar
static bool ItemDroppedOnBeggar(P_CLIENT ps, PKGx08 *pp, P_ITEM pi)
{
UOXSOCKET s=ps->GetSocket();
CHARACTER cc=ps->GetCurrChar();
P_CHAR pc_currchar = MAKE_CHARREF_LRV(cc,false);
int t=calcCharFromSer(pp->Tserial);
if(pi->id()!=0x0EED)
{
sprintf((char*)temp,"Sorry %s i can only use gold",pc_currchar->name);
npctalk(s,t,(char*)temp,0);
return false;
}
sprintf((char*)temp,"Thank you %s for the %i gold!",pc_currchar->name,pi->amount);
npctalk(s,t,(char*)temp,0);
if(pi->amount<=100)
{
pc_currchar->karma += 10;
sysmessage(s,"You have gain a little karma!");
}
else
{
pc_currchar->karma += 50;
sysmessage(s,"You have gain some karma!");
}
Items->DeleItem(pi);
return true;
}
示例8: clearalltrades
void cTrade::clearalltrades()
{
AllItemsIterator iterItems;
for (iterItems.Begin(); !iterItems.atEnd(); iterItems++)
{
P_ITEM pi = iterItems.GetData();
if (pi->type==1 && pi->pos.x==26 && pi->pos.y==0 && pi->pos.z==0 &&
pi->id()==0x1E5E)
{
P_CHAR pc = FindCharBySerial(pi->contserial);
P_ITEM pBackpack = Packitem(pc);
SERIAL serial = pi->serial;
unsigned int ci;
vector<SERIAL> vecContainer = contsp.getData(serial);
for (ci = 0; ci < vecContainer.size(); ci++)
{
P_ITEM pj = FindItemBySerial(vecContainer[ci]);
if (pj != NULL)
if ((pj->contserial==serial))
{
if(pBackpack != NULL)
{
pBackpack->AddItem(pj);
}
}
}
iterItems--; // Iterator will became invalid when deletting.
Items->DeleItem(pi);
clConsole.send("Trade cleared\n");
}
}
}
示例9: dropOnBanker
void cDragItems::dropOnBanker( P_CLIENT client, P_ITEM pItem, P_CHAR pBanker )
{
P_CHAR pChar = client->player();
// No cheque ? >> Put into bank
if( ( pItem->id() != 0x14F0 ) && ( pItem->type() != 1000 ) )
{
P_ITEM bankBox = pChar->getBankBox();
if( bankBox )
bankBox->AddItem( pItem );
else
bounceItem( client, pItem );
pBanker->talk( QString( "The %1 is now in thy bank box" ).arg( pItem->getName() ) );
return;
}
// No Value ?!
if( !pItem->value )
{
pBanker->talk( "This cheque does not have any value!" );
bounceItem( client, pItem );
return;
}
pChar->giveGold( pItem->value, true );
pBanker->talk( QString( "%1 I have cashed thy cheque and deposited %2 gold." ).arg( pChar->name.c_str() ).arg( pItem->amount() ) );
pItem->ReduceAmount();
statwindow( client->socket(), pChar );
}
示例10: NewCalc
void cWeight::NewCalc(P_CHAR pc)
{
float totalweight=0.0;
//get weight for items on players
unsigned int ci = 0;
P_ITEM pi;
vector<SERIAL> vecContainer = contsp.getData(pc->serial);
for ( ci = 0; ci < vecContainer.size(); ci++)
{
pi = FindItemBySerial(vecContainer[ci]);
if (pi == NULL || (pi != NULL && pi->id() == 0x1E5E)) // trade window ?
continue;
if ((pi->layer()!=0x0B) && (pi->layer()!=0x10) && //no weight for hair/beard
(pi->layer()!=0x1D) && (pi->layer()!=0x19)) //no weight for steed/bank box
{
totalweight+=(pi->getWeight()/100.0f);
}
}
// Items in players pack
P_ITEM pBackpack = Packitem(pc);
if (pBackpack != NULL) totalweight += RecursePacks(pBackpack); //LB
pc->weight = (int)totalweight;
return;
}
示例11: 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]);
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*SrvParms->goldweight);
else
totalweight += (float)((itemsweight*pi->amount)/100.0f);
}
return totalweight;
}
示例12: equipItem
// Tries to equip an item
// if that fails it tries to put the item in the users backpack
// if *that* fails it puts it at the characters feet
// That works for NPCs as well
void equipItem( P_CHAR wearer, P_ITEM item )
{
tile_st tile = TileCache::instance()->getTile( item->id() );
// User cannot wear the item
if ( tile.layer == 0 )
{
if ( wearer->objectType() == enPlayer )
{
P_PLAYER pp = dynamic_cast<P_PLAYER>( wearer );
if ( pp->socket() )
pp->socket()->sysMessage( tr( "You cannot wear that item." ) );
}
item->toBackpack( wearer );
return;
}
cBaseChar::ItemContainer container = wearer->content();
cBaseChar::ItemContainer::const_iterator it( container.begin() );
for ( ; it != container.end(); ++it )
{
P_ITEM equip = *it;
// Unequip the item and free the layer that way
if ( equip && ( equip->layer() == tile.layer ) )
equip->toBackpack( wearer );
}
// *finally* equip the item
wearer->addItem( static_cast<cBaseChar::enLayer>( item->layer() ), item );
}
示例13: 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;
}
示例14: ItemDroppedOnBanker
static bool ItemDroppedOnBanker(P_CLIENT ps, PKGx08 *pp, P_ITEM pi)
{
UOXSOCKET s=ps->GetSocket();
CHARACTER cc=ps->GetCurrChar();
P_CHAR pc_currchar = MAKE_CHARREF_LRV(cc,true);
int t=calcCharFromSer(pp->Tserial);
P_ITEM bankbox = pc_currchar->GetBankBox();
int amt = pi->amount;
int value = pi->value;
if (pi->id() == 0x14F0 && pi->type == 1000)
{
const P_ITEM pi_n = Items->SpawnItem(DEREF_P_CHAR(pc_currchar), DEREF_P_CHAR(pc_currchar),value,"#",1,0x0E,0xED,0,0,0,0);
if(pi_n == NULL) return false;
sprintf((char*)temp,"%s I have cashed your check and deposited %i gold.",pc_currchar->name, value);
npctalk(s,t,(char*)temp,0);
bankbox->AddItem(pi_n);
statwindow(s, DEREF_P_CHAR(pc_currchar));
return true;
}
else
{
if (pi->id() == 0x0EED)
{
sprintf((char*)temp,"%s you have deposited %i gold.",pc_currchar->name, amt);
npctalk(s,t,(char*)temp,0);
bankbox->AddItem(pi);
statwindow(s, DEREF_P_CHAR(pc_currchar));
return true;
}
else
{
sprintf((char*)temp,"Sorry %s i can only deposit gold",pc_currchar->name);
npctalk(s,t,(char*)temp,0);
Sndbounce5(s);
if (ps->IsDragging())
{
ps->ResetDragging();
item_bounce5(s,pi);
return true;
}
}
return true;
}
}
示例15: HouseSpeech
// Handles house commands from friends of the house.
// msg must already be capitalized
void HouseSpeech( cUOSocket *socket, P_CHAR pPlayer, const QString& msg )
{
Q_UNUSED(socket);
// Not inside a multi
if( pPlayer->multis() == INVALID_SERIAL )
return;
P_ITEM pMulti = FindItemBySerial( pPlayer->multis() );
if( !pMulti )
{
clConsole.send( tr( "Player %1 [0x%2] has bad multi serial [0x%1]" ).arg( pPlayer->name() ).arg( pPlayer->serial(), 8, 16 ).arg( pPlayer->multis() ) );
pPlayer->setMultis( INVALID_SERIAL );
return;
}
if ( pMulti && IsHouse( pMulti->id() ) )
{
cHouse* pHouse = dynamic_cast< cHouse* >( pMulti );
// Only the owner or a friend of the house can control it
if( !( pPlayer->Owns( pHouse ) || pHouse->isFriend( pPlayer ) ) )
return;
}
else
return;
// >> LEGACY
/*if(msg.contains("I BAN THEE"))
{ // house ban
addid1[s] = pMulti->serial()>>24;
addid2[s] = pMulti->serial()>>16;
addid3[s] = pMulti->serial()>>8;
addid4[s] = pMulti->serial()%256;
target(s, 0, 1, 0, 229, "Select person to ban from house.");
}
else if(msg.contains("REMOVE THYSELF"))
{ // kick out of house
addid1[s] = pMulti->serial()>>24;
addid2[s] = pMulti->serial()>>16;
addid3[s] = pMulti->serial()>>8;
addid4[s] = pMulti->serial()%256;
target(s, 0, 1, 0, 228, "Select person to eject from house.");
}
else if (msg.contains("I WISH TO LOCK THIS DOWN"))
{ // lock down code AB/LB
target(s, 0, 1, 0, 232, "Select item to lock down");
}
else if (msg.contains("I WISH TO RELEASE THIS"))
{ // lock down code AB/LB
target(s, 0, 1, 0, 233, "Select item to release");
}
else if (msg.contains("I WISH TO SECURE THIS"))
{ // lock down code AB/LB
target(s, 0, 1, 0, 234, "Select item to secure");
}*/
}