本文整理汇总了C++中P_NPC::callGuards方法的典型用法代码示例。如果您正苦于以下问题:C++ P_NPC::callGuards方法的具体用法?C++ P_NPC::callGuards怎么用?C++ P_NPC::callGuards使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_NPC
的用法示例。
在下文中一共展示了P_NPC::callGuards方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RandomSteal
//.........这里部分代码省略.........
float maxWeight = ( float ) QMIN( 1, pChar->skillValue( STEALING ) ); // We can steal max. 10 Stones when we are a GM
// 1000 Skill == 100 Weight == 10 Stones
QPtrList<cItem> containment = pBackpack->getContainment();
Q_UINT32 chance = containment.count();
P_ITEM pItem = containment.first();
P_ITEM pToSteal = 0;
bool sawOkItem = false;
while ( !pToSteal )
{
// We have nothing that could be stolen?
if ( !pItem && !sawOkItem )
{
socket->sysMessage( tr( "Your victim posesses nothing you could steal." ) );
return;
}
// Jump back to the beginning
else if ( !pItem && sawOkItem )
{
pItem = containment.first();
}
// Check if our chance becomes true (no spellbooks!)
if ( pItem->totalweight() <= maxWeight && !pItem->isLockedDown() && !pItem->newbie() && pItem->type() != 9 )
{
sawOkItem = true; // We have items that could be stolen (just in case we reach the end of our list)
// We have the chance of 1/chance that we reached our desired item
if ( RandomNum( 1, ( int )chance ) == ( int )chance )
{
pToSteal = pItem;
break;
}
}
pItem = containment.next();
}
socket->sysMessage( tr( "You reach into %1's backpack and try to steal something..." ).arg( pVictim->name() ) );
// The success of our Theft depends on the weight of the stolen item
bool success = pChar->checkSkill( STEALING, 0, ( long int )pToSteal->weight() );
bool caught = false;
if ( success )
{
socket->sysMessage( tr( "You successfully steal %1." ).arg( pToSteal->getName() ) );
P_ITEM pPack = pChar->getBackpack();
pPack->addItem( pToSteal );
// Update item onyl if still existent
if ( !pToSteal->free )
pToSteal->update();
caught = pChar->skillValue( STEALING ) < rand() % 1001;
}
else
{
socket->sysMessage( tr( "You fail to steal the item." ) );
// 1 in 5 Chance if we failed
caught = RandomNum( 1, 5 ) == 1;
}
// Did we get caught?
if ( caught )
{
socket->sysMessage( tr( "You have been cought!" ) );
// Human non red NPCs need special handling
if ( pVictim->objectType() == enNPC && pVictim->isInnocent() && pVictim->isHuman() )
{
P_NPC pn = dynamic_cast<P_NPC>( pVictim );
pVictim->talk( tr( "Guards! A thief is amoung us!" ), 0xFFFF, 0x09 );
if ( pVictim->region() && pVictim->region()->isGuarded() )
pn->callGuards();
}
if ( pVictim->notoriety( pChar ) == 0x01 )
pChar->makeCriminal();
// Our Victim always notices it.
if ( pVictim->objectType() == enPlayer )
{
P_PLAYER pp = dynamic_cast<P_PLAYER>( pVictim );
if ( pp->socket() )
pp->socket()->showSpeech( pChar, tr( "You notice %1 trying to steal %2 from you." ).arg( pChar->name() ).arg( pToSteal->getName( true ) ) );
}
QString message = tr( "You notice %1 trying to steal %2 from %3." ).arg( pChar->name() ).arg( pItem->getName() ).arg( pVictim->name() );
for ( cUOSocket*mSock = Network::instance()->first(); mSock; mSock = Network::instance()->next() )
{
// Everyone within 7 Tiles notices us
if ( mSock != socket && mSock->player() && mSock->player()->serial() != pVictim->serial() && mSock->player()->inRange( pChar, 7 ) )
mSock->showSpeech( pChar, message );
}
}
}