Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_LightningComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted", description: "")]
5
7class SCR_LightningComponent : ScriptComponent
8{
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")];
19
20 [Attribute(defvalue: "200")];
22
23 [Attribute(defvalue: "30")];
25
26 [Attribute(defvalue: "100")];
28
29 [Attribute(defvalue: "1")]
31
32 [Attribute(defvalue: "3")]
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 //------------------------------------------------------------------------------------------------
56 {
59 && m_aFlashesStartTime.Count() == m_aFlashesDuration.Count()
61 {
62 ChimeraWorld world = GetOwner().GetWorld();
63 TimeAndWeatherManagerEntity tawme =world.GetTimeAndWeatherManager();
64 if(!tawme)
65 return;
66
67 //inform weather entity
69 wl.SetPosition(GetOwner().GetOrigin());
70 wl.SetRadius(m_fRadiusKM);
71
72 for(int n = m_iCurFlashIndex; n < m_aFlashesStartTime.Count(); n++)
73 {
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);
85 }
86 }
87
88 //------------------------------------------------------------------------------------------------
89 override void OnPostInit(IEntity owner)
90 {
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 {
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}
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
vector GetOrigin()
SCR_CacheNoteComponentClass ScriptComponentClass RplProp()] protected ref array< string > m_aLines
float m_fRadiusKM
float m_fFlashMaxCooldownMillis
int m_iMinFlashes
ref array< float > m_aFlashesStartTime
float m_fFlashMaxVisibilityRadiusKM
ref array< float > m_aFlashesCooldownDuration
ref array< float > m_aFlashesDuration
float m_fFlashMinVisibilityRadiusKM
void OnFlashesRpl()
float m_fFlashMinCooldownMillis
SCR_LightningComponentClass m_pRandomGenerator
Inform the weather manager a lightning has been spawned. Weather Manager will handle light changes.
float m_fFlashMinDurationMillis
int m_iMaxFlashes
float m_fFlashMaxDurationMillis
int m_iCurFlashIndex
int m_iNumFlashes
proto external Managed FindComponent(typename typeName)
proto external BaseWorld GetWorld()
proto external GenericEntity GetOwner()
Get owner entity.
Definition int.c:13
SCR_FieldOfViewSettings Attribute
RplRole
Role of replicated node (and all items in it) within the replication system.
Definition RplRole.c:14