Jump to content
nickmow

Get an AI unit to report its co-ordinates

Recommended Posts

_proto = getText( configFile >> "CfgRadio");    ????
_directory = ( getArray ( configFile >> "CfgRadio" ) ) select 0;   ?????

 

 

Share this post


Link to post
Share on other sites

I said yes, it's wrong, I was just using this as an example in my question in finding a pathway. No one needs "?????"

Share this post


Link to post
Share on other sites

This is by far not enough. Larrows script crawls hundreds  thousands and thousands of different possible sounds in configs for each possible speaker (and their languages) and for different behavior types. You can't just create 10 entries in cfgradio to get it work.

Larrow did a generalized solution.

 

Edit:

I counted all at least needed cfgradio entries. These are 7,700 !

Share this post


Link to post
Share on other sites

This creates an array with classnames for use in cfgradio and the proper sound paths. For sure not the most effective solution but works:

 

Spoiler

private ["_sound_array_normal", "_protocol", "_directory", "_dummy"];

// [ _speaker, directory, protocol ]
private _speakers_array = ( [ configFile >> "CfgVoice" , 0] call BIS_fnc_returnChildren ) apply { configName _x } select 
{ ( getArray ( configFile >> "CfgVoice" >> _x >> "directories" ) select 0 ) isNotEqualTo "" } apply
{
 _directory = ( getArray ( configFile >> "CfgVoice" >> _x >> "directories" ) select 0 ) select [ 1 ];
 [ _x, _directory , getText( configFile >> "CfgVoice" >> _x >> "protocol") ]
};

private _protocol_array = _speakers_array apply { _x select 2};

// [ [protocol, [ sound name, [ normal sound array ], [ combat ], [stealth ] ] ] ]
_protocol_array = (_protocol_array arrayIntersect _protocol_array) apply 
{ 
 _protocol = _x;
 _sound_array_normal = ( configProperties [configFile >> _protocol >> "Words" >> "Normal"] ) apply { configName _x } select { "grid_" in _x and not ( "_move_to_" in _x ) };
 _sound_array_normal = _sound_array_normal apply { [ _x, getArray ( configFile >> _protocol >> "Words" >> "Normal" >> _x ) ] };

 _sound_array_combat = ( configProperties [configFile >> _protocol >> "Words" >> "Combat"] ) apply { configName _x } select { "grid_" in _x and not ( "_move_to_" in _x ) };
 _sound_array_combat = _sound_array_combat apply { [ _x, getArray ( configFile >> _protocol >> "Words" >> "Combat" >> _x ) ] };

 _sound_array_stealth = ( configProperties [configFile >> _protocol >> "Words" >> "Stealth"] ) apply { configName _x } select { "grid_" in _x and not ( "_move_to_" in _x ) };
 _sound_array_stealth = _sound_array_stealth apply { [ _x, getArray ( configFile >> _protocol >> "Words" >> "Stealth" >> _x ) ] };
 [ _x, _sound_array_normal, _sound_array_combat, _sound_array_stealth ] 
};

_classnames_and_sounds = [];

_dummy =
{
 _speaker = _x select 0;
 _speaker_dir = _x select 1;
 _protocol = _x select 2;
 _speaker_name = _speaker + "_" + _protocol + "_";
 _speaker_path = "@" +  _speaker_dir;
 _speakers_protocol_array = _protocol_array select (_protocol_array findIf { (_x select 0) isEqualTo _protocol } );
 _speakers_protocol_array = _speakers_protocol_array select [ 1, count _speakers_protocol_array ];


  _sound_normal_array = _speakers_protocol_array select 0;
  _sound_combat_array = _speakers_protocol_array select 1;
  _sound_stealth_array = _speakers_protocol_array select 2;

  _sound_normal_array append _sound_combat_array;
  _sound_normal_array append _sound_stealth_array;

 _dummy =
 {
  _sound_name = _x select 0;
  _sound_1 = _x select 1 select 0;
  _sound_2 = _x select 1 select 1;

   _dummy = _classnames_and_sounds pushBackUnique [ ( _speaker_name + "Normal_" + _sound_name + "_1"), ( _speaker_path  +  _sound_1 ) ];
   _dummy = _classnames_and_sounds pushBackUnique [ ( _speaker_name + "Normal_" + _sound_name + "_2"), ( _speaker_path  +  _sound_2 ) ];

 } count _sound_normal_array;

} count _speakers_array;

  copyToClipboard str _classnames_and_sounds;

  systemChat str ( count _classnames_and_sounds );

 

