scripts/4_World/Entities/ItemBase/Rangefinder.c
// Measures the distance and returns result in formated string
Measures the distance and returns result in formated string
Measures the distance and returns result in formated string
string DoMeasurement(PlayerBase player)
	{
		string 		message			= "";
		const float	MAX_RANGE 		= 9999;
		float 		energy_needed 	= GetCompEM().GetEnergyUsage() * GetMeasurementUpdateInterval();
		vector 		from 			= GetGame().GetCurrentCameraPosition();
		vector 		to 				= from + (GetGame().GetCurrentCameraDirection() * MAX_RANGE);
		vector 		contact_pos;
		vector 		contact_dir;
		int 		contactComponent;
		DayZPhysics.RaycastRV( from, to, contact_pos, contact_dir, contactComponent, NULL , NULL, player, false, false, ObjIntersectIFire);
		Debug.DrawArrow( from, contact_pos ); 
		bool is_device_working = GetCompEM().ConsumeEnergy( energy_needed );
		if (is_device_working)
		{
			float dist = vector.Distance( from, contact_pos );
			dist = Math.Round(dist);
			message = "#range_finder_distance" + ": " + dist.ToString() + " #meters";
		}
		else
		{
			message = "#range_finder_distance" + ": ----" + " #meters";
		}
		return message;
	}
string DoMeasurement ( PlayerBase player ) { string message = " " ; const float MAX_RANGE = 9999 ; float energy_needed = GetCompEM ( ) . GetEnergyUsage ( ) * GetMeasurementUpdateInterval ( ) ; vector from = GetGame ( ) . GetCurrentCameraPosition ( ) ; vector to = from + ( GetGame ( ) . GetCurrentCameraDirection ( ) * MAX_RANGE ) ; vector contact_pos ; vector contact_dir ; int contactComponent ; DayZPhysics . RaycastRV ( from , to , contact_pos , contact_dir , contactComponent , NULL , NULL , player , false , false , ObjIntersectIFire ) ; Debug . DrawArrow ( from , contact_pos ) ; bool is_device_working = GetCompEM ( ) . ConsumeEnergy ( energy_needed ) ; if ( is_device_working ) { float dist = vector . Distance ( from , contact_pos ) ; dist = Math . Round ( dist ) ; message = " " + " " + dist . ToString ( ) + " " ; } else { message = " " + " " + " " ; } return message ; }
Measures the distance and returns result in formated string
Measures the distance and returns result in formated string
// Fire raycast // Uncomment for debugging of raycast positions // Use energy // Generate result