//------------------------------------------------------------------------
bool CVehicleUsableActionEnter::Init(IVehicle* pVehicle, const CVehicleParams& table)
{
    CVehicleParams enterTable = table.findChild("Enter");
    if (!enterTable)
        return false;

    m_pVehicle = static_cast<CVehicle*>(pVehicle);

    if (CVehicleParams seatsTables = enterTable.findChild("Seats"))
    {
        int c = seatsTables.getChildCount();
        int i = 0;
        m_seatIds.reserve(c);

        for (; i < c; i++)
        {
            CVehicleParams seatRef = seatsTables.getChild(i);

            if (const char* pSeatName = seatRef.getAttr("value"))
            {
                if (TVehicleSeatId seatId = m_pVehicle->GetSeatId(pSeatName))
                    m_seatIds.push_back(seatId);
            }
        }
    }

    return !m_seatIds.empty();
}
//------------------------------------------------------------------------
bool CVehicleSeatActionRotateTurret::Init(IVehicle* pVehicle, IVehicleSeat* pSeat, const CVehicleParams &table)
{
	m_pUserEntity = NULL;
	m_aimGoal.zero();
	m_aimGoalPriority = 0;

	m_rotTestHelpers[0] = NULL;
	m_rotTestHelpers[1] = NULL;
	m_rotTestRadius     = 0.f;

	m_pVehicle = static_cast<CVehicle*>(pVehicle);
	m_pSeat    = static_cast<CVehicleSeat*>(pSeat);
	assert(m_pSeat);

	CVehicleParams rotationTable = table.findChild("RotateTurret");
	if (!rotationTable)
		return false;

	// first the actual rotation setups
	if (CVehicleParams pitchTable = rotationTable.findChild("Pitch"))
	{
		InitRotation(pVehicle, pitchTable, eVTRT_Pitch);
		InitRotationSounds(pitchTable, eVTRT_Pitch);
	}
	if (CVehicleParams yawTable = rotationTable.findChild("Yaw"))
	{
		InitRotation(pVehicle, yawTable, eVTRT_Yaw);
		InitRotationSounds(yawTable, eVTRT_Yaw);
	}

	// then the (optional) rotation testing
	if (CVehicleParams rotationTestTable = rotationTable.findChild("RotationTest"))
	{
		if (rotationTestTable.haveAttr("helper1"))
		{
			const char* helpName = rotationTestTable.getAttr("helper1");
			if (IVehicleHelper* pHelper = m_pVehicle->GetHelper(helpName))
				m_rotTestHelpers[0] = pHelper;
		}
		if (rotationTestTable.haveAttr("helper2"))
		{
			const char* helpName = rotationTestTable.getAttr("helper2");
			if (IVehicleHelper* pHelper = m_pVehicle->GetHelper(helpName))
				m_rotTestHelpers[1] = pHelper;
		}

		rotationTestTable.getAttr("radius", m_rotTestRadius);
	}

	return true;
}
//------------------------------------------------------------------------
bool CVehicleDamageBehaviorImpulse::Init(IVehicle* pVehicle, const CVehicleParams& table)
{
	m_pVehicle = (CVehicle*) pVehicle;

	CVehicleParams impulseParams = table.findChild("Impulse");
	if (!impulseParams)
		return false;

  impulseParams.getAttr("worldSpace", m_worldSpace);
	impulseParams.getAttr("forceMin", m_forceMin);
	impulseParams.getAttr("forceMax", m_forceMax);
	
  impulseParams.getAttr("direction", m_impulseDir);
  m_impulseDir.NormalizeSafe(Vec3(0,0,1));
  
	if (!impulseParams.getAttr("momentum", m_angImpulse))
		m_angImpulse.zero();

	if (impulseParams.haveAttr("helper"))
		m_pImpulseLocation = m_pVehicle->GetHelper(impulseParams.getAttr("helper"));
	else
		m_pImpulseLocation = NULL;

	return true;
}
//------------------------------------------------------------------------
bool CVehicleActionDeployRope::Init(IVehicle *pVehicle, IVehicleSeat *pSeat, const CVehicleParams &table)
{
	m_pVehicle = pVehicle;
	m_pSeat = pSeat;

	CVehicleParams deployRopeTable = table.findChild("DeployRope");

	if(!deployRopeTable)
		return false;

	if(deployRopeTable.haveAttr("helper"))
		m_pRopeHelper = m_pVehicle->GetHelper(deployRopeTable.getAttr("helper"));

	if(deployRopeTable.haveAttr("animation"))
	{
		if(m_pDeployAnim = m_pVehicle->GetAnimation(deployRopeTable.getAttr("animation")))
		{
			m_deployAnimOpenedId = m_pDeployAnim->GetStateId("opened");
			m_deployAnimClosedId = m_pDeployAnim->GetStateId("closed");

			if(m_deployAnimOpenedId == InvalidVehicleAnimStateId
					|| m_deployAnimClosedId == InvalidVehicleAnimStateId)
			{
				m_pDeployAnim = NULL;
			}
		}
	}

	return m_pRopeHelper != NULL;
}
//------------------------------------------------------------------------
bool CVehicleDamageBehaviorExplosion::Init(IVehicle* pVehicle, const CVehicleParams& table)
{
	m_pVehicle = pVehicle;
  m_exploded = false;

	CVehicleParams explosionParams = table.findChild("Explosion");
	if (!explosionParams)
		return false;

	explosionParams.getAttr("damage", m_damage);
	explosionParams.getAttr("radius", m_radius);
	explosionParams.getAttr("pressure", m_pressure);
	
	if (!explosionParams.getAttr("minRadius", m_minRadius))
		m_minRadius = m_radius/2.0f;

	if (!explosionParams.getAttr("physRadius", m_physRadius))
		m_physRadius = min(m_radius, 5.0f);

	if (!explosionParams.getAttr("minPhysRadius", m_minPhysRadius))
		m_minPhysRadius = m_physRadius/2.0f;

	if (explosionParams.haveAttr("helper"))
		m_pHelper = m_pVehicle->GetHelper(explosionParams.getAttr("helper"));
	else
		m_pHelper = NULL;

	return true;
}
//------------------------------------------------------------------------
bool CVehicleDamageBehaviorBurn::Init(IVehicle *pVehicle, const CVehicleParams &table)
{
	m_pVehicle = pVehicle;
	m_isActive = false;
	m_damageRatioMin = 1.f;
	m_timerId = -1;

	m_shooterId = 0;

	table.getAttr("damageRatioMin", m_damageRatioMin);

	if(CVehicleParams burnTable = table.findChild("Burn"))
	{
		burnTable.getAttr("damage", m_damage);
		burnTable.getAttr("selfDamage", m_selfDamage);
		burnTable.getAttr("interval", m_interval);
		burnTable.getAttr("radius", m_radius);

		m_pHelper = NULL;

		if(burnTable.haveAttr("helper"))
			m_pHelper = m_pVehicle->GetHelper(burnTable.getAttr("helper"));
		else
			m_pHelper = NULL;

		return true;
	}

	return false;
}
//------------------------------------------------------------------------
bool CVehicleSeatActionRotateTurret::InitRotationSounds(const CVehicleParams &rotationParams, EVehicleTurretRotationType eType)
{
	CVehicleParams sound = rotationParams.findChild("Sound");
	if (!sound)
		return false;

	if (sound.haveAttr("event"))
	{
		if (string helperName = sound.getAttr("helper"))
		{
			if (IVehicleHelper* pHelper = m_pVehicle->GetHelper(helperName))
			{
				SVehicleSoundInfo info;
				info.name                        = sound.getAttr("event");
				info.pHelper                     = pHelper;
				m_rotations[eType].m_turnSoundId = m_pVehicle->AddSoundEvent(info);

				if (sound.haveAttr("eventDamage"))
				{
					SVehicleSoundInfo dmgInfo;
					info.name                          = sound.getAttr("eventDamage");
					info.pHelper                       = pHelper;
					m_rotations[eType].m_damageSoundId = m_pVehicle->AddSoundEvent(info);
				}

				return true;
			}
		}

		return false;
	}

	return true;
}
示例#8
0
//------------------------------------------------------------------------
bool CVehiclePartEntity::Init(IVehicle *pVehicle, const CVehicleParams &table, IVehiclePart *parent, CVehicle::SPartInitInfo &initInfo, int partType)
{
	if(!CVehiclePartBase::Init(pVehicle, table, parent, initInfo, eVPT_Entity))
	{
		return false;
	}

	if(CVehicleParams params = table.findChild("Entity"))
	{
		//prefer to use index, if not available try id
		bool found = params.getAttr("index", m_index);
		if( !found )
		{
			params.getAttr("id", m_index);
		}

		m_entityName			= params.getAttr("name");
		m_entityArchetype = params.getAttr("archetype");
		m_helperName			= params.getAttr("helper");
	
		//getAttr is confused by bitfield bool
		bool temp = true;
		params.getAttr( "collideWithParent", temp );
		m_CollideWithParent = temp;

		temp = false;
		params.getAttr( "detachInsteadOfDestroy", temp );
		m_shouldDetachInsteadOfDestroy = temp;
	}

	m_pVehicle->RegisterVehicleEventListener(this, "VehiclePartEntity");

	return true;
}
示例#9
0
//------------------------------------------------------------------------
bool CVehicleSeatGroup::Init(IVehicle* pVehicle, const CVehicleParams& paramsTable)
{
	m_pVehicle = static_cast<CVehicle*>(pVehicle);
	m_isSwitchingReverse = false;

	if (CVehicleParams seatsTable = paramsTable.findChild("Seats"))
	{
		int i = 0;
		int c = seatsTable.getChildCount();
		m_seats.reserve(c);

		for (; i < c; i++)
		{
			string seatName = seatsTable.getChild(i).getAttr("value");
			if (!seatName.empty())
			{
				TVehicleSeatId seatId = m_pVehicle->GetSeatId(seatName);
				if (CVehicleSeat* pSeat = (CVehicleSeat*)m_pVehicle->GetSeatById(seatId))
				{
					pSeat->SetSeatGroup(this);
					m_seats.push_back(pSeat);
				}
			}
		}
	}

	if (!paramsTable.getAttr("keepEngineWarm", m_isKeepingEngineWarm))
		m_isKeepingEngineWarm = false;

	return !m_seats.empty();
}
//------------------------------------------------------------------------
bool CVehicleMovementWarrior::Init(IVehicle *pVehicle, const CVehicleParams &table)
{
	CVehicleParams hovercraftTable = table.findChild("Hovercraft");

	if(!hovercraftTable)
		return false;

	if(!CVehicleMovementHovercraft::Init(pVehicle, hovercraftTable))
		return false;

	table.getAttr("maxThrustersDamaged", m_maxThrustersDamaged);
	table.getAttr("collapsedFeetAngle", m_collapsedFeetAngle);
	table.getAttr("collapsedLegAngle", m_collapsedLegAngle);
	table.getAttr("recoverTime", m_recoverTime);

	// save original thruster values
	m_thrustersInit.reserve(m_vecThrusters.size());

	for(TThrusters::iterator it=m_vecThrusters.begin(); it!=m_vecThrusters.end(); ++it)
	{
		m_thrustersInit.push_back(new SThruster(**it));
	}

	m_pTurret = m_pVehicle->GetPart("turret1");
	m_pCannon = m_pVehicle->GetPart("cannon");
	m_pWing   = m_pVehicle->GetPart("generator");

	m_pPlatformPos = m_pVehicle->GetHelper("platform_pos");

	return true;
}
//------------------------------------------------------------------------
bool CVehicleActionEntityAttachment::Init(IVehicle *pVehicle, const CVehicleParams &table)
{
	m_pVehicle = pVehicle;

	CVehicleParams entityAttachmentTable = table.findChild("EntityAttachment");

	if(!entityAttachmentTable)
		return false;

	if(entityAttachmentTable.haveAttr("helper"))
		m_pHelper = m_pVehicle->GetHelper(entityAttachmentTable.getAttr("helper"));

	if(entityAttachmentTable.haveAttr("class"))
	{
		IEntityClassRegistry *pClassRegistry = gEnv->pEntitySystem->GetClassRegistry();
		assert(pClassRegistry);

		m_entityClassName = entityAttachmentTable.getAttr("class");

		if(IEntityClass *pEntityClass = pClassRegistry->FindClass(m_entityClassName.c_str()))
		{
			SpawnEntity();
			return true;
		}
	}

	return false;
}
//------------------------------------------------------------------------
bool CVehicleMovementHelicopter::Init(IVehicle* pVehicle, const CVehicleParams& table)
{
	if (!CVehicleMovementBase::Init(pVehicle, table))
		return false;

	// Initialise the arcade physics, handling helper
	if (CVehicleParams handlingParams = table.findChild("HandlingArcade"))
		if (!m_arcade.Init(pVehicle, handlingParams))
			return false;

	MOVEMENT_VALUE("engineWarmupDelay", m_engineWarmupDelay);
	MOVEMENT_VALUE("enginePowerMax", m_enginePowerMax);
	MOVEMENT_VALUE("yawPerRoll", m_yawPerRoll);
	MOVEMENT_VALUE("maxSpeed", m_maxSpeed);
	MOVEMENT_VALUE("maxPitchAngle", m_maxPitchAngle);
	MOVEMENT_VALUE("maxRollAngle", m_maxRollAngle);
	MOVEMENT_VALUE("rollDamping", m_rollDamping);

	if(table.haveAttr("extendMoveTarget"))
	{
		table.getAttr("extendMoveTarget", m_bExtendMoveTarget);
	}
	table.getAttr("applyNoiseAsVelocity", m_bApplyNoiseAsVelocity);

	if(CVehicleParams noiseParams = table.findChild("MovementNoise"))
	{
		InitMovementNoise(noiseParams, m_defaultNoise);
	}

	// high-level controller
	Ang3 angles				= m_pEntity->GetWorldAngles();
	m_enginePower			= 0.0f;

	if (table.haveAttr("rotorPartName"))
		m_pRotorPart = m_pVehicle->GetPart(table.getAttr("rotorPartName"));

	m_isEngineGoingOff = true;
	m_isEnginePowered = false;

	ResetActions();

	m_pVehicle->GetGameObject()->EnableUpdateSlot(m_pVehicle, IVehicle::eVUS_EnginePowered);

	return true;
}
bool CVehicleMovementAmphibiousT<CVehicleMovementArcadeWheeled>::InitWheeled(IVehicle* pVehicle, const CVehicleParams& table)
{
	CVehicleParams wheeledTable = table.findChild("ArcadeWheeled");
	if (wheeledTable)
	{
		return CVehicleMovementArcadeWheeled::Init(pVehicle, wheeledTable);
	}
	return false;
}
bool CVehicleMovementAmphibiousT<Wheeled>::Init(IVehicle* pVehicle, const CVehicleParams& table)
{
	if (InitWheeled(pVehicle, table))
	{
		CVehicleParams stdBoatTable = table.findChild("StdBoat");
		if (stdBoatTable )
		{
			return m_boat.Init(pVehicle, stdBoatTable);
		}
	}
	return false;
}
//------------------------------------------------------------------------
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();
}
//------------------------------------------------------------------------
bool CVehicleDamageBehaviorEffect::Init(IVehicle *pVehicle, const CVehicleParams &table)
{
	m_pVehicle			= pVehicle;
	m_pDamageEffect	= NULL;
	m_slot					= -1;

	CVehicleParams	effectParams = table.findChild("Effect");

	if(!effectParams)
	{
		return false;
	}

	string								effectName = effectParams.getAttr("effect");

	CryFixedStringT<256>	sharedParamsName;

	sharedParamsName.Format("%s::DamageBehaviorEffect::%s", pVehicle->GetEntity()->GetClass()->GetName(), effectName.c_str());

	ISharedParamsManager	*pSharedParamsManager = CCryAction::GetCryAction()->GetISharedParamsManager();

	CRY_ASSERT(pSharedParamsManager);

	m_pSharedParams = CastSharedParamsPtr<SSharedParams>(pSharedParamsManager->Get(sharedParamsName));

	if(!m_pSharedParams)
	{
		SSharedParams	sharedParams;

		sharedParams.effectName = effectName;

		sharedParams.damageRatioMin = 1.0f;
		sharedParams.updateFromHelper = false;

		table.getAttr("damageRatioMin", sharedParams.damageRatioMin);

		sharedParams.disableAfterExplosion = false;

		effectParams.getAttr("disableAfterExplosion", sharedParams.disableAfterExplosion);

		effectParams.getAttr("updateFromHelper", sharedParams.updateFromHelper);

		m_pSharedParams = CastSharedParamsPtr<SSharedParams>(pSharedParamsManager->Register(sharedParamsName, sharedParams));
	}

	CRY_ASSERT(m_pSharedParams.get());

	return true;
}
示例#17
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 CVehiclePartPulsingLight::Init( IVehicle* pVehicle, const CVehicleParams& table, IVehiclePart* parent, CVehicle::SPartInitInfo& initInfo, int partType )
{
	if (!CVehiclePartLight::Init(pVehicle, table, parent, initInfo, eVPT_Light))
		return false;

	if(CVehicleParams lightTable = table.findChild("PulsingLight"))
	{
		lightTable.getAttr("minColorMult", m_minColorMult);
		lightTable.getAttr("toggleOnMinDamageRatio", m_toggleOnMinDamageRatio);
		lightTable.getAttr("colorMultSpeed", m_colorMultSpeed);
		lightTable.getAttr("toggleStageTwoMinDamageRatio", m_toggleStageTwoMinDamageRatio);
		lightTable.getAttr("colorMultSpeedStageTwo", m_colorMultSpeedStageTwo);
	}

	return true;
}
//------------------------------------------------------------------------
bool CVehicleDamageBehaviorMovementNotification::Init(IVehicle* pVehicle, const CVehicleParams& table)
{
	CRY_ASSERT(pVehicle);
	m_pVehicle = pVehicle;

	m_param = 0;

	if (CVehicleParams notificationParams = table.findChild("MovementNotification"))
	{
		notificationParams.getAttr("isSteering", m_isSteeringInvolved);		
    notificationParams.getAttr("isFatal", m_isFatal);
		notificationParams.getAttr("param", m_param);
		notificationParams.getAttr("isDamageAlwaysFull", m_isDamageAlwaysFull);
	}

	return true;
}
示例#20
0
//------------------------------------------------------------------------
bool CVehiclePartAnimated::Init(IVehicle* pVehicle, const CVehicleParams &table, IVehiclePart* parent, CVehicle::SPartInitInfo &initInfo, int partType)
{
	if (!CVehiclePartBase::Init(pVehicle, table, parent, initInfo, eVPT_Animated))
		return false;

	if (CVehicleParams animatedTable = table.findChild("Animated"))
	{
		animatedTable.getAttr("ignoreDestroyedState", m_ignoreDestroyedState);
	}

	InitGeometry();

	m_state = eVGS_Default;

	m_pVehicle->SetObjectUpdate(this, IVehicle::eVOU_AlwaysUpdate);

	return true;
}
//------------------------------------------------------------------------
bool CVehicleDamageBehaviorBlowTire::Init(IVehicle *pVehicle, const CVehicleParams &table)
{
	m_pVehicle = pVehicle;
	m_isActive = false;
	m_aiImmobilizedTimer = -1;
	m_sBlowTireEffect = "";

	if(CVehicleParams blowTireTable = table.findChild("BlowTire"))
	{
		m_sBlowTireEffect = blowTireTable.getAttr("effect");

		if(!m_sBlowTireEffect.empty())
		{
			gEnv->pParticleManager->FindEffect(m_sBlowTireEffect.c_str(), "CVehicleDamageBehaviorBlowTire::Init");
		}
	}

	return true;
}
//------------------------------------------------------------------------
bool CVehicleSeatActionRotateTurret::InitRotation(IVehicle* pVehicle, const CVehicleParams &rotationTable, EVehicleTurretRotationType eType)
{
	if (rotationTable)
	{
		if (rotationTable.haveAttr("part"))
			m_rotations[eType].m_pPart = static_cast<CVehiclePartBase*>(m_pVehicle->GetPart(rotationTable.getAttr("part")));

		if (rotationTable.getAttr("speed", m_rotations[eType].m_speed) && m_rotations[eType].m_pPart)
		{
			m_rotations[eType].m_pPart->SetMoveable();

			rotationTable.getAttr("accel", m_rotations[eType].m_acceleration);

			if (CVehicleParams limitsTable = rotationTable.findChild("Limits"))
			{
				// Forward facing limits
				if (limitsTable.getChildCount() >= 2)
				{
					if (CVehicleParams limitRef = limitsTable.getChild(0))
						m_rotations[eType].m_minLimitF = (float)DEG2RAD((float)atof(limitRef.getAttr("value")));
					else
						m_rotations[eType].m_minLimitF = 0.0f;

					if (CVehicleParams limitRef = limitsTable.getChild(1))
						m_rotations[eType].m_maxLimit = (float)DEG2RAD((float)atof(limitRef.getAttr("value")));
					else
						m_rotations[eType].m_maxLimit = 0.0f;
				}

				// Backwards facing limits
				m_rotations[eType].m_minLimitB = m_rotations[eType].m_minLimitF;
				if (limitsTable.getChildCount() >= 3)
				{
					if (CVehicleParams limitRef = limitsTable.getChild(2))
						m_rotations[eType].m_minLimitB = (float)DEG2RAD((float)atof(limitRef.getAttr("value")));
				}
			}
		}
		rotationTable.getAttr("worldSpace", m_rotations[eType].m_worldSpace);
	}

	return true;
}
//------------------------------------------------------------------------
bool CVehiclePartParticleEffect::Init(IVehicle *pVehicle, const CVehicleParams &table, IVehiclePart *parent, CVehicle::SPartInitInfo &initInfo, int partType)
{
	if(!CVehiclePartBase::Init(pVehicle, table, parent, initInfo, eVPT_Entity))
	{
		return false;
	}

	if(CVehicleParams params = table.findChild("ParticleEffect"))
	{
		params.getAttr("id", m_id);

		m_particleEffectName	= params.getAttr("particleEffect");
		m_helperName					= params.getAttr("helper");
	}

	m_pVehicle->RegisterVehicleEventListener(this, "VehiclePartParticleEffect");

	return true;
}
示例#24
0
//------------------------------------------------------------------------
void CVehicleDamages::InitDamages(CVehicle* pVehicle, const CVehicleParams& table)
{
	m_pVehicle = pVehicle;
  
	if (CVehicleParams damagesTable = table.findChild("Damages"))
	{
		if (CVehicleParams damagesGroupTable = damagesTable.findChild("DamagesGroups"))
		{
			int c = damagesGroupTable.getChildCount();
			int i = 0;

			m_damagesGroups.reserve(c);

			for (; i < c; i++)
			{
				if (CVehicleParams groupTable = damagesGroupTable.getChild(i))
				{
					CVehicleDamagesGroup* pDamageGroup = new CVehicleDamagesGroup;
					if (pDamageGroup->Init(pVehicle, groupTable))
						m_damagesGroups.push_back(pDamageGroup);
					else
						delete pDamageGroup;
				}
			}
		}

		damagesTable.getAttr("submergedRatioMax", m_damageParams.submergedRatioMax);
		damagesTable.getAttr("submergedDamageMult", m_damageParams.submergedDamageMult);

    damagesTable.getAttr("collDamageThreshold", m_damageParams.collisionDamageThreshold);    
    damagesTable.getAttr("groundCollisionMinMult", m_damageParams.groundCollisionMinMult);    
    damagesTable.getAttr("groundCollisionMaxMult", m_damageParams.groundCollisionMaxMult);    
    damagesTable.getAttr("groundCollisionMinSpeed", m_damageParams.groundCollisionMinSpeed);    
    damagesTable.getAttr("groundCollisionMaxSpeed", m_damageParams.groundCollisionMaxSpeed);  
		damagesTable.getAttr("vehicleCollisionDestructionSpeed", m_damageParams.vehicleCollisionDestructionSpeed);
		damagesTable.getAttr("aiKillPlayerSpeed", m_damageParams.aiKillPlayerSpeed);
		damagesTable.getAttr("playerKillAISpeed", m_damageParams.playerKillAISpeed);
		damagesTable.getAttr("aiKillAISpeed", m_damageParams.aiKillAISpeed);

		ParseDamageMultipliers(m_damageMultipliersByHitType, m_damageMultipliersByProjectile, damagesTable);
	}
}
bool CVehicleSeatActionOrientateBoneToView::Init(IVehicle* pVehicle, IVehicleSeat* pSeat, const CVehicleParams& table)
{
	m_pVehicle = pVehicle;
	m_pSeat = pSeat;

	IDefaultSkeleton& rIDefaultSkeleton = *GetCharacterModelSkeleton();
	{
		if(table.haveAttr("MoveBone") )
		{
			const char* boneName = table.getAttr("MoveBone");
			m_MoveBoneId = rIDefaultSkeleton.GetJointIDByName(boneName);
		}

		if(table.haveAttr("LookBone") )
		{
			const char* boneName = table.getAttr("LookBone");
			m_LookBoneId = rIDefaultSkeleton.GetJointIDByName(boneName);
		}
	}

	if( table.haveAttr("Sluggishness") )
	{
		table.getAttr("Sluggishness", m_Sluggishness);
	}

	if ( CVehicleParams baseOrientationTable = table.findChild("MoveBoneBaseOrientation") )
	{
		float x, y, z;
		baseOrientationTable.getAttr("x", x);
		baseOrientationTable.getAttr("y", y);
		baseOrientationTable.getAttr("z", z);

		m_BoneBaseOrientation = Quat::CreateRotationXYZ( Ang3(x, y, z) );
	}
	else
	{
		m_BoneBaseOrientation.SetIdentity();
	}

	return true;
}
//------------------------------------------------------------------------
bool CVehicleSeatActionSound::Init(IVehicle* pVehicle, IVehicleSeat* pSeat, const CVehicleParams& table)
{
	m_pVehicle = pVehicle;
	m_pSeat = static_cast<CVehicleSeat*>(pSeat);

	CVehicleParams soundTable = table.findChild("Audio");
	if (!soundTable)
		return false;

	gEnv->pAudioSystem->GetAudioTriggerID(soundTable.getAttr("startTrigger"), m_nAudioControlIDStart);
	gEnv->pAudioSystem->GetAudioTriggerID(soundTable.getAttr("stopTrigger"), m_nAudioControlIDStop);

	if (soundTable.haveAttr("helper"))
		m_pHelper = m_pVehicle->GetHelper(soundTable.getAttr("helper"));

	if (!m_pHelper)
		return false;

	m_enabled = false;
	return true;
}
//------------------------------------------------------------------------
bool CVehicleActionAutomaticDoor::Init(IVehicle* pVehicle, const CVehicleParams& table)
{
    m_pVehicle = pVehicle;

    CVehicleParams autoDoorTable = table.findChild("AutomaticDoor");
    if (!autoDoorTable)
        return false;

    if (autoDoorTable.haveAttr("animation"))
        m_pDoorAnim = m_pVehicle->GetAnimation(autoDoorTable.getAttr("animation"));

    autoDoorTable.getAttr("timeMax", m_timeMax);

    if (!m_pDoorAnim)
        return false;

    m_doorOpenedStateId = m_pDoorAnim->GetStateId("opened");
    m_doorClosedStateId = m_pDoorAnim->GetStateId("closed");

    autoDoorTable.getAttr("disabled", m_isDisabled);

    m_pVehicle->SetObjectUpdate(this, IVehicle::eVOU_AlwaysUpdate);

    m_pVehicle->RegisterVehicleEventListener(this, "VehicleActionAutomaticDoor");

    m_pDoorAnim->StopAnimation();
    m_pDoorAnim->StartAnimation();
    m_pDoorAnim->ToggleManualUpdate(true);

    if(!m_isDisabled)
        m_pDoorAnim->SetTime(DOOR_OPENED);
    else
        {
            m_pDoorAnim->SetTime(DOOR_CLOSED);
            m_animTime = DOOR_CLOSED;
            m_animGoal = DOOR_CLOSED;
        }

    return true;
}
bool CVehiclePartWaterRipplesGenerator::Init(IVehicle* pVehicle, const CVehicleParams& table, IVehiclePart* parent, CVehicle::SPartInitInfo& initInfo, int partType)
{
    if (!CVehiclePartBase::Init(pVehicle, table, parent, initInfo, eVPT_Massbox))
        return false;

    m_pVehicle = pVehicle;

    const CVehicleParams waterRipplesTable = table.findChild("WaterRipplesGen");
    if (waterRipplesTable)
    {
        waterRipplesTable.getAttr("scale", m_waterRipplesScale);
        waterRipplesTable.getAttr("strength", m_waterRipplesStrength);
        waterRipplesTable.getAttr("minMovementSpeed", m_minMovementSpeed);
        waterRipplesTable.getAttr("moveForwardOnly", m_onlyMovingForward);

        m_minMovementSpeed = max( m_minMovementSpeed, 0.01f );
    }

    m_pVehicle->SetObjectUpdate(this, IVehicle::eVOU_AlwaysUpdate);

    return true;
}
//------------------------------------------------------------------------
bool CVehicleSeatActionAnimation::Init(IVehicle* pVehicle, IVehicleSeat* pSeat, const CVehicleParams &table)
{
	m_pVehicle = pVehicle;

	CVehicleParams animTable = table.findChild("Animation");
	if (!animTable)
		return false;

	if (animTable.haveAttr("vehicleAnimation"))
		m_pVehicleAnim = m_pVehicle->GetAnimation(animTable.getAttr("vehicleAnimation"));

	string control = animTable.getAttr("control");
	if (!control.empty())
	{
		if (control == "roll")
		{
			m_control[0] = eVAI_RollLeft;
			m_control[1] = eVAI_RollRight;
		}
	}

	animTable.getAttr("manualUpdate", m_manualUpdate);
	animTable.getAttr("speed", m_speed);

	REINST("start/stop event?");
	/*m_pIEntityAudioProxy = (IEntityAudioProxy*)m_pVehicle->GetEntity()->GetProxy(ENTITY_PROXY_AUDIO);

	   if (m_pIEntityAudioProxy)
	   {
	   if (animTable.haveAttr("sound"))
	    m_pSound = gEnv->pAudioSystem->CreateSound(animTable.getAttr("sound"), FLAG_SOUND_DEFAULT_3D);

	   if (animTable.haveAttr("stopSound"))
	    m_pStopSound = gEnv->pAudioSystem->CreateSound(animTable.getAttr("stopSound"), FLAG_SOUND_DEFAULT_3D);
	   }*/

	return true;
}
//------------------------------------------------------------------------
bool CVehicleDamageBehaviorDetachPart::Init(IVehicle* pVehicle, const CVehicleParams& table)
{
	m_pVehicle = static_cast<CVehicle*>(pVehicle);

	m_detachedEntityId = 0;

	//<DetachPartParams geometry="door2" direction="1.0,0.0,0.0" />

	if (CVehicleParams detachPartParams = table.findChild("DetachPart"))
	{
		m_partName = detachPartParams.getAttr("part");
		detachPartParams.getAttr("notifyMovement", m_notifyMovement);

		// Get optional custom particle effect
		if (detachPartParams.haveAttr("effect"))
			m_pEffect = gEnv->pParticleManager->FindEffect(detachPartParams.getAttr("effect"), "CVehicleDamageBehaviorDetachPart()");

		detachPartParams.getAttr("pickable", m_pickableDebris);

		return true;
	}
 
	return false;
}