Jump to content
doc. caliban

Adding rangefinder functionality to custom scope

Recommended Posts

After almost 3 hours of google, examples, multiple approaches, etc, the best I've gotten is something that returns the distance to the cursorTarget unless that target "see through" and does not register.  I've used reveal, etc, but no combo that I've used will return a simple distance number no matter what I'm looking at.

 

I'm very done trying to figure this one out.  Can someone give me an example of a working script so I can see how it's done?

 

Thank you,

 

-Doc

Share this post


Link to post
Share on other sites

you want GUI numbers? Like vanilla rangefinders (-> config) ? Or custom script functionality (->script)?

Share this post


Link to post
Share on other sites

It's determined by the weaponInfoType you use for the optic.

 

There are already Rsc classes ingame that you can assign directly to add ranging (like maybe weaponInfoType = "RscOptics_Rangefinder"; but that shows some other things like vision modes and heading).

However, I figure you might want to customise it a bit, so it's probably better to write your own Rsc class.

 

In your scope you need:

weaponInfoType = "RscOptics_myOptic"; or some other equivalent custom classname

Which points to a custom Rsc something like this if you want to customise the font, colour and position of the ranging text under CA_Distance:

	class VScrollbar; //External Class Reference
	class HScrollbar; //External Class Reference
	class RscText; //External Class Reference
	class RscControlsGroup; //External Class Reference

	class RscInGameUI
	{
		class RscUnitInfo; //External Class Reference

		class RscOptics_myOptic: RscUnitInfo
		{
			idd = 300;
			controls[] = {"CA_IGUI_elements_group"};
			class CA_IGUI_elements_group: RscControlsGroup
			{
				idc = 170;
				class VScrollbar: VScrollbar
				{
					width = 0;
				};
				class HScrollbar: HScrollbar
				{
					height = 0;
				};
				x = "0 * (0.01875 * SafezoneH) + (SafezoneX + ((SafezoneW - SafezoneH) / 2))";
				y = "0 * (0.025 * SafezoneH) + (SafezoneY)";
				w = "53.5 * (0.01875 * SafezoneH)";
				h = "40 * (0.025 * SafezoneH)";
				class controls
				{
					class CA_Distance: RscText
					{
						idc = 151;
						style = 0;
						sizeEx = "0.045*SafezoneH";
						colorText[] = {0, 1, 0, 0.5};
						shadow = 0;
						font = "EtelkaMonospacePro";
						text = "- - - -";
						x = "38 * (0.01875 * SafezoneH)";
						y = "19.1 * (0.025 * SafezoneH)";
						w = "5.6 * (0.01875 * SafezoneH)";
						h = "2 * (0.025 * SafezoneH)";
					};
				};
			};
		};
	};

idc = 151; gives continuous range readings.

Use idc = 198; if you want the discrete range-finding used in the game's dev branch for Tank FCS. This requires player to press a key each time to change the rangefinder reading. https://forums.bistudio.com/forums/topic/202603-tanks-fire-control-system/?do=findComment&comment=3160717

However, this wont work on stable branch yet (AFAIK it's projected to be included in the 1.70 patch).

 

x,y,w,h parameters determine the size and position of the textbox

 

Other dialog control parameters you can find here https://community.bistudio.com/wiki/Dialog_Control#Controls

Share this post


Link to post
Share on other sites

THANK YOU!

 

I love doing things "the long way" in Arma, but I spend so much time trying to work things out on my own that sometimes I just spent way too much time getting nowhere.  I appreciate having a new, yet specific, thing to learn now.  This is awesome.

 

I have a couple guys on my small team who use the nightstalker all the time because they want that constant range indicator.  Fine with me, but I have missions where I'd like to use some less-capable optics, yet keep that range finder working for them so they can play the game the way they like it.   My plan is to make copies of some of the existing scopes and simply add this feature to them.  The custom Rsc class sounds like just the ticket.

 

Best,

 

-Doc

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×