Exemplo n.º 1
0
	void OnVehicleEvent(EVehicleEvent event, const SVehicleEventParams& params)
	{
		if ( (event == eVE_Destroyed) || 
				 (event == eVE_PreVehicleDeletion) ||
				 (event == eVE_Hide) ) // Safer to ensure the listener is removed at this point
		{
			SetActive(false);
		}
		else if (event == eVE_VehicleDeleted) // This shouldn't be called due to above but just in case
		{
			SetActive(false);
		}
		else if (event == eVE_Collision) // Currently disabled in C2 code
		{
			ActivateOutput(&m_actInfo, EOP_Collided, true);
		}
		else if (event == eVE_Hit) // Needed to detect collision in C2 code since above is disabled
		{
			IGameRules* pGameRules = gEnv->pGame->GetIGameFramework()->GetIGameRulesSystem()->GetCurrentGameRules();
			if (pGameRules)
			{
				const int collisionHitType = pGameRules->GetHitTypeId("collision");

				if (params.iParam == collisionHitType)
				{
					ActivateOutput(&m_actInfo, EOP_Collided, true);
				}
			}
		}
	}
Exemplo n.º 2
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) );
					}
				}
			}				
		}
	}
}
void CDamageEffectController::Init(CActor* actor)
{
	if (CKVoltEffect::s_hashId == 0) //once initialised it can't be 0
	{
		CKVoltEffect::s_hashId = CreateHash("KVoltFX");
		CTinnitusEffect::s_hashId = CreateHash("TinnitusFx");
		CEntityTimerEffect::s_hashId = CreateHash("TimerFX");
	}

	IGameRules* pGameRules = g_pGame->GetGameRules();
	m_ownerActor = actor;

	const IItemParamsNode* actorParams = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActorParams(actor->GetEntityClassName());
	const IItemParamsNode* damageEffectParams = actorParams ? actorParams->GetChild("DamageEffectParams") : 0;

	if (damageEffectParams)
	{
		int numChildren = damageEffectParams->GetChildCount();
		int allowSerialise = 1;

		damageEffectParams->GetAttribute("allowSerialise", allowSerialise);
		m_allowSerialise = allowSerialise ? true : false;

		CRY_ASSERT_MESSAGE(numChildren <= MAX_NUM_DAMAGE_EFFECTS, "Too many damage effects found. Increase the MAX_NUM_DAMAGE_EFFECTS and size of activeEffects and effectsResetSwitch");

		for (int i = 0; i < numChildren; i++)
		{
			const IItemParamsNode* child = damageEffectParams->GetChild(i);
			const IItemParamsNode* effect = child->GetChild(0);

			const char* hittype = child->GetAttribute("hittype");
			const char* name = effect->GetName();

			m_associatedHitType[i] = pGameRules->GetHitTypeId(hittype);

			child->GetAttribute("minDamage", m_minDamage[i]);	
			
			uint64 hashcode = CreateHash(name);

			if (hashcode == CKVoltEffect::s_hashId)
			{
				m_effectList[i] = new CKVoltEffect();
			}
			else if (hashcode == CTinnitusEffect::s_hashId)
			{
				m_effectList[i] = new CTinnitusEffect();
			}
			else if (hashcode == CEntityTimerEffect::s_hashId)
			{
				m_effectList[i] = new CEntityTimerEffect();
			}
			else
			{
				GameWarning("INVALID DAMAGE EFFECT PARSED");
				m_associatedHitType[i] = -1;
			}
			
			if(m_effectList[i])
			{
				m_effectList[i]->Init(actor, effect);
			}
		}
	}
}