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


C++ P_CHAR类代码示例

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


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

示例1: findBestTarget

void Monster_BladeSpirit::check()
{
	// Our current victim
	P_CHAR m_currentVictim = World::instance()->findChar( m_currentVictimSer );
	if ( !m_currentVictim )
	{
		m_currentVictimSer = INVALID_SERIAL;
	}

	if ( m_currentVictim && invalidTarget( m_npc, m_currentVictim ) ) {
		m_currentVictim = 0;
		m_currentVictimSer = INVALID_SERIAL;
		m_npc->fight( 0 );
	}

	if ( nextVictimCheck < Server::instance()->time() )
	{
		// Don't switch if we can hit it...
		if ( !m_currentVictim || m_currentVictim->dist( m_npc ) > 1 )
		{
			P_CHAR target = findBestTarget( m_npc );
			if ( target )
			{
				m_currentVictim = target;
				m_currentVictimSer = target->serial();
				m_npc->fight( target );
			}
		}

		nextVictimCheck = Server::instance()->time() + 1500;
	}

	AbstractAI::check();
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:34,代码来源:ai_bladespirit.cpp

示例2: spawnGuard

void cCombat::spawnGuard( P_CHAR pOffender, P_CHAR pCaller, const Coord& pos )
{
	if ( !pOffender || !pCaller )
		return;

	if ( pOffender->isDead() || pCaller->isDead() )
		return;

	cTerritory* pRegion = pCaller->region();

	if ( pRegion == NULL )
		return;

	if ( pRegion->isGuarded() && Config::instance()->guardsActive() )
	{
		QString guardsect = pRegion->getGuardSect();

		P_NPC pGuard = ( guardsect.isNull() ? NULL : cNPC::createFromScript( guardsect, pos ) );

		if ( !pGuard )
			return;

		// Send guard to surrounding Players
		pGuard->resend( false );
		pGuard->soundEffect( 0x1FE );
		pGuard->effect( 0x372A, 0x09, 0x06 );
		pGuard->fight( pOffender );
	}
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:29,代码来源:combat.cpp

示例3: Off

void cTmpEff::Off(P_CHAR pc)
{
	if (!pc)
		return;

	switch(this->num)
	{
	case 1:	pc->priv2 &= 0xFD;			break;
	case 2:	pc->fixedlight='\xFF';		break;
	case 3:	pc->chgDex(this->more1);	break;
	case 4:	pc->in+=this->more1;		break;
	case 5:	pc->st+=this->more1;		break;
	case 6:	pc->chgDex(-1 * this->more1);break;
	case 7:	pc->in-=this->more1;		break;
	case 8:	pc->st-=this->more1;		break;
	case 11:
		pc->st-=this->more1;
		pc->chgDex(-1 * this->more2);
		pc->in-=this->more3;
		break;
	case 12:
		pc->st+=this->more1;
		pc->chgDex(this->more2);
		pc->in+=this->more3;
		break;
	}
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:27,代码来源:TmpEff.cpp

示例4: item_bounce3

// Name:	item_bounce3
// Purpose:	holds some statements that were COPIED some 50 times
// Remarks:	temporary functions to revamp the 30 occurences of the 'bouncing bugfix'
// History:	init Duke, 10.8.2000 / bugfix for bonus stats, Xanathar, 05-aug-2001
static void item_bounce3(const P_ITEM pi)
{
	VALIDATEPI( pi );
	pi->setContSerial( pi->getContSerial(true) );
	pi->setPosition( pi->getOldPosition() );
	pi->layer=pi->oldlayer;

	P_CHAR pc = pointers::findCharBySerial( pi->getContSerial(true) );
	if(pc==NULL)
		return ;
	VALIDATEPC( pc );
	if ( pi->layer > 0 )
	{
		// Xanathar -- add BONUS STATS given by equipped special items
		pc->setStrength( pc->getStrength() + pi->st2, true );
		//pc->st += pi->st2;
		pc->dx += pi->dx2;
		pc->in += pi->in2;
		// Xanathar -- for poisoned items
		if (pi->poisoned)
		{
			pc->poison += pi->poisoned;
			if ( pc->poison < 0)
				pc->poison = 0;
		}
	}
}
开发者ID:nox-wizard,项目名称:noxwizard,代码行数:31,代码来源:dragdrop.cpp

示例5: reload

void cScriptManager::reload()
{
	cItemIterator iter_items;
	cCharIterator iter_chars;

	P_ITEM pItem;
	P_CHAR pChar;

	for ( pItem = iter_items.first(); pItem; pItem = iter_items.next() )
		pItem->freezeScriptChain();

	for ( pChar = iter_chars.first(); pChar; pChar = iter_chars.next() )
		pChar->freezeScriptChain();

	// First unload, then reload
	unload();

	// Stop + Restart Python
	//stopPython();
	//startPython( qApp->argc(), qApp->argv() );
	PythonEngine::instance()->unload();
	PythonEngine::instance()->load();

	load();

	for ( pItem = iter_items.first(); pItem; pItem = iter_items.next() )
		pItem->unfreezeScriptChain();

	for ( pChar = iter_chars.first(); pChar; pChar = iter_chars.next() )
		pChar->unfreezeScriptChain();

	CharBaseDefs::instance()->refreshScripts();
	ItemBaseDefs::instance()->refreshScripts();
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:34,代码来源:scriptmanager.cpp

示例6: type

/*!
	Returns the variant as an int if the variant has type()
	StringType, CString, IntType, UInt, DoubleType, Bool or KeySequence; or 0 otherwise.

	If \a ok is non-null, \a *ok is set to TRUE if the value could be
	converted to an int and FALSE otherwise.

	\sa asInt() canCast()
*/
int cVariant::toInt( bool* ok ) const
{
	if ( typ == StringType )
		return hex2dec( *( ( QString * ) value.ptr ) ).toInt( ok );

	if ( ok )
		*ok = canCast( IntType );

	if ( typ == IntType )
		return value.i;

	if ( typ == LongType )
		return ( int ) value.d;

	if ( typ == DoubleType )
		return ( int ) value.d;

	if ( typ == BaseCharType )
	{
		P_CHAR pChar = static_cast<P_CHAR>( value.ptr );
		return pChar ? pChar->serial() : INVALID_SERIAL;
	}

	if ( typ == ItemType )
	{
		P_ITEM pItem = static_cast<P_ITEM>( value.ptr );
		return pItem ? pItem->serial() : INVALID_SERIAL;
	}

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

示例7: sysmessage

// guildrecruit() Let the guild members recruit some player into the guild.
// Checks the guild database if "to be recruited" player already in any other guild.
// puts a tag with players serial number into the guilds recruit database.
void cGuildStone::Recruit(UOXSOCKET s)
{

	if ( currchar[s]->guildstone() == INVALID_SERIAL ) 
	{
		sysmessage(s,"you are in no guild");
		return;
	}

	if(buffer[s][11]==0xFF && buffer[s][12]==0xFF && buffer[s][13]==0xFF && buffer[s][14]==0xFF) return; // check if user canceled operation - Morrolan
	int serial = calcserial(buffer[s][7],buffer[s][8],buffer[s][9],buffer[s][10]);
	P_CHAR pc = FindCharBySerial( serial );
	if(pc != NULL)
	{
			if (pc->guildstone() != INVALID_SERIAL) 
				sysmessage(s,"This person is already in a guild.");
			else 
			{
				if (pc->isPlayer())
				{
					this->recruit.push_back(pc->serial);
				} 
				else sysmessage(s,"This is not a player.");
			}
			//break;
		//} for
	}
	this->Menu(s,1);
	return;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:33,代码来源:guildstones.cpp

示例8: inRange

/*!
	Checks if the specified object is in given range
*/
bool cUObject::inRange( cUObject* object, quint32 range ) const
{
	if ( !object )
		return false;

	Coord pos = object->pos_;

	if ( object->isItem() )
	{
		P_ITEM pItem = dynamic_cast<P_ITEM>( object );

		if ( pItem )
		{
			P_ITEM pCont = pItem->getOutmostItem();
			P_CHAR pEquipped = pItem->getOutmostChar();

			if ( pEquipped )
			{
				pos = pEquipped->pos();
			}
			else if ( pCont )
			{
				pos = pCont->pos();
			}
		}
	}

	return pos_.distance( pos ) <= range;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:32,代码来源:uobject.cpp

示例9: GuildResign

// OKAY (but take another look)
// guildresign() : Player gets removed from the guilddatabase, and gets a message.
// Offcourse guilddatabase gets checked for members left, if everyone is gone, then vanish
// the guildstone. After Guildmaster resigns, the fealty of each remaining member calculates
// a new guildmaster, if there is a draw then we'll have no master until they change their minds ;)
void GuildResign(int s)
{

	P_CHAR pc = currchar[s];

	cGuildStone* pStone = dynamic_cast<cGuildStone*>(FindItemBySerial(pc->guildstone()));

	if (pStone == NULL)
	{
		sysmessage(s, "You are in no guild");
		return;
	}

	pStone->removeMember( currchar[s] );
	sysmessage(s,"You are no longer in that guild.");
	if ((pStone->ownserial == pc->serial) && (!pStone->member.empty()))
	{
		pStone->SetOwnSerial(INVALID_SERIAL);
		pStone->CalcMaster();
	}
	if (pStone->member.empty())
	{
		Items->DeleItem( pStone );
		sysmessage(s,"You have been the last member of that guild so the stone vanishes.");
	}
	return;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:32,代码来源:guildstones.cpp

示例10: ToggleAbbreviation

// guildtoggleabbreviation() Toggles the settings for showing or not showing the guild title
// Informs player about his change
void cGuildStone::ToggleAbbreviation(UOXSOCKET s)
{
	P_CHAR pc = currchar[s];

	if (!isMember(pc)) 
	{
		sysmessage(s, "you are not a guild member");
		return;
	}

	if (this->guildType != cGuildStone::standard)		// Check for Order/Chaos
	{
		sysmessage(s, "You are in an Order/Chaos guild, you cannot toggle your title.");
	}
	else
	{
		if (!pc->guildtoggle())									// If set to Off then
		{
			pc->setGuildtoggle(true);									// Turn it On
			sysmessage(s, "You toggled your abbreviation on.");	// Tell player about the change
		}
		else													// Otherwise
		{
			pc->setGuildtoggle(false);					// Turn if Off
			sysmessage(s, "You toggled your abbreviation off.");	// And tell him also
		}
	}
	this->Menu(s, 1);										// Send him back to the menu
	return;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:32,代码来源:guildstones.cpp

示例11: execSpell

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

示例12: FindCharBySerial

// TESTED: OKAY (i think so, but ugly -> redo it!)
// guildmastercalc(guildnumber) counts all fealty settings of all members of 'guildnumber' and sets
// a new guildmaster if there is a draw then there will be no master, til the next check ;)
void cGuildStone::CalcMaster()
{

	std::map<unsigned int, unsigned int> votes; // Key is member serial and data #votes
	
	unsigned int i;
	for ( i = 0; i < member.size(); ++i)
	{
		P_CHAR pc = FindCharBySerial( member[i] );
		votes[pc->guildfealty()]++;
	}

/*	struct maxVotes : public binary_function< pair<unsigned int, unsigned int>, pair<unsigned int, unsigned int>, bool>
	{
		operator(pair<unsigned int, unsigned int> a, pair<unsigned int, unsigned int> b) 
		{ 
			return (a.second < b.second);
		}
	};*/

	std::map<unsigned int, unsigned int>::iterator it = max_element(votes.begin(), votes.end(), votes.value_comp());

	unsigned int currenthighest = it->first;
	unsigned int currenthighestvotes = it->second;
	votes.erase( it );
	// check for draw;
	it = max_element(votes.begin(), votes.end(), votes.value_comp());
	bool draw =  ( it->second == currenthighestvotes );

	if (!draw)
		this->master = currenthighest;
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:35,代码来源:guildstones.cpp

示例13: checkReq

/*!
\brief Check if the player is skilled enough and have requested items
\return bool can or can't 
\param pc the player
\param inMenu if write a sysmessage on error
\todo Add message if haven't enough item..
*/
bool cMakeItem::checkReq( P_CHAR pc, bool inMenu, cRawItem* def )
{

    if( pc->IsGM() ) 
		return true;

    if( (skillToCheck!=INVALID) && (pc->skill[skillToCheck]<minskill) ) {
        if( !inMenu ) 
			pc->sysmsg(TRANSLATE("You're not enough skilled"));
        return false;
    }

	for( int i=0; i<2; ++i ) {
        cRawItem& raw = reqitems[i];
		if( raw.id!=0 ) {
			bool have = ( def!=NULL )? (def[i].number>=raw.number) : ( pc->CountItems( raw.id, raw.color)>= raw.number );
			if( !have ) {
				if( !inMenu )
					pc->sysmsg(TRANSLATE("You've not enough resources"));
				return false;
			}
        }
    }


    return true;
}
开发者ID:BackupTheBerlios,项目名称:hypnos-svn,代码行数:34,代码来源:addmenu.cpp

示例14: postCondition

float Action_Defend::postCondition()
{
	/*
	 * Defending has the following postconditions:
	 * - The character isn't attacking us anymore.
	 * - The attacker has died.
	 * - The attacker is not within combat range.
	 * - Health is critical.
	 *
	 * Fuzzy: The nearer we get to the critical health line,
	 *        the higher is the chance to end the defend action.
	 */

	P_CHAR pAttacker = m_npc->attackTarget();
	if( !pAttacker || pAttacker->isDead() )
		return 1.0f;

	UINT8 range = 1;
	if( m_npc->rightHandItem() && IsBowType( m_npc->rightHandItem()->id() ) )
		range = ARCHERY_RANGE;

	if( !m_npc->inRange( pAttacker, range ) )
		return 1.0f;

	// 1.0 = Full Health, 0.0 = Dead
	float diff = 1.0 - QMAX(0, (m_npc->maxHitpoints() - m_npc->hitpoints()) / (float)m_npc->maxHitpoints());

	if (diff <= m_npc->criticalHealth() / 100.0) {
		return 1.0;
	}

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

示例15: 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


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