当前位置: 首页>>代码示例>>C++>>正文


C++ P_PLAYER类代码示例

本文整理汇总了C++中P_PLAYER的典型用法代码示例。如果您正苦于以下问题:C++ P_PLAYER类的具体用法?C++ P_PLAYER怎么用?C++ P_PLAYER使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了P_PLAYER类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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 );
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:36,代码来源:dragdrop.cpp

示例2: wpMulti_sendcustomhouse

/*!
	Sends custom house to client
*/
static PyObject* wpMulti_sendcustomhouse( wpMulti* self, PyObject* args )
{
	Q_UNUSED(args);	
	if( !self->pMulti || self->pMulti->free || !self->pMulti->ishouse() )
		return PyFalse;
	
	if( !checkArgChar( 0 ) )
	{
		PyErr_BadArgument();
		return NULL;
	}
	P_PLAYER player = dynamic_cast<P_PLAYER>( getArgChar( 0 ) );
	if ( !player )
		return PyFalse;

//	self->pMulti->sendCH( player->socket() );
	cUOTxAskCustomHouse askch;

	askch.setSerial( self->pMulti->serial() );
	askch.setId( self->pMulti->revision() );

	player->socket()->send( &askch );

	return PyTrue;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:28,代码来源:multi.cpp

示例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);
	}
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:35,代码来源:dragdrop.cpp

示例4: onSpeechInput

