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


C++ CItemBase::GetSpeed方法代码示例

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


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

示例1: Calc_CombatAttackSpeed

int CResource::Calc_CombatAttackSpeed( CChar * pChar, CItem * pWeapon )
{
	// Combat: Speed of the attack
	// based on dex and weight of the weapon.
	// ? my tactics ?
	// ? my skill with weapon ?
	// ? How much weight i'm carrying ?
	// RETURN: 
	//  Time in tenths of a sec. (for entire swing, not just time to hit)

	ASSERT(pChar);

	if ( pWeapon != NULL )
	{
		CItemBase * pItemDef = dynamic_cast <CItemBase *> (pWeapon->Base_GetDef());
		if ( pItemDef )
		{
			BYTE speed = pItemDef->GetSpeed();
			if ( speed )
			{
				int iWaitTime = (TICK_PER_SEC * g_Cfg.m_iSpeedScaleFactor) / ( ( pChar->Stat_GetAdjusted(STAT_DEX) + 100 ) * speed );
				return (iWaitTime > 5 ? iWaitTime : 5);
			}
		}
	}
	if ( pChar->m_pNPC &&
		pChar->m_pNPC->m_Brain == NPCBRAIN_GUARD &&
		m_fGuardsInstantKill )
		return( 1 );

	// Base speed is just your DEX range=40 to 0
	int iWaitTime = IMULDIV( 100 - pChar->Stat_GetAdjusted(STAT_DEX), 40, 100 );
	if ( iWaitTime < 5 )	// no-one needs to be this fast.
		iWaitTime = 5;
	else
		iWaitTime += 5;

	// Speed of the weapon as well effected by strength (minor).

	if ( pWeapon != NULL )
	{
		DEBUG_CHECK( pWeapon->IsItemEquipped());
		int iWeaponWait = (pWeapon->GetWeight() * 10 ) / ( 4 * WEIGHT_UNITS );	// tenths of a stone.
		if ( pWeapon->GetEquipLayer() == LAYER_HAND2 )	// 2 handed is slower
		{
			iWeaponWait += iWaitTime/2;
		}
		iWaitTime += iWeaponWait;
	}
	else
	{
		iWaitTime += 2;
	}

	return( iWaitTime );
}
开发者ID:GenerationOfWorlds,项目名称:Sphere,代码行数:56,代码来源:CResourceCalc.cpp


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