it also writes the number of entries to system chat. 7,700 !

now there has to be created a script which creates the proper cfgradio entries ...


Edit:

Now the class entries for CfgRadio are done. This script creates all entries for all sounds which could be used by larrows script. Just execute it in debug console and paste your clipboard content into cfgRadio after that...

 

Spoiler

private ["_sound_array_normal", "_protocol", "_directory", "_dummy", "_cfg_radio_string"];

// [ _speaker, directory, protocol ]
private _speakers_array = ( [ configFile >> "CfgVoice" , 0] call BIS_fnc_returnChildren ) apply { configName _x } select 
{ ( getArray ( configFile >> "CfgVoice" >> _x >> "directories" ) select 0 ) isNotEqualTo "" } apply
{
 _directory = ( getArray ( configFile >> "CfgVoice" >> _x >> "directories" ) select 0 ) select [ 1 ];
 [ _x, _directory , getText( configFile >> "CfgVoice" >> _x >> "protocol") ]
};

private _protocol_array = _speakers_array apply { _x select 2};

// [ [protocol, [ sound name, [ normal sound array ], [ combat ], [stealth ] ] ] ]
_protocol_array = (_protocol_array arrayIntersect _protocol_array) apply 
{ 
 _protocol = _x;
 _sound_array_normal = ( configProperties [configFile >> _protocol >> "Words" >> "Normal"] ) apply { configName _x } select { "grid_" in _x and not ( "_move_to_" in _x ) };
 _sound_array_normal = _sound_array_normal apply { [ _x, getArray ( configFile >> _protocol >> "Words" >> "Normal" >> _x ) ] };

 _sound_array_combat = ( configProperties [configFile >> _protocol >> "Words" >> "Combat"] ) apply { configName _x } select { "grid_" in _x and not ( "_move_to_" in _x ) };
 _sound_array_combat = _sound_array_combat apply { [ _x, getArray ( configFile >> _protocol >> "Words" >> "Combat" >> _x ) ] };

 _sound_array_stealth = ( configProperties [configFile >> _protocol >> "Words" >> "Stealth"] ) apply { configName _x } select { "grid_" in _x and not ( "_move_to_" in _x ) };
 _sound_array_stealth = _sound_array_stealth apply { [ _x, getArray ( configFile >> _protocol >> "Words" >> "Stealth" >> _x ) ] };
 [ _x, _sound_array_normal, _sound_array_combat, _sound_array_stealth ] 
};

_classnames_and_sounds = [];

_dummy =
{
 _speaker = _x select 0;
 _speaker_dir = _x select 1;
 _protocol = _x select 2;
 _speaker_name = _speaker + "_" + _protocol + "_";
 _speaker_path = "@" +  _speaker_dir;
 _speakers_protocol_array = _protocol_array select (_protocol_array findIf { (_x select 0) isEqualTo _protocol } );
 _speakers_protocol_array = _speakers_protocol_array select [ 1, count _speakers_protocol_array ];


  _sound_normal_array = _speakers_protocol_array select 0;
  _sound_combat_array = _speakers_protocol_array select 1;
  _sound_stealth_array = _speakers_protocol_array select 2;

  _sound_normal_array append _sound_combat_array;
  _sound_normal_array append _sound_stealth_array;

 _dummy =
 {
  _sound_name = _x select 0;
  _sound_1 = _x select 1 select 0;
  _sound_2 = _x select 1 select 1;

   _dummy = _classnames_and_sounds pushBackUnique [ ( _speaker_name + "Normal_" + _sound_name + "_1"), ( _speaker_path  +  _sound_1 ) ];
   _dummy = _classnames_and_sounds pushBackUnique [ ( _speaker_name + "Normal_" + _sound_name + "_2"), ( _speaker_path  +  _sound_2 ) ];

 } count _sound_normal_array;

} count _speakers_array;

