File size: 1,535 Bytes
24b81cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class CameraShake
{
	const float MIN_PLAYER_DISTANCE = 40;
	
	float m_Radius;
	float m_RadiusDecaySpeed;
	float m_RandomAngle;
	float m_Time;
	float m_InitLR;
	float m_InitUD;
	bool m_ToDelete;
	float m_Smoothness;
	float m_StregthFactor;
	DayZPlayerImplement m_Player;
	
	void ~CameraShake()
	{
		if(m_Player)
			m_Player.GetAimingModel().SetCamShakeValues(0, 0);

	}
	
	void CameraShake( float strength_factor, float radius, float smoothness, float radius_decay_speed )
	{
		/*
		
		Print("-----------ON CREATE------------");
		Print(camera_offset);
		Print("-----------ON CREATE END------------");
		*/
		//m_Player = DayZPlayerImplement.Cast(player);
		m_Player = DayZPlayerImplement.Cast(GetGame().GetPlayer());
		m_StregthFactor = strength_factor;
		//m_InitLR = lr_angle;
		//m_InitUD = ud_angle;
		m_Radius = radius;
		m_RadiusDecaySpeed = radius_decay_speed;
		m_Smoothness = smoothness;
	}
	
	void Update(float delta_time, out float x_axis, out float y_axis)
	{
		if(m_ToDelete)
			delete this;
		
		m_Radius -= delta_time * m_RadiusDecaySpeed; //diminish radius each frame
		
		if( m_RandomAngle >= 0 )
		{
			m_RandomAngle = -m_Radius + (Math.RandomFloat( -m_Radius / m_Smoothness, m_Radius / m_Smoothness));
		}
		else
		{
			m_RandomAngle = m_Radius + (Math.RandomFloat( -m_Radius / m_Smoothness, m_Radius / m_Smoothness));
		}
		
		x_axis = m_RandomAngle * m_StregthFactor;
		y_axis = m_RandomAngle * m_StregthFactor;

		//Print(x_axis);
		//Print(y_axis);
		
		if( m_Radius < 0.01 )
		{
			m_ToDelete = true;
		}
	}
}