DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
WeaponDebug.c
См. документацию.
7
9{
10 const int BUFFER_SIZE = 1000;
11
13 int m_PointCount = 0;
21
23
24 //ref array<Selection> m_Selections = new array<Selection>();
25
29 //Shape temp_shape;
32
34 {
35 Weapon weaponInHands;
36 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
37 if (player)
38 {
39 Class.CastTo(weaponInHands, player.GetItemInHands());
40 }
41
42 return weaponInHands;
43 }
44
46 {
47 m_DebugModesNames.Insert(eWeaponDebugMode.NORMAL, "Mode "+eWeaponDebugMode.NORMAL.ToString()+": normal");
48 m_DebugModesNames.Insert(eWeaponDebugMode.LOCAL,"Mode "+eWeaponDebugMode.LOCAL.ToString()+": Ignore mouse move ");
49 }
50
52 {
53 RemoveAllShapes(true);
54
55 }
56
69
70
72 {
73 m_IsFireKeyPressed = false;
74
75 if (KeyState(KeyCode.KC_P) == 1)
76 {
78 {
79 OnKeyDown(KeyCode.KC_P);
80 }
82 }
83 else
84 {
86 {
87 //OnKeyUp();
88 }
89 m_IsDrawKeyHeldDown = false;
90 }
91
92 if (KeyState(KeyCode.KC_Z) == 1)
93 {
94 ClearKey(KeyCode.KC_Z);
96 m_PointCount = 0;
97 }
98
99 if (KeyState(KeyCode.KC_X) == 1)
100 {
101 m_IsFireKeyPressed = true;
102 ClearKey(KeyCode.KC_X);
103 }
104 }
105
107 {
108 if (key == KeyCode.KC_X)
109 {
110 }
111
112 if (key == KeyCode.KC_P)
113 {
114 m_PointCount = 0;
115 }
116 }
117
119 {
121 if ( m_CurrentMode == eWeaponDebugMode.COUNT )
122 {
123 m_CurrentMode = 0;
124 }
125
126 }
127
129 {
130 Weapon weapon = GetWeaponInHands();
131 if (weapon)
132 {
134
135 vector cameraDirection = g_Game.GetCurrentCameraDirection();
136 vector cameraPosition = g_Game.GetCurrentCameraPosition();
137 vector usti_hlavne_position = weapon.GetSelectionPositionLS( "usti hlavne" );//usti hlavne
138 usti_hlavne_position = weapon.ModelToWorld(usti_hlavne_position);
139
140 DrawLineOfFireMuzzleToHit(usti_hlavne_position, cameraDirection, cameraPosition);
141
142 if (m_PointCount)
143 {
144 if (m_CurrentMode == eWeaponDebugMode.LOCAL)
145 {
146 m_ShapeTrailLines = Debug.DrawLines( m_AimTrailOrdered,m_PointCount, COLOR_YELLOW, ShapeFlags.NOZBUFFER );//TODO Local space -> world space (player camera)
147 }
148 else
149 {
151 }
152 }
153
156 }
157 }
158
160 {
164 {
165 m_BufferIndex = 0;
166 }
168 {
169 m_PointCount++;
170 }
171 }
172
174 {
175 int unordered_index;
176 for (int i = 0; i < m_PointCount; i++)
177 {
178 unordered_index = m_BufferIndex - 1 - i;
179 if ( unordered_index < 0 )
180 {
181 unordered_index = BUFFER_SIZE + unordered_index;
182 }
183 m_AimTrailOrdered[i] = m_AimTrailCyclic[unordered_index];
184 }
185 }
186
188 {
189 DbgUI.Begin("sway weight", 50, 50);
190 DayZPlayerImplement player = DayZPlayerImplement.Cast(g_Game.GetPlayer());
191 float sway_weight = player.GetAimingModel().GetSwayWeight();
192 DbgUI.Text("value: " + sway_weight.ToString());
193 DbgUI.Text("Hold P to draw debug line");
194 DbgUI.Text("Press X to simulate fire");
195 //DbgUI.Text("Press Z to cycle debug modes");
196 //DbgUI.Text("Debug " +m_DebugModesNames.Get(m_CurrentMode) );
197 //DbgUI.Text("");
198 DbgUI.End();
199 }
200
202 {
203 DbgUI.Begin("target distance", 50,200);
204 DbgUI.Text("value: " + m_TargetDistance.ToString());
205 DbgUI.End();
206 }
207
208 void DrawLineOfFireMuzzleToHit(vector begin_point, vector camera_dir, vector camera_pos)
209 {
210 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
211 if (player.IsRaised())
212 {
213 vector transform[4];
214 player.GetTransformWS(transform);
215
216 HumanCommandWeapons hcw = player.GetCommandModifier_Weapons();
217 HumanInputController hic = player.GetInputController();
218
219 float UpDownBase = hcw.GetBaseAimingAngleUD();
220 float LeftRightBase = hcw.GetBaseAimingAngleLR();
221 float UpDownOffset = hcw.GetAimingHandsOffsetUD();
222 float LeftRightOffset = hcw.GetAimingHandsOffsetLR();
223
224
225 vector aimAngles = Vector(LeftRightBase + LeftRightOffset, UpDownBase + UpDownOffset, 0.0);
226 vector plrAngles = Math3D.MatrixToAngles(transform);
227
228 vector resAngle = aimAngles + plrAngles;
229
230 vector start = camera_pos;
231 //MiscGameplayFunctions.GetHeadBonePos(player, start);
232
233 vector direction = resAngle.AnglesToVector();
234
235 float range = 50.0;
236
237 vector end = start + (direction * range);
238 vector contact;
239 vector contactDir;
240 int muz;
241
243 if ( DayZPhysics.RaycastRV(start, end, contact, contactDir, muz, null, null, player, false, false, ObjIntersectFire, 0.0) )
244 {
245 m_TargetDistance = vector.Distance( player.GetPosition(), contact);
247 m_ShapeFireDirCamera = Debug.DrawLine(begin_point, contact, Colors.RED, ShapeFlags.NOZBUFFER );
248
249
251 {
252 if (m_CurrentMode == eWeaponDebugMode.LOCAL)
253 AddPosToCyclicBuffer(contact);//TODO change to local space
254 else
255 AddPosToCyclicBuffer(contact);
257 }
258
259 if ( m_IsFireKeyPressed )
260 {
263 m_PermanentLine1 = Debug.DrawLine(begin_point, contact, Colors.RED, ShapeFlags.NOZBUFFER );
264 m_PermanentLine2 = Debug.DrawLine(camera_pos, contact, Colors.GREEN, ShapeFlags.NOZBUFFER );
265 }
266
267
268
269
270 }
271 else
272 {
273 m_HitShape = Debug.DrawSphere(end, 0.15, COLOR_RED);
274
275 m_ShapeFireDirCamera = Debug.DrawLine(begin_point, end, Colors.GREEN, ShapeFlags.NOZBUFFER );
276 m_TargetDistance = -1;
277
279 {
280 if (m_CurrentMode == eWeaponDebugMode.LOCAL)
281 AddPosToCyclicBuffer(end);//TODO change to local space
282 else
285 }
286
287 if ( m_IsFireKeyPressed )
288 {
291 m_PermanentLine1 = Debug.DrawLine(begin_point, end, Colors.RED, ShapeFlags.NOZBUFFER );
292 m_PermanentLine2 = Debug.DrawLine(camera_pos, end, Colors.GREEN, ShapeFlags.NOZBUFFER );
293 }
294 }
295 }
296 }
297}
DayZGame g_Game
Определения DayZGame.c:4074
@ NORMAL
Определения ECameraZoomType.c:4
@ COUNT
Определения EGameStateIcons.c:7
@ LOCAL
Определения GizmoApi.c:13
eWeaponDebugMode
Определения WeaponDebug.c:2
Super root of all classes in Enforce script.
Определения EnScript.c:11
const int GREEN
Определения Colors.c:8
const int RED
Определения Colors.c:5
Определения Colors.c:4
static proto bool RaycastRV(vector begPos, vector endPos, out vector contactPos, out vector contactDir, out int contactComponent, set< Object > results=NULL, Object with=NULL, Object ignore=NULL, bool sorted=false, bool ground_only=false, int iType=ObjIntersectView, float radius=0.0, CollisionFlags flags=CollisionFlags.NEARESTCONTACT)
Raycasts world by given parameters.
Определения DayZPhysics.c:124
Определения ManBase.c:2
Определения DbgUI.c:60
static Shape DrawLines(vector[] positions, int count, int color=0xFFFFFFFF, int flags=0)
Определения 3_Game/DayZ/tools/Debug.c:487
static Shape DrawSphere(vector pos, float size=1, int color=0x1fff7f7f, ShapeFlags flags=ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE)
Определения 3_Game/DayZ/tools/Debug.c:395
static void RemoveShape(out Shape shape)
Определения 3_Game/DayZ/tools/Debug.c:113
static Shape DrawLine(vector from, vector to, int color=0xFFFFFFFF, int flags=0)
Определения 3_Game/DayZ/tools/Debug.c:474
Определения 3_Game/DayZ/tools/Debug.c:2
proto native float GetAimingHandsOffsetUD()
returns aiming hands up/down (y) offset angle
proto native float GetBaseAimingAngleLR()
returns base aiming angle LR - without sway/offsets/...
proto native float GetAimingHandsOffsetLR()
returns aiming hands left/right (x) offset angle
proto native float GetBaseAimingAngleUD()
returns base aiming angle UD - without sway/offsets/...
Определения human.c:1027
Определения human.c:18
Определения EnMath3D.c:28
Определения PlayerBaseClient.c:2
Shape m_ShapeTrailLines
Определения WeaponDebug.c:27
vector m_AimTrailOrdered[BUFFER_SIZE]
Определения WeaponDebug.c:20
bool m_IsFireKeyPressed
Определения WeaponDebug.c:16
void DisplayGeneralInfo()
Определения WeaponDebug.c:187
eWeaponDebugMode m_CurrentMode
Определения WeaponDebug.c:18
void DisplayTargetInfo()
Определения WeaponDebug.c:201
void CycleWeaponDebugMode()
Определения WeaponDebug.c:118
void OnCommandHandlerUpdate()
Определения WeaponDebug.c:71
void OnKeyDown(KeyCode key)
Определения WeaponDebug.c:106
void RemoveAllShapes(bool is_exit=false)
Определения WeaponDebug.c:57
void DrawLineOfFireMuzzleToHit(vector begin_point, vector camera_dir, vector camera_pos)
Определения WeaponDebug.c:208
ref map< int, string > m_DebugModesNames
Определения WeaponDebug.c:22
Shape m_PermanentLine2
Определения WeaponDebug.c:31
vector m_AimTrailCyclic[BUFFER_SIZE]
Определения WeaponDebug.c:19
Shape m_PermanentLine1
Определения WeaponDebug.c:30
bool m_IsDrawKeyHeldDown
Определения WeaponDebug.c:15
void WeaponDebug()
Определения WeaponDebug.c:45
float m_TargetDistance
Определения WeaponDebug.c:17
Weapon GetWeaponInHands()
Определения WeaponDebug.c:33
void ~WeaponDebug()
Определения WeaponDebug.c:51
void OnPostFrameUpdate()
Определения WeaponDebug.c:128
int m_BufferIndex
Определения WeaponDebug.c:12
int m_PointCount
Определения WeaponDebug.c:13
void AddPosToCyclicBuffer(vector pos)
Определения WeaponDebug.c:159
bool m_IsDrawKeyHeldDownPrev
Определения WeaponDebug.c:14
void OrderTrailArray()
Определения WeaponDebug.c:173
const int BUFFER_SIZE
Определения WeaponDebug.c:10
Shape m_ShapeFireDirCamera
Определения WeaponDebug.c:28
Shape m_HitShape
Определения WeaponDebug.c:26
script counterpart to engine's class Weapon
proto string ToString(bool simple=true)
Определения Transport.c:70
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto vector AnglesToVector()
Converts spherical coordinates (yaw, pitch, roll in degrees) to unit length vector.
Определения EnConvert.c:119
const int COLOR_RED
Определения 1_Core/DayZ/constants.c:64
const int COLOR_YELLOW
Определения 1_Core/DayZ/constants.c:67
ShapeFlags
Определения EnDebug.c:126
static proto native void End()
static proto native void Begin(string windowTitle, float x=0, float y=0)
static proto native void Text(string label)
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
proto native void ClearKey(KeyCode key)
KeyCode
Определения EnSystem.c:157
proto native int KeyState(KeyCode key)
static proto vector MatrixToAngles(vector mat[3])
Returns angles of rotation matrix.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.