Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_HelicopterSoundComponent.c
Go to the documentation of this file.
1
[
EntityEditorProps
(
category
:
"GameScripted/Sound"
, description:
""
)]
2
class
SCR_HelicopterSoundComponentClass
:
SCR_VehicleSoundComponentClass
3
{
4
}
5
6
class
SCR_HelicopterSoundComponent :
SCR_VehicleSoundComponent
7
{
8
// Signal names
9
protected
const
string
SPEED_TO_CAMERA_SIGNAL_NAME
=
"SpeedToCamera"
;
10
protected
const
string
DISTANCE_SIGNAL_NAME
=
"Distance"
;
11
protected
const
string
ALTITUDE_AGL
=
"AltitudeAGL"
;
12
protected
const
string
MAIN_ROTOR_RPM_SCALED
=
"MainRotorRPMScaled"
;
13
protected
const
string
MAIN_ROTOR_HIT_ZONE_NAME
=
"RotorMain"
;
14
protected
const
string
DAMAGE_STATE_SIGNAL_NAME
=
"DamageState"
;
15
protected
const
string
ROTOR_MAIN_DAMAGE_STATE_SIGNAL_NAME
=
"RotorMainDamageState"
;
16
17
// Constants
18
protected
const
float
UPDATE_TIME
= 0.15;
19
protected
const
float
WASH_ROTOR_DISTANCE_LIMIT
= 100;
20
protected
const
float
ALTITUDE_LIMIT
= 50;
21
protected
const
float
MAIN_ROTOR_RPM_SCALED_THRESHOLD
= 0.2;
22
23
// Signal indexes
24
protected
int
m_iDistanceSignalIdx
;
25
protected
int
m_iSpeedToCameraSignalIdx
;
26
protected
int
m_AltitudeAGLSignalIdx
;
27
protected
int
m_MainRotorRPMScaledIdx
;
28
29
//
30
protected
SignalsManagerComponent
m_SignalsManagerComponent
;
31
protected
float
m_fTimer
;
32
34
protected
AudioHandle
m_WashRotorAudioHandle
=
AudioHandle
.Invalid;
35
37
protected
SCR_HelicopterDamageManagerComponent
m_HelicopterDamageManagerComponent
;
38
40
protected
SCR_HitZone
m_RotorMainHitZone
;
41
42
protected
EDamageState
m_eRotorMainDamageState
;
43
44
//------------------------------------------------------------------------------------------------
45
override
void
UpdateSoundJob(
IEntity
owner,
float
timeSlice)
46
{
47
super.UpdateSoundJob(owner, timeSlice);
48
49
if
(!
m_SignalsManagerComponent
)
50
return
;
51
52
m_fTimer
+= timeSlice;
53
if
(
m_fTimer
<
UPDATE_TIME
)
54
return
;
55
56
CalculateSpeedToCameraSignal
(owner);
57
HandleWashRotor
(owner);
58
m_fTimer
= 0;
59
}
60
61
//------------------------------------------------------------------------------------------------
64
protected
void
CalculateSpeedToCameraSignal
(
IEntity
owner)
65
{
66
Physics
physics = owner.
GetPhysics
();
67
if
(!physics)
68
return
;
69
70
vector
cameraTransform[4];
71
GetGame
().GetWorld().GetCurrentCamera(cameraTransform);
72
73
vector
entityPos = owner.
GetOrigin
();
74
vector
entityVelocity = physics.GetVelocity();
75
76
vector
directionCameraEntity = (cameraTransform[3] - entityPos).Normalized();
77
float
speed =
vector
.Dot(entityVelocity, directionCameraEntity);
78
79
// Set SpeedToCamera signal
80
m_SignalsManagerComponent
.SetSignalValue(
m_iSpeedToCameraSignalIdx
, speed);
81
}
82
83
//------------------------------------------------------------------------------------------------
86
protected
void
HandleWashRotor
(
IEntity
owner)
87
{
88
if
(
m_eRotorMainDamageState
==
EDamageState
.DESTROYED ||
m_SignalsManagerComponent
.GetSignalValue(
m_iDistanceSignalIdx
) >
WASH_ROTOR_DISTANCE_LIMIT
||
m_SignalsManagerComponent
.GetSignalValue(
m_MainRotorRPMScaledIdx
) <
MAIN_ROTOR_RPM_SCALED_THRESHOLD
)
89
{
90
Terminate
(
m_WashRotorAudioHandle
);
91
return
;
92
}
93
94
float
altitudeAGL =
m_SignalsManagerComponent
.GetSignalValue(
m_AltitudeAGLSignalIdx
);
95
if
(altitudeAGL >
ALTITUDE_LIMIT
)
96
{
97
Terminate
(
m_WashRotorAudioHandle
);
98
return
;
99
}
100
101
vector
mat[4];
102
owner.
GetTransform
(mat);
103
mat[3][1] = mat[3][1] - altitudeAGL;
104
105
if
(
IsFinishedPlaying
(
m_WashRotorAudioHandle
))
106
m_WashRotorAudioHandle
= SoundEvent(
SCR_SoundEvent
.SOUND_ROTOR_WASH_LP);
107
108
SetSoundTransformation
(
m_WashRotorAudioHandle
, mat);
109
}
110
111
//------------------------------------------------------------------------------------------------
112
protected
void
RegisterOnDamageChanged
()
113
{
114
m_HelicopterDamageManagerComponent
= SCR_HelicopterDamageManagerComponent.Cast(
GetOwner
().FindComponent(SCR_HelicopterDamageManagerComponent));
115
if
(!
m_HelicopterDamageManagerComponent
)
116
return
;
117
118
m_HelicopterDamageManagerComponent
.GetOnDamageStateChanged().Insert(
OnDamageStateChanged
);
119
}
120
121
//------------------------------------------------------------------------------------------------
122
protected
void
UnregisterOnDamageChanged
()
123
{
124
if
(
m_HelicopterDamageManagerComponent
)
125
m_HelicopterDamageManagerComponent
.GetOnDamageStateChanged().Remove(
OnDamageStateChanged
);
126
}
127
128
//------------------------------------------------------------------------------------------------
129
protected
void
OnDamageStateChanged
(
EDamageState
state)
130
{
131
m_SignalsManagerComponent
.SetSignalValue(
m_SignalsManagerComponent
.AddOrFindSignal(
DAMAGE_STATE_SIGNAL_NAME
), state);
132
}
133
134
//------------------------------------------------------------------------------------------------
135
protected
void
RegisterRotorMainOnDamageChanged
()
136
{
137
SCR_DamageManagerComponent hitZoneContainerComponent = SCR_DamageManagerComponent.Cast(
GetOwner
().FindComponent(SCR_DamageManagerComponent));
138
if
(!hitZoneContainerComponent)
139
return
;
140
141
HitZone
hitZone = hitZoneContainerComponent.GetHitZoneByName(
MAIN_ROTOR_HIT_ZONE_NAME
);
142
m_RotorMainHitZone
=
SCR_HitZone
.Cast(hitZone);
143
if
(
m_RotorMainHitZone
)
144
m_RotorMainHitZone
.GetOnDamageStateChanged().Insert(
RotorMainOnStateChanged
);
145
}
146
147
//------------------------------------------------------------------------------------------------
148
protected
void
UnregisterRotorMainOnDamageChanged
()
149
{
150
SCR_DamageManagerComponent hitZoneContainerComponent = SCR_DamageManagerComponent.Cast(
GetOwner
().FindComponent(SCR_DamageManagerComponent));
151
if
(!hitZoneContainerComponent)
152
return
;
153
154
HitZone
hitZone = hitZoneContainerComponent.GetHitZoneByName(
MAIN_ROTOR_HIT_ZONE_NAME
);
155
m_RotorMainHitZone
=
SCR_HitZone
.Cast(hitZone);
156
if
(
m_RotorMainHitZone
)
157
m_RotorMainHitZone
.GetOnDamageStateChanged().Remove(
RotorMainOnStateChanged
);
158
}
159
160
//------------------------------------------------------------------------------------------------
161
protected
void
RotorMainOnStateChanged
()
162
{
163
m_eRotorMainDamageState
=
m_RotorMainHitZone
.GetDamageState();
164
165
if
(!
m_SignalsManagerComponent
)
166
return
;
167
168
m_SignalsManagerComponent
.SetSignalValue(
m_SignalsManagerComponent
.AddOrFindSignal(
ROTOR_MAIN_DAMAGE_STATE_SIGNAL_NAME
),
SCR_HitZoneStateSignal
.
DamageStateToSignalValue
(
m_eRotorMainDamageState
))
169
}
170
171
//------------------------------------------------------------------------------------------------
172
override
void
OnPostInit
(
IEntity
owner)
173
{
174
super.OnPostInit(owner);
175
176
m_SignalsManagerComponent
=
SignalsManagerComponent
.Cast(owner.
FindComponent
(
SignalsManagerComponent
));
177
if
(!
m_SignalsManagerComponent
)
178
return
;
179
180
m_iDistanceSignalIdx
=
m_SignalsManagerComponent
.AddOrFindSignal(
DISTANCE_SIGNAL_NAME
);
181
m_iSpeedToCameraSignalIdx
=
m_SignalsManagerComponent
.AddOrFindSignal(
SPEED_TO_CAMERA_SIGNAL_NAME
);
182
m_AltitudeAGLSignalIdx
=
m_SignalsManagerComponent
.AddOrFindSignal(
ALTITUDE_AGL
);
183
m_MainRotorRPMScaledIdx
=
m_SignalsManagerComponent
.AddOrFindSignal(
MAIN_ROTOR_RPM_SCALED
);
184
}
185
186
//------------------------------------------------------------------------------------------------
187
override
void
OnInit
(
IEntity
owner)
188
{
189
super.OnInit(owner);
190
191
RegisterOnDamageChanged
();
192
RegisterRotorMainOnDamageChanged
();
193
}
194
195
//------------------------------------------------------------------------------------------------
196
// destructor
197
void
~SCR_HelicopterSoundComponent
()
198
{
199
UnregisterOnDamageChanged
();
200
UnregisterRotorMainOnDamageChanged
();
201
}
202
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
Terminate
void Terminate(bool fadeOut=true)
Definition
SCR_AudioSource.c:128
m_fTimer
float m_fTimer
Definition
SCR_CampaignMilitaryBaseComponent.c:82
m_SignalsManagerComponent
SCR_CharacterSoundComponentClass m_SignalsManagerComponent
EntityEditorProps
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
Definition
SCR_CompassComponent.c:10
OnDamageStateChanged
override void OnDamageStateChanged(EDamageState newState, EDamageState previousDamageState, bool isJIP)
Definition
SCR_HelicopterDamageManagerComponent.c:31
~SCR_HelicopterSoundComponent
void ~SCR_HelicopterSoundComponent()
Definition
SCR_HelicopterSoundComponent.c:197
ROTOR_MAIN_DAMAGE_STATE_SIGNAL_NAME
const string ROTOR_MAIN_DAMAGE_STATE_SIGNAL_NAME
Definition
SCR_HelicopterSoundComponent.c:15
SPEED_TO_CAMERA_SIGNAL_NAME
SCR_HelicopterSoundComponentClass SPEED_TO_CAMERA_SIGNAL_NAME
m_RotorMainHitZone
SCR_HitZone m_RotorMainHitZone
Main rotor damage state.
Definition
SCR_HelicopterSoundComponent.c:40
UnregisterOnDamageChanged
void UnregisterOnDamageChanged()
Definition
SCR_HelicopterSoundComponent.c:122
m_iDistanceSignalIdx
int m_iDistanceSignalIdx
Definition
SCR_HelicopterSoundComponent.c:24
UnregisterRotorMainOnDamageChanged
void UnregisterRotorMainOnDamageChanged()
Definition
SCR_HelicopterSoundComponent.c:148
m_iSpeedToCameraSignalIdx
int m_iSpeedToCameraSignalIdx
Definition
SCR_HelicopterSoundComponent.c:25
m_eRotorMainDamageState
EDamageState m_eRotorMainDamageState
Definition
SCR_HelicopterSoundComponent.c:42
HandleWashRotor
void HandleWashRotor(IEntity owner)
Definition
SCR_HelicopterSoundComponent.c:86
m_HelicopterDamageManagerComponent
SCR_HelicopterDamageManagerComponent m_HelicopterDamageManagerComponent
Damage state signal.
Definition
SCR_HelicopterSoundComponent.c:37
RegisterOnDamageChanged
void RegisterOnDamageChanged()
Definition
SCR_HelicopterSoundComponent.c:112
ALTITUDE_AGL
const string ALTITUDE_AGL
Definition
SCR_HelicopterSoundComponent.c:11
RotorMainOnStateChanged
void RotorMainOnStateChanged()
Definition
SCR_HelicopterSoundComponent.c:161
WASH_ROTOR_DISTANCE_LIMIT
const float WASH_ROTOR_DISTANCE_LIMIT
Definition
SCR_HelicopterSoundComponent.c:19
MAIN_ROTOR_RPM_SCALED
const string MAIN_ROTOR_RPM_SCALED
Definition
SCR_HelicopterSoundComponent.c:12
m_WashRotorAudioHandle
AudioHandle m_WashRotorAudioHandle
Wash rotor audio handle.
Definition
SCR_HelicopterSoundComponent.c:34
m_MainRotorRPMScaledIdx
int m_MainRotorRPMScaledIdx
Definition
SCR_HelicopterSoundComponent.c:27
DAMAGE_STATE_SIGNAL_NAME
const string DAMAGE_STATE_SIGNAL_NAME
Definition
SCR_HelicopterSoundComponent.c:14
ALTITUDE_LIMIT
const float ALTITUDE_LIMIT
Definition
SCR_HelicopterSoundComponent.c:20
MAIN_ROTOR_RPM_SCALED_THRESHOLD
const float MAIN_ROTOR_RPM_SCALED_THRESHOLD
Definition
SCR_HelicopterSoundComponent.c:21
MAIN_ROTOR_HIT_ZONE_NAME
const string MAIN_ROTOR_HIT_ZONE_NAME
Definition
SCR_HelicopterSoundComponent.c:13
RegisterRotorMainOnDamageChanged
void RegisterRotorMainOnDamageChanged()
Definition
SCR_HelicopterSoundComponent.c:135
DISTANCE_SIGNAL_NAME
const string DISTANCE_SIGNAL_NAME
Definition
SCR_HelicopterSoundComponent.c:10
m_AltitudeAGLSignalIdx
int m_AltitudeAGLSignalIdx
Definition
SCR_HelicopterSoundComponent.c:26
CalculateSpeedToCameraSignal
void CalculateSpeedToCameraSignal(IEntity owner)
Definition
SCR_HelicopterSoundComponent.c:64
UPDATE_TIME
const float UPDATE_TIME
Definition
SCR_HelicopterSoundComponent.c:18
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
SCR_VehicleSoundComponent
void SCR_VehicleSoundComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition
SCR_VehicleSoundComponent.c:71
AudioHandle
Definition
EnAudio.c:9
HitZone
Definition
HitZone.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::GetOrigin
proto external vector GetOrigin()
IEntity::GetPhysics
proto external Physics GetPhysics()
IEntity::GetTransform
proto external void GetTransform(out vector mat[])
Physics
Definition
Physics.c:22
SCR_HelicopterSoundComponentClass
Definition
SCR_HelicopterSoundComponent.c:3
SCR_HitZone
Definition
SCR_HitZone.c:2
SCR_HitZoneStateSignal
Definition
SCR_HitZoneStateSignal.c:2
SCR_HitZoneStateSignal::DamageStateToSignalValue
static int DamageStateToSignalValue(EDamageState damageState)
Definition
SCR_HitZoneStateSignal.c:79
SCR_SoundEvent
Definition
SCR_SoundEvent.c:2
SCR_VehicleSoundComponentClass
Definition
SCR_VehicleSoundComponent.c:3
SignalsManagerComponent
Definition
SignalsManagerComponent.c:13
vector
Definition
vector.c:13
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition
SCR_FuelNode.c:128
IsFinishedPlaying
proto external bool IsFinishedPlaying(AudioHandle handle)
SetSoundTransformation
proto external void SetSoundTransformation(AudioHandle handle, vector transf[])
EDamageState
EDamageState
Definition
EDamageState.c:13
OnPostInit
@ OnPostInit
Definition
SndComponentCallbacks.c:15
OnInit
@ OnInit
Definition
SndComponentCallbacks.c:17
scripts
Game
Components
VehicleSoundComponent
SCR_HelicopterSoundComponent.c
Generated by
1.17.0