Jump to content
Sign in to follow this  
kyfohatl

Can you spot the error in this script?

Recommended Posts

This script is an altered version of Klomain's useful urban patrol script (thanks Klomain!). Basicaly, it scans a town using a trigger for the faction with the strongest presense (a script I wrote a while ago with the help of the community), then it spawns a group of reinforcements and some patrols for that city. The reinforcements group then joins the DAC zone for that faction and becomes a part of a large DAC battle that expands over a large part of the map:

The script is called via a trigger that is placed directly over the town, with Activation set to "ANYBODY" and "PRESENT", and with a condition of time > 60 (time needed for DAC to initiate). In the onActivation box:

MyProcedure = [city,thisList] execVM "CityPatrol.sqf"

Where "city" is the name of the marker placed directy on the town.

Here is CityPatrol.sqf (NOTE: both scripts have copied across to this post a bit strangely, so sometimes there are some extra line spacings that aren't there in the original script):

private 
["_unitList","_factionList","_N0CDF","_N0USMC","_N0RU","_N0GUE","_classCDF","_classUS

MC","_classRU","_classGUE","_Patrolgrp1","_Patrolgrp2","_Patrolgrp3","_Patrolgrp4","_

Patrolgrp5","_Patrolgrp6","_Patrolgrp7","_Patrolgrp8","_Patrolgrp9","_Patrolgrp9","_P

atrolgrp10","_Patrolgrp11","_Patrolgrp12","_classRandom","_CDF","_USMC","_RU","_GUE",

"_rulingFaction","_city"];

waitUntil {!isNil "BIS_func_init"};
sleep 1;
hint format ['Script'];

_city = _this select 0;

_CDF = 1;
_USMC = 2;
_RU = 3;
_GUE = 4;
_rulingFaction = 5;

// Chooses random class reinforcements
_classRandom = ["Infantry","Mechanized","Motorized","Armored"] call 

BIS_fnc_selectRandom;

// Loop every 60 sec
while {true} do {
// Count N0 units per faction
_unitList = _this select 1;
_factionList = [];
{_factionList = _factionList + [(faction _x)]} foreach _unitList;
_N0CDF = {_x == 'CDF'} count _factionList;
_N0USMC = {_x == 'USMC'} count _factionList;
_N0RU = {_x == 'RU'} count _factionList;
_N0GUE = {_x == 'GUE'} count _factionList;

// Checks for dominating faction

if ((_N0CDF > _N0USMC) AND (_N0CDF > _N0RU) AND (_N0CDF > _N0GUE)) then {


// Spawns reinforcements
Reinforcements = [_CDF,_classRandom,_city] execVM "Reinforcements.sqf";

// Check to see if this faction is not already the ruling faction
if (_rulingFaction != _CDF) then {

// Creates patrols
_classCDF = 
["CDF_InfSquad","CDF_InfSquad_Weapons","CDF_InfSection_AT","CDF_InfSection_Patrol"]; 

call 
BIS_fnc_selectRandom;

_Patrolgrp1 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "CDF" >> "Infantry" >> _classCDF)] call BIS_fnc_spawnGroup;
[_patrolgrp1, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp2 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "CDF" >> "Infantry" >> _classCDF)] call BIS_fnc_spawnGroup;
[_patrolgrp2, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp3 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "CDF" >> "Infantry" >> _classCDF)] call BIS_fnc_spawnGroup;
[_patrolgrp3, getMarkerPos _city] call BIS_fnc_taskDefend;
};
};