_cfg_radio_string = 'class saroSnd{name="";title="";};' + endl;

{
  _cfg_radio_string = _cfg_radio_string + 'class ' + (_x select 0) + ':saroSnd' + '{sound[]={"' + (_x select 1) + '",1,1};};' + endl;
} count _classnames_and_sounds;

copyToClipboard _cfg_radio_string;

 

 

Next thing to do is to rewrite Larrows script for CfgRadio usage...

 

Edit: dont use scripts of this post. They have a major bug. go with the next post instead...

  • Like 1

Share this post


Link to post
Share on other sites

okay, finally I got it working. There is a big downside which can not be worked around. The problem is that there is a mic beep after each grid number. this is an effect of cfgradio.

 

what to do to get it work on your mission:

 

1. create an empty file called cfgradio.hpp in your missions root folder.

2. execute the following script in debug console and wait for "Finished." in chat:

 

Spoiler

(findDisplay 49) closeDisplay 2;

h = [] spawn {

private ["_sound_array_normal", "_protocol", "_directory", "_dummy", "_cfg_radio_string"];

systemChat "Building speaker array.";

private _speakers_array = ( [ configFile >> "CfgVoice" , 0] call BIS_fnc_returnChildren ) apply { configName _x } select 
{ ( getArray ( configFile >> "CfgVoice" >> _x >> "directories" ) select 0 ) isNotEqualTo "" } apply
{
 _directory = ( getArray ( configFile >> "CfgVoice" >> _x >> "directories" ) select 0 ) select [ 1 ];
 [ _x, _directory , getText( configFile >> "CfgVoice" >> _x >> "protocol") ]
};

systemChat "Building protocol array.";
private _protocol_array = _speakers_array apply { _x select 2};

_protocol_array = (_protocol_array arrayIntersect _protocol_array) apply 
{ 
 _protocol = _x;
 _sound_array_normal = ( configProperties [configFile >> _protocol >> "Words" >> "Normal"] ) apply { configName _x } select { "grid_" in _x and not ( "_move_to_" in _x ) };
 _sound_array_normal = _sound_array_normal apply { [ _x, getArray ( configFile >> _protocol >> "Words" >> "Normal" >> _x ) ] };

 _sound_array_combat = ( configProperties [configFile >> _protocol >> "Words" >> "Combat"] ) apply { configName _x } select { "grid_" in _x and not ( "_move_to_" in _x ) };
 _sound_array_combat = _sound_array_combat apply { [ _x, getArray ( configFile >> _protocol >> "Words" >> "Combat" >> _x ) ] };

 _sound_array_stealth = ( configProperties [configFile >> _protocol >> "Words" >> "Stealth"] ) apply { configName _x } select { "grid_" in _x and not ( "_move_to_" in _x ) };
 _sound_array_stealth = _sound_array_stealth apply { [ _x, getArray ( configFile >> _protocol >> "Words" >> "Stealth" >> _x ) ] };
 [ _x, _sound_array_normal, _sound_array_combat, _sound_array_stealth ] 
};

_classnames_and_sounds = [];

systemChat "Mergeing arrays to sound array";

_dummy =
{
 _speaker = _x select 0;
 _speaker_dir = _x select 1;
 _protocol = _x select 2;
 _speaker_name = _speaker + "_" + _protocol + "_";
 _speaker_path = "@" +  _speaker_dir;
 _speakers_protocol_array = _protocol_array select (_protocol_array findIf { (_x select 0) isEqualTo _protocol } );
 _speakers_protocol_array = _speakers_protocol_array select [ 1, count _speakers_protocol_array ];


  _sound_normal_array = _speakers_protocol_array select 0;
  _sound_combat_array = _speakers_protocol_array select 1;
  _sound_stealth_array = _speakers_protocol_array select 2;

 _dummy =
 {
  _sound_name = _x select 0;
  _sound_1 = _x select 1 select 0;
  _sound_2 = _x select 1 select 1;

   _dummy = _classnames_and_sounds pushBack [ ( _speaker_name + "Normal_" + _sound_name + "_1"), ( _speaker_path  +  _sound_1 ) ];
   _dummy = _classnames_and_sounds pushBack [ ( _speaker_name + "Normal_" + _sound_name + "_2"), ( _speaker_path  +  _sound_2 ) ];

 } count _sound_normal_array;

 _dummy =
 {
  _sound_name = _x select 0;
  _sound_1 = _x select 1 select 0;
  _sound_2 = _x select 1 select 1;

   _dummy = _classnames_and_sounds pushBack [ ( _speaker_name + "Combat_" + _sound_name + "_1"), ( _speaker_path  +  _sound_1 ) ];
   _dummy = _classnames_and_sounds pushBack [ ( _speaker_name + "Combat_" + _sound_name + "_2"), ( _speaker_path  +  _sound_2 ) ];

 } count _sound_combat_array;

  _dummy =
 {
  _sound_name = _x select 0;
  _sound_1 = _x select 1 select 0;
  _sound_2 = _x select 1 select 1;

   _dummy = _classnames_and_sounds pushBack [ ( _speaker_name + "Stealth_" + _sound_name + "_1"), ( _speaker_path  +  _sound_1 ) ];
   _dummy = _classnames_and_sounds pushBack [ ( _speaker_name + "Stealth_" + _sound_name + "_2"), ( _speaker_path  +  _sound_2 ) ];

 } count _sound_stealth_array;

} count _speakers_array;

systemChat "Building CfgRadio String.";

systemChat ("Found " + str (count _classnames_and_sounds) + " possible sounds.");

_cfg_radio_string = 'class saroSnd{name="";title="";};' + endl;

_classnames_and_sounds = flatten  ( _classnames_and_sounds apply { [ 'class ', (_x select 0), ':saroSnd', '{sound[]={"', (_x select 1), '",1,1};};', endl] } );

_cfg_radio_string = _cfg_radio_string + ( _classnames_and_sounds joinString "" );

copyToClipboard _cfg_radio_string;

systemChat "Finished.";
};

 

 

