Jump to content
Sign in to follow this  
vad

[Solved] Return true if certain class is distance <3

Recommended Posts

// scenario setup, I have a Linguist, only he will get the addAction from an informant, but won't give up the information if the interrogator is not present.

 

Linguist class:    B_Story_Protagonist_F

Interrogator class:   B_CTRG_soldier_GL_LAT_F

 

on the target:

nul = [this]execVM "Interview.sqf";

 

Interview.sqf:

_target = (_this select 0);
_target addAction [  
 "<t color='#00ff00'>Ask Questions</t>",  
"lingmsg.sqf",  
 [], 1.5, true, true, "", 
 "(alive target1) && (typeOf player) in ['B_Story_Protagonist_F']", 
 1.7 
 ];

this part works fine (though I'd like to change target1 to _target but this doesnt work so I just name each target) I can live with this part.

 

lingmsg.sqf:

 

OK figured it out:

 

_ling = (_this select 1);
_tar = (_this select 0);


_ints = [];
{
	if ((typeOf _x) in ['B_CTRG_soldier_GL_LAT_F']) then
	{
		_ints pushBack _x;
	};
} forEach playableUnits;


_intsnear = false;
{
	if ((_x distance _tar) <3) then
	{
		_intsnear = true;
	};
} forEach _ints;


if 
	(
		_intsnear
	)
then 
	{
	hint format ["OK, OK, I'll talk, theres a bomb factory at grid 014,023"] 
	}
else
	{
	hint format [ "Go away American"]
	};

if there's a cleaner way to do it I'm all ears

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
Sign in to follow this  

×