Jump to content
nickmow

Get an AI unit to report its co-ordinates

Recommended Posts

Simple question,

Via a trigger how do I get an AI unit not under my command to report its co-ordinates ? By voice would be a bonus but not essential. Searched like crazy !

Share this post


Link to post
Share on other sites

I'm not exactly sure why you mention a trigger there. Do you want that unit to report its position as soon as it's arrived a specific position which could be triggered or can the position be anywhere around the map?

Share this post


Link to post
Share on other sites

Anywhere Johnny, using an area trigger would be easy, I just want a grid reference same as if you interogate a member of your own squad with 5,5

Share this post


Link to post
Share on other sites

Couldn't you just use the vanilla report position feature?

Share this post


Link to post
Share on other sites

In that case, you could simply create a marker on the map, e.g. periodically tracking that unit:

[color=#FF8040][color=#191970][b]while[/b][/color] [color=#8B3E2F][b]{[/b][/color][color=#000000]true[/color][color=#8B3E2F][b]}[/b][/color] [color=#191970][b]do[/b][/color]
[color=#8B3E2F][b]{[/b][/color]
   [color=#1874CD]_unitPosition[/color] [color=#8B3E2F][b]=[/b][/color] [color=#191970][b]getPos[/b][/color] [color=#1874CD]_unit[/color][color=#8B3E2F][b];[/b][/color]
   [color=#1874CD]_unitPositionMarker[/color] [color=#8B3E2F][b]=[/b][/color] [color=#191970][b]createMarker[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"marker_unitPosition"[/color][color=#8B3E2F][b],[/b][/color] [color=#1874CD]_unitPosition[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color]
   [color=#1874CD]_unitPositionMarker[/color] [color=#191970][b]setMarkerType[/b][/color] [color=#7A7A7A]"mil_dot"[/color][color=#8B3E2F][b];[/b][/color]
   [color=#1874CD]_unitPositionMarker[/color] [color=#191970][b]setMarkerColor[/b][/color] [color=#7A7A7A]"ColorBlue"[/color][color=#8B3E2F][b];[/b][/color]
   [color=#1874CD]_unitPositionMarker[/color] [color=#191970][b]setMarkerText[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#191970][b]str[/b][/color] [color=#1874CD]_unitPosition[/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b];
[/b][/color]    [color=#FF8040][color=#191970][b]sleep[/b][/color] [color=#FF0000]10[/color][color=#8B3E2F][b];[/b][/color][/color]
[color=#FF8040]    [color=#191970][b]deleteMarker[/b][/color] [color=#7A7A7A]"marker_unitPosition"[/color][color=#8B3E2F][b];[/b][/color][/color]
[color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color][/color]

Kudos to Killzone_Kid for his SQF to BBCode Converter.

Share this post


Link to post
Share on other sites

Unit sidechat format ["I'm at grid %1",mapGridPosition getposatl Unit];

should do the trick.

Couldn't you just use the vanilla report position feature?

How exactly would one do that with a unit outside of your own group? No idea on that one.

  • Like 1

Share this post


Link to post
Share on other sites

How exactly would one do that with a unit outside of your own group? No idea on that one.

Sorry on my phone since I'm away for the holiday, read over the part about the unit not being under his command :p.

Share this post


Link to post
Share on other sites

Thanks chaps, marker would sort of defeat the purpose initially Johnny, but I already have the marker thing sorted. Thanks Grumpy just what I was after.

Scenario is basically CSAR mission, initial search based on pilot reporting position. I have a marker appear when within a certain range of the downed bird which has worked well in previous efforts and dissapears once out of range (by changing marker size to 0,0) but didnt want a fly to marker, far too easy for the Rescue dudes :cool:

Will report results

Cheers Nick

---------- Post added at 03:08 PM ---------- Previous post was at 02:35 PM ----------

Works copied and pasted Grumpy's text to a trigger an trialled it using a repeatable radio trigger. Unit (An MH9 called Helo) reports its grid reference in side chat. Perfect, and will do the job. Don't suppose there's anyway you can get them to say it out loud ? or is that a script nightmare lol

thanks very much

Nick

Share this post


Link to post
Share on other sites

Would be possible, but requires some additional scripts and I don't know if there's a phrase like "I'm at grid" or similar in the existing audio files.

Share this post


Link to post
Share on other sites

Thanks mate I'll go with what Ive got, really useful scripting that you gave me, much appreciated

Share this post


Link to post
Share on other sites

Its very easy to get the AI to fake a reply with group chat:

unitName groupChat format ["Grid: %1", mapGridPosition unitName]

Getting the audio is another issue...

EDIT Oops, didn't notice Grumpy Old Man's reply above :)

Edited by ceeeb
  • Like 1

Share this post


Link to post
Share on other sites
Don't suppose there's anyway you can get them to say it out loud ? or is that a script nightmare lol

h = player spawn {
_unit = _this;
_speaker = speaker _unit;
_proto = getText( configFile >> "CfgVoice" >> _speaker >> "protocol");
_directory = ( getArray ( configFile >> "CfgVoice" >> _speaker >> "directories" ) ) select 0;
_directory = _directory select [ 1, ( count _directory ) -1 ];
_behaviour = behaviour _unit;
if ( !( _behaviour in [ "COMBAT", "STEALTH" ]) ) then {
	_behaviour = "NORMAL";
};
_words = ( configFile >> _proto >> "Words" >> _behaviour);

_sentence = [];

_strPos = mapGridPosition _unit;
_unit sideChat ( "Grid: " + _strPos );

_xPos = _strPos select [ 0, 3 ];
_yPos = _strPos select [ 3, 3 ];

{
	_prefix = "grid_";
	_suffix = [ "", "_2"] select _forEachIndex;
	for "_i" from 0 to ( count _x ) -1 do {
		_num = _x select [ _i, 1 ];
		_gridNum = ( [
		"zero",
		"one",
		"two",
		"three",
		"four",
		"five",
		"six",
		"seven",
		"eight",
		"nine"
		] select ( call compile _num ) );

		switch ( _i ) do {
			case ( 1 ) : {
				_suffix = "_2";
			};
			case ( 2 ) : {
				_suffix = "_3";
			};
		};

		_sentence pushBack ( format [ "%1%2%3", _prefix, _gridNum, _suffix ] );
	};
}forEach [ _xPos, _yPos ];

{
	_files = getArray ( _words >> _x );
	_sound = _directory + ( _files select floor( random( count _files ) ) );
	playSound3D [ _sound, _unit];
	sleep 0.75;
}forEach _sentence;

};

Theres something to get you going, uses proper voice for the passed unit as per his identity.

Edited by Larrow
added behaviour voices
  • Like 2

Share this post


Link to post
Share on other sites

Larrow, nice script. I know this is 7 years later, but do you (or anyone) happen to know how to make the voice sound like it's over the radio? I see something about RadioProtocolENG, but after many attempts, I have no idea how to implement this into the script... 

Thank you!

Share this post


Link to post
Share on other sites
13 hours ago, bcon117 said:

do you (or anyone) happen to know how to make the voice sound like it's over the radio?

 

I read a bit bout but tested nothing.

It seems that you have to use a command which sends the sound through a channel.

Those commands can be found here:

https://community.bistudio.com/wiki/Category:Command_Group:_Radio_and_Chat

 

command, global, group and side channels have default radio effects in their config. Can be seen with config viewer: configFile >> "RadioChannels"

 

you could also create a custom channel with radio effects but thats not needed.

 

to play the sound on group channel which has radio effects by default u could try this:

 

_unit groupRadio _sound;

but group radio has local effects only. therefore it has to be executed on each client...

  • Like 1

Share this post


Link to post
Share on other sites

I also would like to know how to play vanilla arma commands/responses through the radio (so you get radio static fx with the audio line).  For example, playsound3d needs full path to sound, but plays the sound without the radio static fx.  This works without radio static fx:

playsound3d ["A3\Dubbing_Radio_F\data\ENG\Male01ENG\RadioProtocolENG\Normal\100_Commands\RallyUp.ogg",player]; 

How do we use this same sound with sideRadio or groupRadio? 

 

The following do NOT work:

player sideRadio "A3\Dubbing_Radio_F\data\ENG\Male01ENG\RadioProtocolENG\Normal\100_Commands\RallyUp.ogg"; 
player sideRadio "RallyUp";

 

Share this post


Link to post
Share on other sites

I have no time to test much currently but what I tested so far and what is working is this example from Biki:

 

player groupRadio configName selectRandom ("true" configClasses (configFile >> "CfgRadio"));

take care to follow this biki advice as well:

Quote

 

Sends the audio message to the group radio channel. Must have assigned "ItemRadio" to send or receive the transmission.

 

  • Thanks 1

Share this post


Link to post
Share on other sites
6 minutes ago, sarogahtyp said:

("true" configClasses (configFile >> "CfgRadio"))

That example works, but when you dump all the sound file entries from the above command, they do NOT include the normal command/response audio.  

Share this post


Link to post
Share on other sites

@johnnyboy tested and working:

 

description.ext

class CfgRadio
{
	sounds[] = {};
	class RallyUp
	{
		// display name
		name	= "Blabla";

		// filename, volume, pitch
		sound[]	= { "@A3\Dubbing_Radio_F\data\ENG\Male01ENG\RadioProtocolENG\Normal\100_Commands\RallyUp.ogg", 1, 1 };

		// radio caption
		title	= "Maids, rally up.";
	};
};

 

debug console

player groupRadio "RallyUp";

 

  • Thanks 1

Share this post


Link to post
Share on other sites
4 minutes ago, sarogahtyp said:

player groupRadio "RallyUp";

Thanks. That's cool for very specific lines you need in a particular mission.  But since there are hundreds of these lines per speaker, its not really viable as a generalized solution.  Its a damn shame that BIS didn't expose a radio voice call that allows us to reuse all the commands/responses (for all speakers and languages) via radio instead of playsound3D.

Share this post


Link to post
Share on other sites

Should be possible to write an export function which creates  cfgradio entries from your generalization rule which you can paste in cfgradio class of description.ext then.

After that you would be able to apply that rule on cfgradio during mission.

@johnnyboy

  • Thanks 1

Share this post


Link to post
Share on other sites
Quote

h = player spawn { 
_unit = corpsman1
_speaker = speaker _unit; 
_proto = getText( configFile >> "CfgRadio"); 
_directory = ( getArray ( configFile >> "CfgRadio" ) ) select 0; 
_directory = _directory select [ 1, ( count _directory ) -1 ]; 
_behaviour = behaviour _unit; 
if ( !( _behaviour in [ "COMBAT", "STEALTH" ]) ) then { 
 _behaviour = "NORMAL"; 
}; 
_words = ( configFile >> "CfgRadio"); 
 
_sentence = []; 
 
_strPos = mapGridPosition _unit; 
_unit sideChat ( "Grid: " + _strPos ); 
 
_xPos = _strPos select [ 0, 3 ]; 
_yPos = _strPos select [ 3, 3 ]; 
 

 _prefix = "grid_"; 
 _suffix = [ "", "_2"] select _forEachIndex; 
 for "_i" from 0 to ( count _x ) -1 do { 
  _num = _x select [ _i, 1 ]; 
  _gridNum = ( [ 
  "zero", 
  "one", 
  "two", 
  "three", 
  "four", 
  "five", 
  "six", 
  "seven", 
  "eight", 
  "nine" 
  ] select ( call compile _num ) ); 
 
  switch ( _i ) do { 
   case ( 1 ) : { 
    _suffix = "_2"; 
   }; 
   case ( 2 ) : { 
    _suffix = "_3"; 
   }; 
  }; 
 
  _sentence pushBack ( format [ "%1%2%3", _prefix, _gridNum, _suffix ] ); 
 }; 
}forEach [ _xPos, _yPos ]; 
 

 _files = getArray ( _words >> _x ); 
 _sound = _directory + ( _files select floor( random( count _files ) ) ); 
 playSound3D [_sound, _unit]; 
 sleep 0.75; 
}forEach _sentence; 
 
};

I made my only change in bold, an attempt at a pathway to cfgradio in my description.ext. I know this is wrong, just figured I'd try. I have sounds in numbers 0-9. I've been using CfgSounds in description.ext for awhile, but never tried this. I just get error message that "_directory cannot be found."  Any ideas?

Go easy on me because I'm obviously novice here...

  • Like 1

Share this post


Link to post
Share on other sites

This can not be done by simply changing cfgvoice to cfgradio...

Someone has to write a function which creates entries for cfgradio for each sound. Those entries have to be copied into cfgradio in description.ext then.

After that larrow's function has to be rewritten for use on those cfgradio entries.

 

This is not an easy task...

Share this post


Link to post
Share on other sites

That's what I did... As I said, I created a descripton.ext for CfgRadio for each sound, numbered 0-9. Then I attempted to rewrite a pathway to CfgRadio entries. I'm just asking for the proper code for the pathway...

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

×