예제 #1
0
//------------------------------------------------------------------------
void CVehicleDamages::ParseDamageMultipliers(TDamageMultipliers& multipliersByHitType, TDamageMultipliers& multipliersByProjectile, const CVehicleParams& table)
{
	CVehicleParams damageMultipliersTable = table.findChild("DamageMultipliers");
	if (!damageMultipliersTable)
		return;

	int i = 0;
	int c = damageMultipliersTable.getChildCount();
	
	IGameRules* pGR = CCryAction::GetCryAction()->GetIGameRulesSystem()->GetCurrentGameRules();
	assert(pGR);

	for (; i < c; i++)
	{
		if (CVehicleParams multiplierTable = damageMultipliersTable.getChild(i))
		{
			string damageType = multiplierTable.getAttr("damageType");
			if (!damageType.empty())
			{
				int hitTypeId = 0;
				if(pGR && damageType != "default")
					hitTypeId = pGR->GetHitTypeId(damageType.c_str());

				assert(hitTypeId != 0 || damageType == "default");
				
				if(hitTypeId != 0 || damageType == "default")
				{
					GetAndInsertMultiplier( multipliersByHitType, multiplierTable, int(hitTypeId) );
				}
			}		

			string ammoType = multiplierTable.getAttr("ammoType");
		  if (!ammoType.empty())
			{
				int projectileType = 0;
				if(pGR && ammoType != "default")
				{
					uint16 classId(~uint16(0));

					if( ammoType == "default" || gEnv->pGame->GetIGameFramework()->GetNetworkSafeClassId(classId, ammoType.c_str()) )
					{
						GetAndInsertMultiplier( multipliersByProjectile, multiplierTable, int(classId) );
					}
				}
			}				
		}
	}
}
//------------------------------------------------------------------------
bool CVehicleSeatActionPassengerIK::Init(IVehicle* pVehicle, IVehicleSeat* pSeat, const CVehicleParams& table)
{
	m_pVehicle = pVehicle;
	m_passengerId = 0;

	CVehicleParams ikTable = table.findChild("PassengerIK");
	if (!ikTable)
		return false;

	CVehicleParams limbsTable = ikTable.findChild("Limbs");
	if (!limbsTable)
		return false;

	if (!ikTable.getAttr("waitShortlyBeforeStarting", m_waitShortlyBeforeStarting))
		m_waitShortlyBeforeStarting = false;

	int i = 0;
	int c = limbsTable.getChildCount();
	m_ikLimbs.reserve(c);

	for (; i < c; i++)
	{
		if (CVehicleParams limbTable = limbsTable.getChild(i))
		{
			SIKLimb limb;

			if (limbTable.haveAttr("limb"))
			{
				limb.limbName = limbTable.getAttr("limb");
				if (limbTable.haveAttr("helper"))
				{
					if (limb.pHelper = m_pVehicle->GetHelper(limbTable.getAttr("helper")))
						m_ikLimbs.push_back(limb);
				}
			}			
		}
	}

	return !m_ikLimbs.empty();
}