void Human_Stablemaster::onSpeechInput( P_PLAYER pTalker, const QString& message )
{
	if ( !pTalker->socket() )
		return;

	if ( m_npc->inRange( pTalker, 4 ) && ( VendorChkName( m_npc, message ) || message.contains( tr( "STABLEMASTER" ) ) ) )
	{
		if ( message.contains( tr( " STABLE" ) ) )
		{
			m_npc->talk( tr( "Which pet do you want me to stable?" ) );
			pTalker->socket()->attachTarget( new cStableTarget( m_npc ) );
		}
		else if ( message.contains( tr( " RELEASE" ) ) )
		{
			int gold = pTalker->countBankGold() + pTalker->countGold();
			P_ITEM pPack = m_npc->getBankbox();
			
			cItem::ContainerContent stableitems;
			if ( pPack )
			{
				cItem::ContainerContent content = pPack->content();
				cItem::ContainerContent::const_iterator it( content.begin() );
				while ( it != content.end() )
				{
					if ( !( *it )->hasTag( "player" ) || !( *it )->hasTag( "pet" ) )
						continue;

					if ( ( *it ) && ( uint )( *it )->getTag( "player" ).toInt() == pTalker->serial() )
						stableitems.push_back( ( *it ) );
					++it;
				}
			}

			if ( !stableitems.empty() )
			{
				cItem::ContainerContent::const_iterator it( stableitems.begin() );
				while ( it != stableitems.end() )
				{
					if ( ( *it ) )
					{
						P_NPC pPet = dynamic_cast<P_NPC>( World::instance()->findChar( ( *it )->getTag( "pet" ).toInt() ) );
						if ( pPet )
						{
							pPet->free = false;
							// we need this for db saves
							pPet->setStablemasterSerial( INVALID_SERIAL );
							pPet->moveTo( m_npc->pos() );
							pPet->resend();
						}
						( *it )->remove();
					}
					++it;
				}

				pPack->update();
				m_npc->talk( tr( "Here's your pet back!" ) );
			}
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:60,代码来源:ai_humans.cpp

示例5: handleTeleporters

void cMovement::handleTeleporters( P_CHAR pc, const Coord& oldpos )
{
	cTerritory* territory = pc->region();

	if ( !territory )
		Territories::instance()->check( pc );

	if ( territory && pc->pos() != oldpos )
	{
		if ( territory->haveTeleporters() )
		{
			Coord destination = pc->pos();
			if ( territory->findTeleporterSpot( destination ) )
			{
				bool quick = pc->pos().map != destination.map;
				pc->removeFromView( false );
				pc->moveTo( destination );
				pc->resend( false );
				P_PLAYER player = dynamic_cast<P_PLAYER>( pc );
				if ( player && player->socket() )
				{
					player->socket()->resendPlayer( quick );
					player->socket()->resendWorld();
				}
			}
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:28,代码来源:walking.cpp

示例6: postCondition

float Animal_Wild_Flee::postCondition()
{
	/*
	 * Fleeing from an approaching player has the following postconditions:
	 * - There is no character in flight range.
	 * - There is an character attacking us.
	 * - Our owner has come in range.
	 *
	 */

	if ( m_npc->attackTarget() )
		return 1.0f;

	bool found = false;
	MapCharsIterator ri = MapObjects::instance()->listCharsInCircle( m_npc->pos(), Config::instance()->animalWildFleeRange() );
	for ( P_CHAR pChar = ri.first(); pChar; pChar = ri.next() )
	{
		P_PLAYER pPlayer = dynamic_cast<P_PLAYER>( pChar );
		if ( pPlayer && !pPlayer->free && !pPlayer->isGMorCounselor() && !pPlayer->isHidden() && !pPlayer->isInvisible() )
			found = true;

		if ( pPlayer && m_npc->owner() == pPlayer )
			return 1.0f;
	}

	if ( found )
		return 0.0f;

	return 1.0f;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:30,代码来源:ai_animals.cpp

示例7: playerRegisterAfterLoading

static void playerRegisterAfterLoading( P_PLAYER pc )
{
	if ( pc->account() == 0 )
	{
		// We need to remove the equipment here.
		cBaseChar::ItemContainer container( pc->content() );
		cBaseChar::ItemContainer::const_iterator it( container.begin() );
		cBaseChar::ItemContainer::const_iterator end( container.end() );
		for ( ; it != end; ++it )
		{
			P_ITEM pItem = *it;
			if ( !pItem )
				continue;

			pItem->remove();
		}
		pc->del();
		return;
	}
	/*	else
		{
			pc->setBody(0x0190);
			Console::instance()->send("player: %s with bugged body-value detected, restored to male shape\n",pc->name().latin1());
		}*/
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:25,代码来源:player.cpp

示例8:

cParty::~cParty()
{
	P_PLAYER member;
	for ( member = members_.first(); member; member = members_.next() )
	{
		member->setParty( 0 );

		if ( member->socket() )
		{
			cUOTxPartyRemoveMember updateparty;
			updateparty.setSerial( member->serial() );
			member->socket()->send( &updateparty );
			member->socket()->clilocMessage( 1005449 );
		}
	}

	for ( member = canidates_.first(); member; member = canidates_.next() )
	{
		if ( member->socket() )
		{
			cUOTxPartyRemoveMember updateparty;
			updateparty.setSerial( member->serial() );
			member->socket()->send( &updateparty );
			member->socket()->clilocMessage( 1005449 );
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:27,代码来源:party.cpp

示例9: ri

float Animal_Wild_Flee::postCondition()
{
    /*
     * Fleeing from an approaching player has the following postconditions:
     * - There is no character in flight range.
     * - There is an character attacking us.
     * - Our owner has come in range.
     *
     */

    if( m_npc->attackTarget() )
        return 1.0f;

    RegionIterator4Chars ri( m_npc->pos(), SrvParams->animalWildFleeRange() );
    bool found = false;
    for(ri.Begin(); !ri.atEnd(); ri++)
    {
        P_PLAYER pPlayer = dynamic_cast<P_PLAYER>(ri.GetData());
        if( pPlayer && !pPlayer->free && !pPlayer->isGMorCounselor() && !pPlayer->isHidden() && !pPlayer->isInvisible() )
            found = true;

        if( pPlayer && m_npc->owner() == pPlayer )
            return 1.0f;
    }

    if( found )
        return 0.0f;

    return 1.0f;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:30,代码来源:ai_animals.cpp

示例10: findSpell

void cNewMagic::execSpell( P_CHAR pMage, UINT8 spell, UINT8 type, cUORxTarget* target )
{
	stNewSpell *sInfo = findSpell( spell );
	P_PLAYER pp = dynamic_cast<P_PLAYER>(pMage);

	if( ( ( pp || !pp->isGM() ) && !checkReagents( pMage, spell ) ) || !useMana( pMage, spell ) )
	{
		pMage->setCasting( false );
		return;
	}
	if( !pp || !pp->isGM() )
		useReagents( pMage, spell );
	
	if( !checkSkill( pMage, spell, false ) )
	{
		disturb( pMage, true, -1 );
		return;
	}
	
	// Call the Spell Effect for this Spell
	if( sInfo->script )
		sInfo->script->onSpellSuccess( pMage, spell, type, target );
	
	// End Casting
	pMage->setCasting( false );
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:26,代码来源:newmagic.cpp

示例11: process

// Main Command processing function
void cCommands::process( cUOSocket *socket, const QString &command )
{
	if( !socket->player() )
		return;

	P_PLAYER pChar = socket->player();
	QStringList pArgs = QStringList::split( " ", command, true );

	// No Command? No Processing
	if( pArgs.isEmpty() )
		return;

	QString pCommand = pArgs[0].upper(); // First element should be the command

	// Remove it from the argument list
	pArgs.erase( pArgs.begin() );

	// Check if the priviledges are ok
	if( !pChar->account()->authorized("command", pCommand.latin1() ))
	{
		socket->sysMessage( tr( "Access to command '%1' was denied" ).arg( pCommand.lower() ) );
		socket->log( QString("Access to command '%1' was denied\n").arg(pCommand.lower()) );
		return;
	}

	// Dispatch the command
	if ( dispatch( socket, pCommand, pArgs ) )
		socket->log( QString( "Used command '%1'.\n" ).arg( command ) );
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:30,代码来源:commands.cpp

示例12: handleItems

/*!
	Sends items which came in range and handles collisions with teleporters
	or damaging items.
*/
void handleItems( P_CHAR pChar, const Coord& oldpos )
{
	P_PLAYER player = dynamic_cast<P_PLAYER>( pChar );

	MapItemsIterator iter = MapObjects::instance()->listItemsInCircle( pChar->pos(), VISRANGE );
	for ( P_ITEM pItem = iter.first(); pItem; pItem = iter.next() )
	{
		// Check for item collisions here.
		if ( pChar->pos().x == pItem->pos().x && pChar->pos().y == pItem->pos().y )
		{
			if ( pItem->pos().z >= pChar->pos().z - 15 && pItem->pos().z <= pChar->pos().z + 15 )
			{
				if ( handleItemCollision( pChar, pItem ) )
				{
					break;
				}
			}
		}

		// If we are a connected player then send new items
		if ( player && player->socket() )
		{
			UI32 oldDist = oldpos.distance( pItem->pos() );
			if ( oldDist >= player->visualRange() )
			{
				// was out of range before and now is in range
				pItem->update( player->socket() );
			}
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:35,代码来源:walking.cpp

示例13: preCondition

float Animal_Wild_Flee::preCondition()
{
	return 0.0f;

	/*
	 * Fleeing from an approaching player has the following preconditions:
	 * - There is a player within flight range.
	 * - There is no character attacking us.
	 * - Our owner is not in range.
	 *
	 */

	if ( m_npc->attackTarget() )
		return 0.0f;

	MapCharsIterator ri = MapObjects::instance()->listCharsInCircle( m_npc->pos(), Config::instance()->animalWildFleeRange() );
	for ( P_CHAR pChar = ri.first(); pChar; pChar = ri.next() )
	{
		P_PLAYER pPlayer = dynamic_cast<P_PLAYER>( pChar );
		if ( pPlayer && !pPlayer->free && !pPlayer->isGMorCounselor() && !pPlayer->isHidden() && !pPlayer->isInvisible() )
		{
			pFleeFromSer = pPlayer->serial();
		}
		if ( pPlayer && m_npc->owner() == pPlayer )
			return 0.0f;
	}

	if ( pFleeFromSer != INVALID_SERIAL )
		return 1.0f;

	return 0.0f;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:32,代码来源:ai_animals.cpp

示例14: QuestionSpeech

// All this Stuff should be scripted
bool QuestionSpeech( cUOSocket *socket, P_PLAYER pPlayer, P_NPC pChar, const QString& comm )
{
	if( !pChar->isHuman() || pPlayer->dist( pChar ) > 3 )
		return false;
	
	// Tell the questioner our name
	if( comm.contains( "NAME" ) )
	{
		pChar->talk( tr( "Hello, my name is %1." ).arg( pChar->name() ) );
		return true;
	}
	
    // say time and the npChar gives the time.
	if( comm.contains( "TIME" ) )
	{
		pChar->talk( tr( "It is now %1" ).arg( uoTime.toString() ) );
		return true;
	}	

	if( comm.contains( "LOCATION" ) )
	{
		cTerritory* Region = pPlayer->region();
		
		if( Region )
			pChar->talk( tr( "You are in %1" ).arg( Region->name() ) );
		else 
			pChar->talk( tr( "You are in the wilderness" ) );
				
		return true;
	}

	// We couldn't handle the speech
	return false;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:35,代码来源:speech.cpp

示例15: Dispel

	/*!
		If source is 0 and silent is true, nothing happens. Otherwise
		the canidate is removed from the party without notification.
	*/
	void Dispel( P_CHAR /*source*/, bool silent )
	{
		P_PLAYER player = dynamic_cast<P_PLAYER>( World::instance()->findChar( destSer ) );
		P_PLAYER leader = dynamic_cast<P_PLAYER>( World::instance()->findChar( this->leader ) );

		if ( leader && leader->party() && !silent )
			leader->party()->removeMember( player );
	}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:12,代码来源:party.cpp


注:本文中的P_PLAYER类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。