Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
VehicleCinematicTrack.c
Go to the documentation of this file.
1[CinematicTrackAttribute(name:"Vehicle Track", description:"Allows you to control vehicles")]
3{
4 [Attribute("false")]
5 bool m_bStartEngine;
6
7 [Attribute("1.0", params:"0 100000")]
8 float m_fEfficiency;
9
10 [Attribute("0.0", params:"-1.0 1.0")]
11 float m_fSteering;
12
13 [Attribute("2", params: "0 5")]
14 int m_fGear;
15
16 [Attribute("1.0", params: "0.0 1.0")]
17 float m_fClutch;
18
19 [Attribute("0.0", params:"0.0 1.0")]
20 float m_fBreak;
21
22 [Attribute("false")]
23 bool m_bHandBrake;
24
25 [Attribute("false")]
26 bool m_bLightsOn;
27
28 [Attribute("0.0", params:"0.0 1.0")]
29 float m_fThrottle;
30
31 [Attribute("false")]
32 bool m_bTurretControl;
33
34 [Attribute("false")]
35 bool m_bTurretShot;
36
37 [Attribute("0.0", params: "-3 3")]
38 float m_fTurretLeftRight;
39
40 [Attribute("0.0", params: "-3 3")]
41 float m_fTurretDownUp;
42
43 private GenericEntity m_Vehicle;
44 private CarControllerComponent m_Vehicle_c;
45 private VehicleWheeledSimulation m_Vehicle_s;
46 private BaseLightManagerComponent m_Vehicle_l;
47 private World actualWorld;
48
49 private SlotManagerComponent slotManager;
50 private SlotManagerComponent secondarySlotManager;
51
52 private int lastGear = 0;
53
55 void insertGunner()
56 {
57 if (slotManager)
58 {
59 array<EntitySlotInfo> vehicleSlotInfos = {};
60 slotManager.GetSlotInfos(vehicleSlotInfos);
61
62 foreach (EntitySlotInfo slotInfo : vehicleSlotInfos)
63 {
64 IEntity slotEntity = slotInfo.GetAttachedEntity();
65
66 if (!slotEntity)
67 continue;
68
70
71 if (turret)
72 {
73 BaseCompartmentSlot compartment = turret.GetCompartmentSlot();
74 if (compartment)
75 {
76 if (!compartment.IsOccupied())
77 {
78 AIGroup group;
79 compartment.SpawnDefaultCharacterInCompartment(group);
80 }
81 }
82 }
83 }
84 }
85 }
86
87 override void OnInit(World world)
88 {
89
90 actualWorld = world;
91
92 // Find vehicle entity by using name of track
93 findEntity(world);
94
95 if (m_Vehicle) {
96
97 // Find vehicle control and simulation components
98 m_Vehicle_c = CarControllerComponent.Cast(m_Vehicle.FindComponent(CarControllerComponent));
99 m_Vehicle_l = BaseLightManagerComponent.Cast(m_Vehicle.FindComponent(BaseLightManagerComponent));
100 m_Vehicle_s = VehicleWheeledSimulation.Cast(m_Vehicle.FindComponent(VehicleWheeledSimulation));
101 slotManager = SlotManagerComponent.Cast(m_Vehicle.FindComponent(SlotManagerComponent));
102 }
103 }
104
105 void findEntity(World world)
106 {
107 // Find particle entity by using name of track
108 TStringArray strs = new TStringArray;
109 GetTrackName().Split("_", strs, true);
110
111 m_Vehicle = GenericEntity.Cast(world.FindEntityByName(strs.Get(0)));
112 }
113
114 override void OnApply(float time)
115 {
116
117 if (m_Vehicle && m_Vehicle_c && m_Vehicle_s)
118 {
119
121 int id = chanim.BindFloatVariable("VehicleSteering");
122 chanim.SetFloatVariable(id,m_fSteering);
123
124 //zeroes sentsitivities
125 m_Vehicle_s.SetNoiseSteerSensitivity(0);
126 m_Vehicle_s.SetRoughnessSensitivity(0);
127 m_Vehicle_c.SetPersistentHandBrake(0);
128 m_Vehicle_s.GearboxSetEfficiencyState(m_fEfficiency);
129
130
131 if(m_Vehicle_l)
132 {
133 m_Vehicle_l.SetLightsState(ELightType.Head, m_bLightsOn, 0);
134 m_Vehicle_l.SetLightsState(ELightType.Head, m_bLightsOn, 1);
135 }
136
137 //Start or stop engine
138 if (m_bStartEngine && !m_Vehicle_c.IsEngineOn())
139 {
140 m_Vehicle_c.ForceStartEngine();
141
142 } else if (!m_bStartEngine && m_Vehicle_c.IsEngineOn()) {
143
144 m_Vehicle_c.ForceStopEngine();
145 }
146
147
148 //Break and hand-brake
149 m_Vehicle_s.SetBreak(m_fBreak, m_bHandBrake);
150
151 //Ggear
152 if(m_fGear != lastGear)
153 {
154 m_Vehicle_s.SetGear(m_fGear);
155 lastGear = m_fGear;
156 }
157
158 //Clutch
159 m_Vehicle_s.SetClutch(m_fClutch);
160
161 //Throttle
162 m_Vehicle_s.SetThrottle(m_fThrottle);
163
164 //Steering
165 m_Vehicle_s.SetSteering(m_fSteering);
166
167
168 if (slotManager && m_bTurretControl)
169 {
170 array<EntitySlotInfo> vehicleSlotInfos = {};
171 slotManager.GetSlotInfos(vehicleSlotInfos);
172
173 foreach (EntitySlotInfo slotInfo : vehicleSlotInfos)
174 {
175 IEntity slotEntity = slotInfo.GetAttachedEntity();
176
177 if (!slotEntity)
178 continue;
179
181
182 if (turret)
183 {
184
185 turret.SetAimingAngles(m_fTurretLeftRight,m_fTurretDownUp);
186
187 if (m_bTurretShot)
188 turret.SetFireWeaponWanted(true);
189 else
190 turret.SetFireWeaponWanted(false);
191
192 } else {
193
194 //second layer of slots
195 secondarySlotManager = SlotManagerComponent.Cast(slotEntity.FindComponent(SlotManagerComponent));
196
197 if (secondarySlotManager)
198 {
199 array<EntitySlotInfo> secondaryVehicleSlotInfos = {};
200 secondarySlotManager.GetSlotInfos(secondaryVehicleSlotInfos);
201
202 foreach (EntitySlotInfo secondarySlotInfo : secondaryVehicleSlotInfos)
203 {
204 IEntity secondarySlotEntity = secondarySlotInfo.GetAttachedEntity();
205
206 if (!secondarySlotEntity)
207 continue;
208
210
211 if (secondaryTurret)
212 {
213 secondaryTurret.SetAimingAngles(m_fTurretLeftRight,m_fTurretDownUp);
214
215 if (m_bTurretShot)
216 secondaryTurret.SetFireWeaponWanted(true);
217 }
218 }
219 }
220 }
221
222 }
223 }
224 }
225 }
226}
ELightType
Definition ELightType.c:8
void CinematicEventAttribute(string name="")
Definition attributes.c:18
IEntity SpawnDefaultCharacterInCompartment(inout AIGroup group, ResourceName groupPrefab="{000CD338713F2B5A}Prefabs/AI/Groups/Group_Base.et")
Adds ability to attach an object to a slot.
proto external Managed FindComponent(typename typeName)
Definition World.c:16
SCR_FieldOfViewSettings Attribute
array< string > TStringArray
Definition Types.c:385