//------------------------------------------------------------------------
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;
}
예제 #2
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 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 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 CVehicleMovementVTOL::Init(IVehicle *pVehicle, const CVehicleParams &table)
{
	if (!CVehicleMovementHelicopter::Init(pVehicle, table))
	{
		return false;
	}

	MOVEMENT_VALUE("horizFwdForce", m_horizFwdForce);
	MOVEMENT_VALUE("horizLeftForce", m_horizLeftForce);
	MOVEMENT_VALUE("boostForce", m_boostForce);
	MOVEMENT_VALUE("strafeForce", m_strafeForce);
	MOVEMENT_VALUE("angleLift", m_angleLift);
	m_playerDampingBase = 0.15f;
	m_playerDampingRotation = 0.3f;
	m_playerDimLowInput = 0.01f;
	m_playerRotationMult.x = 55.0f;
	m_playerRotationMult.y = 40.0f;
	m_playerRotationMult.z = 0.0f;
	m_maxFwdSpeedHorizMode = m_maxFwdSpeed;
	m_maxUpSpeedHorizMode = m_maxUpSpeed;
	m_pWingsAnimation = NULL;
	m_wingHorizontalStateId = InvalidVehicleAnimStateId;
	m_wingVerticalStateId = InvalidVehicleAnimStateId;

	if (!table.getAttr("timeUntilWingsRotate", m_timeUntilWingsRotate))
	{
		m_timeUntilWingsRotate = 0.65f;
	}

	m_engineUpDir.Set(0.0f, 0.0f, 1.0f);

	if (!table.getAttr("wingsSpeed", m_wingsSpeed))
	{
		m_wingsSpeed = 1.0f;
	}

	m_playerDampingBase *= 3.0f;
	m_fwdPID.Reset();
	m_fwdPID.m_kP = 0.66f;
	m_fwdPID.m_kD = 0.2f;
	m_fwdPID.m_kI = 0.0f;
	m_relaxForce = 0.50f;
	m_relaxPitchTime = 0.0f;
	m_relaxRollTime = 0.0f;
	m_playerControls.RegisterValue(&m_forwardAction, false, 0.0f, "forward");
	m_playerControls.RegisterAction(eVAI_MoveForward, CHelicopterPlayerControls::eVM_Positive, &m_forwardAction);
	m_playerControls.RegisterAction(eVAI_MoveBack, CHelicopterPlayerControls::eVM_Negative, &m_forwardAction);
	m_playerControls.RegisterValue(&m_strafeAction, false, 0.0f, "strafe");
	m_playerControls.RegisterAction(eVAI_StrafeLeft, CHelicopterPlayerControls::eVM_Negative, &m_strafeAction);
	m_playerControls.RegisterAction(eVAI_StrafeRight, CHelicopterPlayerControls::eVM_Positive, &m_strafeAction);
	m_playerControls.SetActionMult(eVAI_RotateYaw, m_maxYawRate * 0.4f);
	m_playerControls.SetActionMult(eVAI_RotatePitch, m_maxYawRate * 0.4f);
	m_pStabilizeVTOL = gEnv->pConsole->GetCVar("v_stabilizeVTOL");
	m_maxSpeed = 75.0f;
	return true;
}
//------------------------------------------------------------------------
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 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;
}
예제 #9
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) );
					}
				}
			}				
		}
	}
}
예제 #10
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;
}
void CVehicleMovementHelicopter::InitMovementNoise( const CVehicleParams& noiseParams, CVTolNoise& noise )
{
	Vec3 amplitude(ZERO);
	Vec3 frequency(ZERO);
	Vec3 rotAmplitudeDeg(ZERO);
	Vec3 rotFrequency(ZERO);
	float startDamageRatio = 0.f;

	noiseParams.getAttr("amplitude", amplitude);
	noiseParams.getAttr("frequency", frequency);
	noiseParams.getAttr("rotAmplitude", rotAmplitudeDeg);
	noiseParams.getAttr("rotFrequency", rotFrequency);
	noiseParams.getAttr("startDamageRatio", startDamageRatio);

	noise.Init(amplitude, frequency, DEG2RAD(rotAmplitudeDeg), rotFrequency, startDamageRatio);
}
예제 #12
0
//------------------------------------------------------------------------
bool CVehicleDamagesGroup::Init(CVehicle* pVehicle, const CVehicleParams& table)
{
	m_pVehicle = pVehicle;
	m_name = table.getAttr("name");
  m_damageSubGroups.clear();

	return !m_name.empty() && ParseDamagesGroup(table);
}
//------------------------------------------------------------------------
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;
}
예제 #14
0
static void getFlag(CVehicleParams &params, const char* key, int &flags, int flag)
{
	int tmp = flags & flag;
	params.getAttr(key, tmp);
	if (tmp)
		flags |= flag;
	else
		flags &= ~flag;
}
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 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 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 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;
}
예제 #20
0
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;
}
예제 #22
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 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;
}
//------------------------------------------------------------------------
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;
}
예제 #26
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 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;
}
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 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 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;
}