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_LightningComponent.c
Go to the documentation of this file.
1
[
ComponentEditorProps
(
category
:
"GameScripted"
, description:
""
)]
2
class
SCR_LightningComponentClass
:
ScriptComponentClass
3
{
4
}
5
7
class
SCR_LightningComponent :
ScriptComponent
8
{
9
protected
ref
RandomGenerator
m_pRandomGenerator
=
new
RandomGenerator
();
10
11
[
Attribute
(defvalue:
"4"
)]
12
protected
int
m_iMinFlashes
;
13
14
[
Attribute
(defvalue:
"8"
)]
15
protected
int
m_iMaxFlashes
;
16
17
[
Attribute
(defvalue:
"25"
)];
18
protected
float
m_fFlashMinDurationMillis
;
19
20
[
Attribute
(defvalue:
"200"
)];
21
protected
float
m_fFlashMaxDurationMillis
;
22
23
[
Attribute
(defvalue:
"30"
)];
24
protected
float
m_fFlashMinCooldownMillis
;
25
26
[
Attribute
(defvalue:
"100"
)];
27
protected
float
m_fFlashMaxCooldownMillis
;
28
29
[
Attribute
(defvalue:
"1"
)]
30
protected
float
m_fFlashMinVisibilityRadiusKM
;
31
32
[
Attribute
(defvalue:
"3"
)]
33
protected
float
m_fFlashMaxVisibilityRadiusKM
;
34
35
36
[
RplProp
(onRplName:
"OnFlashesRpl"
)]
37
protected
int
m_iNumFlashes
;
38
39
[
RplProp
(onRplName:
"OnFlashesRpl"
)]
40
protected
float
m_fRadiusKM
;
41
42
[
RplProp
(onRplName:
"OnFlashesRpl"
)]
43
protected
ref array<float>
m_aFlashesStartTime
= {};
44
45
[
RplProp
(onRplName:
"OnFlashesRpl"
)]
46
protected
ref array<float>
m_aFlashesDuration
= {};
47
48
[
RplProp
(onRplName:
"OnFlashesRpl"
)]
49
protected
ref array<float>
m_aFlashesCooldownDuration
= {};
50
51
protected
int
m_iCurFlashIndex
;
52
53
//------------------------------------------------------------------------------------------------
55
void
OnFlashesRpl
()
56
{
57
if
(
m_iCurFlashIndex
<
m_iNumFlashes
58
&&
m_iNumFlashes
==
m_aFlashesStartTime
.Count()
59
&&
m_aFlashesStartTime
.Count() ==
m_aFlashesDuration
.Count()
60
&&
m_aFlashesStartTime
.Count() ==
m_aFlashesCooldownDuration
.Count())
61
{
62
ChimeraWorld
world =
GetOwner
().
GetWorld
();
63
TimeAndWeatherManagerEntity
tawme =world.GetTimeAndWeatherManager();
64
if
(!tawme)
65
return
;
66
67
//inform weather entity
68
WeatherLightning
wl =
new
WeatherLightning
();
69
wl.SetPosition(
GetOwner
().
GetOrigin
());
70
wl.SetRadius(
m_fRadiusKM
);
71
72
for
(
int
n =
m_iCurFlashIndex
; n <
m_aFlashesStartTime
.Count(); n++)
73
{
74
WeatherLightningFlash
wlf =
new
WeatherLightningFlash
();
75
76
wlf.SetStartTime(
m_aFlashesStartTime
[n]);
77
wlf.SetDuration(
m_aFlashesDuration
[n]);
78
wlf.SetCooldown(
m_aFlashesCooldownDuration
[n]);
79
80
wl.AddLightningFlash(wlf);
81
}
82
83
tawme.AddLightning(wl);
84
m_iCurFlashIndex
+=
m_aFlashesStartTime
.Count();
85
}
86
}
87
88
//------------------------------------------------------------------------------------------------
89
override
void
OnPostInit
(
IEntity
owner)
90
{
91
m_iCurFlashIndex
= 0;
92
93
//SetEventMask(owner, EntityEvent.FRAME);
94
RplComponent rpl = RplComponent.Cast(owner.
FindComponent
(RplComponent));
95
96
ChimeraWorld
world =
ChimeraWorld
.CastFrom(
GetOwner
().GetWorld());
97
if
(!world)
98
return
;
99
100
TimeAndWeatherManagerEntity
tawme = world.GetTimeAndWeatherManager();
101
if
(!tawme)
102
return
;
103
104
if
(rpl && rpl.Role() ==
RplRole
.Authority)
105
{
106
m_fRadiusKM
=
m_pRandomGenerator
.RandFloatXY(
m_fFlashMinVisibilityRadiusKM
,
m_fFlashMaxVisibilityRadiusKM
);
107
m_iNumFlashes
=
m_iMinFlashes
+ ((
int
)(
m_pRandomGenerator
.RandFloat01() * ((
float
)
m_iMaxFlashes
- (
float
)
m_iMinFlashes
)));
108
109
//decide whether to use game time or global engine time, however,
110
//if we use game time and auto-advancement is disabled, this will mess
111
//with the lightnings, or any other effect based on game time.
112
float
curEngineTime = tawme.GetEngineTime();
113
114
for
(
int
n = 0; n <
m_iNumFlashes
; n++)
115
{
116
float
flashStartTime = curEngineTime;
117
float
flashDuration = (
m_pRandomGenerator
.RandFloatXY(
m_fFlashMinDurationMillis
,
m_fFlashMaxDurationMillis
) * 0.001);
118
float
flashCooldownDuration = (
m_pRandomGenerator
.RandFloatXY(
m_fFlashMinCooldownMillis
,
m_fFlashMaxCooldownMillis
) * 0.001);
119
120
curEngineTime += (flashDuration + flashCooldownDuration);
121
122
m_aFlashesStartTime
.Insert(flashStartTime);
123
m_aFlashesDuration
.Insert(flashDuration);
124
m_aFlashesCooldownDuration
.Insert(flashCooldownDuration);
125
}
126
127
OnFlashesRpl
();
128
}
129
}
130
}
ComponentEditorProps
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
Definition
SCR_AIGroupUtilityComponent.c:12
GetOrigin
vector GetOrigin()
Definition
SCR_AIUtilityComponent.c:471
RplProp
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
m_fRadiusKM
float m_fRadiusKM
Definition
SCR_LightningComponent.c:40
m_fFlashMaxCooldownMillis
float m_fFlashMaxCooldownMillis
Definition
SCR_LightningComponent.c:27
m_iMinFlashes
int m_iMinFlashes
Definition
SCR_LightningComponent.c:12
m_aFlashesStartTime
ref array< float > m_aFlashesStartTime
Definition
SCR_LightningComponent.c:43
m_fFlashMaxVisibilityRadiusKM
float m_fFlashMaxVisibilityRadiusKM
Definition
SCR_LightningComponent.c:33
m_aFlashesCooldownDuration
ref array< float > m_aFlashesCooldownDuration
Definition
SCR_LightningComponent.c:49
m_aFlashesDuration
ref array< float > m_aFlashesDuration
Definition
SCR_LightningComponent.c:46
m_fFlashMinVisibilityRadiusKM
float m_fFlashMinVisibilityRadiusKM
Definition
SCR_LightningComponent.c:30
OnFlashesRpl
void OnFlashesRpl()
Definition
SCR_LightningComponent.c:55
m_fFlashMinCooldownMillis
float m_fFlashMinCooldownMillis
Definition
SCR_LightningComponent.c:24
m_pRandomGenerator
SCR_LightningComponentClass m_pRandomGenerator
Inform the weather manager a lightning has been spawned. Weather Manager will handle light changes.
m_fFlashMinDurationMillis
float m_fFlashMinDurationMillis
Definition
SCR_LightningComponent.c:18
m_iMaxFlashes
int m_iMaxFlashes
Definition
SCR_LightningComponent.c:15
m_fFlashMaxDurationMillis
float m_fFlashMaxDurationMillis
Definition
SCR_LightningComponent.c:21
m_iCurFlashIndex
int m_iCurFlashIndex
Definition
SCR_LightningComponent.c:51
m_iNumFlashes
int m_iNumFlashes
Definition
SCR_LightningComponent.c:37
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
ChimeraWorld
Definition
ChimeraWorld.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::GetWorld
proto external BaseWorld GetWorld()
RandomGenerator
Definition
RandomGenerator.c:13
SCR_LightningComponentClass
Definition
SCR_LightningComponent.c:3
ScriptComponentClass
Definition
ScriptComponentClass.c:8
ScriptComponent
Definition
ScriptComponent.c:24
ScriptComponent::GetOwner
proto external GenericEntity GetOwner()
Get owner entity.
TimeAndWeatherManagerEntity
Definition
TimeAndWeatherManagerEntity.c:26
WeatherLightningFlash
Definition
WeatherLightningFlash.c:8
WeatherLightning
Definition
WeatherLightning.c:8
int
Definition
int.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
RplRole
RplRole
Role of replicated node (and all items in it) within the replication system.
Definition
RplRole.c:14
OnPostInit
@ OnPostInit
Definition
SndComponentCallbacks.c:15
scripts
Game
Components
SCR_LightningComponent.c
Generated by
1.17.0