3. Now just paste the content of your clipboard into the cfgradio.hpp file by pressing CTRL+V and save the file.

4. add this to your description.ext if you don't have a CfgRadio entry there. If you have allready then add the #include line to it only. Save the file:

Spoiler

class CfgRadio
{
	sounds[] = {};
	#include "cfgradio.hpp"
}

 

 

5 a return to Eden Editor to get the new description.ext and it's new include loaded.

5 b start mission again

5. execute the following script of @Larrow which I edited for use with the created CfgRadio entries where you like. Works in debug console as well:

Spoiler

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 ( [ _prefix, _gridNum, _suffix ] joinString "" );
  };
 } forEach [ _xPos, _yPos ];

 {
  _sound = [ _speaker, _proto, _behaviour, _x, selectRandom ["1", "2"] ] joinString "_";
  _unit sideRadio _sound;
  sleep random [0.8, 1, 1.5];
 } forEach _sentence;
};

 

 

Now you should hear the grid position via radio. To change the channel you have to change sideRadio into groupRadio or whatever you like...

 

Edit

Removed major bug.
Optimized performance for cfgradio entry getter. No game halting anymore...

Added random pauses to get it sound more humanly

 

Edit2

Dropbox links to avoid copy-paste-invisible-character-bug:

 

saros_cfgradio_creator.sqf (use this in debug console to create needed classes for CfgRadio)

cfgradio.hpp (for vanilla arma only. if u use mods which create new sounds then u have to generate your own with content of saros_cfgradio_creator.sqf)

larrows_grid_speaker.sqf (use this to speak grid positions through radio)

 

  • Like 1
  • Thanks 1

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

×