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_PoisonScreenEffect.c
Go to the documentation of this file.
1
// This screen effect is used in the SCR_HudManagerComponent of {6E2BB64764E3BE9B}Prefabs/Characters/Core/DefaultPlayerController.et
2
// And it operates on what is in {BFBCF7C2CF2E36EE}UI/layouts/HUD/ScreenEffects/ScreenEffects.layout
3
class
SCR_PoisonScreenEffect
:
SCR_BaseScreenEffect
4
{
5
[
Attribute
(defvalue:
"0.17"
,
desc
:
"Min alpha mask progress value"
,
params
:
"0 1 0.01"
)]
6
protected
float
m_fMinEnabledAlpha
;
7
8
[
Attribute
(defvalue:
"0.45"
,
desc
:
"Max alpha mask progress value"
,
params
:
"0 1 0.01"
)]
9
protected
float
m_fMaxEnabledAlpha
;
10
11
[
Attribute
(defvalue:
"0.4"
,
desc
:
"Minimal opacity value that will be used by the poison widgets"
,
params
:
"0 1 0.01"
)]
12
protected
float
m_fMinEnabledEffectOpacity
;
13
14
[
Attribute
(defvalue:
"1"
,
desc
:
"Base animation speed for the opacity"
,
params
:
"0.01 inf 0.01"
)]
15
protected
float
m_fAnimationSpeed
;
16
17
[
Attribute
(defvalue:
"1.1"
,
desc
:
"Max additional speed that can be applied to the opacity animation"
,
params
:
"0.01 inf 0.01"
)]
18
protected
float
m_fMaxRandomAnimationSpeedDifference
;
19
20
[
Attribute
(defvalue:
"0.1"
,
desc
:
"Multiplier applied to the currently total amount of poison damge, to convert it into the opacity value"
,
params
:
"0.01 inf 0.01"
)]
21
protected
float
m_fDamageToOpacityFactor
;
22
23
protected
ImageWidget
m_wPoisonEffect1
;
24
protected
ImageWidget
m_wPoisonEffect2
;
25
26
protected
SCR_DamageSufferingSystem
m_DamageSystem
;
27
protected
ref set<DotDamageEffect>
m_DamageEffects
;
28
29
//------------------------------------------------------------------------------------------------
30
override
void
DisplayStartDraw
(
IEntity
owner)
31
{
32
m_wPoisonEffect1
=
ImageWidget
.Cast(
m_wRoot
.FindAnyWidget(
"PoisonVignette1"
));
33
m_wPoisonEffect2
=
ImageWidget
.Cast(
m_wRoot
.FindAnyWidget(
"PoisonVignette2"
));
34
m_DamageSystem
=
SCR_DamageSufferingSystem
.GetInstance();
35
SetEnabled
(
false
);
36
}
37
38
//------------------------------------------------------------------------------------------------
39
override
void
ClearEffects
()
40
{
41
if
(
m_DamageEffects
)
42
m_DamageEffects
.Clear();
43
44
if
(!
m_wPoisonEffect1
|| !
m_wPoisonEffect2
)
45
return
;
46
47
AnimateWidget
.
StopAllAnimations
(
m_wPoisonEffect1
);
48
AnimateWidget
.
StopAllAnimations
(
m_wPoisonEffect2
);
49
if
(
m_wPoisonEffect1
.GetMaskProgress() > 0)
50
{
51
AnimateWidget
.
Opacity
(
m_wPoisonEffect1
, 0, 1);
52
AnimateWidget
.
Opacity
(
m_wPoisonEffect2
, 0, 1);
53
AnimateWidget
.
AlphaMask
(
m_wPoisonEffect1
, 0, 1);
54
AnimateWidget
.
AlphaMask
(
m_wPoisonEffect2
, 0, 1).GetOnCompleted().Insert(
HideEffects
);
55
return
;
56
}
57
58
HideEffects
();
59
}
60
61
//------------------------------------------------------------------------------------------------
63
protected
void
HideEffects
()
64
{
65
if
(!
m_wPoisonEffect1
|| !
m_wPoisonEffect2
)
66
return
;
67
68
m_wPoisonEffect1
.SetMaskProgress(0);
69
m_wPoisonEffect2
.SetMaskProgress(0);
70
m_wPoisonEffect2
.GetParent().SetVisible(
false
);
71
}
72
73
//------------------------------------------------------------------------------------------------
75
protected
void
StartEffects
()
76
{
77
if
(!
m_wPoisonEffect1
|| !
m_wPoisonEffect2
)
78
return
;
79
80
UpdateAnimation
(
m_wPoisonEffect1
);
81
UpdateAnimation
(
m_wPoisonEffect2
);
82
83
m_wPoisonEffect1
.GetParent().SetVisible(
true
);
84
}
85
86
//------------------------------------------------------------------------------------------------
89
protected
void
UpdateAnimation
(notnull
ImageWidget
widget)
90
{
91
float
speedFactor = 1;
92
float
targetOpacity = 1;
93
if
(widget.GetOpacity() >
m_fMinEnabledEffectOpacity
)
94
{
95
targetOpacity =
m_fMinEnabledEffectOpacity
;
96
speedFactor = 0.5;
97
}
98
99
AnimateWidget
.
Opacity
(widget, targetOpacity, (
m_fAnimationSpeed
+
SCR_Math
.
RandomFloat
(0,
m_fMaxRandomAnimationSpeedDifference
)) * speedFactor);
100
}
101
102
//------------------------------------------------------------------------------------------------
103
override
void
SetEnabled
(
bool
isEnabled)
104
{
105
if
(isEnabled)
106
StartEffects
();
107
else
108
ClearEffects
();
109
110
super.SetEnabled(isEnabled);
111
}
112
113
//------------------------------------------------------------------------------------------------
114
override
void
DisplayControlledEntityChanged
(
IEntity
from,
IEntity
to)
115
{
116
SetEnabled
(
false
);
117
HideEffects
();
118
119
ChimeraCharacter
character =
ChimeraCharacter
.Cast(to);
120
if
(!character)
121
return
;
122
123
SCR_CharacterDamageManagerComponent
dmgManager =
SCR_CharacterDamageManagerComponent
.Cast(character.GetDamageManager());
124
if
(!dmgManager)
125
return
;
126
127
const
HitZone
defaultHitZone = dmgManager.GetDefaultHitZone();
128
129
array<ref SCR_PersistentDamageEffect> effects = {};
130
if
(dmgManager.FindAllDamageEffectsOfTypeOnHitZone(
SCR_PoisonDamageEffect
, defaultHitZone, effects) < 1)
131
return
;
132
133
// find all damage effects that are important for this screen effect and add it
134
SCR_PoisonDamageEffect
poisonEffect;
135
foreach
(
SCR_PersistentDamageEffect
effect : effects)
136
{
137
poisonEffect =
SCR_PoisonDamageEffect
.Cast(effect);
138
if
(!poisonEffect)
139
continue
;
140
141
// add them but dont start the effect as its will be done afterwards just once
142
OnDamageEffectAdded
(poisonEffect,
false
);
143
}
144
145
if
(!
m_DamageEffects
||
m_DamageEffects
.IsEmpty())
146
return
;
147
148
// now that we are sure that there is a reason to tick this effect start it
149
SetEnabled
(
true
);
150
}
151
152
//------------------------------------------------------------------------------------------------
156
void
OnDamageEffectAdded
(notnull
DotDamageEffect
dmgEffect,
bool
updateVisuals =
true
)
157
{
158
if
(!
m_DamageEffects
)
159
m_DamageEffects
=
new
set<DotDamageEffect>();
160
161
if
(!
m_DamageEffects
.Insert(dmgEffect))
162
return
;
163
164
if
(!updateVisuals)
165
return
;
166
167
SetEnabled
(
true
);
168
}
169
170
//------------------------------------------------------------------------------------------------
173
void
OnDamageEffectRemoved
(notnull
DotDamageEffect
dmgEffect)
174
{
175
if
(
m_DamageEffects
.RemoveItem(dmgEffect))
176
{
177
if
(
m_DamageEffects
.IsEmpty())
178
SetEnabled
(
false
);
179
}
180
}
181
182
//------------------------------------------------------------------------------------------------
183
override
protected
void
DisplayUpdate
(
IEntity
owner,
float
timeSlice)
184
{
185
if
(!
m_DamageEffects
||
m_DamageEffects
.IsEmpty())
186
{
187
SetEnabled
(
false
);
188
return
;
189
}
190
191
float
newMaskProgress;
192
//const Widget parent = m_wPoisonEffect1.GetMaskProgress();
193
newMaskProgress =
Math
.Max(
m_wPoisonEffect1
.GetMaskProgress(),
m_fMinEnabledAlpha
);
194
EvaluateDamageEffects
(newMaskProgress);
195
newMaskProgress =
Math
.Min(
Math
.Lerp(
m_wPoisonEffect1
.GetMaskProgress(), newMaskProgress, timeSlice),
m_fMaxEnabledAlpha
);
196
197
m_wPoisonEffect1
.SetMaskProgress(newMaskProgress);
198
m_wPoisonEffect2
.SetMaskProgress(newMaskProgress);
199
200
if
(!
AnimateWidget
.
IsAnimating
(
m_wPoisonEffect1
))
201
UpdateAnimation
(
m_wPoisonEffect1
);
202
203
if
(!
AnimateWidget
.
IsAnimating
(
m_wPoisonEffect2
))
204
UpdateAnimation
(
m_wPoisonEffect2
);
205
}
206
207
//------------------------------------------------------------------------------------------------
210
protected
void
EvaluateDamageEffects
(inout
float
newMaskProgress)
211
{
212
SCR_BatchedPoisonDamageEffects
batchedData =
SCR_BatchedPoisonDamageEffects
.Cast(
m_DamageSystem
.GetBatchedDataForLocalCharacter(
SCR_PoisonDamageEffect
));
213
if
(batchedData)
214
newMaskProgress = batchedData.m_fDamageValue *
m_fDamageToOpacityFactor
;
215
}
216
}
m_wRoot
Widget m_wRoot
Definition
SCR_GameModeCleanSweep.c:25
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
AnimateWidget
Definition
AnimateWidget.c:3
AnimateWidget::Opacity
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
Definition
AnimateWidget.c:167
AnimateWidget::AlphaMask
static WidgetAnimationAlphaMask AlphaMask(Widget widget, float targetValue, float speed)
Definition
AnimateWidget.c:189
AnimateWidget::StopAllAnimations
static void StopAllAnimations(Widget w)
Definition
AnimateWidget.c:73
AnimateWidget::IsAnimating
static bool IsAnimating(Widget w)
Definition
AnimateWidget.c:86
ChimeraCharacter
Definition
ChimeraCharacter.c:13
DotDamageEffect
Definition
DotDamageEffect.c:13
HitZone
Definition
HitZone.c:13
IEntity
Definition
IEntity.c:13
ImageWidget
Definition
ImageWidget.c:13
Math
Definition
Math.c:13
SCR_BaseScreenEffect
Definition
SCR_BaseScreenEffect.c:2
SCR_BatchedPoisonDamageEffects
Definition
SCR_BatchedPoisonDamageEffects.c:2
SCR_CharacterDamageManagerComponent
Definition
SCR_CharacterDamageManagerComponent.c:19
SCR_DamageSufferingSystem
Definition
SCR_DamageSufferingSystem.c:2
SCR_Math
Definition
SCR_Math.c:2
SCR_Math::RandomFloat
static float RandomFloat(float min, float max)
Definition
SCR_Math.c:18
SCR_PersistentDamageEffect
Definition
SCR_PersistentDamageEffect.c:7
SCR_PoisonDamageEffect
Definition
SCR_PoisonDamageEffect.c:2
SCR_PoisonScreenEffect
Definition
SCR_PoisonScreenEffect.c:4
SCR_PoisonScreenEffect::m_wPoisonEffect1
ImageWidget m_wPoisonEffect1
Definition
SCR_PoisonScreenEffect.c:23
SCR_PoisonScreenEffect::DisplayUpdate
void DisplayUpdate(IEntity owner, float timeSlice)
Definition
SCR_PoisonScreenEffect.c:183
SCR_PoisonScreenEffect::UpdateAnimation
void UpdateAnimation(notnull ImageWidget widget)
Definition
SCR_PoisonScreenEffect.c:89
SCR_PoisonScreenEffect::m_fMinEnabledEffectOpacity
float m_fMinEnabledEffectOpacity
Definition
SCR_PoisonScreenEffect.c:12
SCR_PoisonScreenEffect::OnDamageEffectRemoved
void OnDamageEffectRemoved(notnull DotDamageEffect dmgEffect)
Definition
SCR_PoisonScreenEffect.c:173
SCR_PoisonScreenEffect::StartEffects
void StartEffects()
Definition
SCR_PoisonScreenEffect.c:75
SCR_PoisonScreenEffect::EvaluateDamageEffects
void EvaluateDamageEffects(inout float newMaskProgress)
Definition
SCR_PoisonScreenEffect.c:210
SCR_PoisonScreenEffect::m_wPoisonEffect2
ImageWidget m_wPoisonEffect2
Definition
SCR_PoisonScreenEffect.c:24
SCR_PoisonScreenEffect::m_fDamageToOpacityFactor
float m_fDamageToOpacityFactor
Definition
SCR_PoisonScreenEffect.c:21
SCR_PoisonScreenEffect::DisplayStartDraw
override void DisplayStartDraw(IEntity owner)
Definition
SCR_PoisonScreenEffect.c:30
SCR_PoisonScreenEffect::m_DamageSystem
SCR_DamageSufferingSystem m_DamageSystem
Definition
SCR_PoisonScreenEffect.c:26
SCR_PoisonScreenEffect::HideEffects
void HideEffects()
Definition
SCR_PoisonScreenEffect.c:63
SCR_PoisonScreenEffect::m_fMinEnabledAlpha
float m_fMinEnabledAlpha
Definition
SCR_PoisonScreenEffect.c:6
SCR_PoisonScreenEffect::DisplayControlledEntityChanged
override void DisplayControlledEntityChanged(IEntity from, IEntity to)
Definition
SCR_PoisonScreenEffect.c:114
SCR_PoisonScreenEffect::m_fMaxEnabledAlpha
float m_fMaxEnabledAlpha
Definition
SCR_PoisonScreenEffect.c:9
SCR_PoisonScreenEffect::m_DamageEffects
ref set< DotDamageEffect > m_DamageEffects
Definition
SCR_PoisonScreenEffect.c:27
SCR_PoisonScreenEffect::SetEnabled
override void SetEnabled(bool isEnabled)
Definition
SCR_PoisonScreenEffect.c:103
SCR_PoisonScreenEffect::OnDamageEffectAdded
void OnDamageEffectAdded(notnull DotDamageEffect dmgEffect, bool updateVisuals=true)
Definition
SCR_PoisonScreenEffect.c:156
SCR_PoisonScreenEffect::ClearEffects
override void ClearEffects()
Definition
SCR_PoisonScreenEffect.c:39
SCR_PoisonScreenEffect::m_fMaxRandomAnimationSpeedDifference
float m_fMaxRandomAnimationSpeedDifference
Definition
SCR_PoisonScreenEffect.c:18
SCR_PoisonScreenEffect::m_fAnimationSpeed
float m_fAnimationSpeed
Definition
SCR_PoisonScreenEffect.c:15
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
UI
ScreenEffects
SCR_PoisonScreenEffect.c
Generated by
1.17.0