if ((_N0USMC > _N0CDF) AND (_N0USMC > _N0RU) AND (_N0USMC > _N0GUE)) then {

Reinforcements = [_USMC,_classRandom,_city] execVM "Reinforcements.sqf";

If (_rulingFaction != _USMC) then {

_classUSMC = 
["USMC_InfSquad","USMC_FireTeam","USMC_FireTeam_AT","USMC_FireTeam_MG","USMC_FireTeam_Support","USMC_HeavyATTeam"] call BIS_fnc_selectRandom;
_Patrolgrp4 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantyry" >> _classUSMC)] call BIS_fnc_spawnGroup;
[_patrolgrp4, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp5 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantyry" >> _classUSMC)] call BIS_fnc_spawnGroup;
[_patrolgrp5, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp6 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantyry" >> _classUSMC)] call BIS_fnc_spawnGroup;
[_patrolgrp6, getMarkerPos _city] call BIS_fnc_taskDefend;
};
};


if ((_N0Ru > _N0USMC) AND (_N0RU > _N0CDF) AND (_N0RU > _N0GUE)) then {

Reinforcements = [_RU,_classRandom,_city] execVM "Reinforcements.sqf";

If (_rulingFaction != _RU) then {

_classRU = 

["RU_InfSquad","RU_InfSection","RU_InfSection_AT","RU_InfSection_MG"] 
call BIS_fnc_selectRandom;

_Patrolgrp7 = [getMarkerPos _city, EAST, (configFile >> "CfgGroups" >> "EAST" >> "RU" >> "Infantry" >> _classRU)] call BIS_fnc_spawnGroup;
[_patrolgrp7, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp8 = [getMarkerPos _city, EAST, (configFile >> "CfgGroups" >> "EAST" >> "RU" >> "Infantry" >> _classRU)] call BIS_fnc_spawnGroup;
[_patrolgrp8, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp9 = [getMarkerPos _city, EAST, (configFile >> "CfgGroups" >> "EAST" >> "RU" >> "Infantry" >> _classRU)] call BIS_fnc_spawnGroup;
[_patrolgrp9, getMarkerPos _city] call BIS_fnc_taskDefend;
};
};


if ((_N0GUE > _N0USMC) AND (_N0GUE > _N0CDF) AND (_N0GUE > _N0RU)) then {

Reinforcements = [_GUE,_classRandom,_city] execVM "Reinforcements.sqf";

If (_rulingFaction != _GUE) then {

_classGUE = 
["GUE_InfSquad","GUE_InfSquad_Assault","GUE_InfSquad_Weapons","GUE_InfTeam_1","GUE_InfTeam_2","GUE_InfTeam_AT"];

_Patrolgrp10 = [getMarkerPos _city, RESISTANCE, (configFile >> "CfgGroups" >> "RESISTANCE" >> "GUE" >> "Infantry" >> _classGUE)] call BIS_fnc_spawnGroup;
[_patrolgrp10, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp11 = [getMarkerPos _city, RESISTANCE, (configFile >> "CfgGroups" >> "RESISTANCE" >> "GUE" >> "Infantry" >> _classGUE)] call BIS_fnc_spawnGroup;
[_patrolgrp11, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp12 = [getMarkerPos _city, RESISTANCE, (configFile >> "CfgGroups" >> "RESISTANCE" >> "GUE" >> "Infantry" >> _classGUE)] call BIS_fnc_spawnGroup;
[_patrolgrp12, getMarkerPos _city] call BIS_fnc_taskDefend;
};
};

sleep 60;
};

And here's Reinforcements.sqf:

// Script to generate reinforcements
private 

["_faction","_classType","_InfCDF","_MotCDF","_MechCDF","_InfUSMC","_MotUSMC","_MechU

SMC","_InfRU","_MotRU","_MechRU","_InfGUE","_MotGUE","_MechGUE","_grp1","_grp2","_grp

3","_grp4","_grp5","_grp6","_grp7","_grp8","_grp9","_grp10","_grp11","_grp12","_grp13

","_grp14","_grp15","_grp16","_CDF","_USMC","_RU","_GUE","_city"];

_faction = _this select 0;
_classType = _this select 1;
_city = _this select 2;

_CDF = 1;
_USMC = 2;
_RU = 3;
_GUE = 4;

/////////////////////////////////////////////////////////////////////////////////////

/////
//CDF
// Checks for faction
if (_faction == _CDF) then {
// Checks for class type
switch (_classType) do {

	case "Infantry": {
		// Randomizes class type
		_InfCDF = 

["CDF_InfSquad","CDF_InfSquad_Weapons","CDF_InfSection_AT","CDF_InfSection_AA","CDF_I

nfSection_MG","CDF_InfSection_Patrol","CDF_SniperTeam"] call BIS_fnc_selectRandom;

		_grp1 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "CDF" >> "Infantry" >> _InfCDF)] call BIS_fnc_spawnGroup;

		[_grp1,1,[z2],20,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
	};

	case "Motorized": {
	_MotCDF = 

["CDF_MotInfSquad","CDF_MotInfSection","CDF_MotInfSection_Weapons"] call BIS_fnc_selectRandom;

		_grp2 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "CDF" >> "Motorized" >> _MotCDF)] call BIS_fnc_spawnGroup;

		[_grp2,2,[z2],20,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
	};

	case "Mechanized": {
		_MechCDF = 

["CDF_MechInfSquad","CDF_MechReconSection","CDF_MechATSection"] call 

BIS_fnc_selectRandom;

		_grp3 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "CDF" >> "Mechanized" >> _MechCDF)] call BIS_fnc_spawnGroup;

		[_grp3,2,[z2],20,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
	};

	case "Armored": {
		_grp4 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "CDF" >> "Armored" >> "CDF_TankPlatoon")] call BIS_fnc_spawnGroup;

		[_grp4,3,[z2],20,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
	};
};
};


/////////////////////////////////////////////////////////////////////////////////////

////
//USMC

if (_faction == _USMC) then {
// Checks for class type
switch (_classType) do {

	case "Infantry": {
		// Randomizes class type
		_InfUSMC = 

["USMC_InfSquad","USMC_FireTeam","USMC_FireTeam_MG","USMC_FireTeam_AT","USMC_FireTeam

_Support","USMC_HeavyATTeam","USMC_SniperTeam","USMC_FRTeam"] call BIS_fnc_selectRandom;

		_grp5 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Infantry" >> _InfUSMC)] call BIS_fnc_spawnGroup;

		[_grp5,1,[z3],20,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
	};

	case "Motorized": {
	_MotUSMC = ["USMC_MotInfSection","USMC_MotInfSection_AT"] call 

BIS_fnc_selectRandom;

		_grp6 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Motorized" >> _MotUSMC)] call BIS_fnc_spawnGroup;

		[_grp6,2,[z3],20,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
	};

	case "Mechanized": {
		_MechUSMC = ["USMC_MechInfSquad","USMC_MechReconSection"] call BIS_fnc_selectRandom;

		_grp7 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Mechanized" >> _MechUSMC)] call BIS_fnc_spawnGroup;

		[_grp7,2,[z3],20,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
	};

	case "Armored": {
		_grp8 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Armored" >> "USMC_TankPlatoon")] call BIS_fnc_spawnGroup;

		[_grp8,3,[z3],20,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
	};
};
};


/////////////////////////////////////////////////////////////////////////////////////

////
//RU

if (_faction == _RU) then {
// Checks for class type
switch (_classType) do {

	case "Infantry": {
		// Randomizes class type
		_InfRU = 

["RU_InfSquad","RU_InfSection","RU_InfSection_AT","RU_InfSection_AA","RU_InfSection_M

G","RU_SniperTeam","RUS_ReconTeam","MVD_AssaultTeam"] call BIS_fnc_selectRandom;

		_grp9 = [getMarkerPos _city, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Infantry" >> _InfRU)] call BIS_fnc_spawnGroup;

		[_grp9,1,[z1],20,0,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
	};

	case "Motorized": {
	_MotRU = 

["RU_MotInfSquad","RU_MotInfSection_Recon","RU_MotInfSection_Patrol"] call 

BIS_fnc_selectRandom;

		_grp10 = [getMarkerPos _city, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Motorized" >> _MotRU)] call BIS_fnc_spawnGroup;

		[_grp10,2,[z1],20,0,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
	};

	case "Mechanized": {
		_MechRU = ["RU_MechInfSquad_1","RU_MechInfSquad_2"] call 

BIS_fnc_selectRandom;

		_grp11 = [getMarkerPos _city, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Mechanized" >> _MechRU)] call BIS_fnc_spawnGroup;

		[_grp11,2,[z1],20,0,1,[1,1,1],0,false] spawn 

DAC_fInsertGroup;
	};

	case "Armored": {
		_grp12 = [getMarkerPos _city, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Armored" >> "RU_TankPlatoon")] call BIS_fnc_spawnGroup;

		[_grp12,3,[z1],20,0,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
	};
};
};


/////////////////////////////////////////////////////////////////////////////////////

////
//GUE

if (_faction == _GUE) then {
// Checks for class type
switch (_classType) do {

	case "Infantry": {
		// Randomizes class type
		_InfGUE = ["GUE_InfSquad","GUE_InfSquad_Assault","GUE_InfSquad_Weapons","GUE_InfTeam_1","GUE_InfTeam_2","GUE_InfTeam_AT","GUE_GrpInf_TeamAA","GUE_GrpInf_TeamSniper"] call BIS_fnc_selectRandom;

		_grp13 = [getMarkerPos _city, RESISTANCE, (configFile >> "CfgGroups" >> "RESISTANCE" >> "GUE" >> "Infantry" >> _InfGUE)] call BIS_fnc_spawnGroup;

		[_grp13,1,[z4],20,2,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
	};

	case "Motorized": {
	_MotGUE = ["GUE_MotInfSection","GUE_MotInfSquad"] call BIS_fnc_selectRandom;

		_grp14 = [getMarkerPos _city, RESISTANCE, (configFile >> "CfgGroups" >> "RESISTANCE" >> "GUE" >> "Motorized" >> _MotGUE)] call BIS_fnc_spawnGroup;

		[_grp14,2,[z4],20,2,1,[1,1,1],0,false] spawn 

DAC_fInsertGroup;
	};

	case "Mechanized": {
		_MechGUE = ["GUE_MechInfSection","GUE_MechInfSquad"] call 

BIS_fnc_selectRandom;

		_grp15 = [getMarkerPos _city, RESISTANCE, (configFile >> "CfgGroups" >> "RESISTANCE" >> "GUE" >> "Mechanized" >> _MechGUE)] call 

BIS_fnc_spawnGroup;

		[_grp15,2,[z4],20,2,1,[1,1,1],0,false] spawn 

DAC_fInsertGroup;
	};

	case "Armored": {
		_MechGUE = ["GUE_MechInfSection","GUE_MechInfSquad"] call 

BIS_fnc_selectRandom;
		_grp16 = [getMarkerPos _city, RESISTANCE, (configFile >> "CfgGroups" >> "RESISTANCE" >> "GUE" >> "Mechanized" >> _MechGUE)] call 
BIS_fnc_spawnGroup;

		[_grp16,2,[z4],20,2,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
	};
};
};

...and for some reason it doesn't work. I've tried most part of my script individually, and they work fine, but together they don't. For example creating a patrol group on player's position as an individual script, or inserting some editor placed units into DAC work fine alone. Also note that I've added "hint format ['Script']" at the start of the script to note the player that the script is runing. But for some reason the hint never appears, even though BIS_fnc_init intializes fine (I've tested it). I've also checked both scripts using squint, and here's what it tells me:

For CityPatrol.sqf:

No matching signature for '<config> >> <Array>'

But it identifies this problem ONLY with the GUERILLA and the CDF, so the config lines for USMC and RUSSIA are apparantly correct.

For reinforcements.sqf:

Unknow variable z1

Unknown variable DAC_fInsertGroup

The in-game script error finder tells me nothing though...

Also, I personally think that error might have something to do with the "switch" I'm using:

case "Infantry": {

Maybe because the variable Infantry has quotation marks around it and it's not supossed to?

Thanks in advance for any help.

Edited by kyfohatl

Share this post


Link to post
Share on other sites
where do you define z1 z2 z3 z4

Do I need to define them? They are DAC zones, already present in the map. You probably already know what DAC is, but just in case you don't: With DAC, you can put a trigger on the map, and the trigger will spawn random groups that patrol randomly generated waypoints within the radius of the trigger. But you have to name the triggers using, "z1,z2,z3,etc." (representing zone1, zone2, etc.). So "z1,z2 and z3" are names of triggers in the map.

Here's a script I wrote to test to see if the DAC_fInsertGroup works:

[grp1,1,[z1],10,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;

And it works fine. So group 1 joins the DAC and begins patrolling between the randomly generated waypoints. So I don't know what squint is talking about there...

EDIT: Maybe the groups have to be global?

Share this post


Link to post
Share on other sites
No matching signature for '<config> >> <Array>'

That's because in the line

_Patrolgrp1 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "CDF" >> "Infantry" >> _classCDF)] call BIS_fnc_spawnGroup;

_classCDF is an array. You can't (afaik) reference a config entry by an array. Maybe you meant to select an element of the array ?

Unknow variable z1

Unknown variable DAC_fInsertGroup

Assuming these variables/functions really are defined elsewhere, you can ignore these warnings.

Maybe because the variable Infantry has quotation marks around it and it's not supossed to?

Quotation marks are fine but bear in mind that comparisons of switch variables are case-sensitive so make sure you have the right capitalisation when you call reinforcements.sqf.

Share this post


Link to post
Share on other sites

@sbsmac: Actually, the game's ingame script error finder tells me that "_classCDF" is a string. This is because I was testing it to see if it's an array, and the game told me:

Error: Type string, expected array

The reason why squint was warning me about an error was because I had accidentally placed a ";" somewhere in the script (relating to CDF) that wasn't a syntax error, but stuffed up the overall script. Anyway, I fixed that and now, so I get nor errors for CityPatrol.sqf when I put it in squint.

I think the error is the marker's position. I tested it with the simple script bellow:

_city = _this select 0
hint format ["%1", (getMarkerPos _city)

And I execute it using "MyProcedure = [city] execVM "test.sqf" where "city" is the marker placed on the city. In game I get a hint, but the hint says, "array" repeatedly. I don't know what's wrong here.

Oh, and by the way, great job with squint, it was very useful :).

Here's the fixed version of CityPatrol.sqf (though it still doesn't work):

private 
["_unitList","_factionList","_N0CDF","_N0USMC","_N0RU","_N0GUE","_classCDF","_classUSMC","_classRU","_classGUE","_Patrolgrp1","_Patrolgrp2","_Patrolgrp3","_Patrolgrp4","_Patrolgrp5","_Patrolgrp6","_Patrolgrp7","_Patrolgrp8","_Patrolgrp9","_Patrolgrp9","_Patrolgrp10","_Patrolgrp11","_Patrolgrp12","_classRandom","_CDF","_USMC","_RU","_GUE","_rulingFaction","_city"];

waitUntil {!isNil "BIS_func_init"};

_city = _this select 0;

_CDF = 1;
_USMC = 2;
_RU = 3;
_GUE = 4;
_rulingFaction = 5;

// Chooses random class reinforcements
_classRandom = ["Infantry","Mechanized","Motorized","Armored"] call BIS_fnc_selectRandom;

// Loop every 60 sec
while {true} do {
// Count N0 units per faction
_unitList = _this;
_factionList = [];
{_factionList = _factionList + [(faction _x)]} foreach _unitList;
_N0CDF = {_x == 'CDF'} count _factionList;
_N0USMC = {_x == 'USMC'} count _factionList;
_N0RU = {_x == 'RU'} count _factionList;
_N0GUE = {_x == 'GUE'} count _factionList;

// Checks for dominating faction

if ((_N0CDF > _N0USMC) AND (_N0CDF > _N0RU) AND (_N0CDF > _N0GUE)) then {


// Spawns reinforcements
Reinforcements = [_CDF,_classRandom,_city] execVM "Reinforcements.sqf";

// Check to see if this faction is not already the ruling faction
if (_rulingFaction != _CDF) then {

// Creates patrols
_classCDF = 
["CDF_InfSquad","CDF_InfSquad_Weapons","CDF_InfSection_AT","CDF_InfSection_Patrol"] call BIS_fnc_selectRandom;

_Patrolgrp1 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "CDF" >> "Infantry" >> _classCDF)] call BIS_fnc_spawnGroup;
[_patrolgrp1, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp2 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "CDF" >> "Infantry" >> _classCDF)] call BIS_fnc_spawnGroup;
[_patrolgrp2, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp3 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> "CDF" >> "Infantry" >> _classCDF)] call BIS_fnc_spawnGroup;
[_patrolgrp3, getMarkerPos _city] call BIS_fnc_taskDefend;
};
};


if ((_N0USMC > _N0CDF) AND (_N0USMC > _N0RU) AND (_N0USMC > _N0GUE)) then {

Reinforcements = [_USMC,_classRandom,_city] execVM "Reinforcements.sqf";

If (_rulingFaction != _USMC) then {

_classUSMC = 
["USMC_InfSquad","USMC_FireTeam","USMC_FireTeam_AT","USMC_FireTeam_MG","USMC_FireTeam_Support","USMC_HeavyATTeam"] call BIS_fnc_selectRandom;
_Patrolgrp4 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> 
"USMC" >> "Infantyry" >> _classUSMC)] call BIS_fnc_spawnGroup;
[_patrolgrp4, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp5 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> 
"USMC" >> "Infantyry" >> _classUSMC)] call BIS_fnc_spawnGroup;
[_patrolgrp5, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp6 = [getMarkerPos _city, WEST, (configFile >> "CfgGroups" >> "West" >> 
"USMC" >> "Infantyry" >> _classUSMC)] call BIS_fnc_spawnGroup;
[_patrolgrp6, getMarkerPos _city] call BIS_fnc_taskDefend;
};
};


if ((_N0Ru > _N0USMC) AND (_N0RU > _N0CDF) AND (_N0RU > _N0GUE)) then {

Reinforcements = [_RU,_classRandom,_city] execVM "Reinforcements.sqf";

If (_rulingFaction != _RU) then {

_classRU = ["RU_InfSquad","RU_InfSection","RU_InfSection_AT","RU_InfSection_MG"] 
call BIS_fnc_selectRandom;

_Patrolgrp7 = [getMarkerPos _city, EAST, (configFile >> "CfgGroups" >> "EAST" >> 
"RU" >> "Infantry" >> _classRU)] call BIS_fnc_spawnGroup;
[_patrolgrp7, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp8 = [getMarkerPos _city, EAST, (configFile >> "CfgGroups" >> "EAST" >> 
"RU" >> "Infantry" >> _classRU)] call BIS_fnc_spawnGroup;
[_patrolgrp8, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp9 = [getMarkerPos _city, EAST, (configFile >> "CfgGroups" >> "EAST" >> 
"RU" >> "Infantry" >> _classRU)] call BIS_fnc_spawnGroup;
[_patrolgrp9, getMarkerPos _city] call BIS_fnc_taskDefend;
};
};


if ((_N0GUE > _N0USMC) AND (_N0GUE > _N0CDF) AND (_N0GUE > _N0RU)) then {

Reinforcements = [_GUE,_classRandom,_city] execVM "Reinforcements.sqf";

If (_rulingFaction != _GUE) then {

_classGUE = 
["GUE_InfSquad","GUE_InfSquad_Assault","GUE_InfSquad_Weapons","GUE_InfTeam_1","GUE_InfTeam_2","GUE_InfTeam_AT"] call BIS_fnc_selectRandom;

_Patrolgrp10 = [getMarkerPos _city, RESISTANCE, (configFile >> "CfgGroups" >> "RESISTANCE" >> "GUE" >> "Infantry" >> _classGUE)] call BIS_fnc_spawnGroup;
[_patrolgrp10, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp11 = [getMarkerPos _city, RESISTANCE, (configFile >> "CfgGroups" >> "RESISTANCE" >> "GUE" >> "Infantry" >> _classGUE)] call BIS_fnc_spawnGroup;
[_patrolgrp11, getMarkerPos _city, 150] call BIS_fnc_taskPatrol;

_patrolgrp12 = [getMarkerPos _city, RESISTANCE, (configFile >> "CfgGroups" >> "RESISTANCE" >> "GUE" >> "Infantry" >> _classGUE)] call BIS_fnc_spawnGroup;
[_patrolgrp12, getMarkerPos _city] call BIS_fnc_taskDefend;
};
};

sleep 60;
};

This one gives no errors insquint, but still doesn't work.

Thanks for the help.

Share this post


Link to post
Share on other sites

I GOT IT WORKING (after many corrections)... Except for the Independents :(. But the script for spawning units for independents is pretty much a copy and paste of the previous ones with some changes to class names. So I don't know why it's not working. Here are the scripts:

For CityPatrol.sqf:

private 

["_CDF","_USMC","_RU","_GUE","_rulingFaction","_classRandom","_unitList","_factionList

","_N0CDF","_N0USMC","_N0RU","_N0GUE","_classCDF","_classUSMC","_classRU","_classGUE",

"_patrolgrp1","_patrolgrp2","_patrolgrp3","_patrolgrp4","_patrolgrp5","_patrolgrp6","_

patrolgrp7","_patrolgrp8"];

WaitUntil {!isNil "BIS_fnc_init"};

// Waits for DAC to initialize
sleep 20;
_CDF = 1;
_USMC = 2;
_RU = 3;
_GUE = 4;
_rulingFaction = 5;

// Loop
while {true} do {

// Randomizes class types for reinforcements
_classRandom = ["Infantry","Motorized","Mechanized"] call BIS_fnc_selectRandom;

// Finds the faction with the greates number of forces in the trigger area
_unitList = _this;
_factionList = [];
{_factionList = _factionList + [(faction _x)]} foreach _unitList;
_N0CDF = {_x == 'CDF'} count _factionList;
_N0USMC = {_x == 'USMC'} count _factionList;
_N0RU = {_x == 'RU'} count _factionList;
_N0GUE = {_x == 'GUE'} count _factionList;

//////////////////////////////////////////////////////////////////////////////////////
// CDF

if ((_N0CDF > _N0USMC) AND (_N0CDF > _N0RU) AND (_N0CDF > _N0GUE)) then {
            // Spawn some reinforcements that will join the battle on the side of the faction
Reinforcements = [_classRandom,_CDF] execVM "Reinforcements.sqf";

            // Checks to see if this faction is not already controling the area
if (_rulingFaction != _CDF) then {
sleep 20;

            // Spawns some patrols the first time a faction captures the town
_ClassCDF = 

["CDF_InfSquad","CDF_InfSquad_Weapons","CDF_InfSection_AT","CDF_InfSection_Patrol"] 

call BIS_fnc_selectRandom;

_patrolgrp1 = [getMarkerPos "city", WEST, (configFile >> "cfgGroups" >> "West" 

>> "CDF" >> "Infantry" >> _classCDF)] call BIS_fnc_spawnGroup;
[_patrolgrp1, getMarkerPos "city", 150] call BIS_fnc_taskPatrol;

_patrolgrp2 = [getMarkerPos "city", WEST, (configFile >> "cfgGroups" >> "West" 

>> "CDF" >> "Infantry" >> _classCDF)] call BIS_fnc_spawnGroup;
[_patrolgrp2, getMarkerPos "city", 150] call BIS_fnc_taskPatrol;
_rulingFaction = _CDF;
};
};


//////////////////////////////////////////////////////////////////////////////////////
// USMC

if ((_N0USMC > _N0CDF) AND (_N0USMC > _N0RU) AND (_N0USMC > _N0GUE)) then {
Reinforcements = [_classRandom,_USMC] execVM "Reinforcements.sqf";

if (_rulingFaction != _USMC) then {
sleep 20;
_ClassUSMC = 

["USMC_InfSquad","USMC_FireTeam","USMC_FireTeam_AT","USMC_FireTeam_MG","USMC_FireTeam_

Support","USMC_HeavyATTeam"] call BIS_fnc_selectRandom;

_patrolgrp3 = [getMarkerPos "city", WEST, (configFile >> "cfgGroups" >> "West" 

>> "USMC" >> "Infantry" >> _classUSMC)] call BIS_fnc_spawnGroup;
[_patrolgrp3, getMarkerPos "city", 150] call BIS_fnc_taskPatrol;

_patrolgrp4 = [getMarkerPos "city", WEST, (configFile >> "cfgGroups" >> "West" 

>> "USMC" >> "Infantry" >> _classUSMC)] call BIS_fnc_spawnGroup;
[_patrolgrp4, getMarkerPos "city", 150] call BIS_fnc_taskPatrol;
_rulingFaction = _USMC;
};
};


//////////////////////////////////////////////////////////////////////////////////////
// RU

if ((_N0RU > _N0USMC) AND (_N0RU > _N0CDF) AND (_N0RU > _N0GUE)) then {
Reinforcements = [_classRandom,_RU] execVM "Reinforcements.sqf";

if (_rulingFaction != _RU) then {
sleep 20;
_ClassRU = 

["RU_InfSquad","RU_InfSection","RU_InfSection_AT","RU_InfSection_MG"] 
call BIS_fnc_selectRandom;

_patrolgrp5 = [getMarkerPos "city", EAST, (configFile >> "cfgGroups" >> "East" 

>> "RU" >> "Infantry" >> _classRU)] call BIS_fnc_spawnGroup;
[_patrolgrp5, getMarkerPos "city", 150] call BIS_fnc_taskPatrol;

_patrolgrp6 = [getMarkerPos "city", EAST, (configFile >> "cfgGroups" >> "East" 

>> "RU" >> "Infantry" >> _classRU)] call BIS_fnc_spawnGroup;
[_patrolgrp6, getMarkerPos "city", 150] call BIS_fnc_taskPatrol;
_rulingFaction = _RU;
};
};


//////////////////////////////////////////////////////////////////////////////////////
// GUE

if ((_N0GUE > _N0USMC) AND (_N0GUE > _N0CDF) AND (_N0GUE > _N0RU)) then {
Reinforcements = [_classRandom,_GUE] execVM "Reinforcements.sqf";

if (_rulingFaction != _GUE) then {
sleep 20;
_ClassGUE = 

["GUE_InfSquad","GUE_InfSquad_Assault","GUE_InfSquad_Weapons","GUE_InfTeam_1","GUE_Inf

Team_2","GUE_InfTeam_AT"] call BIS_fnc_selectRandom;

_patrolgrp7 = [getMarkerPos "city", RESISTANCE, (configFile >> "cfgGroups" >> 

"Resistance" >> "GUE" >> "Infantry" >> _classGUE)] call BIS_fnc_spawnGroup;
[_patrolgrp7, getMarkerPos "city", 150] call BIS_fnc_taskPatrol;

_patrolgrp8 = [getMarkerPos "city", RESISTANCE, (configFile >> "cfgGroups" >> 

"Resistance" >> "GUE" >> "Infantry" >> _classGUE)] call BIS_fnc_spawnGroup;
[_patrolgrp8, getMarkerPos "city", 150] call BIS_fnc_taskPatrol;
_rulingFaction = _GUE;
};
};

sleep 180;
};

And "Reinforcements.sqf":

private ["_CDF", "_USMC", "_RU", "_GUE", "_classType", "_faction", "_InfCDF", "_InfUSMC", "_InfRU", "_InfGUE", "_MechCDF", "_MechUSMC", "_MechRU", "_MechGUE", "_MotCDF", "_MotUSMC", "_MotRU", "_MotGUE", "_grp1", "_grp2", "_grp3", "_grp4", "_grp5", "_grp6", "_grp7", "_grp8", "_grp9", "_grp10", "_grp11", "_grp12", "_grp13", "_grp14", "_grp15"];

// The reinforcements spawned are of random class and type. This script basically does this
_CDF = 1;
_USMC = 2;
_RU = 3;
_GUE = 4;
_classType = _this select 0;
_faction = _this select 1;
sleep 1;

//////////////////////////////////////////////////////////////////////////////////////
// CDF

If (_faction == _CDF) then {
switch (_classType) do {

case "Infantry": {
_InfCDF = ["CDF_InfSquad","CDF_InfSquad_Weapons","CDF_InfSection_AT","CDF_InfSection_AA","CDF_InfSection_Patrol","CDF_InfSection_MG","CDF_SniperTeam"] call BIS_fnc_selectRandom;

_grp1 = [getMarkerPos "city", WEST, (configFile >> "cfgGroups" >> "West" >> "CDF" >> "Infantry" >> _InfCDF)] call BIS_fnc_spawnGroup;

            // Causes the spawned reinforcements to join the DAC zone "z1"
[_grp1,1,[z1],10,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};

case "Motorized": {
_MotCDF = ["CDF_MotInfSquad","CDF_MotInfSection","CDF_MotInfSection_Weapons"] call BIS_fnc_selectRandom;

_grp2 = [getMarkerPos "city", WEST, (configFile >> "cfgGroups" >> "West" >> "CDF" >> "Motorized" >> _MotCDF)] call BIS_fnc_spawnGroup;
[_grp2,2,[z1],10,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};

case "Mechanized": {
_MechCDF = ["CDF_MechInfSquad","CDF_MechReconSection","CDF_MechATSection"] call BIS_fnc_selectRandom;

_grp3 = [getMarkerPos "city", WEST, (configFile >> "cfgGroups" >> "West" >> "CDF" >> "Mechanized" >> _MechCDF)] call BIS_fnc_spawnGroup;
[_grp3,2,[z1],10,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};

case "Armored": {
_grp4 = [getMarkerPos "city", WEST, (configFile >> "CfgGroups" >> "West" >> "CDF" >> "Armored" >> "CDF_TankPlatoon")] call BIS_fnc_spawnGroup;
[_grp4,3,[z1],10,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};
};};


//////////////////////////////////////////////////////////////////////////////////////
// USMC

If (_faction == _USMC) then {
switch (_classType) do {

case "Infantry": {
_InfUSMC = ["USMC_InfSquad","USMC_FireTeam","USMC_FireTeam_MG","USMC_FireTeam_AT","USMC_FireTeam_Support","USMC_HeavyATTeam","USMC_SniperTeam","USMC_FRTeam"] call BIS_fnc_selectRandom;

_grp5 = [getMarkerPos "city", WEST, (configFile >> "cfgGroups" >> "West" >> "USMC" >> "Infantry" >> _InfUSMC)] call BIS_fnc_spawnGroup;
[_grp5,1,[z1],10,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};

case "Motorized": {
_MotUSMC = ["USMC_MotInfSection","USMC_MotInfSection_AT"] call BIS_fnc_selectRandom;

_grp6 = [getMarkerPos "city", WEST, (configFile >> "cfgGroups" >> "West" >> "USMC" >> "Motorized" >> _MotUSMC)] call BIS_fnc_spawnGroup;
[_grp6,2,[z1],10,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};

case "Mechanized": {
_MechUSMC = ["USMC_MechInfSquad","USMC_MechReconSection"] call BIS_fnc_selectRandom;

_grp7 = [getMarkerPos "city", WEST, (configFile >> "cfgGroups" >> "West" >> "USMC" >> "Mechanized" >> _MechUSMC)] call BIS_fnc_spawnGroup;
[_grp7,2,[z1],10,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};

case "Armored": {
_grp8 = [getMarkerPos "city", WEST, (configFile >> "CfgGroups" >> "West" >> "USMC" >> "Armored" >> "USMC_TankPlatoon")] call BIS_fnc_spawnGroup;
[_grp8,3,[z1],10,1,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};
};};


//////////////////////////////////////////////////////////////////////////////////////
// RU

If (_faction == _RU) then {
switch (_classType) do {

case "Infantry": {
_InfRU = ["RU_InfSquad","RU_InfSection","RU_InfSection_AT","RU_InfSection_AA","RU_InfSection_MG","RU_SniperTeam","RUS_ReconTeam","MVD_AssaultTeam"] call BIS_fnc_selectRandom;

_grp9 = [getMarkerPos "city", EAST, (configFile >> "cfgGroups" >> "East" >> "RU" >> "Infantry" >> _InfRU)] call BIS_fnc_spawnGroup;
[_grp9,1,[z1],10,0,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};

case "Motorized": {
_MotRU = ["RU_MotInfSquad","RU_MotInfSection_Recon","RU_MotInfSection_Patrol"] call BIS_fnc_selectRandom;

_grp10 = [getMarkerPos "city", EAST, (configFile >> "cfgGroups" >> "East" >> "RU" >> "Motorized" >> _MotRU)] call BIS_fnc_spawnGroup;
[_grp10,2,[z1],10,0,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};

case "Mechanized": {
_MechRU = ["RU_MechInfSquad_1","RU_MechInfSquad_2"] call BIS_fnc_selectRandom;

_grp11 = [getMarkerPos "city", EAST, (configFile >> "cfgGroups" >> "East" >> "RU" >> "Mechanized" >> _MechRU)] call BIS_fnc_spawnGroup;
[_grp11,2,[z1],10,0,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};

case "Armored": {
_grp12 = [getMarkerPos "city", EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Armored" >> "RU_TankPlatoon")] call BIS_fnc_spawnGroup;
[_grp12,3,[z1],10,0,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};
};};


//////////////////////////////////////////////////////////////////////////////////////
// GUE

If (_faction == _GUE) then {
switch (_classType) do {

case "Infantry": {
_InfGUE = ["GUE_InfSquad","GUE_InfSquad_Assault","GUE_InfSquad_Weapons","GUE_InfTeam_1","GUE_InfTeam_2","GUE_InfTeam_AT","GUE_GrpInf_TeamAA","GUE_GrpInf_TeamSniper"] call BIS_fnc_selectRandom;

_grp13 = [getMarkerPos "city", RESISTANCE, (configFile >> "cfgGroups" >> "Resistance" >> "GUE" >> "Infantry" >> _InfGUE)] call BIS_fnc_spawnGroup;
[_grp13,1,[z1],10,2,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};

case "Motorized": {
_MotGUE = ["GUE_MotInfSection","GUE_MotInfSquad"] call BIS_fnc_selectRandom;

_grp14 = [getMarkerPos "city", RESISTANCE, (configFile >> "cfgGroups" >> "Resistance" >> "GUE" >> "Motorized" >> _MotGUE)] call BIS_fnc_spawnGroup;
[_grp14,2,[z1],10,2,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};

case "Mechanized": {
_MechGUE = ["GUE_MechInfSection","GUE_MechInfSquad"] call BIS_fnc_selectRandom;

_grp15 = [getMarkerPos "city", RESISTANCE, (configFile >> "cfgGroups" >> "Resistance" >> "GUE" >> "Mechanized" >> _MechGUE)] call BIS_fnc_spawnGroup;
[_grp15,2,[z1],10,2,1,[1,1,1],0,false] spawn DAC_fInsertGroup;
};
};};

As I said, the guerilla (Independents) are the only ones that don't work. So if a set a trigger, the script will spawn units for the faction with the most forces in the trigger area, some of which will patrol the town and the rest will join the battle, except for the guerilla. Any help please?

Oh, and "z1" is just a nuetral DAC zone with waypoints for all types of units, so anyone can join it.

Thanks for your time.

Edited by kyfohatl

Share this post


Link to post
Share on other sites

try changing to

[color=#000000][color=#007700][...([/color][color=#0000bb]configFile [/color][color=#007700]>> [/color][color=#dd0000]"cfgGroups" [/color][color=#007700]>> [/color][color=#dd0000]"Guerrila"[/color][/color] [color=#000000][color=#007700]>> [/color][color=#dd0000]"GUE" [/color][color=#007700]>> ...[/color][color=#007700]>> [/color]...[color=#007700])] [/color][color=#0000bb]call BIS_fnc_spawnGroup[/color][color=#007700];
[/color][/color]

instead of Resistance

Edited by nuxil

Share this post


Link to post
Share on other sites
try changing to

[color=#000000][color=#007700][...([/color][color=#0000bb]configFile [/color][color=#007700]>> [/color][color=#dd0000]"cfgGroups" [/color][color=#007700]>> [/color][color=#dd0000]"Guerrila"[/color][/color] [color=#000000][color=#007700]>> [/color][color=#dd0000]"GUE" [/color][color=#007700]>> ...[/color][color=#007700]>> [/color]...[color=#007700])] [/color][color=#0000bb]call BIS_fnc_spawnGroup[/color][color=#007700];
[/color][/color]

instead of Resistance

Excellent, it worked :yay: Thank you very much nuxil..

Ok, I'm going to change the title of this thread so that people searching for a script like this later on can find it.

...Noobish question: Is there a way to change the title?

Edited by kyfohatl

Share this post


Link to post
Share on other sites

nice to see your script working :)

Can you upload an exemple please ?

Thanks :)

Share this post


Link to post
Share on other sites
nice to see your script working :)

Can you upload an exemple please ?

Thanks :)

You mean an example mission? Because I was going to release this as a part of my mission (so don't worry, I will uploead one eventually :)). It's actually a very fun script, and pretty easy to use, and all you need to do is to attach it to a few towns, add a couple of DAC zones (you juts have to place a couple of markers and change a few things), then you're set and you'll have a pretty dynamic battle.

I will also edit the first post with my final version of the script soon.

Cheers

Edited by kyfohatl

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  

×