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


C++ CBasePlayerItem::GetItemInfo方法代码示例

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


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

示例1: UpdateStats

void UpdateStats( CBasePlayer *pPlayer )
{
	int i;

	int ammoCount[ MAX_AMMO_SLOTS ];
	memcpy( ammoCount, pPlayer->m_rgAmmo, MAX_AMMO_SLOTS * sizeof(int) );

	// Keep a running time, so the graph doesn't overlap
	
	if ( gpGlobals->time < gStats.lastGameTime )	// Changed level or died, don't b0rk
	{
		gStats.lastGameTime = gpGlobals->time;
		gStats.dataTime = gStats.gameTime;
	}

	gStats.gameTime += gpGlobals->time - gStats.lastGameTime;
	gStats.lastGameTime = gpGlobals->time;

	for (i = 0; i < MAX_ITEM_TYPES; i++)
	{
		CBasePlayerItem *p = pPlayer->m_rgpPlayerItems[i];
		while (p)
		{
			ItemInfo II;
			
			memset(&II, 0, sizeof(II));
			p->GetItemInfo(&II);

			int index = pPlayer->GetAmmoIndex(II.pszAmmo1);
			if ( index >= 0 )
				ammoCount[ index ] += ((CBasePlayerWeapon *)p)->m_iClip;
			
			p = p->m_pNext;
		}
	}

	float ammo = 0;
	for (i = 1; i < MAX_AMMO_SLOTS; i++)
	{
		ammo += ammoCount[i] * AmmoDamage( CBasePlayerItem::AmmoInfoArray[i].pszName );
	}

	float health = pPlayer->pev->health + pPlayer->pev->armorvalue * 2;	// Armor is 2X health
	float ammoDelta = fabs( ammo - gStats.lastAmmo );
	float healthDelta = fabs( health - gStats.lastHealth );
	int forceWrite = 0;
	if ( health <= 0 && gStats.lastHealth > 0 )
		forceWrite = 1;

	if ( (ammoDelta > AMMO_THRESHOLD || healthDelta > HEALTH_THRESHOLD) && !forceWrite )
	{
		if ( gStats.nextOutputTime == 0 )
			gStats.dataTime = gStats.gameTime;

		gStats.lastAmmo = ammo;
		gStats.lastHealth = health;

		gStats.nextOutputTime = gStats.gameTime + OUTPUT_LATENCY;
	}
	else if ( (gStats.nextOutputTime != 0 && gStats.nextOutputTime < gStats.gameTime) || forceWrite )
	{
		UpdateStatsFile( gStats.dataTime, (char *)STRING(gpGlobals->mapname), health, ammo, (int)CVAR_GET_FLOAT("skill") );

		gStats.lastAmmo = ammo;
		gStats.lastHealth = health;
		gStats.lastOutputTime = gStats.gameTime;
		gStats.nextOutputTime = 0;
	}
}
开发者ID:tschumann,项目名称:naturalselection,代码行数:69,代码来源:stats.cpp


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