DayZ 1.24
Loading...
Searching...
No Matches
WeaponDebug.c
Go to the documentation of this file.
8
9
11{
12 const int BUFFER_SIZE = 1000;
17
28
30
31 //ref array<Selection> m_Selections = new array<Selection>();
32
44 //Shape temp_shape;
47
50
52 {
55 if (player && player.GetItemInHands()) Class.CastTo(weapon_in_hands, player.GetItemInHands());
56
57 return weapon_in_hands;
58 }
59
61 {
62 m_DebugModesNames.Insert(eDebugMode.NORMAL, "Mode " + eDebugMode.NORMAL.ToString() + ": shoot along the weapon barrel");
63 m_DebugModesNames.Insert(eDebugMode.MUZZLE_FIRE, "Mode " + eDebugMode.MUZZLE_FIRE.ToString() + ": shoot from muzzle end to camera trace hit point");
64 m_DebugModesNames.Insert(eDebugMode.CAMERA_MUZZLE_HYBRID, "Mode " + eDebugMode.CAMERA_MUZZLE_HYBRID.ToString() + ": shoot either from camera lens or from muzzle \n depending on the situation");
65 }
66
68 {
69 RemoveAllShapes(true);
70
71 }
72
95
96
98 {
99
100 m_IsLMBPressed = false;
101 m_IsFireKeyPressed = false;
102
103 if (KeyState(KeyCode.KC_LWIN) == 1)
104 {
106 OnKeyDown(KeyCode.KC_LWIN);
107 m_IsDrawKeyHeldDown = true;
108 }
109 else
110 {
112 {
113 //OnKeyUp();
114 }
115 m_IsDrawKeyHeldDown = false;
116 }
117
118 if (KeyState(KeyCode.KC_Z) == 1)
119 {
120 ClearKey(KeyCode.KC_Z);
122 }
123
124 if (KeyState(KeyCode.KC_X) == 1)
125 {
126 m_IsFireKeyPressed = true;
127 ClearKey(KeyCode.KC_X);
128 }
129
131 m_IsLMBPressed = true;
132 }
133
135 {
136 if (key == KeyCode.KC_X)
137 {
138 }
139 }
140
142 {
144 if (m_CurrentMode == eDebugMode.COUNT)
145 m_CurrentMode = 0;
146
147 }
148
150 {
151 if (GetWeaponInHands())
152 {
155 vector cameraDirection = GetGame().GetCurrentCameraDirection();
156 vector cameraPosition = GetGame().GetCurrentCameraPosition();
157 vector usti_hlavne_position = weapon.GetSelectionPositionMS("usti hlavne"); //usti hlavne
158 vector konec_hlavne_position = weapon.GetSelectionPositionMS("konec hlavne"); //konec hlavne
161
162 if (m_CurrentMode == eDebugMode.NORMAL)
164
165 if (m_CurrentMode == eDebugMode.MUZZLE_FIRE)
167
168 if (m_CurrentMode == eDebugMode.CAMERA_MUZZLE_HYBRID)
170
172 {
175 }
176
178
179
184 /*
185 vector pos;
186 weapon.GetProjectedCursorPos3d(pos);
187 Debug.RemoveShape(temp_shape);
188 temp_shape = Debug.DrawSphere(pos, 0.1, Colors.GREEN);
189 */
190 }
191 }
192
194 {
196 {
197 m_Shape_usti = Debug.DrawSphere(end_point, 0.011, Colors.GREEN, ShapeFlags.TRANSP | ShapeFlags.NOOUTLINE | ShapeFlags.NOZBUFFER);
198 m_Shape_konec = Debug.DrawSphere(begin_point, 0.011, Colors.GREEN, ShapeFlags.TRANSP | ShapeFlags.NOOUTLINE | ShapeFlags.NOZBUFFER);
199 }
200 }
201
202
225
233
246
252
254 {
255 string memory_point_name = weapon.ConfigGetString("memoryPointCamera");
256 ItemBase optics = weapon.GetAttachedOptics();
257 if (optics)
258 {
259 memory_point_name = optics.ConfigGetString("memoryPointCamera");
260 return optics.ModelToWorld(optics.GetSelectionPositionLS(memory_point_name));
261 }
262 return weapon.ModelToWorld(weapon.GetSelectionPositionLS(memory_point_name));
263
264 }
265
267 {
268 DbgUI.Begin("sway weight", 50, 50);
270 float sway_weight = player.GetAimingModel().GetSwayWeight();
271 DbgUI.Text("value: " + sway_weight.ToString());
272 DbgUI.Text("Hold LWIN to draw debug line");
273 DbgUI.Text("Press X to simulate fire");
274 DbgUI.Text("Press Z to cycle debug modes");
275 DbgUI.Text("Debug " + m_DebugModesNames.Get(m_CurrentMode));
276 DbgUI.Text("");
277 DbgUI.End();
278 }
279
281 {
282 DbgUI.Begin("target distance", 50, 200);
283 DbgUI.Text("value: " + m_TargetDistance.ToString());
284 DbgUI.End();
285 }
286
287
289 {
292
295
298
301
303 Man player = GetGame().GetPlayer();
306
308 {
312
314 {
319 }
320
321 }
322
323 else
324 {
326 m_TargetDistance = -1;
327 }
328
331 }
332
334 {
335 bool muzzle_shot;
338
340
343
345
348
349 float distance_to_aim_at;
353 weapon_aim_direction.Normalize();
354
355 Man player = GetGame().GetPlayer();
358
360 {
363
365 {
368
370 {
371 muzzle_shot = true;
373 }
374 }
375 }
376
377
379
381 {
385
387
388 if (muzzle_shot)
389 {
392 PrintString("muzle shot");
393 }
394 else
395 {
397 dir.Normalize();
398 dir = dir * 100;
401
402 //m_PermanentShape1 = Debug.DrawSphere(start_point, 0.015,Colors.GREEN);
404 PrintString("camera shot");
405 }
406 }
407
410 float hit_sphere_size = Math.Lerp(0.025, 0.75, distance_normalized);
411
416
417 }
418
419}
PlayerBase GetPlayer()
eDebugMode
Definition WeaponDebug.c:2
@ CAMERA_MUZZLE_HYBRID
Definition WeaponDebug.c:5
@ COUNT
Definition WeaponDebug.c:6
@ MUZZLE_FIRE
Definition WeaponDebug.c:4
@ NORMAL
Definition WeaponDebug.c:3
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition Colors.c:4
const int GREEN
Definition Colors.c:8
const int RED
Definition Colors.c:5
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.
Definition DbgUI.c:60
Definition Debug.c:14
static Shape DrawLines(vector[] positions, int count, int color=0xFFFFFFFF, int flags=0)
Definition Debug.c:502
static Shape DrawSphere(vector pos, float size=1, int color=0x1fff7f7f, ShapeFlags flags=ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE)
Definition Debug.c:434
static void RemoveShape(out Shape shape)
Definition Debug.c:107
static Shape DrawLine(vector from, vector to, int color=0xFFFFFFFF, int flags=0)
Definition Debug.c:489
Definition EnMath.c:7
Shape m_ShapeTrailLines
Definition WeaponDebug.c:39
void DrawBarrelMemoryPoints(vector begin_point, vector end_point)
vector m_AimTrailOrdered[BUFFER_SIZE]
Definition WeaponDebug.c:27
bool m_IsLMBPressed
Definition WeaponDebug.c:21
const float CAMERA_TRACE_MIN_DISTANCE_TOLERANCE
Definition WeaponDebug.c:16
bool m_IsFireKeyPressed
Definition WeaponDebug.c:23
bool m_IsToggleKeyPressed
Definition WeaponDebug.c:22
void DisplayGeneralInfo()
Shape m_Shape_konec
Definition WeaponDebug.c:34
void DrawLineOfFire(vector begin_point, vector end_point)
void DisplayTargetInfo()
void OnCommandHandlerUpdate()
Definition WeaponDebug.c:97
void OnKeyDown(KeyCode key)
const float COLLISIONS_DISTANCE_TOLERANCE
Definition WeaponDebug.c:13
Shape m_HitShape4
Definition WeaponDebug.c:43
void RemoveAllShapes(bool is_exit=false)
Definition WeaponDebug.c:73
const float MAX_MUZZLE_DISTANCE_TOLERANCE
Definition WeaponDebug.c:14
void DrawLineOfFireMuzzleToHit(vector begin_point, vector camera_dir, vector camera_pos)
ref map< int, string > m_DebugModesNames
Definition WeaponDebug.c:29
Shape m_PermanentLine2
Definition WeaponDebug.c:46
Shape m_Shape_usti
Definition WeaponDebug.c:33
vector m_AimTrailCyclic[BUFFER_SIZE]
Definition WeaponDebug.c:26
const float CAMERA_BULLET_ORIGIN_OFFSET
Definition WeaponDebug.c:15
Shape m_HitShape2
Definition WeaponDebug.c:41
Shape m_PermanentShape2
Definition WeaponDebug.c:49
vector GetEyePointPosition(Weapon weapon)
Shape m_PermanentLine1
Definition WeaponDebug.c:45
void CycleDebugMode()
bool m_IsDrawKeyHeldDown
Definition WeaponDebug.c:20
void WeaponDebug()
Definition WeaponDebug.c:60
Shape m_ShapeFireDirection2
Definition WeaponDebug.c:36
Shape m_PermanentShape1
Definition WeaponDebug.c:48
Shape m_HitShape3
Definition WeaponDebug.c:42
float m_TargetDistance
Definition WeaponDebug.c:24
Weapon GetWeaponInHands()
Definition WeaponDebug.c:51
void ~WeaponDebug()
Definition WeaponDebug.c:67
void OnPostFrameUpdate()
int m_BufferIndex
Definition WeaponDebug.c:19
void AddPosToCyclicBuffer(vector pos)
Shape m_ShapeFireDirection1
Definition WeaponDebug.c:35
void OrderTrailArray()
const int BUFFER_SIZE
Definition WeaponDebug.c:12
Weapon m_WeaponInHands
Definition WeaponDebug.c:18
void DrawLineOfFireCameraHybrid(vector usti_hlavne_position, vector camera_dir, vector camera_pos, vector konec_hlavne_position)
void DrawEyePoint(Weapon weapon)
eDebugMode m_CurrentMode
Definition WeaponDebug.c:25
Shape m_ShapeFireDirCamera
Definition WeaponDebug.c:40
Shape m_ShapeEye
Definition WeaponDebug.c:38
Shape m_HitShape
Definition WeaponDebug.c:37
script counterpart to engine's class Weapon
proto string ToString()
proto float Normalize()
Normalizes vector. Returns length.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto native CGame GetGame()
const int COLOR_BLUE
Definition constants.c:66
const int COLOR_RED
Definition constants.c:64
const int COLOR_YELLOW
Definition constants.c:67
ShapeFlags
Definition 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.
void PrintString(string s)
Helper for printing out string expression. Example: PrintString("Hello " + var);.
Definition EnScript.c:344
proto native void ClearKey(KeyCode key)
KeyCode
Definition EnSystem.c:157
proto native int KeyState(KeyCode key)
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
MouseState
Definition EnSystem.c:311
proto native int GetMouseState(MouseState index)