Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
pperhmpghosts.c
Go to the documentation of this file.
1class PPERequester_HMPGhosts extends PPERequester_GameplayBase
2{
3 protected bool m_PulseActive;
4 protected float m_PulseProgress;
5
6 protected ref array<float> m_ChannelWeights = { 0, 0, 0, 0 };
7 protected ref array<float> m_ColorMod = { 1, 1, 1, 1 };
8
9 protected bool m_Stopping;
10 protected bool m_StopNext;
11 protected float m_FadeOutTimeTarget;
12 protected float m_FadingTimeElapsed;
13 protected float m_FadingProgress;
14 protected float m_ElapsedTime;
15
16 override protected void OnStart(Param par = null)
17 {
18 super.OnStart(par);
19
20 m_Stopping = false;
21 m_StopNext = false;
22 m_ElapsedTime = 0.0;
24 m_FadingProgress = 0.0;
25
26 //following changes only performed once, on start
27 //noise
28 float nScaleX = 0.05; //inverse scaling!
29 float nScaleY = 0.05; //inverse scaling!
30 //ghosts
31 float gOffsetX = 30;
32 float gOffsetY = 13;
33 float gScaleX = 1; //inverse scaling!
34 float gScaleY = 1; //inverse scaling!
35 //color modulation
36 m_ColorMod[0] = 0.8;
37 m_ColorMod[1] = 0.8;
38 m_ColorMod[2] = 0.8;
39 m_ColorMod[3] = 0.85;
40
41 SetTargetValueFloat(PostProcessEffectType.Ghost,PPEGhost.PARAM_NOISE_SCALE_X,false, nScaleX,PPEGhost.L_4_HMP,PPOperators.LOWEST);
42 SetTargetValueFloat(PostProcessEffectType.Ghost,PPEGhost.PARAM_NOISE_SCALE_Y,false, nScaleY,PPEGhost.L_5_HMP,PPOperators.LOWEST);
43 SetTargetValueFloat(PostProcessEffectType.Ghost,PPEGhost.PARAM_GHOST_OFFSET_X,false, gOffsetX,PPEGhost.L_6_HMP,PPOperators.ADD);
44 SetTargetValueFloat(PostProcessEffectType.Ghost,PPEGhost.PARAM_GHOST_OFFSET_Y,false, gOffsetY,PPEGhost.L_7_HMP,PPOperators.ADD);
45 SetTargetValueFloat(PostProcessEffectType.Ghost,PPEGhost.PARAM_GHOST_SCALE_X,false, gScaleX,PPEGhost.L_8_HMP,PPOperators.LOWEST);
46 SetTargetValueFloat(PostProcessEffectType.Ghost,PPEGhost.PARAM_GHOST_SCALE_Y,false, gScaleY,PPEGhost.L_9_HMP,PPOperators.LOWEST);
48 }
49
50 override protected void OnUpdate(float delta)
51 {
52 if (m_StopNext)
53 {
54 if (m_IsRunning)
55 Stop();
56 return;
57 }
58
59 if (m_IsRunning)
60 ProcessSimulation(delta);
61
62 super.OnUpdate(delta);
63
64 if (m_IsRunning)
66 }
67
68 protected void ProcessSimulation(float delta)
69 {
70 if (m_Stopping)
71 ProcessFading(delta);
72
73 if (m_PulseActive)
74 {
75 //channel weights
76 float time = m_ElapsedTime * 0.65;
77 SampleChannels(time);
78 ReSampleChannels(time);
79
80 //noise
81 float nOffsetX = (Math.Sin( time * 0.29 ) * 0.5 + 0.5) * 0.3;
82 float nOffsetY = (Math.Cos( time * 0.17 ) * 0.5 + 0.5) * 0.3;
83
84 //channel remapping
85 float animLo = (Math.Sin( time ) * 0.5 + 0.5) * 1;
86 float animHi = (Math.Sin( time ) * 0.5 + 0.5) * 1;
87 float rmpLoAll = Math.Lerp(0.1,0.3,animLo);
88 float rmpHiAll = Math.Lerp(0.9,1.2,animHi);
89
90 SetTargetValueColor(PostProcessEffectType.Ghost,PPEGhost.PARAM_NOISE_CHANNEL_WEIGHT,m_ChannelWeights,PPEGhost.L_1_HMP,PPOperators.SET);
91 SetTargetValueFloat(PostProcessEffectType.Ghost,PPEGhost.PARAM_NOISE_OFFSET_X,false, nOffsetX,PPEGhost.L_2_HMP,PPOperators.ADD);
92 SetTargetValueFloat(PostProcessEffectType.Ghost,PPEGhost.PARAM_NOISE_OFFSET_Y,false, nOffsetY,PPEGhost.L_3_HMP,PPOperators.ADD);
93 SetTargetValueColor(PostProcessEffectType.Ghost,PPEGhost.PARAM_NOISE_REMAP_LO,{rmpLoAll,rmpLoAll,rmpLoAll,rmpLoAll},PPEGhost.L_1_HMP,PPOperators.SET);
94 SetTargetValueColor(PostProcessEffectType.Ghost,PPEGhost.PARAM_NOISE_REMAP_HI,{rmpHiAll,rmpHiAll,rmpHiAll,rmpHiAll},PPEGhost.L_1_HMP,PPOperators.SET);
95
97 }
98
99 m_ElapsedTime += delta;
100 }
101
102 protected void SampleChannels(float time)
103 {
104 float offset;
105 // luckily 4 channels * 90 fit into 360 nicely, so no need to distribute weights other way
106 for (int i = 0; i < 4; ++i)
107 {
108 offset = i * Math.PI_HALF;
109 m_ChannelWeights[i] = Math.Sin( time + offset );
110 }
111 }
112
113 protected void ReSampleChannels(float time)
114 {
115 float rampingCoef = 1.1;
116 float w = Math.Clamp((Math.Sin(m_PulseProgress * Math.PI) * rampingCoef),0,1);
117 w = Math.Lerp(0,w,1 - m_FadingProgress);
118
119 for (int i = 0; i < 4; ++i)
121 }
122
123 protected void ProcessFading(float delta)
124 {
125 m_FadingTimeElapsed += delta;
127
129 }
130
131 void SetPulseProgress(float progress) //0..1
132 {
133 m_PulseActive = true;
134 m_PulseProgress = progress;
135 }
136
137 void FadeOutEffect(float targetTime)
138 {
139 m_Stopping = true;
140 m_FadeOutTimeTarget = targetTime;
142 }
143}
Definition enmath.c:7
Ghost - PostProcessEffectType.Ghost.
Definition ppeghost.c:3
base, not to be used directly, would lead to layering collisions!
void SetPulseProgress(float progress)
void ReSampleChannels(float time)
void OnStart(Param par=null)
void SampleChannels(float time)
void OnUpdate(float delta)
void ProcessFading(float delta)
void FadeOutEffect(float targetTime)
ref array< float > m_ColorMod
ref array< float > m_ChannelWeights
void ProcessSimulation(float delta)
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
PostProcessEffectType
Post-process effect type.
Definition enworld.c:72
void Stop()
Stops all elements this effect consists of.
Definition effect.c:183
PPOperators
PP operators, specify operation between subsequent layers.
bool m_IsRunning
void SetTargetValueFloat(int mat_id, int param_idx, bool relative, float val, int priority_layer, int operator=PPOperators.ADD_RELATIVE)
void SetTargetValueColor(int mat_id, int param_idx, array< float > val, int priority_layer, int operator=PPOperators.ADD_RELATIVE)
void SetRequesterUpdating(bool state)
Has to be set for the requester to be handled.