Jump to content

Recommended Posts

nul = [getPos _position, _faction, (configfile >> "CfgGroups" >> "East" >> "OPF_T_F" >> "Armored" >> "O_T_SPGPlatoon_Scorcher")] call BIS_fnc_spawnGroup;

Works just fine for me, units are spawned and life is good. The trouble comes in here.

_template = _this select 0;

_faction = side _template;
 
_armored2 =  "(configfile >> ""CfgGroups"" >> ""East"" >> ""OPF_T_F"" >> ""Armored"" >> ";


_armored21 = _armored2 + selectRandom Armored1;

hint _armored21;	
nul = [[_position], _faction, [_armored21]] call BIS_fnc_spawnGroup;

The hint gives me 

(configfile >> "CfgGroups" >> "East" >> "OPF_T_F" >> "Armored" >> "O_T_SPGPlatoon_Scorcher")

or whatever random predefined group ends up selected. However no units spawn and no script errors are given.. Any help would be much appreciated.

 

To answer the things I know will be asked and said I have prepared the following list.

1. The end goal is an easy to setup framework for wave defense missions.

2. I have looked at the scripts that are available, all of them I have tried are not fully functional after the Road to APEX/APEX updates. Besides this is a good learning experience for me.

3. That is not all the code I have, it is just the relevant bits. Full code below.

if (isServer || isDedicated) then {
_array = execVM "unit_array.sqf"; // This is a list of predefined groups cut into types. it contains the array Armored1
waitUntil {isNull _array};
//No No space
private ["_template","_point","_origin","_totalWaves","_threat","_faction","_doSpawn","_position","_curWave","_Wave"];

//input
_template = _this select 0;
_point = _this select 1;
_origin = _this select 2; 
_totalWaves = _this select 3;

//defines
_threat = 0;
_faction = side _template;
_position = _origin call BIS_fnc_selectRandom;
_curWave = 0;
_Wave = _template;
_totalWaves = _totalWaves - 1;
_armored2 =  "(configfile >> ""CfgGroups"" >> ""East"" >> ""OPF_T_F"" >> ""Armored"" >> ";
//hint _armored2;
_armored21 = _armored2 + selectRandom Armored1;
 

hint _armored21;	
nul = [[_position], _faction, [_armored21]] call BIS_fnc_spawnGroup;


//spawn units
//while {_curwave <= _totalWaves && {alive _x} count units _wave <= 1} do {
//	_position = _origin call BIS_fnc_selectRandom;
//	_Wave1 = [getPos _position, _faction, 1] call BIS_fnc_spawnGroup;
//	_Wave1 addWaypoint [position player, 50];
// 	_curWave = _curwave + 1;
//	hint str _curwave;
//	sleep 10;
};


//Handle ending
//while {_curwave >= _totalWaves && {alive _x} count units _wave == 0} do {
//		endmission "END1";
//	};

//};

Share this post


Link to post
Share on other sites
_array = execVM "unit_array.sqf"; // This is a list of predefined groups cut into types. it contains the array Armored1
waitUntil {isNull _array};

this wont work because only thing execVM returns is handle to the run script. So waitUntil wont also end.

 

what you need is something like this:

unitArray = Compile preprocessFileLineNumbers  "unit_array.sqf";

_array = call unitArray;

no waituntil necessary there

Share this post


Link to post
Share on other sites
nul = [[_position], _faction, [_armored21]] call BIS_fnc_spawnGroup;

to

nul = [_position, _faction, _armored21] call BIS_fnc_spawnGroup;

Share this post


Link to post
Share on other sites
_array = execVM "unit_array.sqf"; // This is a list of predefined groups cut into types. it contains the array Armored1
waitUntil {isNull _array};

this wont work because only thing execVM returns is handle to the run script. So waitUntil wont also end.

 

what you need is something like this:

unitArray = Compile preprocessFileLineNumbers  "unit_array.sqf";

_array = call unitArray;

no waituntil necessary there

 

Many thanks. I get the error 

'...isdedicated0 then {
unitArray = Compile |#|preprocessFileLineNumbers "unit_array.sq...'
Error Missing ;

When trying to use anything but exceVM on unit_array.sqf.

Share this post


Link to post
Share on other sites
nul = [[_position], _faction, [_armored21]] call BIS_fnc_spawnGroup;

to

nul = [_position, _faction, _armored21] call BIS_fnc_spawnGroup;

Many thanks. This gives me the error 

error Type Object, expected Array 

for file A3\functions_f\spawning\fn_spawngroup.sqf

Share this post


Link to post
Share on other sites

Many thanks. I get the error 

'...isdedicated0 then {
unitArray = Compile |#|preprocessFileLineNumbers "unit_array.sq...'
Error Missing ;

