Dayz
Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Toggle main menu visibility
Loading...
Searching...
No Matches
kurushake.c
Go to the documentation of this file.
1
class
KuruShake
2
{
3
const
float
RANDOM_RANGE_POINT
= 1;
4
const
float
RANDOM_RANGE_DEVIATION
= 0.50;
5
const
float
SHAKE_DURATION_PHASE1
= 0.01;
6
const
float
SHAKE_STRENGTH_MIN
= 1;
7
const
float
SHAKE_STRENGTH_MAX
= 5;
8
9
PlayerBase
m_Player
;
10
float
m_Time
;
11
float
m_Time2
;
12
float
m_RelativeTime
;
13
float
m_RelativeTime2
;
14
float
m_ShakeStrength
;
15
16
17
ref
array<vector>
m_Curve
=
new
array<vector>
;
18
19
void
KuruShake
(
PlayerBase
player,
float
amount)
20
{
21
22
vector
pos1;
23
int
seed =
Math
.
Randomize
(player.GetRandomGeneratorSyncManager().GetRandomInRange(
RandomGeneratorSyncUsage
.RGSGeneric,0,10000));
24
Math
.
RandomFloat
(-
RANDOM_RANGE_POINT
,
RANDOM_RANGE_POINT
);
//throw away
25
m_ShakeStrength
=
Math
.
Lerp
(
SHAKE_STRENGTH_MIN
,
SHAKE_STRENGTH_MAX
, amount);
26
pos1[0] =
Math
.
RandomFloat
(-
RANDOM_RANGE_POINT
,
RANDOM_RANGE_POINT
);
27
pos1[1] =
Math
.
RandomFloat
(-
RANDOM_RANGE_POINT
,
RANDOM_RANGE_POINT
);
28
pos1.
Normalize
();
29
pos1 = pos1 *
m_ShakeStrength
;
30
31
vector
pos2;
32
pos2[0] = pos1[0] +
Math
.
RandomFloat
(-
RANDOM_RANGE_DEVIATION
,
RANDOM_RANGE_DEVIATION
) + pos1[0];
33
pos2[1] = pos1[1] +
Math
.
RandomFloat
(-
RANDOM_RANGE_DEVIATION
,
RANDOM_RANGE_DEVIATION
) + pos1[1];
34
m_Curve
.Insert(
"0 0 0"
);
35
m_Curve
.Insert(pos1);
36
m_Curve
.Insert(pos2);
37
38
/*
39
Print("==========================");
40
for(int i = 0; i < m_Curve.Count(); i++)
41
{
42
Print(m_Curve[i]);
43
}
44
Print("==========================");
45
*/
46
}
47
48
void
Update
(
float
delta_time, out
float
pos_x, out
float
pos_y )
49
{
50
if
(
m_RelativeTime
< 0.99)
51
{
52
m_Time
+= delta_time;
53
m_RelativeTime
=
Math
.
InverseLerp
(0,
SHAKE_DURATION_PHASE1
,
m_Time
);
54
//m_RelativeTime = m_RelativeTime - 0.01;
55
m_RelativeTime
=
Easing
.
EaseInQuint
(
m_RelativeTime
);
56
vector
pos =
Math3D
.
Curve
(
ECurveType
.CatmullRom,
m_RelativeTime
,
m_Curve
);
57
pos_x = pos[0];
58
pos_y = pos[1];
59
}
60
else
61
{
62
m_Time2
+= delta_time * 1;
63
m_RelativeTime2
= 1 -
m_Time2
;
64
m_RelativeTime2
=
Easing
.
EaseInQuint
(
m_RelativeTime2
);
65
vector
pos2 =
Math3D
.
Curve
(
ECurveType
.CatmullRom,
m_RelativeTime2
,
m_Curve
);
66
pos_x = pos2[0];
67
pos_y = pos2[1];
68
}
69
70
if
(
m_Time2
>= 0.99)
71
{
72
delete
this
;
73
}
74
}
75
76
77
78
}
Easing
Input value between 0 and 1, returns value adjusted by easing, no automatic clamping of input(do your...
Definition
easing.c:3
Easing::EaseInQuint
static float EaseInQuint(float t)
Definition
easing.c:78
KuruShake::m_RelativeTime2
float m_RelativeTime2
Definition
kurushake.c:13
KuruShake::RANDOM_RANGE_DEVIATION
const float RANDOM_RANGE_DEVIATION
Definition
kurushake.c:4
KuruShake::m_Time
float m_Time
Definition
kurushake.c:10
KuruShake::m_Curve
ref array< vector > m_Curve
Definition
kurushake.c:17
KuruShake::SHAKE_STRENGTH_MIN
const float SHAKE_STRENGTH_MIN
Definition
kurushake.c:6
KuruShake::m_Time2
float m_Time2
Definition
kurushake.c:11
KuruShake::Update
void Update(float delta_time, out float pos_x, out float pos_y)
Definition
kurushake.c:48
KuruShake::m_Player
PlayerBase m_Player
Definition
kurushake.c:9
KuruShake::SHAKE_DURATION_PHASE1
const float SHAKE_DURATION_PHASE1
Definition
kurushake.c:5
KuruShake::RANDOM_RANGE_POINT
const float RANDOM_RANGE_POINT
Definition
kurushake.c:3
KuruShake::KuruShake
void KuruShake(PlayerBase player, float amount)
Definition
kurushake.c:19
KuruShake::SHAKE_STRENGTH_MAX
const float SHAKE_STRENGTH_MAX
Definition
kurushake.c:7
KuruShake::m_RelativeTime
float m_RelativeTime
Definition
kurushake.c:12
KuruShake::m_ShakeStrength
float m_ShakeStrength
Definition
kurushake.c:14
Math3D
Definition
enmath3d.c:28
Math
Definition
enmath.c:7
PlayerBase
Definition
playerbaseclient.c:2
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition
isboxcollidinggeometryproxyclasses.c:28
vector
Definition
enconvert.c:119
vector::Normalize
proto float Normalize()
Normalizes vector.
ECurveType
ECurveType
Definition
enmath3d.c:21
Math3D::Curve
static proto native vector Curve(ECurveType type, float param, notnull array< vector > points)
Computes curve.
Math::Randomize
static proto int Randomize(int seed)
Sets the seed for the random number generator.
Math::InverseLerp
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
Math::RandomFloat
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
Math::Lerp
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
RandomGeneratorSyncUsage
RandomGeneratorSyncUsage
Definition
randomgeneratorsyncmanager.c:2
Games
Dayz
scripts
4_world
classes
kurushake.c
Generated by
1.17.0