56 if( player && player.GetItemInHands() )
Class.
CastTo(weapon_in_hands, player.GetItemInHands());
58 return weapon_in_hands;
65 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");
164 vector usti_hlavne_position = weapon.GetSelectionPositionMS(
"usti hlavne" );
165 vector konec_hlavne_position = weapon.GetSelectionPositionMS(
"konec hlavne" );
166 usti_hlavne_position = weapon.ModelToWorld(usti_hlavne_position);
167 konec_hlavne_position = weapon.ModelToWorld(konec_hlavne_position);
220 vector aim_point = end_point - begin_point;
221 int contact_component;
224 aim_point = aim_point + end_point;
229 if (
DayZPhysics.
RaycastRV(end_point, aim_point, contact_point, contact_dir, contact_component, null, null, null,
false,
false, ObjIntersectFire) )
274 string memory_point_name = weapon.ConfigGetString(
"memoryPointCamera");
275 ItemBase optics = weapon.GetAttachedOptics();
278 memory_point_name = optics.ConfigGetString(
"memoryPointCamera");
279 return optics.ModelToWorld(optics.GetSelectionPositionLS( memory_point_name ));
281 return weapon.ModelToWorld(weapon.GetSelectionPositionLS( memory_point_name ));
289 float sway_weight = player.GetAimingModel().GetSwayWeight();
291 DbgUI.
Text(
"Hold LWIN to draw debug line");
293 DbgUI.
Text(
"Press Z to cycle debug modes");
309 vector contact_point_cam_trace;
310 vector contact_point_muzzle_trace;
312 vector contact_dir_muzzle;
313 vector contact_dir_camera;
318 int contact_component;
319 int contact_component_muzzle;
321 vector end_point = camera_pos + camera_dir * 1000;
326 if (
DayZPhysics.
RaycastRV(camera_pos, end_point, contact_point_cam_trace, contact_dir_camera, contact_component,null, null, player_o ,
false,
false, ObjIntersectFire, 0.1) )
348 if (
DayZPhysics.
RaycastRV(begin_point, contact_point_cam_trace, contact_point_muzzle_trace, contact_dir_muzzle, contact_component_muzzle, null, null, null,
false,
false, ObjIntersectFire, 0.0) )
357 vector contact_point_cam_trace;
358 vector contact_point_muzzle_trace;
362 vector contact_dir_muzzle;
367 int contact_component;
368 int contact_component_muzzle;
370 float distance_to_aim_at;
371 vector end_point = camera_pos + camera_dir * 100;
373 vector weapon_aim_direction = usti_hlavne_position - konec_hlavne_position;
380 if (
DayZPhysics.
RaycastRV(start_point, end_point, contact_point_cam_trace, contact_dir, contact_component,null, null, player_o ,
false,
false, ObjIntersectFire) )
383 aim_at_position = contact_point_cam_trace;
385 if (
DayZPhysics.
RaycastRV(usti_hlavne_position, contact_point_cam_trace, contact_point_muzzle_trace, contact_dir, contact_component,null, null, player_o ,
false,
false, ObjIntersectFire, 0.05) )
387 float collision_distance =
vector.
Distance(contact_point_cam_trace, contact_point_muzzle_trace);
388 float muzzle_collision_distance =
vector.
Distance(usti_hlavne_position, contact_point_muzzle_trace);
393 aim_at_position = contact_point_muzzle_trace;
400 distance_to_aim_at =
vector.
Distance(camera_pos, aim_at_position);
408 vector contact_point_temp;
418 vector dir = contact_point_cam_trace - camera_pos;
422 float dist2 =
vector.
Distance(camera_pos, contact_point_cam_trace);
430 float clamped_distance =
Math.
Clamp(distance_to_aim_at, 0 , 100);
431 float distance_normalized =
Math.
InverseLerp(0, 100, clamped_distance);
432 float hit_sphere_size =
Math.
Lerp(0.025, 0.75, distance_normalized);
proto native DayZPlayer GetPlayer()
proto native vector GetCurrentCameraPosition()
proto native vector GetCurrentCameraDirection()
Super root of all classes in Enforce script.
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.
static Shape DrawLines(vector[] positions, int count, int color=0xFFFFFFFF, int flags=0)
static Shape DrawSphere(vector pos, float size=1, int color=0x1fff7f7f, ShapeFlags flags=ShapeFlags.TRANSP|ShapeFlags.NOOUTLINE)
static void RemoveShape(out Shape shape)
static Shape DrawLine(vector from, vector to, int color=0xFFFFFFFF, int flags=0)
void DrawBarrelMemoryPoints(vector begin_point, vector end_point)
vector m_AimTrailOrdered[BUFFER_SIZE]
const float CAMERA_TRACE_MIN_DISTANCE_TOLERANCE
bool m_IsToggleKeyPressed
void DisplayGeneralInfo()
void DrawLineOfFire(vector begin_point, vector end_point)
void OnCommandHandlerUpdate()
void OnKeyDown(KeyCode key)
const float COLLISIONS_DISTANCE_TOLERANCE
void RemoveAllShapes(bool is_exit=false)
const float MAX_MUZZLE_DISTANCE_TOLERANCE
void DrawLineOfFireMuzzleToHit(vector begin_point, vector camera_dir, vector camera_pos)
ref map< int, string > m_DebugModesNames
vector m_AimTrailCyclic[BUFFER_SIZE]
const float CAMERA_BULLET_ORIGIN_OFFSET
vector GetEyePointPosition(Weapon weapon)
Shape m_ShapeFireDirection2
Weapon GetWeaponInHands()
void AddPosToCyclicBuffer(vector pos)
Shape m_ShapeFireDirection1
void DrawLineOfFireCameraHybrid(vector usti_hlavne_position, vector camera_dir, vector camera_pos, vector konec_hlavne_position)
void DrawEyePoint(Weapon weapon)
Shape m_ShapeFireDirCamera
script counterpart to engine's class Weapon
proto string ToString(bool simple=true)
proto vector Normalized()
return normalized vector (keeps orginal vector untouched)
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()
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)
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);.
proto native void ClearKey(KeyCode key)
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,...
proto native int GetMouseState(MouseState index)