When trying to use anything but exceVM on unit_array.sqf.

 

there seems to be problem with the if statement.. there's 0 after isdedicated and no brackets.

 

I would also recommend to put the unitArray = Compile preprocessFileLineNumbers  "unit_array.sqf";

into init.sqf , so that its run only once.

Share this post


Link to post
Share on other sites

there seems to be problem with the if statement.. there's 0 after isdedicated and no brackets.

 

I would also recommend to put the unitArray = Compile preprocessFileLineNumbers  "unit_array.sqf";

into init.sqf , so that its run only once.

The 0 is just my typo. I get an 

Error Undefined Variable in expression: unitarray

when 

unitArray = Compile preprocessFileLineNumbers  "unit_array.sqf";

is in init.sqf and 

_array = call unitArray;

is in the main script. Am I doing that correctly?

Share this post


Link to post
Share on other sites

It may be worth noting that I am only using unit_array.sqf to store a couple arrays in variables. Those arrays can be moved into the script.

Share this post


Link to post
Share on other sites

Changing 

_array = call unitarray;

to

call unitarray;

is working. 

hint _armored21;

is returning the correct value with the random selection form the array. So that leaves me exactly where I started.

Share this post


Link to post
Share on other sites
Error Undefined Variable in expression: unitarray

 

 

from where are you calling the main script? putting a "sleep 1" in there gives enough time for unitArray to become valid...

 

 i have to go now.. i will get back to you tomorrow if you still need help.

Share this post


Link to post
Share on other sites

from where are you calling the main script? putting a "sleep 1" in there gives enough time for unitArray to become valid...

 

 i have to go now.. i will get back to you tomorrow if you still need help.

 

Called from a trigger on Radio Alpha. unitArray must be active to get the proper return from 

_armored21 = _armored2 + selectRandom Armored1;

as Armored1 is stored in unitArray.

Share this post


Link to post
Share on other sites

I am getting no script errors, the Spawn function is now as follows

_spawnVeh = [[_position], _faction, [_armored21]] call BIS_fnc_spawnGroup;
hint str _spawnveh;

with the hint returning 

<NULL-group>

Share this post


Link to post
Share on other sites

when your _position variable is indeed a position and not an object then you basically send this position inside an array to the script.

This can not work.

Also from your examples you're sending the config entry as a string to the script as the third parameter, which also can not work.

You should use it like this:

_position = getposatl player;
_side = east;
_config = (configfile >> "CfgGroups" >> "East" >> "OPF_T_F" >> "Armored" >> "O_T_SPGPlatoon_Scorcher");
[_position,_side,_config] spawn BIS_fnc_spawnGroup;

What I believe you are doing from the looks of your scripts is this:

_position = getposatl player;
_side = east;
_config = "(configfile >> "CfgGroups" >> "East" >> "OPF_T_F" >> "Armored" >> "O_T_SPGPlatoon_Scorcher")";
[[_position],_side,_config] spawn BIS_fnc_spawnGroup;

which is why it won't work.

Also rename _faction into _side, is less confusing.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

 

I am getting no script errors, the Spawn function is now as follows

_spawnVeh = [[_position], _faction, [_armored21]] call BIS_fnc_spawnGroup;
hint str _spawnveh;

with the hint returning 

<NULL-group>

Is _position an object or what?

BIS_fnc_spawnGroup's first argument is a position which should be in an array format, thus meaning it can't be something like [object]. Additionally, the third argument is either: an array of unit types, a number, or a config entry. You're using a config entry, which does not need to be in an array, as far as I know.

Share this post


Link to post
Share on other sites

when your _position variable is indeed a position and not an object then you basically send this position inside an array to the script.

This can not work.

Also from your examples you're sending the config entry as a string to the script as the third parameter, which also can not work.

You should use it like this:

_position = getposatl player;
_side = east;
_config = (configfile >> "CfgGroups" >> "East" >> "OPF_T_F" >> "Armored" >> "O_T_SPGPlatoon_Scorcher");
[_position,_side,_config] spawn BIS_fnc_spawnGroup;

What I believe you are doing from the looks of your scripts is this:

_position = getposatl player;
_side = east;
_config = "(configfile >> "CfgGroups" >> "East" >> "OPF_T_F" >> "Armored" >> "O_T_SPGPlatoon_Scorcher")";
[[_position],_side,_config] spawn BIS_fnc_spawnGroup;

which is why it won't work.

Also rename _faction into _side, is less confusing.

 

Cheers

 

 

_position is a randomly selected from a group of named markers/gamelogic/trigger/unit that are passed as an array via _this select 2 as _origin. This part of the script works as intended when using the simple version 

