DayZ 1.24
Loading...
Searching...
No Matches
DayZPlayerImplementHeading.c
Go to the documentation of this file.
1/*
2 DayZPlayerImplement
3
4 this file is implemenation of dayzPlayer in script
5 - logic of movement
6 - camera switching logic
7
8*/
9
11{
12
13 //-------------------------------------------------------------
17
20 {
21 float aDiff = pModel.m_fHeadingAngle - pModel.m_fOrientationAngle;
22 if (aDiff < -Math.PI)
23 aDiff += Math.PI2;
24 else if (aDiff > Math.PI)
25 aDiff -= Math.PI2;
26
27 // Print("Heading model: or: " + pModel.m_fOrientationAngle.ToString() + " head:" + pModel.m_fHeadingAngle.ToString() + " dif:" + aDiff.ToString());
28
30 {
31 aDiff = -Math.PI + 0.01;
33 pModel.m_fHeadingAngle = pModel.m_fOrientationAngle + aDiff;
34
35 // Print("-APA- : or: " + pModel.m_fOrientationAngle.ToString() + " head:" + pModel.m_fHeadingAngle.ToString() + " dif:" + aDiff.ToString());
36
37 return true; // modify heading
38 }
39 else if (pLastHeadingDiff > Math.PI_HALF && aDiff < 0)
40 {
41 aDiff = Math.PI - 0.01;
43 pModel.m_fHeadingAngle = pModel.m_fOrientationAngle + aDiff;
44
45 // Print("-APA- : or: " + pModel.m_fOrientationAngle.ToString() + " head:" + pModel.m_fHeadingAngle.ToString() + " dif:" + aDiff.ToString());
46
47 return true; // modify heading
48 }
49
51 // Print("Heading model diff " + aDiff.ToString());
52 return false;
53 }
54
55 //-------------------------------------------------------------
59
60 static float CONST_ROTLIMIT = Math.PI * 0.95;
61
64 {
65 float aDiff = pModel.m_fHeadingAngle - pModel.m_fOrientationAngle;
66
67 while (aDiff < -Math.PI)
68 aDiff += Math.PI2;
69 while (aDiff > Math.PI)
70 aDiff -= Math.PI2;
71
72 // Print("Heading model: or: " + pModel.m_fOrientationAngle.ToString() + " head:" + pModel.m_fHeadingAngle.ToString() + " dif:" + aDiff.ToString());
73
75 aDiff -= Math.PI2;
76 else if (pLastHeadingDiff > Math.PI_HALF && aDiff < 0)
77 aDiff += Math.PI2;
78
80 if (aDiff < -CONST_ROTLIMIT)
81 {
82 // character is somehow stucked (happens in prone stance)
84 {
86 return false;
87 }
88
89 pModel.m_fOrientationAngle += aDiff + CONST_ROTLIMIT;
90 return true;
91 }
92 else if (aDiff > CONST_ROTLIMIT)
93 {
94 // character is somehow stucked (happens in prone stance)
96 {
98 return false;
99 }
100
101 pModel.m_fOrientationAngle += aDiff - CONST_ROTLIMIT;
102 return true;
103 }
104
105 // Print("Heading model diff " + aDiff.ToString());
106 return false;
107
108 }
109
111 {
113 pModel.m_fHeadingAngle = pModel.m_fOrientationAngle;
114 return true;
115 }
116
117
118}
119
static bool NoHeading(float pDt, SDayZPlayerHeadingModel pModel, out float pLastHeadingDiff)
static bool RotateOrient(float pDt, SDayZPlayerHeadingModel pModel, out float pLastHeadingDiff)
static bool ClampHeading(float pDt, SDayZPlayerHeadingModel pModel, out float pLastHeadingDiff)
Definition EnMath.c:7
void SDayZPlayerHeadingModel()
cannot be created from script
static const float PI2
Definition EnMath.c:13
static const float PI_HALF
Definition EnMath.c:14
static const float PI
Definition EnMath.c:12