3 static const float RANGEFINDER_MAX_DISTANCE = 913.4856;
13 float GetMeasurementUpdateInterval()
20 if( !
GetGame().IsDedicatedServer())
25 if ( player_this == player_owner )
27 StartPeriodicMeasurement();
34 if( !
GetGame().IsDedicatedServer())
39 if ( player_this == player_owner )
41 StopPeriodicMeasurement();
46 void StartPeriodicMeasurement()
53 m_RangeText =
TextWidget.Cast(
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/gameplay/rangefinder_hud.layout" ) );
55 m_Timer.Run( GetMeasurementUpdateInterval(),
this,
"DoMeasurement",
null,
true );
58 void StopPeriodicMeasurement()
79 vector to = from + (
GetGame().GetCurrentCameraDirection() * RANGEFINDER_MAX_DISTANCE);
84 DayZPhysics.RaycastRV( from, to, contact_pos, contact_dir, contactComponent, NULL , NULL, player,
false,
false, ObjIntersectIFire);
87 float dist =
vector.Distance( from, contact_pos );
88 dist =
Math.Round(dist);
90 if (dist < RANGEFINDER_MAX_DISTANCE)
93 m_RangeText.SetText(
"00" + dist.ToString() );
95 m_RangeText.SetText(
"0" + dist.ToString() );
97 m_RangeText.SetText( dist.ToString() );
101 m_RangeText.SetText(
"- - -" );
116 GetInventory().CreateInInventory(
"Battery9V" );