_Wave1 = [getPos _position, _faction, 1] call BIS_fnc_spawnGroup;

_faction is named as it is because it is intended hold the faction (USMC, CSAT etc.) I am simply using it as a place holder until that part of the code is written. The idea is that you would place a unit of the side and faction you wish to fight against as a template. You don't want regular CSAT (OPF_F) units on Tanoa, you want CSAT pacific (OPF_T_F).

 

The system to store the config also has not been built yet but it would be similar to what you have. More like

_CFG = "(configfile >> ""CfgGroups"" >> + _side + ">> " + _faction + " >> " + _GrpType " >> "; 

What I have so far is posted at the top.

Share this post


Link to post
Share on other sites

Is _position an object or what?

BIS_fnc_spawnGroup's first argument is a position which should be in an array format, thus meaning it can't be something like [object]. Additionally, the third argument is either: an array of unit types, a number, or a config entry. You're using a config entry, which does not need to be in an array, as far as I know.

 

_position is an object defined as 

_position = _origin call BIS_fnc_selectRandom;

_origin is 

_origin = _this select 2; 

which is an array of named markers/triggers/gamelogics.

 

I do see where I screwed up now not using 

getPos _position

So what I get from

_spawnVeh = [getPos _position, _faction, _armored21] call BIS_fnc_spawnGroup;
hint str _spawnveh; 

is a group name in hint

 O Alpha 2-3 

but nothing spawns.

Share this post


Link to post
Share on other sites

So _position is not always a position but probably a marker or gamelogic or trigger or object or position?

Like in these examples?

_Wave1 = [getPos player, _faction, 1] call BIS_fnc_spawnGroup;
_Wave2 = [getPos [9257.23,11274.73,0], _faction, 1] call BIS_fnc_spawnGroup;
_Wave3 = [getPos "someMarkerName", _faction, 1] call BIS_fnc_spawnGroup;

Do you see why it won't work in some cases?

You need to understand that certain script commands only work with certain typeNames.

If you want a markers position you need to use getMarkerPosition, catching my drift?

Also your _CFG variable holds a string, not a config.

_CFG = "(configfile >> ""CfgGroups"" >> + _side + ">> " + _faction + " >> " + _GrpType " >> "; 

The way you are using the quotation marks is messed up and won't work if _side, _faction and _GrpType are not strings.

 

From wherever your _origin is coming from, you need to filter for typeNames there and only put out positions.

 

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

_position is an object defined as 

_position = _origin call BIS_fnc_selectRandom;

_origin is 

_origin = _this select 2; 

which is an array of named markers/triggers/gamelogics.

 

I do see where I screwed up now not using 

getPos _position

So what I get from

_spawnVeh = [getPos _position, _faction, _armored21] call BIS_fnc_spawnGroup;
hint str _spawnveh; 

is a group name in hint

 O Alpha 2-3 

but nothing spawns.

You'll need to use getMarkerPos to return the location of a marker.

 

Additionally, why not make (example code):

_armored2 =  "(configfile >> ""CfgGroups"" >> ""East"" >> ""OPF_T_F"" >> ""Armored"" >> ";

_armored21 = _armored2 + selectRandom Armored1;

this:

_armored1 = ["O_T_SPGPlatoon_Scorcher"]; 
_armored21 =  (configfile >> "CfgGroups" >> "East" >> "OPF_T_F" >> "Armored" >> selectRandom _armored1);

That way it remains a config entry and doesn't become a string.

Share this post


Link to post
Share on other sites

So _position is not always a position but probably a marker or gamelogic or trigger or object or position?

Like in these examples?

_Wave1 = [getPos player, _faction, 1] call BIS_fnc_spawnGroup;
_Wave2 = [getPos [9257.23,11274.73,0], _faction, 1] call BIS_fnc_spawnGroup;
_Wave3 = [getPos "someMarkerName", _faction, 1] call BIS_fnc_spawnGroup;

Do you see why it won't work in some cases?

You need to understand that certain script commands only work with certain typeNames.

If you want a markers position you need to use getMarkerPosition, catching my drift?

Also your _CFG variable holds a string, not a config.

_CFG = "(configfile >> ""CfgGroups"" >> + _side + ">> " + _faction + " >> " + _GrpType " >> "; 

The way you are using the quotation marks is messed up and won't work if _side, _faction and _GrpType are not strings.

 

From wherever your _origin is coming from, you need to filter for typeNames there and only put out positions.

 

 

Cheers

I'm picking up what your putting down.

_position is, currently, using named gamelogic. Which is easy enough to have as a restriction.

 

What I need from this part of the script is for it to populate the CfgGroups section of BIS_fnc_spawngroup. This is currently not working because I am passing an array in the space for a config. Any idea how I would do this without assigning a variable to each entry from CfgGroups individually?

