本文整理汇总了C++中P_ITEM类的典型用法代码示例。如果您正苦于以下问题:C++ P_ITEM类的具体用法?C++ P_ITEM怎么用?C++ P_ITEM使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了P_ITEM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InputSpeech
bool InputSpeech( cUOSocket* socket, P_PLAYER pChar, const QString& speech )
{
if ( pChar->inputMode() == cPlayer::enNone )
return false;
P_ITEM pItem = FindItemBySerial( pChar->inputItem() );
if ( !pItem )
return false;
//bool ok = false;
//Q_INT32 num = speech.toInt( &ok ); // Generally try to convert it
QString notification;
switch ( pChar->inputMode() )
{
// Pricing an item - PlayerVendors
case cPlayer::enPricing:
socket->sysMessage( "Ops, sorry not implemented" );
pChar->setInputMode( cPlayer::enDescription );
socket->sysMessage( tr( "Enter a description for this item." ) );
break;
// Describing an item
case cPlayer::enDescription:
socket->sysMessage( "Description is not used anywhere :( not implemented right now" );
socket->sysMessage( tr( "This item is now described as %1." ).arg( speech ) );
pChar->setInputMode( cPlayer::enNone );
pChar->setInputItem( INVALID_SERIAL );
break;
// Renaming ourself
case cPlayer::enNameDeed:
pChar->setName( speech );
socket->sysMessage( tr( "Your new name is: %1" ).arg( speech ) );
pChar->setInputMode( cPlayer::enNone );
pChar->setInputItem( INVALID_SERIAL );
break;
// Renaming a house sign
case cPlayer::enHouseSign:
pItem->setName( speech );
socket->sysMessage( tr( "Your house has been renamed to: %1" ).arg( speech ) );
pChar->setInputMode( cPlayer::enNone );
pChar->setInputItem( INVALID_SERIAL );
break;
default:
break; // do nothing
}
return true;
}
示例2: FindItemBySerial
void DragAndDrop::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() );
// A completely invalid Drop packet
if ( !iCont && !cCont && ( dropPos.x == 0xFFFF ) && ( dropPos.y == 0xFFFF ) )
{
socket->bounceItem( pItem, BR_NO_REASON );
return;
}
float 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 )
pChar->goldSound( pItem->amount() );
// Update our weight.
if ( weight != pChar->weight() )
socket->sendStatWindow();
}
示例3: BountyWithdrawGold
bool cBounty::BountyWithdrawGold( P_CHAR pVictim, int nAmount )
{
int has = pVictim->CountBankGold();
if (has < nAmount)
return false;
P_ITEM pBox = pVictim->GetBankBox();
if (!pBox)
return false; // shouldn't happen coz it's needed in CountBankGold...
pBox->DeleteAmount(nAmount,0x0EED);
return true;
}
示例4: preCondition
float Action_MoveToTarget::preCondition()
{
/*
* Moving to the target has the following preconditions:
* - A target has been set.
* - The NPC is not in combat range.
*
* Here we take the fuzzy logic into account.
* If the npc is injured, the chance of fighting will decrease.
*/
if ( !m_ai )
{
return 0.0f;
}
P_CHAR currentVictim = m_ai->currentVictim();
if ( !currentVictim || !validTarget( m_npc, currentVictim ) )
{
return 0.0f;
}
Q_UINT8 range = 1;
P_ITEM weapon = m_npc->getWeapon();
if ( weapon )
{
if ( weapon->hasTag( "range" ) )
{
range = weapon->getTag( "range" ).toInt();
}
else if ( weapon->basedef() )
{
range = weapon->basedef()->getIntProperty( "range", 1 );
}
}
if ( m_npc->inRange( currentVictim, range ) )
return 0.0f;
// 1.0 = Full Health, 0.0 = Dead
float diff = 1.0 - wpMax<float>( 0, ( m_npc->maxHitpoints() - m_npc->hitpoints() ) / ( float ) m_npc->maxHitpoints() );
if ( diff <= m_npc->criticalHealth() / 100.0 )
{
return 0.0;
}
return 1.0;
}
示例5: ItemDroppedOnGuard
static bool ItemDroppedOnGuard(NXWCLIENT ps, PKGx08 *pp, P_ITEM pi)
{
if (ps == NULL)
return false;
VALIDATEPIR(pi, false);
char temp[TEMP_STR_SIZE]; //xan -> this overrides the global temp var
NXWSOCKET s=ps->toInt();
P_CHAR pc = ps->currChar();
VALIDATEPCR(pc,false);
P_CHAR pc_t=pointers::findCharBySerial(pp->Tserial); //the guard
VALIDATEPCR(pc_t,false);
// Search for the key word "the head of"
if( strstr( pi->getCurrentNameC(), "the head of" ) ) //!!! Wrong! it must check the ItemID, not the name :(
{
// This is a head of someone, see if the owner has a bounty on them
P_CHAR own=pointers::findCharBySerial(pi->getOwnerSerial32());
VALIDATEPCR(own,false);
if( own->questBountyReward > 0 )
{
// Give the person the bounty assuming that they are not the
// same person as the reward is for
if( pc->getSerial32() != own->getSerial32() )
{
// give them the gold for bringing the villan to justice
addgold( s, own->questBountyReward );
pc->playSFX( goldsfx( own->questBountyReward ) );
// Now thank them for their hard work
sprintf( temp, TRANSLATE("Excellent work! You have brought us the head of %s. Here is your reward of %d gold coins."),
own->getCurrentNameC(), own->questBountyReward );
pc_t->talk( s, temp, 0);
// Delete the Bounty from the bulletin board
BountyDelete(own );
// xan : increment fame & karma :)
pc->modifyFame( ServerScp::g_nBountyFameGain );
pc->IncreaseKarma(ServerScp::g_nBountyKarmaGain);
}
else
pc_t->talk( s, TRANSLATE("You can not claim that prize scoundrel. You are lucky I don't strike you down where you stand!"),0);
// Delete the item
pi->Delete();
}
}
return true;
}
示例6: postWorldLoading
void cAllSpawnRegions::postWorldLoading()
{
cItemIterator iItems;
for( P_ITEM pItem = iItems.first(); pItem; pItem = iItems.next() )
{
QString srname = pItem->spawnregion();
if( !srname.isNull() )
{
cSpawnRegion* spawnregion = region( srname );
if( spawnregion )
spawnregion->add( pItem->serial() );
}
}
}
示例7: init
/*!
\brief initializes pointer maps
\author Luxor
*/
void init()
{
pStableMap.clear();
pContMap.clear();
pMounted.clear();
pOwnCharMap.clear();
pOwnItemMap.clear();
//Chars and Stablers
P_CHAR pc = 0;
cAllObjectsIter objs;
for( objs.rewind(); !objs.IsEmpty(); objs++ )
{
if( isCharSerial( objs.getSerial() ) ) {
pc=(P_CHAR)objs.getObject();
{
if( pc->isStabled() ) {
pStableMap[pc->getStablemaster()].push_back(pc);
}
if( pc->mounted )
pMounted[pc->getOwnerSerial32()]=pc;
P_CHAR own=pointers::findCharBySerial(pc->getOwnerSerial32());
pc->setOwnerSerial32( DEREF_P_CHAR(own), true );
}
}
else {
P_ITEM pi = (P_ITEM)objs.getObject();
updContMap(pi);
P_CHAR own=pointers::findCharBySerial(pi->getOwnerSerial32());
pi->setOwnerSerial32( DEREF_P_CHAR(own), true );
}
}
std::map< SERIAL, P_CHAR >::iterator iter( pMounted.begin() ), end( pMounted.end() );
for( ; iter!=end; iter++)
{
pc = pointers::findCharBySerial(iter->first);
if(ISVALIDPC(pc))
pc->setOnHorse();
}
}
示例8: RandomNum
// do one spawn and reset the timer
void cSpawnRegion::reSpawn( void )
{
this->checkForDeleted();
UI16 i = 0;
for( i = 0; i < this->npcsPerCycle_; i++ )
{
if( this->npcSerials_.size() < this->maxNpcAmt_ )
{
// spawn a random npc
// first find a valid position for the npc
Coord_cl pos;
if( this->findValidSpot( pos ) )
{
QString NpcSect = this->npcSections_[ RandomNum( 1, this->npcSections_.size() ) - 1 ];
P_NPC pc = cCharStuff::createScriptNpc( NpcSect, pos );
if( pc != NULL )
{
this->npcSerials_.push_back( pc->serial() );
pc->setSpawnregion( this->name_ );
}
}
}
}
for( i = 0; i < this->itemsPerCycle_; i++ )
{
if( this->itemSerials_.size() < this->maxItemAmt_ )
{
// spawn a random item
// first find a valid position for the item
Coord_cl pos;
if( this->findValidSpot( pos ) )
{
QString ItemSect = this->itemSections_[ RandomNum( 1, this->itemSections_.size() ) - 1 ];
P_ITEM pi = cItem::createFromScript( ItemSect );
if( pi != NULL )
{
pi->moveTo( pos );
this->itemSerials_.push_back( pi->serial() );
// pi->setSpawnRegion( this->name_ );
}
}
}
}
this->nextTime_ = uiCurrentTime + RandomNum( this->minTime_, this->maxTime_ ) * MY_CLOCKS_PER_SEC;
}
示例9: spawnSingleItem
void cSpawnRegion::spawnSingleItem()
{
Coord_cl pos;
if ( findValidSpot( pos ) )
{
QString ItemSect = this->itemSections_[RandomNum( 1, this->itemSections_.size() ) - 1];
P_ITEM pi = cItem::createFromScript( ItemSect );
if ( pi )
{
pi->moveTo( pos, true );
pi->setSpawnregion( this );
pi->update();
onSpawn( pi );
}
}
}
示例10: item_bounce4
static void item_bounce4(const NXWSOCKET socket, const P_ITEM pi)
{
VALIDATEPI( pi );
item_bounce3(pi);
if( (pi->getId() >>8) < 0x40)
senditem( socket, pi );
}
示例11: canMine
static LOGICAL canMine( P_CHAR pc, P_ITEM weapon )
{
VALIDATEPCR(pc,false);
if( !ISVALIDPI(weapon) && ( pc->CountItemsByType(ITYPE_MINING) <= 0 ) )
pc->sysmsg( TRANSLATE("You must have a pickaxe or shovel in hand in order to mine."));
else
{
if ( (ISVALIDPI(weapon) && ( weapon->getType() == ITYPE_MINING )) || (pc->CountItemsByType(ITYPE_MINING) > 0 ))
// Let's see if he has a shovel in his pack
{
if (pc->isMounting())
pc->sysmsg( TRANSLATE("You cant mine while on a horse!"));
else
if( !pc->IsGM() && (ores.stamina<0) && (abs( ores.stamina )>pc->stm) )
pc->sysmsg( TRANSLATE("You are too tired to mine."));
else
return true;
}
}
return false;
}
示例12: 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;
}
示例13: ItemDroppedOnBeggar
static bool ItemDroppedOnBeggar(NXWCLIENT ps, PKGx08 *pp, P_ITEM pi)
{
if (ps == NULL)
return false;
VALIDATEPIR(pi, false);
char temp[TEMP_STR_SIZE]; //xan -> this overrides the global temp var
NXWSOCKET s=ps->toInt();
P_CHAR pc=ps->currChar();
VALIDATEPCR(pc,false);
P_CHAR pc_t=pointers::findCharBySerial(pp->Tserial); //beggar
VALIDATEPCR(pc_t,false);
if(pi->getId()!=ITEMID_GOLD)
{
sprintf(temp,TRANSLATE("Sorry %s i can only use gold"), pc->getCurrentNameC());
pc_t->talk( s,temp,0);
Sndbounce5(s);
if (ps->isDragging())
{
ps->resetDragging();
item_bounce5(s,pi);
return true;
}
}
else
{
sprintf(temp,TRANSLATE("Thank you %s for the %i gold!"), pc->getCurrentNameC(), pi->amount);
pc_t->talk( s,temp,0);
if(pi->amount<=100)
{
pc->IncreaseKarma(10);
ps->sysmsg(TRANSLATE("You have gain a little karma!"));
}
else if(pi->amount>100)
{
pc->IncreaseKarma(50);
ps->sysmsg(TRANSLATE("You have gain some karma!"));
}
pi->Delete();
return true;
}
return true;
}
示例14: 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 );
}
示例15: str2num
bool cCharStuff::cBankerAI::BankCheck(int c, P_CHAR pBanker, const string& comm)
{
P_CHAR pc_currchar = currchar[c];
int beginoffset ;
int endoffset ;
int value =0 ;
string value2;
if ((beginoffset=comm.find_first_of("0123456789")) != string::npos)
{
if ((endoffset=comm.find_first_not_of("0123456789",beginoffset))== string::npos)
endoffset = comm.length();
value2= comm.substr(beginoffset,endoffset-beginoffset) ;
value = str2num(value2) ;
}
int d = pc_currchar->CountBankGold();
{
int goldcount = value;
if (goldcount < 5000 || goldcount > 1000000)
{
sprintf(temp, "%s you can only get checks worth 5000gp to 1000000gp.", pc_currchar->name.c_str());
npctalk(c, pBanker, temp, 1);
return false;
}
if (d >= goldcount)
{
const P_ITEM pi = Items->SpawnItem(c, pc_currchar, 1, "bank check", 0, 0x14, 0xF0, 0, 0, 0); // bank check
if (pi != NULL)
pi->type = 1000;
pi->setId(0x14F0);
pi->color = 0x0099;
pi->priv |= 0x02;
pi->value = goldcount;
DeleBankItem(pc_currchar, 0x0EED, 0, goldcount);
P_ITEM bankbox = pc_currchar->GetBankBox();
bankbox->AddItem(pi);
statwindow(c, pc_currchar);
sprintf(temp, "%s your check has been placed in your bankbox, it is worth %i.", pc_currchar->name.c_str(), goldcount);
npctalk(c, pBanker, temp, 1);
return true;
}
else
sprintf(temp, "%s you have insufficent funds!", pc_currchar->name.c_str());
npctalk(c, pBanker, temp, 1);
return true;
}
}