本文整理汇总了C++中P_PLAYER::name方法的典型用法代码示例。如果您正苦于以下问题:C++ P_PLAYER::name方法的具体用法?C++ P_PLAYER::name怎么用?C++ P_PLAYER::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_PLAYER
的用法示例。
在下文中一共展示了P_PLAYER::name方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Snooping
void cSkills::Snooping( P_PLAYER player, P_ITEM container )
{
cUOSocket* socket = player->socket();
if ( !socket )
return;
P_CHAR pc_owner = container->getOutmostChar();
P_PLAYER pp_owner = dynamic_cast<P_PLAYER>( pc_owner );
if ( pp_owner && pp_owner->isGMorCounselor() )
{
pp_owner->message( tr( "%1 is trying to snoop in your pack" ).arg( player->name() ) );
socket->sysMessage( tr( "You can't peek into that container or you'll be jailed." ) );
return;
}
else if ( player->checkSkill( SNOOPING, 0, 1000 ) )
{
socket->sendContainer( container );
socket->sysMessage( tr( "You successfully peek into that container." ) );
}
else
{
socket->sysMessage( tr( "You failed to peek into that container." ) );
if ( !pp_owner ) // is NPC ?
pc_owner->talk( tr( "Art thou attempting to disturb my privacy?" ) );
else
pp_owner->message( tr( "You notice %1 trying to peek into your pack!" ).arg( player->name() ) );
}
// SetTimerSec(player->objectdelay(), Config::instance()->objectDelay()+Config::instance()->snoopdelay());
player->setObjectDelay( Server::instance()->time() + ( Config::instance()->objectDelay() + Config::instance()->snoopdelay() ) * MY_CLOCKS_PER_SEC );
}
示例2: addMember
void cParty::addMember( P_PLAYER player, bool update )
{
// Remove him from his old party
if ( player->party() )
player->party()->removeMember( player );
else
removeCanidate( player );
if ( update )
send( 1008094, QString::null, player->name(), true );
members_.append( player );
player->setParty( this );
// Send the new memberlist to all members
if ( update )
{
this->update();
if ( player != leader_ && player->socket() )
player->socket()->clilocMessage( 1005445 );
}
}
示例3: talking
void cSpeech::talking( P_PLAYER pChar, const QString &lang, const QString &speech, QValueVector< UINT16 > &keywords, UINT16 color, UINT16 font, UINT8 type ) // PC speech
{
// handle things like renaming or describing an item
if( !pChar->socket() )
return;
cUOSocket *socket = pChar->socket();
if( InputSpeech( socket, pChar, speech ) )
return;
// not allowed to talk
if( pChar->isMuted() )
{
socket->sysMessage( tr( "You re squelched and cannot talk" ) );
return;
}
pChar->unhide();
// Check for Bogus Color
if( !isNormalColor( color ) )
color = 0x2;
if( type == 0 || type == 2)
pChar->setSaycolor( color );
if( SrvParams->speechLog() )
{
QFile lFile( "speech.log" );
if( lFile.open( IO_Append ) )
{
QString logMessage( "[%1] %2: %3 [%4, 0x%5]" );
logMessage = logMessage.arg( QDateTime::currentDateTime().toString() ).arg( pChar->name() ).arg( speech ).arg( pChar->account()->login() ).arg( pChar->serial(), 8, 16 );
lFile.writeBlock( logMessage.latin1(), logMessage.length() );
lFile.close();
}
}
if( pChar->onTalk( type, color, font, speech, lang ) )
return;
if( ( type == 0x09 ) && ( pChar->mayBroadcast() ) )
{
pChar->talk( speech, color, type );
return;
}
pChar->talk( speech, color, type );
QString speechUpr = speech.upper();
if( response( socket, pChar, speech, keywords ) )
return; // Vendor responded already
// 0x0007 -> Speech-id for "Guards"
for( QValueVector< UINT16 >::const_iterator iter = keywords.begin(); iter != keywords.end(); ++iter )
{
UINT16 keyword = *iter;
if( keyword == 0x07 )
pChar->callGuards();
}
// well,i had a strange problem with duplicate speech input
// its quite easy to understand....
// the former loop searched for the tiller man and when it
// was found, the speechInput method of that boat was called.
// in this method the tiller had been removed from the mapregion
// and appended to the end of the cell vector... hence, the
// tiller was found twice...
// therefore we produce a QPtrList of cBoat* pointers and
// then go through it for applying speech --- sereg
RegionIterator4Items rj( pChar->pos() );
QPtrList< cBoat > pboats;
for( rj.Begin(); !rj.atEnd(); rj++ )
{
P_ITEM pi = rj.GetData();
if( !pi )
continue;
if( pi->type() == 117 && pi->tags().get( "tiller" ).toInt() == 1 )
{
cBoat* pBoat = dynamic_cast< cBoat* >(FindItemBySerial( pi->tags().get("boatserial").toInt() ));
if( pBoat )
pboats.append( pBoat );
}
}
QPtrListIterator< cBoat > pit( pboats );
while( pit.current() )
{
pit.current()->speechInput( socket, speechUpr );
++pit;
}
// this makes it so npcs do not respond to isDead people - HEALERS ??
if( pChar->isDead() )
return;
//.........这里部分代码省略.........
示例4: 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;
INT32 num = speech.toInt( &ok ); // Generally try to convert it
QString notification;
switch (pChar->inputMode())
{
// Pricing an item - PlayerVendors
case cPlayer::enPricing:
if (ok)
{
pItem->setPrice( num );
socket->sysMessage( tr( "This item's price has been set to %1." ).arg( num ) );
}
else
socket->sysMessage( tr( "You have to enter a numeric price" ) );
pChar->setInputMode(cPlayer::enDescription);
socket->sysMessage( tr( "Enter a description for this item." ) );
break;
// Describing an item
case cPlayer::enDescription:
pItem->setDescription( speech );
socket->sysMessage( tr( "This item is now described as %1." ).arg( speech ) );
pChar->setInputMode(cPlayer::enNone);
pChar->setInputItem(INVALID_SERIAL);
break;
// Renaming a rune
case cPlayer::enRenameRune:
pItem->setName( tr( "Rune to: %1" ).arg( speech ) );
socket->sysMessage( tr( "Rune renamed to: Rune to: %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;
// Paging a GM
case cPlayer::enPageGM:
{
cPage* pPage = new cPage( pChar->serial(), PT_GM, speech, pChar->pos() );
cPagesManager::getInstance()->push_back( pPage );
notification = tr( "GM Page from %1: %2" ).arg( pChar->name() ).arg( speech );
for ( cUOSocket *mSock = cNetwork::instance()->first(); mSock; mSock = cNetwork::instance()->next())
if( mSock->player() && mSock->player()->isGM() )
mSock->sysMessage( notification );
if( cNetwork::instance()->count() > 0 )
socket->sysMessage( tr( "Available Game Masters have been notified of your request." ) );
else
socket->sysMessage( tr( "There was no Game Master available, page queued." ) );
pChar->setInputMode(cPlayer::enNone);
}
break;
// Paging a Counselor
case cPlayer::enPageCouns:
{
cPage* pPage = new cPage( pChar->serial(), PT_COUNSELOR, speech, pChar->pos() );
cPagesManager::getInstance()->push_back( pPage );
notification = tr( "Counselor Page from %1: %2" ).arg( pChar->name() ).arg( speech );
for ( cUOSocket *mSock = cNetwork::instance()->first(); mSock; mSock = cNetwork::instance()->next())
if( mSock->player() && (socket->player()->isCounselor() || socket->player()->isGM()) )
mSock->sysMessage( notification );
if( cNetwork::instance()->count() > 0 )
socket->sysMessage( tr( "Available Counselors have been notified of your request." ) );
else
socket->sysMessage( tr( "There was no Counselor available, page queued." ) );
pChar->setInputMode(cPlayer::enNone);
}
//.........这里部分代码省略.........
示例5: handlePacket
void cParty::handlePacket( cUOSocket* socket, cUOPacket* packet )
{
unsigned char subcommand = ( *packet )[5];
QString message;
P_PLAYER leader = 0;
P_PLAYER player = socket->player();
switch ( subcommand )
{
// Add a member to the party
case 1:
socket->clilocMessage( 1005454 );
socket->attachTarget( new cPartyInvitation( player->serial() ) );
break;
// Remove member from party.
case 2:
if ( packet->size() == 10 )
{
P_PLAYER target = dynamic_cast<P_PLAYER>( World::instance()->findChar( packet->getInt( 6 ) ) );
if ( target && player->party() && target->party() )
{
if ( player->party() == target->party() && player->party()->leader() == player )
{
socket->log( LOG_TRACE, tr( "Removed '%1' from the party.\n" ).arg( target->account()->login() ) );
player->party()->removeMember( target );
}
else if ( target == player )
{
socket->log( LOG_TRACE, tr( "Left the party.\n" ).arg( player->account()->login() ) );
player->party()->removeMember( target );
}
}
}
break;
// Send a single party member a message
case 3:
if ( player->party() )
{
P_PLAYER target = dynamic_cast<P_PLAYER>( World::instance()->findChar( packet->getInt( 6 ) ) );
if ( target )
{
socket->log( LOG_TRACE, tr( "Told '%1' in party '%2'.\n" ).arg( target->account()->login() ).arg( message ) );
QString message = packet->getUnicodeString( 10, packet->size() - 10 );
player->party()->send( player, target, message );
}
}
break;
// Send the whole party a message
case 4:
if ( player->party() )
{
QString message = packet->getUnicodeString( 6, packet->size() - 6 );
socket->log( LOG_TRACE, tr( "Told the whole party: '%1'.\n" ).arg( message ) );
player->party()->send( player, message );
}
break;
// Allow or Disallow my party from looting my corpse
case 6:
if ( player->party() && packet->size() == 7 )
{
bool allowed = ( *packet )[6] != 0;
player->party()->setLootingAllowed( player, allowed );
socket->clilocMessage( allowed ? 1005447 : 1005448 );
}
break;
// Accept party invitation
case 8:
Timers::instance()->dispel( player, 0, "cancelpartyinvitation", true, false );
leader = dynamic_cast<P_PLAYER>( World::instance()->findChar( packet->getInt( 6 ) ) );
if ( leader && leader->party() && leader->party()->canidates().contains( player ) )
{
leader->party()->addMember( player );
socket->log( tr( "Accepted party invitation from '%1'.\n" ).arg( leader->account()->login() ) );
}
break;
// Decline party invitation
case 9:
Timers::instance()->dispel( player, 0, "cancelpartyinvitation", true, false );
leader = dynamic_cast<P_PLAYER>( World::instance()->findChar( packet->getInt( 6 ) ) );
if ( leader && leader->party() && leader->party()->canidates().contains( player ) )
{
leader->socket()->clilocMessageAffix( 1008091, 0, player->name(), 0x3b2, 3, 0, false, true );
leader->party()->removeMember( player );
socket->clilocMessage( 1008092 );
socket->log( LOG_TRACE, tr( "Declined party invitation from '%1'.\n" ).arg( leader->account()->login() ) );
}
break;
default:
message.sprintf( "Receieved unknown party subcommand: 0x%02x", subcommand );
//.........这里部分代码省略.........
示例6: responsed
bool responsed( cUOSocket* socket, cUORxTarget* target )
{
if ( !isCharSerial( target->serial() ) )
{
socket->clilocMessage( 1005442 );
}
else
{
P_PLAYER leader = dynamic_cast<P_PLAYER>( World::instance()->findChar( this->player ) );
P_CHAR character = World::instance()->findChar( target->serial() );
P_NPC npc = dynamic_cast<P_NPC>( character );
P_PLAYER player = dynamic_cast<P_PLAYER>( character );
if ( !leader || ( leader->party() && leader->party()->leader() != leader ) )
{
socket->clilocMessage( 1005453 );
}
else if ( leader->party() && leader->party()->members().count() + leader->party()->canidates().count() >= 10 )
{
socket->clilocMessage( 1008095 );
// NPC targetted
}
else if ( npc )
{
if ( npc->isHuman() )
socket->clilocMessage( 1005443, 0, npc->saycolor(), 3, npc );
else
socket->clilocMessage( 1005444 );
}
else if ( leader == player )
{
socket->clilocMessage( 1005439 );
}
else if ( player && player->party() && player->party() == leader->party() )
{
socket->clilocMessage( 1005440 );
}
else if ( player && leader->party() && leader->party()->canidates().contains( player ) )
{
socket->clilocMessage( 1005440 );
}
else if ( player && player->party() )
{
socket->clilocMessage( 1005441 );
}
else if ( player && player->socket() )
{
if ( !leader->party() )
{
new cParty( leader );
leader->party()->update();
}
player->socket()->clilocMessageAffix( 1008089, 0, leader->name(), 0x3b2, 3, 0, false, true );
leader->party()->addCanidate( player );
socket->log( LOG_TRACE, tr( "Invited '%1' to join his party.\n" ).arg( player->account()->login() ) );
// Send a party invitation request
cUOTxPartyInvitation invitation;
invitation.setSerial( leader->serial() );
player->socket()->send( &invitation );
// Attach a tempeffect that'll cancel the invitation after ten seconds
Timers::instance()->insert( new cPartyCancelInvitation( leader->serial(), player->serial() ) );
}
}
return true;
}
示例7: RandomSteal
void cSkills::RandomSteal( cUOSocket* socket, SERIAL victim )
{
P_PLAYER pChar = socket->player();
P_CHAR pVictim = FindCharBySerial( victim );
if ( !pVictim || !pChar )
return;
if ( pVictim->serial() == pChar->serial() )
{
socket->sysMessage( tr( "Why don't you simply take it?" ) );
return;
}
/* if( pVictim->npcaitype() == 17 )
{
socket->sysMessage( tr( "You cannot steal from Playervendors." ) );
return;
}
*/
if ( pVictim->objectType() == enPlayer )
{
P_PLAYER pp = dynamic_cast<P_PLAYER>( pVictim );
if ( pp->isGMorCounselor() )
socket->sysMessage( tr( "You can't steal from game masters." ) );
return;
}
if ( !pChar->inRange( pVictim, 1 ) )
{
socket->sysMessage( tr( "You are too far away to steal from that person." ) );
return;
}
P_ITEM pBackpack = pVictim->getBackpack();
if ( !pBackpack )
{
socket->sysMessage( tr( "Bad luck, your victim doesn't have a backpack." ) );
return;
}
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
//.........这里部分代码省略.........
示例8: Snooping
void cSkills::Snooping( P_PLAYER player, P_ITEM container )
{
P_CHAR owner = container->getOutmostChar();
if ( !owner )
return; // Snooping into something thats not equipped?!
PyObject *args = Py_BuildValue( "(NNN)", owner->getPyObject(), container->getPyObject(), player->getPyObject() );
// Event prfen
if ( player->canHandleEvent( EVENT_SNOOPING ) )
{
if ( player->callEventHandler( EVENT_SNOOPING, args ) )
{
Py_DECREF( args );
return;
}
}
if ( owner->canHandleEvent( EVENT_SNOOPING ) )
{
if ( owner->callEventHandler( EVENT_SNOOPING, args ) )
{
Py_DECREF( args );
return;
}
}
Py_DECREF( args );
cUOSocket* socket = player->socket();
if ( !socket )
return;
P_CHAR pc_owner = container->getOutmostChar();
P_PLAYER pp_owner = dynamic_cast<P_PLAYER>( pc_owner );
if ( pp_owner && pp_owner->isGMorCounselor() )
{
pp_owner->message( tr( "%1 is trying to snoop in your pack" ).arg( player->name() ) );
socket->sysMessage( 500209 ); // You can not peek into the container.
return;
}
else if ( player->checkSkill( SNOOPING, 0, 1000 ) )
{
socket->sendContainer( container );
socket->sysMessage( tr( "You successfully peek into that container." ) );
}
else
{
socket->sysMessage( 500210 ); // You failed to peek into the container.
if ( !pp_owner ) // is NPC ?
{
if ( pc_owner )
{
pc_owner->talk( tr( "Art thou attempting to disturb my privacy?" ) );
}
}
else
{
pp_owner->message( tr( "You notice %1 trying to peek into your pack!" ).arg( player->name() ) );
}
}
// SetTimerSec(player->objectdelay(), Config::instance()->objectDelay()+Config::instance()->snoopdelay());
player->setObjectDelay( Server::instance()->time() + ( Config::instance()->objectDelay() + Config::instance()->snoopdelay() ) * MY_CLOCKS_PER_SEC );
}