Share this post


Link to post
Share on other sites

You'll need to use getMarkerPos to return the location of a marker.

 

Additionally, why not make (example code):

_armored2 =  "(configfile >> ""CfgGroups"" >> ""East"" >> ""OPF_T_F"" >> ""Armored"" >> ";

_armored21 = _armored2 + selectRandom Armored1;

this:

_armored1 = ["O_T_SPGPlatoon_Scorcher"]; 
_armored21 =  (configfile >> "CfgGroups" >> "East" >> "OPF_T_F" >> "Armored" >> selectRandom _armored1);

That way it remains a config entry and doesn't become a string.

HAHA you and grumpy both pointing to the same thing. That has it working now as 

_armored2 =  (configfile >> "CfgGroups" >> _faction >> "OPF_T_F" >> "Armored" >> selectRandom Armored1);

Now I just need to make the rest of it.[ Thanks for the help!

  • Like 1

Share this post


Link to post
Share on other sites

So _position is not always a position but probably a marker or gamelogic or trigger or object or position?

Like in these examples?

_Wave1 = [getPos player, _faction, 1] call BIS_fnc_spawnGroup;
_Wave2 = [getPos [9257.23,11274.73,0], _faction, 1] call BIS_fnc_spawnGroup;
_Wave3 = [getPos "someMarkerName", _faction, 1] call BIS_fnc_spawnGroup;

Do you see why it won't work in some cases?

You need to understand that certain script commands only work with certain typeNames.

If you want a markers position you need to use getMarkerPosition, catching my drift?

Also your _CFG variable holds a string, not a config.

_CFG = "(configfile >> ""CfgGroups"" >> + _side + ">> " + _faction + " >> " + _GrpType " >> "; 

The way you are using the quotation marks is messed up and won't work if _side, _faction and _GrpType are not strings.

 

From wherever your _origin is coming from, you need to filter for typeNames there and only put out positions.

 

 

Cheers

 

Between you  u/HallyG I was able to get it going. Thanks for the help.

Share this post


Link to post
Share on other sites

This is currently not working because I am passing an array in the space for a config. Any idea how I would do this without assigning a variable to each entry from CfgGroups individually?

 

Don't pass an array to it then.

hallyg already posted the solution.

 

Again, easiest way:

_armored = ["O_T_SPGPlatoon_Scorcher", "O_T_SPGSection_Scorcher", "O_T_TankPlatoon", "O_T_TankPlatoon_AA", "O_T_TankSection"];
_cfg = (configfile >> "CfgGroups" >> "East" >> "OPF_T_F" >> "Armored" >> selectRandom _armored);

Since you're not telling what exactly your Armored1 array looks like, it's an educated guess at most.

 

Cheers

 

  • Like 1

Share this post


Link to post
Share on other sites

Don't pass an array to it then.

hallyg already posted the solution.

 

Again, easiest way:

_armored = ["O_T_SPGPlatoon_Scorcher", "O_T_SPGSection_Scorcher", "O_T_TankPlatoon", "O_T_TankPlatoon_AA", "O_T_TankSection"];
_cfg = (configfile >> "CfgGroups" >> "East" >> "OPF_T_F" >> "Armored" >> selectRandom _armored);

Since you're not telling what exactly your Armored1 array looks like, it's an educated guess at most.

 

Cheers

 

Sorry I thought I posted that already.  

Armored1 = [
	"O_T_SPGPlatoon_Scorcher",
	"O_T_SPGSection_Scorcher",
	"O_T_TankPlatoon",
	"O_T_TankPlatoon_AA",
	"O_T_TankSection"
];

I did not get Hallyg's reply until after I had replied to you. 

 

If I change Armored1 to _Armored1 will my script still see it as a valid variable? Local global confusion. I really do not know a lot about programming, I am just good at google.

Share this post


Link to post
Share on other sites

Now that I have had time to look at it again I am stuck here on data types.

_side = side _template;

_armored2 =  (configfile >> "CfgGroups" >> _side >> "OPF_T_F" >> "Armored" >> selectRandom Armored1);

Gives me 

Error Type Side, expected String

While 

_side = str side _template;

_armored2 =  (configfile >> "CfgGroups" >> _side >> "OPF_T_F" >> "Armored" >> selectRandom Armored1);

Gives me 

Error type String, expected Side

With this setup I do however get units spawned.

 

I think I can see the error but I have no idea how to correct it. Regardless of the data type used I do not get double quotes around EAST. I would very much appreciate any help anyone could give me on this.

Share this post


Link to post
Share on other sites

What is _template?  Can you just post all your current code? 

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

×