Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EngineHitZone.c
Go to the documentation of this file.
2{
3 [Attribute("25", UIWidgets.Auto, desc: "Minimum engine power scale (% of initial)", params: "0 100 0.1")]
5
6 [Attribute("20", UIWidgets.Auto, desc: "Minimum engine startup chance (% of initial)", params: "0 100 0.1")]
8
9 protected SCR_PowerComponent m_Power;
10
11 //------------------------------------------------------------------------------------------------
13 {
14 EDamageState state = GetDamageState();
15 float efficiency = GetDamageStateThreshold(state);
16
17 // Battery influence on engine power output
18 if (m_Power && m_Power.ShouldApplyNoPowerPenalty() && !m_Power.HasPower())
19 efficiency *= m_Power.GetNoPowerMultiplier();
20
21 return Math.Lerp(0.01 * m_fMinimumEnginePowerScale, 1, efficiency);
22 }
23
25 override void OnInit(IEntity pOwnerEntity, GenericComponent pManagerComponent)
26 {
27 super.OnInit(pOwnerEntity, pManagerComponent);
28
29 Vehicle vehicle = Vehicle.Cast(pOwnerEntity.GetRootParent());
30 if (!vehicle)
31 return;
32
34 if (damageManager)
35 damageManager.RegisterVehicleHitZone(this);
36
37 m_Power = SCR_PowerComponent.Cast(vehicle.FindComponent(SCR_PowerComponent));
38 if (m_Power)
39 m_Power.GetEventBatteryStateChanged().Insert(UpdateEngineState);
40 }
41
42 //------------------------------------------------------------------------------------------------
55 override void OnDamage(notnull BaseDamageContext damageContext)
56 {
57 super.OnDamage(damageContext);
58
59 // Powerful impact should always stop engine
60 if (damageContext.damageValue < GetCriticalDamageThreshold()*GetMaxHealth())
61 return;
62
63 BaseVehicleNodeComponent node = BaseVehicleNodeComponent.Cast(GetOwner().FindComponent(BaseVehicleNodeComponent));
64
65 VehicleControllerComponent controller;
66 if (node)
67 controller = VehicleControllerComponent.Cast(node.FindComponent(VehicleControllerComponent));
68
69 if (controller && controller.IsEngineOn())
70 controller.StopEngine(false);
71 }
72
73 //------------------------------------------------------------------------------------------------
77 override void OnDamageStateChanged(EDamageState newState, EDamageState previousDamageState, bool isJIP)
78 {
79 super.OnDamageStateChanged(newState, previousDamageState, isJIP);
80
82 }
83
84 //------------------------------------------------------------------------------------------------
89 {
90 Vehicle vehicle = Vehicle.Cast(GetOwner().GetRootParent());
91 if (!vehicle)
92 return;
93
94 SCR_VehicleDamageManagerComponent damageManager = SCR_VehicleDamageManagerComponent.Cast(vehicle.GetDamageManager());
95 if (damageManager)
96 damageManager.UpdateVehicleState();
97
98 // Damage and battery influence on starter and engine power output
99 // TODO: Delegate this feature to controller/damage manager
100 EDamageState state = GetDamageState();
101 float health = GetDamageStateThreshold(state);
102 float startupChance;
103 if (m_Power && !m_Power.HasPower())
104 startupChance = 0;
105 else
106 startupChance = Math.Lerp(m_fMinimumEngineStartupChance, 100, health);
107
108 VehicleControllerComponent controller = vehicle.GetVehicleController();
109 if (controller)
110 controller.SetEngineStartupChance(startupChance);
111 }
112}
float GetMaxHealth()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void SCR_VehicleDamageManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
proto external IEntity GetRootParent()
Definition Math.c:13
float m_fMinimumEngineStartupChance
SCR_PowerComponent m_Power
override void OnDamageStateChanged(EDamageState newState, EDamageState previousDamageState, bool isJIP)
override void OnInit(IEntity pOwnerEntity, GenericComponent pManagerComponent)
Called when hit zone is initialized.
override void OnDamage(notnull BaseDamageContext damageContext)
IEntity GetOwner()
Definition SCR_HitZone.c:42
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
SCR_FieldOfViewSettings Attribute
EDamageState