Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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 
19  static bool ClampHeading (float pDt, SDayZPlayerHeadingModel pModel, out float pLastHeadingDiff)
20  {
21  float aDiff = pModel.m_fHeadingAngle - pModel.m_fOrientationAngle;
22  if (aDiff < -Math.PI)
23  {
24  aDiff += Math.PI2;
25  }
26  else if (aDiff > Math.PI)
27  {
28  aDiff -= Math.PI2;
29  }
30 
31  // Print("Heading model: or: " + pModel.m_fOrientationAngle.ToString() + " head:" + pModel.m_fHeadingAngle.ToString() + " dif:" + aDiff.ToString());
32 
33  if (pLastHeadingDiff < -Math.PI_HALF && aDiff > 0)
34  {
35  aDiff = -Math.PI + 0.01;
36  pLastHeadingDiff = aDiff;
37  pModel.m_fHeadingAngle = pModel.m_fOrientationAngle + aDiff;
38 
39  // Print("-APA- : or: " + pModel.m_fOrientationAngle.ToString() + " head:" + pModel.m_fHeadingAngle.ToString() + " dif:" + aDiff.ToString());
40 
41  return true; // modify heading
42  }
43  else if (pLastHeadingDiff > Math.PI_HALF && aDiff < 0)
44  {
45  aDiff = Math.PI - 0.01;
46  pLastHeadingDiff = aDiff;
47  pModel.m_fHeadingAngle = pModel.m_fOrientationAngle + aDiff;
48 
49  // Print("-APA- : or: " + pModel.m_fOrientationAngle.ToString() + " head:" + pModel.m_fHeadingAngle.ToString() + " dif:" + aDiff.ToString());
50 
51  return true; // modify heading
52  }
53 
54  pLastHeadingDiff = aDiff;
55  // Print("Heading model diff " + aDiff.ToString());
56  return false;
57  }
58 
59  //-------------------------------------------------------------
63 
64  static float CONST_ROTLIMIT = Math.PI * 0.95;
65 
67  static bool RotateOrient (float pDt, SDayZPlayerHeadingModel pModel, out float pLastHeadingDiff)
68  {
69  float aDiff = pModel.m_fHeadingAngle - pModel.m_fOrientationAngle;
70 
71  while (aDiff < -Math.PI)
72  {
73  aDiff += Math.PI2;
74  }
75  while (aDiff > Math.PI)
76  {
77  aDiff -= Math.PI2;
78  }
79 
80  // Print("Heading model: or: " + pModel.m_fOrientationAngle.ToString() + " head:" + pModel.m_fHeadingAngle.ToString() + " dif:" + aDiff.ToString());
81 
82  if (pLastHeadingDiff < -Math.PI_HALF && aDiff > 0)
83  {
84  aDiff -= Math.PI2;
85  }
86  else if (pLastHeadingDiff > Math.PI_HALF && aDiff < 0)
87  {
88  aDiff += Math.PI2;
89  }
90 
91  pLastHeadingDiff = aDiff;
92  if (aDiff < -CONST_ROTLIMIT)
93  {
94  // character is somehow stucked (happens in prone stance)
95  if (aDiff < -(Math.PI_HALF + CONST_ROTLIMIT))
96  {
97  pLastHeadingDiff = 0;
98  return false;
99  }
100 
101  pModel.m_fOrientationAngle += aDiff + CONST_ROTLIMIT;
102  return true;
103  }
104  else if (aDiff > CONST_ROTLIMIT)
105  {
106  // character is somehow stucked (happens in prone stance)
107  if (aDiff > (Math.PI_HALF + CONST_ROTLIMIT))
108  {
109  pLastHeadingDiff = 0;
110  return false;
111  }
112 
113  pModel.m_fOrientationAngle += aDiff - CONST_ROTLIMIT;
114  return true;
115  }
116 
117  // Print("Heading model diff " + aDiff.ToString());
118  return false;
119 
120  }
121 
122  static bool NoHeading(float pDt, SDayZPlayerHeadingModel pModel, out float pLastHeadingDiff)
123  {
124  pLastHeadingDiff = 0;
125  pModel.m_fHeadingAngle = pModel.m_fOrientationAngle;
126  return true;
127  }
128 
129 
130 
131 }
132 
SDayZPlayerHeadingModel
private void SDayZPlayerHeadingModel()
cannot be created from script
Definition: dayzplayer.c:1080
DayZPlayerImplementHeading
Definition: dayzplayerimplementheading.c:10
Math
Definition: enmath.c:6