本文整理汇总了C++中P_PLAYER::message方法的典型用法代码示例。如果您正苦于以下问题:C++ P_PLAYER::message方法的具体用法?C++ P_PLAYER::message怎么用?C++ P_PLAYER::message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类P_PLAYER
的用法示例。
在下文中一共展示了P_PLAYER::message方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onSpeechInput
// All ai controlled creatures can be controlled by a gm
// or by their owner if tamed
void AbstractAI::onSpeechInput( P_PLAYER pTalker, const QString &comm ) {
if (!pTalker->isGM() && (!m_npc->isTamed() || m_npc->owner() != pTalker)) {
return;
}
// too far away to hear us
if (pTalker->dist(m_npc) > 7) {
return;
}
if (comm.contains(" FOLLOW")) {
if (comm.contains(" ME")) {
m_npc->setWanderFollowTarget(pTalker);
m_npc->setWanderType(enFollowTarget);
m_npc->bark(cBaseChar::Bark_Attacking);
} else {
pTalker->socket()->attachTarget(new cFollowTarget(m_npc));
}
} else if ((comm.contains(" KILL")) || (comm.contains(" ATTACK"))) {
if (m_npc->inGuardedArea()) {
pTalker->message(tr("You can't have pets attack in town!"));
}
} else if ((comm.contains(" FETCH")) || (comm.contains(" GET"))) {
//pPlayer->setGuarded(false);
// >> LEGACY
//addx[s]=pPet->serial();
//target(s, 0, 1, 0, 124, "Click on the object to fetch.");
} else if (comm.contains(" COME")) {
m_npc->setWanderDestination(pTalker->pos());
m_npc->setWanderType(enDestination);
m_npc->bark(cBaseChar::Bark_Attacking);
} else if (comm.contains(" GUARD")) {
} else if ((comm.contains(" STOP")) || (comm.contains(" STAY"))) {
m_npc->fight(0);
m_npc->setWanderType( enHalt );
m_npc->bark(cBaseChar::Bark_Attacking);
} else if (comm.contains(" TRANSFER")) {
} else if (comm.contains(" RELEASE")) {
// Has it been summoned ? Let's dispel it
if (m_npc->summoned()) {
m_npc->setSummonTime(uiCurrentTime);
}
m_npc->setWanderType(enFreely);
m_npc->setOwner(0);
m_npc->setTamed(false);
m_npc->bark(cBaseChar::Bark_Attacking);
if (SrvParams->tamedDisappear()) {
m_npc->soundEffect(0x01Fe);
cCharStuff::DeleteChar(m_npc);
}
}
}
示例2: commandWhere
void commandWhere( cUOSocket *socket, const QString &command, QStringList &args ) throw()
{
Q_UNUSED(args);
Q_UNUSED(command);
P_PLAYER pChar = socket->player();
if( !pChar )
return;
cTerritory *mRegion = AllTerritories::instance()->region( pChar->pos().x, pChar->pos().y, pChar->pos().map );
QString message = tr( "You are" );
if( mRegion )
message.append( " " + tr( "in %1" ).arg( mRegion->name() ) );
message.append( " " + tr( "at %1,%2,%3 on map %4" ).arg( pChar->pos().x ).arg( pChar->pos().y ).arg( pChar->pos().z ).arg( pChar->pos().map ) );
pChar->message( message );
}
示例3: onSpeechInput
// All ai controlled creatures can be controlled by a gm
// or by their owner if tamed
void AbstractAI::onSpeechInput( P_PLAYER pTalker, const QString& comm )
{
if ( !pTalker->isGM() && ( !m_npc->isTamed() || m_npc->owner() != pTalker ) )
{
return;
}
// too far away to hear us
if ( pTalker->dist( m_npc ) > 7 )
{
return;
}
if ( comm.contains( " FOLLOW" ) )
{
if ( comm.contains( " ME" ) )
{
m_npc->setWanderFollowTarget( pTalker );
m_npc->setWanderType( enFollowTarget );
m_npc->bark( cBaseChar::Bark_Attacking );
}
else
{
pTalker->socket()->attachTarget( new cFollowTarget( m_npc ) );
}
}
else if ( ( comm.contains( " KILL" ) ) || ( comm.contains( " ATTACK" ) ) )
{
if ( m_npc->inGuardedArea() )
{
pTalker->message( tr( "You can't have pets attack in town!" ) );
}
}
else if ( ( comm.contains( " FETCH" ) ) || ( comm.contains( " GET" ) ) )
{
//#pragma note( Implement me )
pTalker->message( tr( "Sorry, not implemented yet :(" ) );
}
else if ( comm.contains( " COME" ) )
{
m_npc->setWanderDestination( pTalker->pos() );
m_npc->setWanderType( enDestination );
m_npc->bark( cBaseChar::Bark_Attacking );
}
else if ( comm.contains( " GUARD" ) )
{
}
else if ( ( comm.contains( " STOP" ) ) || ( comm.contains( " STAY" ) ) )
{
m_npc->fight( 0 );
m_npc->setWanderType( enHalt );
m_npc->bark( cBaseChar::Bark_Attacking );
}
else if ( comm.contains( " TRANSFER" ) )
{
}
else if ( comm.contains( " RELEASE" ) )
{
// Has it been summoned ? Let's dispel it
if ( m_npc->summoned() )
{
m_npc->setSummonTime( Server::instance()->time() );
}
m_npc->setWanderType( enFreely );
m_npc->setOwner( 0 );
m_npc->setTamed( false );
m_npc->bark( cBaseChar::Bark_Attacking );
if ( Config::instance()->tamedDisappear() )
{
m_npc->soundEffect( 0x01Fe );
m_npc->remove();
}
}
}
示例4: PetCommand
bool PetCommand( cUOSocket *socket, P_PLAYER pPlayer, P_NPC pPet, const QString& comm )
{
if( pPet->owner() != pPlayer && !pPlayer->isGM() )
return false;
// player vendor
/* if( pPet->npcaitype() == 17 )
return false;*/
// too far away to hear us
if( pPlayer->dist( pPet ) > 7 )
return false;
QString petname = pPet->name();
bool bAllCommand = false;
if( !comm.contains( petname, false ) )
if( comm.contains( "ALL", false ) )
bAllCommand = true;
else
return false;
bool bReturn = false;
if( comm.contains( " FOLLOW" ) )
{
if( comm.contains( " ME" ) )
{
#pragma note( "TODO: implement state change here" )
// pPet->setWanderFollowTarget( pPlayer->serial() );
// pPet->setWanderType( enFollowTarget );
playmonstersound( pPet, pPet->bodyID(), SND_STARTATTACK );
}
else
{
// LEGACY: target( s, 0, 1, 0, 117, "Click on the target to follow." );
}
bReturn = true;
}
else if( ( comm.contains( " KILL" ) ) || ( comm.contains( " ATTACK" ) ) )
{
if( pPet->inGuardedArea() ) // Ripper..No pet attacking in town.
{
pPlayer->message( tr( "You can't have pets attack in town!" ) );
return false;
}
//pPlayer->setGuarded( false );
// >> LEGACY
//addx[s]=pPet->serial();
//target(s, 0, 1, 0, 118, "Select the target to attack.");//AntiChrist
bReturn = true;
}
else if( ( comm.contains( " FETCH" ) ) || ( comm.contains( " GET" ) ) )
{
//pPlayer->setGuarded(false);
// >> LEGACY
//addx[s]=pPet->serial();
//target(s, 0, 1, 0, 124, "Click on the object to fetch.");
bReturn = true;
}
else if( comm.contains( " COME" ) )
{
//pPlayer->setGuarded( false );
#pragma note( "TODO: implement state change here" )
// pPet->setWanderFollowTarget( pPlayer->serial() );
// pPet->setWanderType( enFollowTarget );
pPet->setNextMoveTime();
pPlayer->message( tr( "Your pet begins following you." ) );
bReturn = true;
}
else if( comm.contains( " GUARD" ) )
{
// LEGACY
/*addx[s] = pPet->serial(); // the pet's serial
addy[s] = 0;
if( comm.find( " ME" ) != string::npos )
addy[s]=1; // indicates we already know whom to guard (for future use)
// for now they still must click on themselves (Duke)
target(s, 0, 1, 0, 120, "Click on the char to guard.");*/
bReturn = true;
}
else if( ( comm.contains( " STOP" ) ) || ( comm.contains(" STAY") ) )
{
//pPlayer->setGuarded( false );
#pragma note( "TODO: implement state change here" )
// pPet->setWanderFollowTarget( INVALID_SERIAL );
pPet->setCombatTarget( INVALID_SERIAL );
if (pPet->isAtWar())
pPet->toggleCombat();
pPet->setWanderType( enHalt );
bReturn = true;
}
else if( comm.contains( " TRANSFER" ) )
{
//.........这里部分代码省略.........
示例5: SkillUse
void cSkills::SkillUse( cUOSocket* socket, Q_UINT16 id ) // Skill is clicked on the skill list
{
P_PLAYER pChar = socket->player();
// No Char no Skill use
if ( !pChar )
return;
/* TODO: reimplementation of jail system
if( pChar->cell() > 0 )
{
socket->sysMessage( tr( "You are in jail and cant use skills here!" ) );
return;
}
*/
if ( pChar->isDead() )
{
socket->sysMessage( tr( "You cannot do that as a ghost." ) );
return;
}
if ( id != STEALTH )
pChar->unhide(); // Don't unhide if we're trying to stealth
pChar->disturbMed(); // Disturb meditation if we're using a skill
if ( pChar->isCasting() )
{
socket->sysMessage( tr( "You can't do that while you are casting." ) );
return;
}
if ( pChar->skillDelay() > Server::instance()->time() && !pChar->isGM() )
{
socket->sysMessage( tr( "You must wait a few moments before using another skill." ) );
return;
}
if ( pChar->onSkillUse( id ) )
return;
cTargetRequest* targetRequest = NULL;
QString message;
switch ( id )
{
case MEDITATION:
Skills::instance()->Meditation( socket );
break;
default:
socket->sysMessage( tr( "That skill has not been implemented yet." ) );
return;
}
if ( targetRequest )
socket->attachTarget( targetRequest );
if ( !message.isEmpty() )
pChar->message( message );
pChar->setSkillDelay( Server::instance()->time() + Config::instance()->skillDelay() * MY_CLOCKS_PER_SEC );
}
示例6: castSpell
void cNewMagic::castSpell( P_PLAYER pMage, UINT8 spell )
{
P_PLAYER pp = dynamic_cast<P_PLAYER>(pMage);
if( !pp || !pp->socket() )
return;
stNewSpell *sInfo = findSpell( spell );
if( !sInfo )
{
pp->socket()->sysMessage( tr( "This spell is either not implemented or invalid" ) );
return;
}
// Check if we can cast this spell
if( !hasSpell( pMage, spell ) )
{
pp->socket()->sysMessage( tr( "You don't know this spell." ) );
return;
}
// Check for required mana and required reagents, if not present: cancel casting
if( !checkMana( pMage, spell ) )
{
pp->message( tr( "You don't have enough mana to cast this spell." ) );
return;
}
if( !pp->isGM() && !checkReagents( pMage, spell ) )
return;
if( pMage->isCasting() )
disturb( pMage, true );
// We start casting here
pMage->setCasting( true );
// We get frozen here too
pMage->setFrozen( true );
// Say the mantra
// Type 0x0A : Spell
pMage->talk( sInfo->mantra, pMage->saycolor() );
// This is a very interesting move of OSI
// They send all action-packets the character has to perform in a row.
// But they use the action 0xE9 instead of 0x10, maybe it's a bitmask
// of 0xD9 but i am unsure.
// This will repeat the animation until
// We are done casting or until we are being
// disturbed.
//pMage->startRepeatedAction( sInfo->action, sInfo->actiondelay ); // Repeat every 1250 ms
// I *do* know that this is a drawback but for now a single animation is exactly what we need.
pMage->action( sInfo->action );
// Now we have to do the following:
// We show the target cursor after a given amount of time (set in the scripts)
// So what we are adding here is cEndCasting() supplying the Serial of our Mage
// And the ID of our Spell.
TempEffects::instance()->insert( new cEndCasting( pMage, spell, CT_BOOK, sInfo->delay ) );
}
示例7: checkReagents
/*!
Just like useReagents this function is checking
for required reagents on a characater to cast a
spell. But unlike useReagents it wont really
consume the reagents but just return false if
the required reagents are not present.
*/
bool cNewMagic::checkReagents( P_CHAR pMage, UINT8 spell )
{
// Check for each reagent.
// So we dont need to loop trough all items over and over again we'll use ONE loop (will be a bit less clean)
P_ITEM pPack = pMage->getBackpack();
stNewSpell *sInfo = findSpell( spell );
UINT8 ginseng = sInfo->reagents.ginseng;
UINT8 bloodmoss = sInfo->reagents.bloodmoss;
UINT8 mandrake = sInfo->reagents.mandrake;
UINT8 blackpearl = sInfo->reagents.blackpearl;
UINT8 spidersilk = sInfo->reagents.spidersilk;
UINT8 garlic = sInfo->reagents.garlic;
UINT8 nightshade = sInfo->reagents.nightshade;
UINT8 sulfurash = sInfo->reagents.sulfurash;
QPtrList< cItem > content = pPack->getContainment();
for( P_ITEM pItem = content.first(); pItem; pItem = content.next() )
{
checkReagent( blackpearl, 0xF7A )
else checkReagent( bloodmoss, 0xF7B )
else checkReagent( garlic, 0xF84 )
else checkReagent( ginseng, 0xF85 )
else checkReagent( mandrake, 0xF86 )
else checkReagent( nightshade, 0xF88 )
else checkReagent( sulfurash, 0xF8C )
else checkReagent( spidersilk, 0xF8D )
}
QStringList missing;
if( ginseng > 0 )
missing.append( tr( "Ginseng" ) );
if( bloodmoss > 0 )
missing.append( tr( "Bloodmoss" ) );
if( mandrake > 0 )
missing.append( tr( "Mandrake" ) );
if( blackpearl > 0 )
missing.append( tr( "Black Pearls" ) );
if( spidersilk > 0 )
missing.append( tr( "Spider's Silk" ) );
if( garlic > 0 )
missing.append( tr( "Garlic" ) );
if( nightshade > 0 )
missing.append( tr( "Nightshade" ) );
if( sulfurash > 0 )
missing.append( tr( "Sulfurous Ash" ) );
bool enoughReagents = true;
if( missing.count() > 0 )
{
if( pMage->objectType() == enPlayer )
{
P_PLAYER pp = dynamic_cast<P_PLAYER>(pMage);
if( pp->socket() )
{
pp->message( tr( "You don't have enough reagents." ) );
pp->socket()->sysMessage( tr( "You lack the following reagents: %1" ).arg( missing.join( ", ") ) );
}
}
enoughReagents = false;
}
return enoughReagents;
}
示例8: SkillUse
void cSkills::SkillUse( cUOSocket* socket, quint16 id ) // Skill is clicked on the skill list
{
P_PLAYER pChar = socket->player();
// No Char no Skill use
if ( !pChar )
return;
if ( pChar->isJailed() ) {
socket->sysMessage( tr("You cannot use skills while you are in jail.") );
return;
}
if ( pChar->isDead() )
{
socket->clilocMessage( 1019048 ); // I am dead and cannot do that.
return;
}
/*
if ( id != STEALTH )
pChar->unhide(); // Don't unhide if we're trying to stealth
*/
pChar->disturbMed(); // Disturb meditation if we're using a skill
if ( pChar->isCasting() )
{
socket->sysMessage( 1061131 ); // You cannot do that while casting a spell.
return;
}
if ( pChar->skillDelay() > Server::instance()->time() && !pChar->isGM() )
{
socket->sysMessage( 500118 ); // You must wait a few moments to use another skill.
return;
}
if ( pChar->onSkillUse( id ) )
return;
cTargetRequest* targetRequest = NULL;
QString message;
switch ( id )
{
case MEDITATION:
Skills::instance()->Meditation( socket );
break;
default:
socket->sysMessage( tr( "That skill has not been implemented yet." ) );
return;
}
if ( targetRequest )
socket->attachTarget( targetRequest );
if ( !message.isEmpty() )
pChar->message( message );
pChar->setSkillDelay( Server::instance()->time() + Config::instance()->skillDelay() * MY_CLOCKS_PER_SEC );
}