Jump to content
twakkie

Sector Module Scripting

Recommended Posts

Hi Guys

I am a novice mission maker but have become quite competent using the editor. I now have started scripting but I am stuck with the Sector Module. I love using this module, and for the most part it is easy to use through the editor, but for the life of me I cannot find anything about how to place this module through using a script. Could someone please help or direct me in the correct direction, thanks.

C

Share this post


Link to post
Share on other sites

That's a bit complicated I believe, because you will need to create a logic vehicle, then attach all the necessary variables associated with the module, then alter/set those variables to your liking, a bit more trouble than it's worth IMO.

Share this post


Link to post
Share on other sites
That's a bit complicated I believe, because you will need to create a logic vehicle, then attach all the necessary variables associated with the module, then alter/set those variables to your liking, a bit more trouble than it's worth IMO.

Thanks for the answer Shock. I didnt think it would be easy. The reason I want to add this is I want to create a gamemode where you can create as many Sectors as you want. Would you maybe humor me for a bit. Below I added BIS_fnc_moduleSector, which just gave me a headache. How would I go about now attaching the variables to the logic vehicle (also would "_unit createUnit ["LOGIC", [0, 0, 0], [], 0, "NONE"];" be the right way to create this logic). Any help would be appreciated.

/*
Author: Karel Moricky

Description:
Initialize a sector module. Can be also used to get sector parameters.

--- Get all sectors ---
Parameter(s):
	0: BOOL

Returns:
ARRAY of OBJECTs

--- Get number of sectors held by a side ---
Parameter(s):
	0: SIDE

Returns:
NUMBER - number of sectors owned by the side

--- Set sector owner ---
Parameter(s):
	0: OBJECT - sector module
	1: SIDE

Returns:
BOOL

--- Initialize ---
Parameter(s):
	0: OBJECT - sector module

Returns:
NOTHING
*/

private ["_logic","_units","_activated"];
_logic = [_this,0,objnull,[objnull,sideunknown,true]] call bis_fnc_param;
_units = [_this,1,[],[[],sideunknown]] call bis_fnc_param;
_activated = [_this,2,true,[true]] call bis_fnc_param;

//--- Return all sectors
if (typename _logic == typename true) exitwith {
missionnamespace getvariable ["BIS_fnc_moduleSector_sectors",[]]
};

//--- Return sectors belonging to a side
if (typename _logic == typename sideunknown) exitwith {
private ["_side","_sideID","_sideSectors"];
_side = _logic;
_sideID = _side call bis_fnc_sideID;
_sideSectors = missionnamespace getvariable ["BIS_fnc_moduleSector_sideSectors",[-1,-1,-1,-1,-1]];
if (_sideID in [0,1,2,3,4]) then {_sideSectors select _sideID} else {-1}
};

//--- Set side
if (typename _units == typename sideunknown) exitwith {
_logic setvariable ["owner",_units,true];
true
};

//--- Initialize the sector
if !(_activated) exitwith {};
_mode = [_this,3,"init",[""]] call bis_fnc_param;

switch _mode do {

case "init": {
	[_logic,[],_activated,"server"] spawn bis_fnc_moduleSector;
	waituntil {!isnil {_logic getvariable "finalized"}}; //--- Wait until the module is initialized
};

case "server": {
	/////////////////////////////////////////////////////////////////////////////////////
	// Server
	/////////////////////////////////////////////////////////////////////////////////////
	_loadingScreen = format ["BIS_fnc_moduleSector:%1",_logic];
	_loadingScreen call bis_fnc_startloadingscreen;

	//--- Prepare error handling
	_exitCode = {
		_sectorsError = missionnamespace getvariable ["BIS_fnc_moduleSector_sectorsError",[]];
		_sectorsError set [count _sectorsError,_logic];
		missionnamespace setvariable ["BIS_fnc_moduleSector_sectorsError",_sectorsError];
		publicvariable "BIS_fnc_moduleSector_sectorsError";
		 _loadingScreen call bis_fnc_endloadingscreen;
	};

	//--- Wait until previous sectors are initialized to maintain the same order as in editor
	waituntil {
		_sectors = (entities "ModuleSector_F") - (missionnamespace getvariable ["BIS_fnc_moduleSector_sectors",[]]) - (missionnamespace getvariable ["BIS_fnc_moduleSector_sectorsError",[]]);
		if (count _sectors > 0) then {(_sectors select 0) == _logic} else {true};
	};

	_logicParent = _logic;
	if (typeof _logic == "ModuleSectorDummy_F") then {
		{
			if (typeof _x == "ModuleSector_F") then {_logicParent = _x;};
		} foreach (synchronizedobjects _logic);
	};

	//--- Load params
	[_logic,"BIS_fnc_moduleSector_sector"] call bis_fnc_objectvar;
	_name = _logic getvariable ["Name",""];
	_designation = _logic getvariable ["Designation",""];
	_ownerLimit = (_logicParent getvariable ["OwnerLimit","0"]) call bis_fnc_parsenumber;
	_onOwnerChange = compile (_logicParent getvariable ["OnOwnerChange","true"]);
	_captureCoef = (_logicParent getvariable ["CaptureCoef","0.05"]) call bis_fnc_parsenumber;
	_costInfantry = (_logicParent getvariable ["CostInfantry","1"]) call bis_fnc_parsenumber;
	_costWheeled = (_logicParent getvariable ["CostWheeled","1"]) call bis_fnc_parsenumber;
	_costTracked = (_logicParent getvariable ["CostTracked","1"]) call bis_fnc_parsenumber;
	_costWater = (_logicParent getvariable ["CostWater","1"]) call bis_fnc_parsenumber;
	_costAir = (_logicParent getvariable ["CostAir","1"]) call bis_fnc_parsenumber;
	_costPlayers = compile (_logicParent getvariable ["CostPlayers","1"]);
	_defaultOwner = (_logicParent getvariable ["DefaultOwner","-1"]) call bis_fnc_parsenumber;
	_taskOwner = (_logicParent getvariable ["TaskOwner",0]) call bis_fnc_parsenumber;
	_taskTitle = _logicParent getvariable ["TaskTitle","%1"];
	_taskDescription = _logicParent getvariable ["TaskDescription","%1%2%3"];
	_scoreReward = (_logicParent getvariable ["ScoreReward",0]) call bis_fnc_parsenumber;
	_sides = _logic getvariable ["sides",[]]; //--- Not configurable in module attributes, only by script
	_useDefaultSides = !isnil {_logic getvariable "sides"};

	//--- Register the expression as a scripted event handler
	[_logic,"ownerChanged",_onOwnerChange] call bis_fnc_addscriptedeventhandler;

	//--- Load visuals
	if (_name == "") then {
		_nameID = ["BIS_fnc_moduleSector_nameID",1] call bis_fnc_counter;
		_nameID = ((_nameID - 1) % 26) + 1;
		_name = _nameID call bis_fnc_phoneticalWord;
		_logic setvariable ["name",_name];
	};
	_nameLocalized = _name call bis_fnc_localize;
	if (_designation == "") then {_designation = _nameLocalized;};
	_designation = tostring [toarray _designation select 0];
	_markerName = if ((toarray _nameLocalized select 0) == (toarray _designation select 0)) then {_nameLocalized} else {format ["%1: %2",_designation,_nameLocalized];};

	_icon = "n_installation";
	_iconTexture = _icon call bis_fnc_textureMarker;

	//--- Load synced objects
	_sectorsModules = count (entities "ModuleSector_F");
	_sectors = missionnamespace getvariable ["BIS_fnc_moduleSector_sectors",[]];
	_sectorID = count _sectors;
	_areas = [];
	_sideUnits = [[],[],[],[],[],[]];
	_sectorScore = [0,0,0,0,0,0];
	_sideScore = [0,0,0,0,0,0];
	_tasks = ["","","","","",""];
	_taskOrders = [true,true,true,true,true,true];
	_flags = [];
	_markersArea = [];
	_markerIcon = "";
	_markerIconText = "";
	_taskDescriptionUnlocks = "";
	_unlockTriggers = [[],[],[],[],[]];

	_fnc_initArea = {
		_trigger = _this;
		_areas = _areas - [_trigger];
		_areas set [count _areas,_trigger];

		_trigger settriggeractivation ["any","present",false];
		_trigger settriggerstatements ["false","",""];
		_trigger settriggertype "none";

		_triggerMarkers = _trigger getvariable ["markers",[]];
		_markerArea = createmarker ["BIS_fnc_moduleSector_area" + str _trigger,position _trigger];
		_markerArea setmarkerbrush "grid";
		_markerArea setmarkercolor "colorwhite";
		_markerArea setmarkeralpha 0;
		_markersArea set [count _markersArea,_markerArea];
		_triggerMarkers set [count _triggerMarkers,_markerArea];

		if (_markerIcon == "") then {
			_markerIcon = createmarker ["BIS_fnc_moduleSector_icon" + str _logic,position _trigger];
			_markerIcon setmarkertype _icon;
			_markerIcon setmarkercolor "colorwhite";
			//_markerIcon setmarkertext _markerName;
			_markerIcon setmarkersize [1.5,1.5];
			_markerIcon setmarkeralpha 0;
			_triggerMarkers set [count _triggerMarkers,_markerIcon];

			_markerIconText = createmarker ["BIS_fnc_moduleSector_iconText" + str _logic,position _trigger];
			_markerIconText setmarkertype "EmptyIcon";
			_markerIconText setmarkercolor "colorblack";
			_markerIconText setmarkertext _markerName;
			_markerIconText setmarkersize [1.5,1.5];
			_markerIconText setmarkeralpha 0;
			_triggerMarkers set [count _triggerMarkers,_markerIconText];
		};
		_trigger setvariable ["markers",_triggerMarkers];
		_trigger setvariable ["pos",[0,0,0]];

		//--- Show sector rewards
		{
			_xtype = tolower typeof _x;
			switch _xType do {
				case "modulerespawnposition_f": {
					_xTypeID = (_x getvariable ["Type","0"]) call bis_fnc_parsenumber;
					_xSideID = (_x getvariable ["Side","-1"]) call bis_fnc_parsenumber;
					_xSideName = if (_xSideID < 0) then {localize "STR_A3_CfgVehicles_ModuleRespawnPosition_F_Arguments_Side_values_Leader_0"} else {_xSideID call bis_fnc_sidename};

					_xMarkerType = ["respawn_inf","respawn_unknown","respawn_motor","respawn_armor","respawn_air","respawn_plane"] select _xTypeID;
					_xMarkerTypeName = gettext (configfile >> "cfgmarkers" >> _xMarkerType >> "name");
					_xMarkerIcon = (gettext (configfile >> "cfgmarkers" >> _xMarkerType >> "texture")) call bis_fnc_textureMarker;
					_taskDescriptionUnlocks = _taskDescriptionUnlocks + format ["<img image='%1' width='16'/> %2 (%3)<br />",_xMarkerIcon,_xMarkerTypeName,_xSideName];
				};
				case "modulerespawnvehicle_f": {
					_xLogic = _x;
					{
						_xCfg = configfile >> "cfgvehicles" >> typeof _x;
						_xSimulation = tolower gettext (_xCfg >> "simulation");
						if (_xSimulation in ["carx","tankx","helicopterx","helicopterrtd","planex","shipx","submarinex"]) then {
							_xName = gettext (_xCfg >> "displayName");
							_xPicture = (gettext (_xCfg >> "picture")) call bis_fnc_textureVehicleIcon;
							_xPosition = (_xLogic getvariable ["Position","0"]) call bis_fnc_parsenumber;
							_xSide = switch _xPosition do {
								case 2: {(getnumber (_xCfg >> "side")) call bis_fnc_sideName;};
								case 3;
								case 4;
								case 5;
								case 6: {(_xPosition - 3) call bis_fnc_sideName;};
								default {""};
							};
							if (_xSide != "") then {_xSide = format ["(%1)",_xSide];};
							_taskDescriptionUnlocks = _taskDescriptionUnlocks + format ["<img image='%1' width='16'/> %2 %3<br />",_xPicture,_xName,_xSide];
						};
					} foreach (synchronizedobjects _x);
				};
			};
		} foreach (synchronizedobjects _trigger);
	};

	{
		switch (true) do {
			case (typeof _x == "LocationArea_F"): {
				{
					if (_x iskindof "EmptyDetector") then {
						_x call _fnc_initArea;
					};
				} foreach (synchronizedobjects _x);
			};
			case (typeof _x == "MiscUnlock_F"): {
				{
					if (_x iskindof "EmptyDetector") then {
						_trigger = _x;
						_side = triggeractivation _trigger select 0;
						_sideIDs = switch _side do {
							case "EAST";
							case "WEST";
							case "GUER";
							case "CIV";
							case "LOGIC": {[["EAST","WEST","GUER","CIV","LOGIC"] find _side];};
							case "ANY": {[0,1,2,3,4]};
							default {[]};
						};
						{
							_sideTriggers = _unlockTriggers select _x;
							_sideTriggers set [count _sideTriggers,_trigger];

							_triggerStatements = triggerstatements _trigger;
							_triggerStatements set [
								0,
								format [
									"(%1 getvariable ['owner',sideunknown]) == %2",
									_logic,
									["east","west","resistance","civilian","sideunknown"] select _x
								]
							];
							_trigger settriggerstatements _triggerStatements;
						} foreach _sideIDs;
					};
				} foreach (synchronizedobjects _x);

			};
			case (_x iskindof "FlagCarrierCore"): {
				_flags set [count _flags,_x];
			};
		};
	} foreach (synchronizedobjects _logic);

	//--- No synced triggers found - create a default one
	if (count _areas == 0) then {
		_areaTrigger = createtrigger ["emptydetector",position _logic];
		_areaTrigger settriggerarea [50,50,0,false];
		_areaTrigger call _fnc_initArea;
		_areaTrigger attachto [_logic];
	};

	//--- Explain capture ratios
	_participant = "<font color='%2'>%1</font>";
	_participantColor = {if (_this > 0) then {"#ffffff"} else {"#33ffffff"}};
	_taskDescriptionCapture = format [
		"<br /><br /><font size='18'>%1</font><br />%2 / %3 / %4 / %5 / %6",
		localize "str_a3_cfgvehicles_modulesector_f_forces",
		format [_participant,gettext (configfile >> "CfgVehicleClasses" >> "Men" >> "displayName"),_costInfantry call _participantColor],
		format [_participant,gettext (configfile >> "CfgVehicleClasses" >> "Car" >> "displayName"),_costWheeled call _participantColor],
		format [_participant,gettext (configfile >> "CfgVehicleClasses" >> "Armored" >> "displayName"),_costTracked call _participantColor],
		format [_participant,gettext (configfile >> "CfgVehicleClasses" >> "Air" >> "displayName"),_costAir call _participantColor],
		format [_participant,gettext (configfile >> "CfgVehicleClasses" >> "Ship" >> "displayName"),_costWater call _participantColor]
		//format [_participant,localize "str_disp_mp_players_title",_costPlayers call _participantColor]
	];

	//--- Explain sector unlocks
	if (_taskDescriptionUnlocks != "") then {
		_taskDescriptionUnlocks = format ["<br /><br /><font size='18'>%1</font><br />%2",localize "str_a3_cfgvehicles_modulesector_f_rewards",_taskDescriptionUnlocks];
	};

	_taskPos = position (_areas select 0);
	{
		switch (true) do {
			case (_x iskindof "SideBLUFOR_F");
			case (_x iskindof "SideOPFOR_F");
			case (_x iskindof "SideResistance_F"): {
				_side = (["SideOPFOR_F","SideBLUFOR_F","SideResistance_F"] find (typeof _x)) call bis_fnc_sideType;
				_sides set [count _sides,_side];
			};
		};
	} foreach ([_logic,[typeof _logic]] call bis_fnc_allSynchronizedObjects);

	if (count _sides == 0 && _useDefaultSides) then {_sides = [east,west,resistance,civilian];};
	//if (count _sides == 0) exitwith {["No sides defined for %1",_logic] call bis_fnc_error; [] call _exitCode};
	if (_defaultOwner >= 0 && !((_defaultOwner call bis_fnc_sidetype) in _sides)) then {["Default owner %1 is not a competing side for sector %2. No default owner used instead.",_defaultOwner call bis_fnc_sidetype,_name] call bis_fnc_error;};

	//--- Save global variables
	_logic setvariable ["finalized",false,true];
	_logic setvariable ["pos",markerpos _markerIcon,true];
	_logic setvariable ["areas",_areas,true];
	_logic setvariable ["sides",_sides,true];
	_logic setvariable ["flags",_flags,true];
	_logic setvariable ["tasks",_tasks,true];
	_logic setvariable ["designation",_designation,true];

	_sectors set [count _sectors,_logic];
	missionnamespace setvariable ["BIS_fnc_moduleSector_sectors",_sectors];
	publicvariable "BIS_fnc_moduleSector_sectors";

	if (isnil {BIS_fnc_moduleSector_sideSectors}) then {BIS_fnc_moduleSector_sideSectors = [0,0,0,0,0];};

	//--- Execute local function
	//[[_logic,[],true,"player"],"bis_fnc_moduleSector",_sides - [sideunknown],true] call bis_fnc_mp;

	_fnc_conversion = {
		_total = 0;
		_result = +(_this select 0);
		_coef = _this select 1;
		{_total = _total + _x;} foreach _result;
		if (_total > 1) then {
			{
				_result set [_foreachindex,(_result select _foreachindex) / _total * _coef];
			} foreach _result;
		};
		_result
	};
	_fnc_threat = {
		private ["_veh","_coef","_scanCrew","_threat","_score"];
		_veh = _this select 0;
		_coef = _this select 1;
		_scanCrew = _this select 2;
		_threat = getarray (configfile >> "cfgvehicles" >> typeof _veh >> "threat");

		_score = 0;
		{_score = _score + _x} foreach _threat;
		_score = _score * _coef;
		if (isplayer _veh) then {_score = _score * _costPlayersLocal;};

		if (_scanCrew) then {
			{
				_score = _score + ([_x,_costInfantry,false] call _fnc_threat);
				if (isplayer _x) then {_score = _score * _costPlayersLocal;};
			} foreach (crew _veh - [_veh]);
		};
		_score
	};
	_fnc_sort = {
		_unsorted = +_sectorScore;
		_sorted = [];
		while {count _sorted != count _unsorted} do {
			_max = -1;
			_maxIndex = -1;
			_index = count _sorted;
			{
				if (_x > _max) then {
					_max = _x;
					_maxIndex = _foreachindex;
					_sorted set [_index,_maxIndex];
				};
			} foreach _unsorted;
			_unsorted set [_maxIndex,-1];
		};
		_sorted
	};

	//--- Wait until scripts are initialized (to avoid being faster than initServer.sqf)
	waituntil {!isnil "bis_fnc_init"};
	_loadingScreen call bis_fnc_endloadingscreen;


	//--- Global loop -----------------------------------------------------------
	_allSides = [east,west,resistance,civilian,sideunknown,sideenemy];
	_time = 0;
	_pos = position _logic;
	_owner = sideEnemy;
	_ownerOld = _owner;
	_maxScoreOld = 0;
	_firstLoop = true;
	_sidesOld = [];
	_sidesOldStr = str _sidesOld;
	_nameOld = _name;
	_step = 0;
	_taskTitles = [];
	_taskDescriptions = [];
	_curatorObject = _logic getvariable ["curatorObject",objnull];
	_logicAreaShow = !isnull _curatorObject;
	_logicArea = objnull;
	_logicAreaSize = 0;

	while {!(isnull _logic) && (simulationenabled _logic) && !(_logic getvariable ["finalized",false])} do {

		//--- Load variables
		_areas = _logic getvariable ["areas",_areas];
		_sides = _logic getvariable ["sides",_sides];
		_flags = _logic getvariable ["flags",_flags];
		_tasks = _logic getvariable ["tasks",_tasks];
		_ownerForced = _logic getvariable ["owner",_owner];
		_name = _logic getvariable ["name",_name];
		_designation = _logic getvariable ["designation",_designation];
		_logicAreaUpdate = false;

		//--- Detect participating sides
		if (str _sides != _sidesOldStr) then {

			//--- Show MP progress HUD
			[[_logic,[],true,"player"],"bis_fnc_moduleSector",_sides - _sidesOld,true] call bis_fnc_mp;

			//--- Get task titles and descriptions per side (scripted option only)
			_taskTitle = _logicParent getvariable ["TaskTitle","%1"];
			_taskTitles = _taskTitle;
			if (typename _taskTitles == typename "") then {
				_taskTitles = [_taskTitles];
			};
			_taskTitle = "";
			for "_i" from 0 to 5 do {
				_taskTitle = [_taskTitles,_i,_taskTitle,[""]] call bis_fnc_paramin;
				_taskTitles set [_i,_taskTitle];
			};
			_taskDescription = _logicParent getvariable ["TaskDescription","%1%2%3"];
			_taskDescriptions = _taskDescription;
			if (typename _taskDescriptions == typename "") then {
				_taskDescriptions = [_taskDescriptions];
			};
			_taskDescription = "";
			for "_i" from 0 to 5 do {
				_taskDescription = [_taskDescriptions,_i,_taskDescription,[""]] call bis_fnc_paramin;
				_taskDescriptions set [_i,_taskDescription];
			};

			//--- Show / hide markers
			if (count _sides > 0) then {
				if (markeralpha _markerIcon == 0) then {
					{_x setmarkeralpha 1;} foreach [_markerIcon,_markerIconText];
					{if (markerColor _x == "colorblack") then {_x setmarkeralpha 0.25;} else {_x setmarkeralpha 0.5;};} foreach _markersArea;
				};
			} else {
				if (markeralpha _markerIcon == 1) then {
					{_x setmarkeralpha 0;} foreach (_markersArea + [_markerIcon,_markerIconText]);
				};
			};

			//--- Add sides
			{
				_side = _x;
				_sideID = _side call bis_fnc_sideID;

				_task = _tasks select _sideID;
				_taskOrder = true;
				_addTask = switch _taskOwner do {
					case 0: {false};
					case 1: {true};
					case 2: {_sideID == _defaultOwner};
					case 3: {_sideID != _defaultOwner};
				};
				if (_task == "" && _addTask) then {

					//--- Set currents tasks from the top (false) or from the bottom (true)
					_taskOrder = if (_defaultOwner >= 0) then {
						[_side,_defaultOwner call bis_fnc_sidetype] call bis_fnc_arefriendly
					} else {
						([_side,east] call bis_fnc_arefriendly) || !([_side,west] call bis_fnc_arefriendly)
					};

					//--- Add tasks
					_taskTitle = _taskTitles select _sideID;
					_taskDescription = _taskDescriptions select _sideID;
					if (_taskTitle == "") then {_taskTitle = "%1";};
					if (_taskDescription == "") then {_taskDescription = "%1%2%3";};
					_taskID = str _logic + str _side;
					_taskPrio = _sectorID / _sectorsModules;
					_taskCurrent = if (_taskOrder) then {_sectorID == _sectorsModules - 1} else {_taskPrio = 1 - _taskPrio; _sectorID == 0};
					_task = [_taskID,_side,[[_taskDescription,_nameLocalized,_taskDescriptionCapture,_taskDescriptionUnlocks],[_taskTitle,_nameLocalized],_nameLocalized],_taskPos,_taskCurrent,_taskPrio] call bis_fnc_setTask;
				};
				_scoreDefault = if (_sideID == _defaultOwner) then {1} else {0};

				_sideUnits set [_sideID,[]];
				_sectorScore set [_sideID,_scoreDefault];
				_sideScore set [_sideID,_scoreDefault];
				_tasks set [_sideID,_task];
				_taskOrders set [_sideID,_taskOrder];
			} foreach (_sides - _sidesOld);

			//--- Remove sides
			{
				_side = _x;
				_sideID = _side call bis_fnc_sideID;
				_task = _tasks select _sideID;
				if (_task != "") then {
					//[_task,nil,nil,nil,"canceled"] call bis_fnc_settask;
					_task call bis_fnc_deletetask;
					_tasks set [_sideID,""];
				};
			} foreach (_sidesOld - _sides);

			_logic setvariable ["tasks",_tasks,true];
		};
		_sidesOld = _sides;
		_sidesOldStr = str _sidesOld;
		_sides = [sideunknown] + _sides;

		//--- Name changed
		if (_name != _nameOld) then {
			_nameLocalized = _name call bis_fnc_localize;
			_designation = tostring [toarray _name select 0];
			_logic setvariable ["designation",_designation,true];
			_markerName = if ((toarray _name select 0) == (toarray _designation select 0)) then {_nameLocalized} else {format ["%1: %2",_designation,_nameLocalized];};
			_markerIconText setmarkertext _markerName;
			{
				if (_x != "") then {
					_taskTitle = _taskTitles select _foreachindex;
					_taskDescription = _taskDescriptions select _foreachindex;
					if (_taskTitle == "") then {_taskTitle = "%1";};
					if (_taskDescription == "") then {_taskDescription = "%1%2%3";};
					[_x,nil,[[_taskDescription,_nameLocalized,_taskDescriptionCapture,_taskDescriptionUnlocks],[_taskTitle,_nameLocalized],_nameLocalized]] call bis_fnc_setTask;
				};
			} foreach _tasks;
			_nameOld = _name;
		};

		//--- Position changed
		if (position _logic distance _pos > 0) then {
			_pos = position _logic;
			{
				[_x,nil,nil,_pos] call bis_fnc_setTask;
			} foreach _tasks;
		};

		//--- Detect leading side
		_owner = sideUnknown;
		_timeCoef = _captureCoef * (time - _time);

		_sectorScore = [_sectorScore,1] call _fnc_conversion;
		_sectorScoreSorted = _sectorScore call _fnc_sort;

		_side1ID = _sectorScoreSorted select 0;
		_side1score = _sectorScore select _side1ID;
		_scoreDiffAdd = 0;
		_scoreDiffRemove = 0;
		if (count _sides > 1) then {
			_side2ID = _sectorScoreSorted select 1;
			_side2score = _sectorScore select _side2ID;
			_scoreDiffAdd = (_side1score - _side2score) * _timeCoef;
			_scoreDiffRemove = _scoreDiffAdd / ((count _sides - 1) max 1);
		};

		//--- Force owner
		if (_ownerForced != _ownerOld && _ownerForced in _sides) then {
			_ownerForcedID = _ownerForced call bis_fnc_sideID;
			{
				_sideScore set [_foreachindex,if (_foreachindex == _ownerForcedID) then {1} else {0}];
			} foreach _sideScore;
		};

		//--- Increase score of the leader, decrease score of others
		_maxScore = 0;
		_ownerScore = 0;
		_totalScore = 0;
		_ownerID = -1;
		_sideUnitsLocal = +_sideUnits;
		{
			if (_x in _sides) then {
				_xScore = _sideScore select _foreachindex;
				_xScore = if (_foreachindex == _side1ID) then {
					_xScore + _scoreDiffAdd
				} else {
					(_xScore - _scoreDiffRemove) max 0
				};
				if (_xScore >= _ownerLimit && _xScore > _ownerScore) then {
					_owner = _x;
					_ownerScore = _xScore;
					_ownerID = _foreachindex;
				};
				_totalScore = _totalScore + _xScore;
				if (_foreachindex > 0) then {_maxScore = _maxScore max _xScore min 1;};
				_sideScore set [_foreachindex,_xScore];
				_sectorScore set [_foreachindex,0];
				_sideUnits set [_foreachindex,[]];
			} else {
				_sideScore set [_foreachindex,0];
			};
		} foreach _allSides;//_sides;
		if (_totalScore < 0.99999) then {_sideScore set [4,1 - _totalScore];}; //--- Don't compare with 1, because it's not always 1 ;)
		_sideScore = [_sideScore,1] call _fnc_conversion;

		//--- Store sector score
		_logic setvariable ["sideScore",_sideScore,true];

		//--- Store sector status
		_contested = _maxScore != _maxScoreOld;
		_contestedOld = _logic getvariable ["contested",false];
		if ((_contested && !_contestedOld) || (!_contested && _contestedOld)) then {
			_logic setvariable ["contested",_contested,true];
		};
		_maxScoreOld = _maxScore;

		//--- Execute code when ownership changes
		if (_owner != _ownerOld) then {

			//--- Call custom code
			[_logic,"ownerChanged",[_logic,_owner,_ownerOld]] call bis_fnc_callscriptedeventhandler;

			//--- Broadcast
			_logic setvariable ["owner",_owner,true];

			//--- Reward
			_owner addscoreside _scoreReward;

			//--- Update total count
			_ownerSideID = _owner call bis_fnc_sideID;
			_ownerOldSideID = (_ownerOld call bis_fnc_sideID) min 4;
			BIS_fnc_moduleSector_sideSectors set [_ownerSideID,(BIS_fnc_moduleSector_sideSectors select _ownerSideID) + 1];
			BIS_fnc_moduleSector_sideSectors set [_ownerOldSideID,((BIS_fnc_moduleSector_sideSectors select _ownerOldSideID) - 1) max 0];
			publicvariable "BIS_fnc_moduleSector_sideSectors";

			//--- Update markers
			//_iconColor = [0.25,0.25,0.25,0.5];
			_markerColor = "colorblack";
			if (_owner != sideUnknown) then {
				//_iconColor = _owner call bis_fnc_sidecolor;
				_markerColor = [_owner,true] call bis_fnc_sidecolor;
			};
			_icon = ["o_installation","b_installation","n_installation","n_installation","u_installation"] select ((_owner call bis_fnc_sideID) min 4);
			_iconTexture = _icon call bis_fnc_texturemarker;
			_markerIcon setmarkertype _icon;
			_markerIcon setmarkercolor _markerColor;
			{
				_x setmarkercolor _markerColor;
				if (markeralpha _x > 0) then {
					if (_markerColor == "colorblack") then {_x setmarkeralpha 0.25;} else {_x setmarkeralpha 0.5;};
				};
			} foreach _markersArea;
			//_logic setvariable ["ownerTexture",_iconTexture,true];
			//_logic setvariable ["ownerColor",_iconColor,true];

			//--- Show notification
			_ownerName = _owner call bis_fnc_sidename;
			if (_owner != sideunknown) then {
				//--- Show it to involved sides and curators (sector itself cannot belong to a curator, but objective module can)
				_curatorObject = _logic getvariable ["curatorObject",objnull];
				_curators = objectcurators _curatorObject;
				{
					//--- Remove curators who are already on side with access to the sector to prevent duplicate notifications
					if (((getassignedcuratorunit _x) call bis_fnc_objectside) in _sides) then {_curators = _curators - [_x];};
				} foreach _curators;
				_nameLocalized = _name call bis_fnc_localize;
				[[format ["sectorCaptured%1",_owner],[_nameLocalized,_ownerName,_iconTexture,_designation]],"BIS_fnc_showNotification",_sides - [_ownerOld] + _curators] call bis_fnc_mp;
				[[format ["sectorLost%1",_owner],[_nameLocalized,_ownerName,_iconTexture,_designation]],"BIS_fnc_showNotification",_ownerOld] call bis_fnc_mp;
			};

			//--- Update flag (not for default owner)
			if ((_firstLoop && _defaultOwner < 0) || !_firstLoop) then {
				_flagTexture = if (_ownerID < 0) then {
					""
				} else {
					_units = _sideUnitsLocal select _ownerID;
					if (count _units > 0) then {
						_ownerFaction = gettext (configfile >> "cfgvehicles" >> typeof effectivecommander (_units select 0) >> "faction");
						gettext (configfile >> "cfgfactionclasses" >> _ownerFaction >> "flag");
					} else {
						(_owner call bis_fnc_sidecolor) call bis_fnc_colorRGBAtoTexture
					};
				};
				{_x setflagtexture _flagTexture;} foreach _flags;
			};

			//--- Update tasks (not in the first run to prevent creating task before others)
			if !(_firstLoop) then {
				_ownerID = _owner call bis_fnc_sideID;//_sides find _owner;
				_firstSector = objnull;
				_lastSector = objnull;
				{
					if (simulationenabled _x || _x == _logic) then {
						if (isnull _firstSector) then {_firstSector = _x;};
						_lastSector = _x;
					};
				} foreach _sectors;
				{
					if (_x != "") then {
						_taskOrder = _taskOrders select _foreachindex;
						_taskState = if (_foreachindex == _ownerID) then {
							"SUCCEEDED"
						} else {
							_compareSector = if (_taskOrder) then {_lastSector} else {_firstSector};
							if (_logic == _compareSector) then {"ASSIGNED"} else {"CREATED"}
						};
						[_x,nil,nil,nil,_taskState,nil,false] call bis_fnc_setTask;
					};
				} foreach _tasks;
			};

			_logicAreaUpdate = true;
		};
		_ownerOld = _owner;
		_time = time;

		//--- Update area positions
		{
			_trigger = _x;
			_triggerPos = position _trigger;
			if (_triggerPos distance (_trigger getvariable ["pos",[0,0,0]]) > 0) then {
				_trigger setvariable ["pos",_triggerPos];
				_markers = _trigger getvariable ["markers",[]];
				{
					_x setmarkerpos position _trigger;
					if (markertype _x == "") then {
						_triggerArea = triggerarea _trigger;
						if (_triggerArea select 3) then {_x setmarkershape "rectangle";} else {_x setmarkershape "ellipse";};
						_x setmarkerdir (_triggerArea select 2);
						_x setmarkersize [_triggerArea select 0,_triggerArea select 1];
						_logicAreaSize = (_triggerArea select 0) * 2;
						_logicAreaUpdate = true;
					};
				} foreach _markers;
				if (_markerIcon in _markers) then {
					_logic setvariable ["pos",markerpos _markerIcon,true];
				};
			};
		} foreach _areas;

		//--- Update 3D marker
		if (_logicAreaShow && _logicAreaUpdate) then {
			if (_logicAreaSize in [100,200,500]) then {
				_logicAreaType = format ["LogicSector%1%2m_F",_owner,_logicAreaSize];
				if (_logicAreaType != typeof _logicArea) then {
					deletevehicle _logicArea;
					_logicArea = createvehicle [_logicAreaType,position _curatorObject,[],0,"none"];
					_logicArea attachto [_curatorObject,[0,0,0]];
					{
						_hideObjects = _x getvariable ["hideObjects",[]];
						_hideObjects = _hideObjects + [_logicArea] - [objnull];
						_x setvariable ["hideObjects",_hideObjects,true];
					} foreach (objectcurators _curatorObject);
				};
			} else {
				deletevehicle _logicArea;
			};
		};

		//--- Calculate side strengths for the next cycle
		_costPlayersLocal = _costPlayers call bis_fnc_parsenumber;
		{
			{
				if ({alive _x} count crew _x > 0) then {
					_side = side group _x;
					if (_side in _sides) then {
						_sideID = _side call bis_fnc_sideID;//_sides find _side;
						_units = _sideUnits select _sideID;
						if !(_x in _units) then {
							_score = _sectorScore select _sideID;

							_simulation = gettext (configfile >> "cfgvehicles" >> typeof _x >> "simulation");

							_xScore = switch (tolower _simulation) do {
								case "soldier": {
									[_x,_costInfantry,true] call _fnc_threat;
								};
								case "carx": {
									[_x,_costWheeled,true] call _fnc_threat;
								};
								case "tankx": {
									[_x,_costTracked,true] call _fnc_threat;
								};
								case "shipx";
								case "submarinex": {
									[_x,_costWater,true] call _fnc_threat;
								};
								case "helicopterrtd";
								case "airplanex";
								case "helicopterx": {
									[_x,_costAir,true] call _fnc_threat;
								};
								default {
									0
								};
							};
							_score = _score + _xScore;
							_sectorScore set [_sideID,_score];

							_units set [count _units,_x];
							_sideUnits set [_sideID,_units];
						};
					};
					sleep 0.05;
				};
			} foreach list _x;
			sleep 0.1;
		} foreach _areas;

		//--- Loop counter for outside use
		_step = _step + 1;
		_logic setvariable ["step",_step];

		_firstLoop = false;
		sleep 0.1;
	};

	//--- Sector finalized
	if (isnull _logic) then {

		_sectors = missionnamespace getvariable ["BIS_fnc_moduleSector_sectors",[]];
		_sectors = _sectors - [_logic,objnull];
		missionnamespace setvariable ["BIS_fnc_moduleSector_sectors",_sectors];
		publicvariable "BIS_fnc_moduleSector_sectors";

		//--- Delete markers
		{
			deletemarker _x;
		} foreach (_markersArea + [_markerIcon,_markerIconText]);
	} else {
		//--- Mark as finalized globaly (enableSImulation is local only)
		_logic setvariable ["finalized",true,true];
		_logic setvariable ["contested",false,true];

		//--- Make markers transparent
		{
			_x setmarkeralpha (markeralpha _x * 0.5);
		} foreach (_markersArea + [_markerIcon,_markerIconText]);
	};

	//--- Delete 3D marker
	deletevehicle _logicArea;

	//--- Activate area triggers
	{
		_x settriggeractivation ["any","present",false];
		_x settriggerstatements ["true","",""];
		_x settriggertype "none";
	} foreach _areas;

	//--- Finalize the tasks
	_ownerID = _owner call bis_fnc_sideID;//_sides find _owner;
	{
		if (_x != "") then {
			_taskState = if (_foreachindex == _ownerID) then {"SUCCEEDED"} else {"CANCELED"};
			[_x,nil,nil,nil,_taskState] call bis_fnc_setTask;
		};
	} foreach _tasks;
};
case "player": {
	/////////////////////////////////////////////////////////////////////////////////////
	// Player
	[_logic,[],true,"area"] call bis_fnc_moduleSector;

	("RscMPProgress" call bis_fnc_rscLayer) cutrsc ["RscMPProgress","plain"];

	waituntil {
		sleep 0.1;
		(_logic getvariable ["finalized",false]) || (isnull _logic)
	};
	_logic enablesimulation false;
};
case "area": {
	/////////////////////////////////////////////////////////////////////////////////////
	// Update default trigger
	_areas = _logic getvariable ["areas",[]];
	_size = _logic getvariable ["size",0];
	{
		_x settriggeractivation ["any","present",false];
		_x settriggerstatements ["false","",""];
		_x settriggertype "none";
		if (_size > 0) then {
			_x settriggerarea [_size,_size,0,false];
		};
	} foreach _areas;
};
};

Share this post


Link to post
Share on other sites

I use the same way as you would place it down in the editor (but just with the commands).

- Place the module - in this case, we just create a game logic

- Place the game logics for the module - exactly the same as in the edito

- Place the trigger for the "Area" game logic

- Synchronize the objects to one another

- Set the module parameters - exactly the same as in the editor.

- Call the module function and pass the created game logic as a parameter - this is the step that is completed when the mission is loaded

// Gets position
_pos = [_this,0,[],[[],objNull,""],3] call BIS_fnc_param; // Can be passed array, object or marker
_pos = _pos call BIS_fnc_position;

_logic = (createGroup sideLogic) createUnit ["Logic",_pos,[],0,"NONE"];

// Creates area & side logics and trigger
_areaLogic = (createGroup sideLogic) createUnit ["LocationArea_F",_pos,[],0,"NONE"];
_sideBLUFORLogic = (createGroup sideLogic) createUnit ["SideBLUFOR_F",_pos,[],0,"NONE"];
_sideOPFORLogic = (createGroup sideLogic) createUnit ["SideOPFOR_F",_pos,[],0,"NONE"];
_sideINDFORLogic = (createGroup sideLogic) createUnit ["SideResistance_F",_pos,[],0,"NONE"];

_trigger = createTrigger ["EmptyDetector",_pos];
_trigger setTriggerArea [500,500,false];

// Synchronizes the objects
_areaLogic synchronizeObjectsAdd [_trigger];
_logic synchronizeObjectsAdd [_areaLogic,_sideBLUFORLogic,_sideOPFORLogic,_sideINDFORLogic];

_logic setVariable ["CostAir","2",true];
_logic setVariable ["CostInfantry","1",true];
_logic setVariable ["CostPlayers","2",true];
_logic setVariable ["CostTracked","4",true];
_logic setVariable ["CostWater","0",true];
_logic setVariable ["CostWheeled","2",true];
_logic setVariable ["DefaultOwner",1,true];
_logic setVariable ["Designation","A",true];
_logic setVariable ["Name","Alpha",true];
_logic setVariable ["OnOwnerChange","",true];
_logic setVariable ["OwnerLimit","0",true];
_logic setVariable ["ScoreReward","0",true];
_logic setVariable ["TaskDescription","Capture Alpha by eliminating the enemies",true];
_logic setVariable ["TaskOwner",3,true];
_logic setVariable ["TaskTitle","Capture Alpha",true];

[_logic] call BIS_fnc_moduleSector;

Produces a few scripting errors, but it works :P

Edited by Bull_A

Share this post


Link to post
Share on other sites

Those are the vehicle class names for the logics used to initialize the module. If you go into the editor and double click on the map to place a unit, in the top-right hand corner of the option box there is a name. When you select a unit this name changes to the vehicle class name that is currently selected.

Share this post


Link to post
Share on other sites
Produces a few scripting errors, but it works :P

Spawn the logic as a ModuleSector_F instead - you then also do not need to call the module function (you would think this would maybe miss a few variables due to timing but from a few test seems ok).

You are also missing the angle from your createTrigger command.

This should all be done server side. There is no need to publicVaraible the variables, the module takes care of doing this for you.

As a minimum you dont even need the other modules (location,sides) and the module will create its own trigger if none is found. The trigger can also be updated once the module is initialized. e.g

//Exit if we are not the server
if !( isServer ) exitWith {};

_pos = [_this,0,[],[[],objNull,""],3] call BIS_fnc_param;
_pos = _pos call BIS_fnc_position;

//Create the sector logic
_logic = (createGroup sideLogic) createUnit ["ModuleSector_F",_pos,[],0,"NONE"];

//Default setting,  which are optional
_logic setVariable ["CostAir","2"];
_logic setVariable ["CostInfantry","1"];
_logic setVariable ["CostPlayers","2"];
_logic setVariable ["CostTracked","4"];
_logic setVariable ["CostWater","0"];
_logic setVariable ["CostWheeled","2"];
_logic setVariable ["DefaultOwner","-1"];
_logic setVariable ["Designation","A"];
_logic setVariable ["Name","Alpha"];
_logic setVariable ["OnOwnerChange",""];
_logic setVariable ["OwnerLimit","0"];
_logic setVariable ["ScoreReward","0"];
_logic setVariable ["TaskDescription","Capture Alpha by eliminating the enemies"];
_logic setVariable ["TaskOwner","3"];
_logic setVariable ["TaskTitle","Capture Alpha"];

//Set the sides for the sector
_logic setVariable ["sides",[ east, west ]];

//Wait until sector is initialised
waitUntil {
!isNil { _logic getVariable [ "finalized", nil ] } &&
{ !( _logic getVariable [ "finalized", true ] ) }
};

//A size for the trigger
_trgSize = 500;
//Set the trigger size on the sector
_logic setVariable [ "size", _trgSize ];
//Make the module update its trigger
[ _logic, [], true, "area" ] call BIS_fnc_moduleSector;

//Unfortunately the sector has not been written to also update its marker so..
//Get the modules trigger
_trg = ( _logic getVariable "areas" ) select 0;
//Get the triggers marker
_mrk = ( _trg getVariable "markers" ) select 0;
//Update the markers size
_mrk setMarkerSize [ _trgSize, _trgSize ];

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Hi Guys

Thank you everyone who help me resolve this. Larrow & Bull_A this works perfectly. Thanks for solving one of the mysteries of ARMA 3 scripting for me ;)

Cheers

Share this post


Link to post
Share on other sites

I am trying to use this code in my mission and I cannot get the sector to spawn at all. How do I set a position for this sector?

http://i.imgur.com/VPpetKn.jpg (187 kB)

Any help would be appreciated. Thank you.

Here is the code I am trying to use.

// Gets position

_pos = [_this,0,[],[[],objNull,"cit2"],3] call BIS_fnc_param; // Can be passed array, object or marker

_pos = _pos call BIS_fnc_position;

_logic = (createGroup sideLogic) createUnit ["Logic",_pos,[],0,"NONE"];

// Creates area & side logics and trigger

_areaLogic = (createGroup sideLogic) createUnit ["LocationArea_F",_pos,[],0,"NONE"];

_sideBLUFORLogic = (createGroup sideLogic) createUnit ["SideBLUFOR_F",_pos,[],0,"NONE"];

_sideOPFORLogic = (createGroup sideLogic) createUnit ["SideOPFOR_F",_pos,[],0,"NONE"];

_sideINDFORLogic = (createGroup sideLogic) createUnit ["SideResistance_F",_pos,[],0,"NONE"];

_trigger = createTrigger ["EmptyDetector",_pos];

_trigger setTriggerArea [500,500,false];

// Synchronizes the objects

_areaLogic synchronizeObjectsAdd [_trigger];

_logic synchronizeObjectsAdd [_areaLogic,_sideBLUFORLogic,_sideOPFORLogic,_sideINDFORLogic];

_logic setVariable ["CostAir","2",true];

_logic setVariable ["CostInfantry","1",true];

_logic setVariable ["CostPlayers","2",true];

_logic setVariable ["CostTracked","4",true];

_logic setVariable ["CostWater","0",true];

_logic setVariable ["CostWheeled","2",true];

_logic setVariable ["DefaultOwner",1,true];

_logic setVariable ["Designation","A",true];

_logic setVariable ["Name","Alpha",true];

_logic setVariable ["OnOwnerChange","",true];

_logic setVariable ["OwnerLimit","0",true];

_logic setVariable ["ScoreReward","0",true];

_logic setVariable ["TaskDescription","Capture Alpha by eliminating the enemies",true];

_logic setVariable ["TaskOwner",3,true];

_logic setVariable ["TaskTitle","Capture Alpha",true];

[_logic] call BIS_fnc_moduleSector;

Share this post


Link to post
Share on other sites
I am trying to use this code in my mission and I cannot get the sector to spawn at all. How do I set a position for this sector?

http://i.imgur.com/VPpetKn.jpg (187 kB)

Any help would be appreciated. Thank you.

Here is the code I am trying to use.

Hi Jakeplissken

Try using Larrows' script rather than Bull_As' one. It is an evolution of Bull_A script. I will also post my refined one tonight when I am back home.

Cheers

C

Share this post


Link to post
Share on other sites

Hi Jakeplissken

So here is my refined script, the one I use in my missions:

//===================================================================================================================
// This script is called to place a sector module on the map for the players to assualt/ defend.
// How to use: Execute this in an execution/init box of a item or trigger
//              null = [sectorMrk,sectorSize,side1,side2,defaultOwner,costAir,costInfantry,costPlayers,
//                      costTracked,costWater,costWheeled,designation,name,onOwnerChange,ownerLimit,
//                      scoreReward,taskDescription,taskOwner,taskTitle] execVM "sectorModule.sqf";
// Variable Explination:
//              sectorMrk     = name of the marker where the sector must be spawned. Ex "sectorMarker" **Critical Variable**
//              trgSize         = Size of the secor that should be spawned. **Optional, Default: 500**
//              side1 & side 2  = is the sides that will contend for the sector. **Optional, Default: east**
//              defaultOwner    = is the default owner the sector. "-1"= None, "0"= West, "1" = East, "2"= Indi **Optional, String, Default: "-1"**
//              costAir         = The cost for the side if an air unit is destroyed. **Optional, Default: "2"**
//              costInfantry    = Cost per infantry unit killed for side. **Optional, Default: "1"**
//              costPlayers     = Cost per player killed for side. **Optional, Default:"2"**
//              costTracked     = Cost per tracked,ie tanks, unit killed. **Optional, Default:"4"**
//              costWater       = Cost per water type unit killed. **Optional, Default:"0"**
//              costWheeled     = Cost per wheeled unit, ie Light Armor, killed. **Optional, Default:"2"**
//              designation     = Designation for the sector. **Optional, Default:"A"**
//              name            = Name for the sector. **Optional, Default:"Alpha"**
//              onOwnerChange   = Script/trigger to activate when ownership change. **Optional, Default:""**
//              ownerLimit      = **Optional, Default:"0"**
//              scoreReward     = **Optional, Default:"0"**
//              taskDescription = Task description. **Optional, Default:"Capture Alpha by eliminating the enemies"**
//              taskOwner       = To whom must the task be assigned. **Optional, Default:"3"**
//              taskTitle       = Title of task. **Optional, Default:"Capture Alpha"**
//
//===================================================================================================================

//Exit if we are not the server 
if !( isServer ) exitWith {}; 

private ["_pos","_trgSize","_side1","_side2","_defaultOwner","_costAir","_costInfantry",
	"_costPlayers","_costTracked","_costWater","_costWheeled","_designation",
	"_name","_onOwnerChange","_ownerLimit","_scoreReward","_taskDescription","_taskOwner","_taskTitle"];

//Default setting,  which are optional
_pos            = _this select 0;
_pos 		  = _pos call BIS_fnc_position; 
_trgSize        = [_this,1,500,[[],objNull,""],2] call BIS_fnc_param;   //A size for the trigger 
_side1          = [_this,2,east,[[],objNull,""],1] call BIS_fnc_param;
_side2          = [_this,3,west,[[],objNull,""],1] call BIS_fnc_param;
_defaultOwner   = [_this,4,"-1",[[],objNull,""],1] call BIS_fnc_param;
_costAir        = [_this,5,"2",[[],objNull,""],1] call BIS_fnc_param;
_costInfantry   = [_this,6,"1",[[],objNull,""],1] call BIS_fnc_param;
_costPlayers    = [_this,7,"2",[[],objNull,""],1] call BIS_fnc_param;
_costTracked    = [_this,8,"4",[[],objNull,""],1] call BIS_fnc_param;
_costWater      = [_this,9,"0",[[],objNull,""],1] call BIS_fnc_param;
_costWheeled    = [_this,10,"2",[[],objNull,""],1] call BIS_fnc_param;
_designation    = [_this,11,"A",[[],objNull,""],1] call BIS_fnc_param;
_name           = [_this,12,"Alpha",[[],objNull,""],1] call BIS_fnc_param;
_onOwnerChange  = [_this,13,"",[[],objNull,""],1] call BIS_fnc_param;
_ownerLimit     = [_this,14,"0",[[],objNull,""],1] call BIS_fnc_param;
_scoreReward    = [_this,15,"0",[[],objNull,""],1] call BIS_fnc_param;
_taskDescription= [_this,16,"Capture Alpha by eliminating the enemies",[[],objNull,""],1] call BIS_fnc_param;
_taskOwner      = [_this,17,"3",[[],objNull,""],1] call BIS_fnc_param;
_taskTitle      = [_this,18,"Capture Alpha",[[],objNull,""],1] call BIS_fnc_param;

//Create the sector logic 
_logic = (createGroup sideLogic) createUnit ["ModuleSector_F",_pos,[],0,"NONE"]; 

//Sector settings
_logic setVariable ["CostAir",_costAir]; 
_logic setVariable ["CostInfantry",_costInfantry]; 
_logic setVariable ["CostPlayers",_costPlayers]; 
_logic setVariable ["CostTracked",_costTracked]; 
_logic setVariable ["CostWater",_costWater]; 
_logic setVariable ["CostWheeled",_costWheeled]; 
_logic setVariable ["DefaultOwner",_defaultOwner]; 
_logic setVariable ["Designation",_designation]; 
_logic setVariable ["Name",_name]; 
_logic setVariable ["OnOwnerChange",_onOwnerChange]; 
_logic setVariable ["OwnerLimit",_ownerLimit]; 
_logic setVariable ["ScoreReward",_scoreReward]; 
_logic setVariable ["TaskDescription",_taskDescription]; 
_logic setVariable ["TaskOwner",_taskOwner]; 
_logic setVariable ["TaskTitle",_taskTitle]; 

//Set the sides for the sector 
_logic setVariable ["sides",[ _side1, _side2 ]]; 

//Wait until sector is initialised 
waitUntil { 
   !isNil { _logic getVariable [ "finalized", nil ] } && 
   { !( _logic getVariable [ "finalized", true ] ) } 
}; 

//Set the trigger size on the sector 
_logic setVariable [ "size", _trgSize ]; 
//Make the module update its trigger 
[ _logic, [], true, "area" ] call BIS_fnc_moduleSector; 

//Unfortunately the sector has not been written to also update its marker so.. 
//Get the modules trigger 
_trg = ( _logic getVariable "areas" ) select 0; 
//Get the triggers marker 
_mrk = ( _trg getVariable "markers" ) select 0; 
//Update the markers size 
_mrk setMarkerSize [ _trgSize, _trgSize ];  

As you can see it is almost exactly the same as Larrows' script with a few changes to allow full control of the settings.

If you are going to use it in public missions etc please just acknowledge Larrow and Bull_A.

Cheers

Twak

Share this post


Link to post
Share on other sites

Hi,

 

Sorry to resurrect an old thread but I don't think the above script seems to work anymore, or I can't get it to work with a simple null = ["mymarker"] execVM "sectorModule.sqf"; in the init line of a unit. I am interested in this working to laydown script defined sectors. The sector doesn't seem to show on the map in single or multiplayer (Eden editor).

 

I hope I find people well.

 

Atmo

Share this post


Link to post
Share on other sites

It seems to be getting stuck waiting for the sector to be initialized.

//Wait until sector is initialised 
waitUntil {
    systemChat format["Here %1", time];
    !isNil { _logic getVariable [ "finalized", nil ] } && { !( _logic getVariable [ "finalized", true ] ) }
};

I'm still trying to track down the problem..

 

Atmo

 

 

 

Share this post


Link to post
Share on other sites

Ah, it seems there is a

[_logic] call BIS_fnc_moduleSector;

missing just before

//Wait until sector is initialised  waitUntil {

waitUntil {

    systemChat format["Here %1", time];

 !isNil { _logic getVariable [ "finalized", nil ] } &&

    { !( _logic getVariable [ "finalized", true ] ) }

};

I don't think the script actually calls the code in the module and therefore doesn't get initialised...

 

There is another issue I've just found...

 

Atmo

 

Share this post


Link to post
Share on other sites

Ok, I think this works now. Calling the module code initializes the module. Also, despite the module creating it's own area and trigger if you add the SpawnAIsectorTactic module it doesn't pick up on this area and fails on FindClosestsector.sqf. Therefore if you add an area to the Sector it will be fine.

 

updated code:

 
//===================================================================================================================

// This script is called to place a sector module on the map for the players to assualt/ defend.

// How to use: Execute this in an execution/init box of a item or trigger

//              null = [sectorMrk,sectorSize,side1,side2,defaultOwner,costAir,costInfantry,costPlayers,

//                      costTracked,costWater,costWheeled,designation,name,onOwnerChange,ownerLimit,

//                      scoreReward,taskDescription,taskOwner,taskTitle] execVM "sectorModule.sqf";

// Variable Explination:

//              sectorMrk     = name of the marker where the sector must be spawned. Ex "sectorMarker" **Critical Variable**

//              trgSize         = Size of the secor that should be spawned. **Optional, Default: 500**

//              side1 & side 2  = is the sides that will contend for the sector. **Optional, Default: east**

//              defaultOwner    = is the default owner the sector. "-1"= None, "0"= West, "1" = East, "2"= Indi **Optional, String, Default: "-1"**

//              costAir         = The cost for the side if an air unit is destroyed. **Optional, Default: "2"**

//              costInfantry    = Cost per infantry unit killed for side. **Optional, Default: "1"**

//              costPlayers     = Cost per player killed for side. **Optional, Default:"2"**

//              costTracked     = Cost per tracked,ie tanks, unit killed. **Optional, Default:"4"**

//              costWater       = Cost per water type unit killed. **Optional, Default:"0"**

//              costWheeled     = Cost per wheeled unit, ie Light Armor, killed. **Optional, Default:"2"**

//              designation     = Designation for the sector. **Optional, Default:"A"**

//              name            = Name for the sector. **Optional, Default:"Alpha"**

//              onOwnerChange   = Script/trigger to activate when ownership change. **Optional, Default:""**

//              ownerLimit      = **Optional, Default:"0"**

//              scoreReward     = **Optional, Default:"0"**

//              taskDescription = Task description. **Optional, Default:"Capture Alpha by eliminating the enemies"**

//              taskOwner       = To whom must the task be assigned. **Optional, Default:"3"**

//              taskTitle       = Title of task. **Optional, Default:"Capture Alpha"**

//

//

// Fixed : Atmo 23/04/2016 - need to add an area if you want to use SpawnAI SectorTactic

// Fixed : Atmo 23/04/2016 - call the module code to initiailize itself.

//

//===================================================================================================================
 
//Exit if we are not the server

if !( isServer ) exitWith {};
 
systemchat "In sectorModule.sqf";
 
private ["_pos","_trgSize","_side1","_side2","_defaultOwner","_costAir","_costInfantry",

  "_costPlayers","_costTracked","_costWater","_costWheeled","_designation",

  "_name","_onOwnerChange","_ownerLimit","_scoreReward","_taskDescription","_taskOwner","_taskTitle"];
 
//Default setting,  which are optional

_pos            = _this select 0;

_pos       = _pos call BIS_fnc_position;

_trgSize        = [_this,1,50,[[],objNull,""],2] call BIS_fnc_param;   //A size for the trigger

_side1          = [_this,2,east,[[],objNull,""],1] call BIS_fnc_param;

_side2          = [_this,3,west,[[],objNull,""],1] call BIS_fnc_param;

_defaultOwner   = [_this,4,"-1",[[],objNull,""],1] call BIS_fnc_param;

_costAir        = [_this,5,"2",[[],objNull,""],1] call BIS_fnc_param;

_costInfantry   = [_this,6,"1",[[],objNull,""],1] call BIS_fnc_param;

_costPlayers    = [_this,7,"2",[[],objNull,""],1] call BIS_fnc_param;

_costTracked    = [_this,8,"4",[[],objNull,""],1] call BIS_fnc_param;

_costWater      = [_this,9,"0",[[],objNull,""],1] call BIS_fnc_param;

_costWheeled    = [_this,10,"2",[[],objNull,""],1] call BIS_fnc_param;

_designation    = [_this,11,"A",[[],objNull,""],1] call BIS_fnc_param;

_name           = [_this,12,"Alpha",[[],objNull,""],1] call BIS_fnc_param;

_onOwnerChange  = [_this,13,"",[[],objNull,""],1] call BIS_fnc_param;

_ownerLimit     = [_this,14,"0",[[],objNull,""],1] call BIS_fnc_param;

_scoreReward    = [_this,15,"0",[[],objNull,""],1] call BIS_fnc_param;

_taskDescription= [_this,16,"Capture Alpha by eliminating the enemies",[[],objNull,""],1] call BIS_fnc_param;

_taskOwner      = [_this,17,"3",[[],objNull,""],1] call BIS_fnc_param;

_taskTitle      = [_this,18,"Capture Alpha",[[],objNull,""],1] call BIS_fnc_param;
 


//Create the sector logic

_logic = (createGroup sideLogic) createUnit ["ModuleSector_F",_pos,[],0,"NONE"];
 
// Creates area & side logics and trigger - we need to do this for SpawnAISector Tactic

// (it somehow misses the area created via the sectormodule and crashes with FindClosestSector.sqf)

_areaLogic = (createGroup sideLogic) createUnit ["LocationArea_F",_pos,[],0,"NONE"];
 
// Synchronizes the area

_logic synchronizeObjectsAdd [_areaLogic];

 

//Sector settings

_logic setVariable ["CostAir",_costAir];

_logic setVariable ["CostInfantry",_costInfantry];

_logic setVariable ["CostPlayers",_costPlayers];

_logic setVariable ["CostTracked",_costTracked];

_logic setVariable ["CostWater",_costWater];

_logic setVariable ["CostWheeled",_costWheeled];

_logic setVariable ["DefaultOwner",_defaultOwner];

_logic setVariable ["Designation",_designation];

_logic setVariable ["Name",_name];

_logic setVariable ["OnOwnerChange",_onOwnerChange];

_logic setVariable ["OwnerLimit",_ownerLimit];

_logic setVariable ["ScoreReward",_scoreReward];

_logic setVariable ["TaskDescription",_taskDescription];

_logic setVariable ["TaskOwner",_taskOwner];

_logic setVariable ["TaskTitle",_taskTitle];
 
//Set the sides for the sector

_logic setVariable ["sides",[ _side1, _side2 ]];
 
// Now call the module code and it will initialise itself

[_logic] call BIS_fnc_moduleSector;
 
//Wait until sector is initialised  waitUntil {

waitUntil {

    systemChat format["Here %1", time];

 !isNil { _logic getVariable [ "finalized", nil ] } &&

    { !( _logic getVariable [ "finalized", true ] ) }

};
 
//Set the trigger size on the sector

_logic setVariable [ "size", _trgSize ];

//Make the module update its trigger

[ _logic, [], true, "area" ] call BIS_fnc_moduleSector;
 
//Unfortunately the sector has not been written to also update its marker so..

//Get the modules trigger

_trg = ( _logic getVariable "areas" ) select 0;

//Get the triggers marker

_mrk = ( _trg getVariable "markers" ) select 0;

//Update the markers size

_mrk setMarkerSize [ _trgSize, _trgSize ]; 
 

Atmo

  • Like 1

Share this post


Link to post
Share on other sites

Ok, I think this works now. Calling the module code initializes the module. Also, despite the module creating it's own area and trigger if you add the SpawnAIsectorTactic module it doesn't pick up on this area and fails on FindClosestsector.sqf. Therefore if you add an area to the Sector it will be fine.

 

updated code:

 
//===================================================================================================================

// This script is called to place a sector module on the map for the players to assualt/ defend.

// How to use: Execute this in an execution/init box of a item or trigger

//              null = [sectorMrk,sectorSize,side1,side2,defaultOwner,costAir,costInfantry,costPlayers,

//                      costTracked,costWater,costWheeled,designation,name,onOwnerChange,ownerLimit,

//                      scoreReward,taskDescription,taskOwner,taskTitle] execVM "sectorModule.sqf";

// Variable Explination:

//              sectorMrk     = name of the marker where the sector must be spawned. Ex "sectorMarker" **Critical Variable**

//              trgSize         = Size of the secor that should be spawned. **Optional, Default: 500**

//              side1 & side 2  = is the sides that will contend for the sector. **Optional, Default: east**

//              defaultOwner    = is the default owner the sector. "-1"= None, "0"= West, "1" = East, "2"= Indi **Optional, String, Default: "-1"**

//              costAir         = The cost for the side if an air unit is destroyed. **Optional, Default: "2"**

//              costInfantry    = Cost per infantry unit killed for side. **Optional, Default: "1"**

//              costPlayers     = Cost per player killed for side. **Optional, Default:"2"**

//              costTracked     = Cost per tracked,ie tanks, unit killed. **Optional, Default:"4"**

//              costWater       = Cost per water type unit killed. **Optional, Default:"0"**

//              costWheeled     = Cost per wheeled unit, ie Light Armor, killed. **Optional, Default:"2"**

//              designation     = Designation for the sector. **Optional, Default:"A"**

//              name            = Name for the sector. **Optional, Default:"Alpha"**

//              onOwnerChange   = Script/trigger to activate when ownership change. **Optional, Default:""**

//              ownerLimit      = **Optional, Default:"0"**

//              scoreReward     = **Optional, Default:"0"**

//              taskDescription = Task description. **Optional, Default:"Capture Alpha by eliminating the enemies"**

//              taskOwner       = To whom must the task be assigned. **Optional, Default:"3"**

//              taskTitle       = Title of task. **Optional, Default:"Capture Alpha"**

//

//

// Fixed : Atmo 23/04/2016 - need to add an area if you want to use SpawnAI SectorTactic

// Fixed : Atmo 23/04/2016 - call the module code to initiailize itself.

//

//===================================================================================================================
 
//Exit if we are not the server

if !( isServer ) exitWith {};
 
systemchat "In sectorModule.sqf";
 
private ["_pos","_trgSize","_side1","_side2","_defaultOwner","_costAir","_costInfantry",

  "_costPlayers","_costTracked","_costWater","_costWheeled","_designation",

  "_name","_onOwnerChange","_ownerLimit","_scoreReward","_taskDescription","_taskOwner","_taskTitle"];
 
//Default setting,  which are optional

_pos            = _this select 0;

_pos       = _pos call BIS_fnc_position;

_trgSize        = [_this,1,50,[[],objNull,""],2] call BIS_fnc_param;   //A size for the trigger

_side1          = [_this,2,east,[[],objNull,""],1] call BIS_fnc_param;

_side2          = [_this,3,west,[[],objNull,""],1] call BIS_fnc_param;

_defaultOwner   = [_this,4,"-1",[[],objNull,""],1] call BIS_fnc_param;

_costAir        = [_this,5,"2",[[],objNull,""],1] call BIS_fnc_param;

_costInfantry   = [_this,6,"1",[[],objNull,""],1] call BIS_fnc_param;

_costPlayers    = [_this,7,"2",[[],objNull,""],1] call BIS_fnc_param;

_costTracked    = [_this,8,"4",[[],objNull,""],1] call BIS_fnc_param;

_costWater      = [_this,9,"0",[[],objNull,""],1] call BIS_fnc_param;

_costWheeled    = [_this,10,"2",[[],objNull,""],1] call BIS_fnc_param;

_designation    = [_this,11,"A",[[],objNull,""],1] call BIS_fnc_param;

_name           = [_this,12,"Alpha",[[],objNull,""],1] call BIS_fnc_param;

_onOwnerChange  = [_this,13,"",[[],objNull,""],1] call BIS_fnc_param;

_ownerLimit     = [_this,14,"0",[[],objNull,""],1] call BIS_fnc_param;

_scoreReward    = [_this,15,"0",[[],objNull,""],1] call BIS_fnc_param;

_taskDescription= [_this,16,"Capture Alpha by eliminating the enemies",[[],objNull,""],1] call BIS_fnc_param;

_taskOwner      = [_this,17,"3",[[],objNull,""],1] call BIS_fnc_param;

_taskTitle      = [_this,18,"Capture Alpha",[[],objNull,""],1] call BIS_fnc_param;
 


//Create the sector logic

_logic = (createGroup sideLogic) createUnit ["ModuleSector_F",_pos,[],0,"NONE"];
 
// Creates area & side logics and trigger - we need to do this for SpawnAISector Tactic

// (it somehow misses the area created via the sectormodule and crashes with FindClosestSector.sqf)

_areaLogic = (createGroup sideLogic) createUnit ["LocationArea_F",_pos,[],0,"NONE"];
 
// Synchronizes the area

_logic synchronizeObjectsAdd [_areaLogic];

 

//Sector settings

_logic setVariable ["CostAir",_costAir];

_logic setVariable ["CostInfantry",_costInfantry];

_logic setVariable ["CostPlayers",_costPlayers];

_logic setVariable ["CostTracked",_costTracked];

_logic setVariable ["CostWater",_costWater];

_logic setVariable ["CostWheeled",_costWheeled];

_logic setVariable ["DefaultOwner",_defaultOwner];

_logic setVariable ["Designation",_designation];

_logic setVariable ["Name",_name];

_logic setVariable ["OnOwnerChange",_onOwnerChange];

_logic setVariable ["OwnerLimit",_ownerLimit];

_logic setVariable ["ScoreReward",_scoreReward];

_logic setVariable ["TaskDescription",_taskDescription];

_logic setVariable ["TaskOwner",_taskOwner];

_logic setVariable ["TaskTitle",_taskTitle];
 
//Set the sides for the sector

_logic setVariable ["sides",[ _side1, _side2 ]];
 
// Now call the module code and it will initialise itself

[_logic] call BIS_fnc_moduleSector;
 
//Wait until sector is initialised  waitUntil {

waitUntil {

    systemChat format["Here %1", time];

 !isNil { _logic getVariable [ "finalized", nil ] } &&

    { !( _logic getVariable [ "finalized", true ] ) }

};
 
//Set the trigger size on the sector

_logic setVariable [ "size", _trgSize ];

//Make the module update its trigger

[ _logic, [], true, "area" ] call BIS_fnc_moduleSector;
 
//Unfortunately the sector has not been written to also update its marker so..

//Get the modules trigger

_trg = ( _logic getVariable "areas" ) select 0;

//Get the triggers marker

_mrk = ( _trg getVariable "markers" ) select 0;

//Update the markers size

_mrk setMarkerSize [ _trgSize, _trgSize ]; 
 

Atmo

Thanks a bunch, this code worked perfectly for me!

Share this post


Link to post
Share on other sites

HI All,

 

I am using Larrow's script from above and I can't figure out why the on-screen designation shows a "S" when I have designated it as "1"? What am I missing here?

 

_logic setVariable ["Designation","1"];
_logic setVariable ["Name","SECTOR 1"];

Share this post


Link to post
Share on other sites

Did you call the script in the format

 null = [sectorMrk,sectorSize,side1,side2,defaultOwner,costAir,costInfantry,costPlayers,
		costTracked,costWater,costWheeled,designation,name,onOwnerChange,ownerLimit,
		scoreReward,taskDescription,taskOwner,taskTitle] execVM "sectorModule.sqf";

?

Share this post


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

Did you call the script in the format


 null = [sectorMrk,sectorSize,side1,side2,defaultOwner,costAir,costInfantry,costPlayers,
		costTracked,costWater,costWheeled,designation,name,onOwnerChange,ownerLimit,
		scoreReward,taskDescription,taskOwner,taskTitle] execVM "sectorModule.sqf";

?

 

HI atmo,

 

I tried using the format above and Larrow's script but it does not make a difference. The on-screen designation still shows an "S" when I have designated it as "1"

 

What is strange is that in the EDITOR it works despite the hint message saying it requires a "letter" in the Designation field.

 

Share this post


Link to post
Share on other sites

Hmm. I am not quite sure what the problem is. I haven't looked at this for a while. Sorry. Let us know if you make any advances in sorting it out. 

Share this post


Link to post
Share on other sites
58 minutes ago, atmo said:

Hmm. I am not quite sure what the problem is. I haven't looked at this for a while. Sorry. Let us know if you make any advances in sorting it out. 

 

Hi Atmo,

 

Quoted you just to grab attention as your script has been the most clearly explained and user friendly to a non-script pro like me.  I am hoping you can help me solve why i cannot get it working, if you need more information to diagnose than wht i have posted below please let me know:

 

Picture of in Game Error when setting Trigger off

Spoiler

IZgs7eB.jpg

 

Arma 3 Log taken after point of Trigger going off

Spoiler

15:19:33 Starting mission:
15:19:33  Mission file: TvT_SectorSpawn_Template
15:19:33  Mission world: VR
15:19:33  Mission directory: C:\Users\user\Documents\Arma 3 - Other Profiles\SPC%2ePriest%2eV\missions\TvT_SectorSpawn_Template.VR\
15:19:35 [80482,2365.18,0,"XEH: PreInit started. v3.7.0.180430"]
15:19:35 "SquadBarDefault: false"
15:19:35 Wrong location draw style - "ACRE_RequiredDrawStyle"
15:19:38 [ACE] (common) INFO: Parsed Settings Configs [109.9 ms]
15:19:38 [XEH]: One or more children of class Car do not support Extended Event Handlers. Fall back to loop.
15:19:39 [80482,2369.22,0,"XEH: PreInit finished."]
15:19:39 Attempt to override final function - bis_fnc_modulemptypesectorcontrol_initcurator
15:19:40  Mission id: 2910f91100930d3db7360e2fc2114427813e1832
15:19:40 "Advanced Rappelling Loading..."
15:19:40 "Advanced Rappelling Loaded"
15:19:40 "Advanced Urban Rappelling Loading..."
15:19:40 "Advanced Urban Rappelling Loaded"
15:19:40 "Advanced Towing Loading..."
15:19:40 "Advanced Towing Loaded"
15:19:40 [81148,2371.03,0,"XEH: PostInit started. MISSIONINIT: missionName=TvT_SectorSpawn_Template, missionVersion=53, worldName=VR, isMultiplayer=false, isServer=true, isDedicated=false, CBA_isHeadlessClient=false, hasInterface=true, didJIP=false"]
15:19:40 [81148,2371.06,0,"CBA_VERSIONING: cba=3.7.0.180430, ctab=2.2.1.4, acre=2.5.1.980, ace=3.12.2.33, acex=3.3.0.6, "]
15:19:41 [ACRE] (sys_core) INFO: Loading Map: \A3\Map_VR\VR.wrp
15:19:41 [ACRE] (sys_core) INFO: AI Detection Activated.
15:19:41 [ACRE] (sys_antenna) INFO: Loaded Binary Atenna Data for ACRE_BaseAntenna [\idi\acre\addons\sys_antenna\binary\Thales_100cm_Whip_gain.aba]: 1
15:19:41 [ACRE] (sys_antenna) INFO: Loaded Binary Atenna Data for ACRE_100CM_VHF_TNC [\idi\acre\addons\sys_antenna\binary\Thales_100cm_Whip_gain.aba]: 1
15:19:41 [ACRE] (sys_antenna) INFO: Loaded Binary Atenna Data for ACRE_100CM_VHF_BNC [\idi\acre\addons\sys_antenna\binary\Thales_100cm_Whip_gain.aba]: 1
15:19:41 [ACRE] (sys_antenna) INFO: Loaded Binary Atenna Data for ACRE_2HALFINCH_UHF_TNC [\idi\acre\addons\sys_antenna\binary\prc343_gain.aba]: 1
15:19:41 [ACRE] (sys_antenna) INFO: Loaded Binary Atenna Data for ACRE_SEM52_SHORT_BNC [\idi\acre\addons\sys_antenna\binary\sem52_short_gain.aba]: 1
15:19:41 [ACRE] (sys_antenna) INFO: Loaded Binary Atenna Data for ACRE_SEM52_LONG_BNC [\idi\acre\addons\sys_antenna\binary\sem52_long_gain.aba]: 1
15:19:41 [ACRE] (sys_antenna) INFO: Loaded Binary Atenna Data for ACRE_SEM70_LONG_BNC [\idi\acre\addons\sys_antenna\binary\sem70_long_gain.aba]: 1
15:19:41 [ACRE] (sys_antenna) INFO: Loaded Binary Atenna Data for ACRE_AT271_38 [\idi\acre\addons\sys_antenna\binary\AT-271_gain.aba]: 1
15:19:41 [ACRE] (sys_antenna) INFO: Loaded Binary Atenna Data for ACRE_123CM_VHF_TNC [\idi\acre\addons\sys_antenna\binary\Harris_123cm_Whip_gain.aba]: 1
15:19:41 [ACE] (common) INFO: ACE is version 3.12.2.33.
15:19:41 [ACE] (common) INFO: CBA is version 3.7.0.180430 (min required 3.6.0)
15:19:41 [ACE] (common) INFO: Extension version: ace_break_line: 3.8.4-ef4d289
15:19:41 [ACE] (common) INFO: Extension version: ace_parse_imagepath: 3.8.4-ef4d289
15:19:41 [ACE] (common) INFO: Extension version: ace_medical: 3.8.4-ef4d289
15:19:41 [ACE] (common) INFO: Extension version: ace_clipboard: 3.8.4-ef4d289
15:19:41 [ACE] (common) INFO: Extension version: ace_fcs: 3.8.4-ef4d289
15:19:41 [ACE] (common) INFO: Extension version: ace_advanced_ballistics: 3.12.0-8ddde18
15:19:41 String STR_RHS_WEAP_PKTM not found
15:19:41 String STR_RHS_WEAP_S25 not found
15:19:41 String STR_RHS_WEAP_S25L not found
15:19:42 [ACE] (nametags) INFO: ACRE Detected.
15:19:43 [81148,2373.13,0,"XEH: PostInit finished."]
15:19:43 [ACRE] (sys_core) INFO: Map Load Complete: \A3\Map_VR\VR.wrp
15:19:43 [ACE] (common) TRACE: 81149 Reading missionConfigFile params: _paramsArray=[] z\ace\addons\common\functions\fnc_readSettingsFromParamsArray.sqf:23
15:19:43 [ACRE] (api) INFO: Difficulty changed. Interference: true - Duplex: false - Terrain Loss: 1 - Omni-directional: 0 - AI Hearing: true
15:19:43 [ACRE] (api) INFO: Difficulty changed. Interference: true - Duplex: false - Terrain Loss: 1 - Omni-directional: 0 - AI Hearing: true
15:19:43 [ACRE] (api) INFO: Difficulty changed. Interference: true - Duplex: false - Terrain Loss: 1 - Omni-directional: 0 - AI Hearing: true
15:19:43 [ACRE] (api) INFO: Difficulty changed. Interference: true - Duplex: false - Terrain Loss: 0.5 - Omni-directional: 0 - AI Hearing: true
15:19:43 [ACRE] (api) INFO: Difficulty changed. Interference: true - Duplex: false - Terrain Loss: 0.5 - Omni-directional: 0 - AI Hearing: true
15:19:43 [ACE] (common) INFO: Settings initialized.
15:19:43 [ACE] (common) INFO: 5 delayed functions running.
15:19:43 WARNING: Function 'name' - L Alpha 1-2:2 (z1) has empty name
15:19:43 WARNING: Function 'name' - L Alpha 1-2:2 (z1) has empty name
15:19:43 [CBA] (events) WARNING: Usage of deprecated CBA_fnc_addLocalEventHandler backwards_comp.sqf:76
15:19:59 Error in expression < bis_fnc_sideID;

_task = _tasks select _sideID;
_taskOrder = true;
_addTask = s>
15:19:59   Error position: <_sideID;
_taskOrder = true;
_addTask = s>
15:19:59   Error Undefined variable in expression: _sideid
15:19:59 File A3\modules_f\Multiplayer\functions\fn_moduleSector.sqf [BIS_fnc_moduleSector], line 496
15:19:59 Error in expression < bis_fnc_sideID;

_task = _tasks select _sideID;
_taskOrder = true;
_addTask = s>
15:19:59   Error position: <_sideID;
_taskOrder = true;
_addTask = s>
15:19:59   Error Undefined variable in expression: _sideid
15:19:59 File A3\modules_f\Multiplayer\functions\fn_moduleSector.sqf [BIS_fnc_moduleSector], line 496
15:19:59 Error in expression <"];
_x settriggertype "none";
if (_size > 0) then {
_x settriggerarea [_size,_si>
15:19:59   Error position: <> 0) then {
_x settriggerarea [_size,_si>
15:19:59   Error >: Type String, expected Number,Not a Number
15:19:59 File A3\modules_f\Multiplayer\functions\fn_moduleSector.sqf [BIS_fnc_moduleSector], line 893
15:19:59 Error in expression < bis_fnc_sideID;

_task = _tasks select _sideID;
_taskOrder = true;
_addTask = s>
15:19:59   Error position: <_sideID;
_taskOrder = true;
_addTask = s>
15:19:59   Error Undefined variable in expression: _sideid
15:19:59 File A3\modules_f\Multiplayer\functions\fn_moduleSector.sqf [BIS_fnc_moduleSector], line 496
15:19:59 Error in expression < bis_fnc_sideID;

_task = _tasks select _sideID;
_taskOrder = true;
_addTask = s>
15:19:59   Error position: <_sideID;
_taskOrder = true;
_addTask = s>
15:19:59   Error Undefined variable in expression: _sideid
15:19:59 File A3\modules_f\Multiplayer\functions\fn_moduleSector.sqf [BIS_fnc_moduleSector], line 496

 

 

Picture from Editor

Spoiler

rFXKDqE.jpg

 

Code inside Triggers "On Activation"

Spoiler

null=["Delta","","East","West","-1","1","1","2","4","0","2","D","Delta","","0","0","Capture Delta","West","Delta"] execVM "Delta.sqf";

 

 

Code in the Delta.SQF file

Spoiler


//===================================================================================================================

// This script is called to place a sector module on the map for the players to assualt/ defend.

// How to use: Execute this in an execution/init box of a item or trigger

//              null = [sectorMrk,sectorSize,side1,side2,defaultOwner,costAir,costInfantry,costPlayers,

//                      costTracked,costWater,costWheeled,designation,name,onOwnerChange,ownerLimit,

//                      scoreReward,taskDescription,taskOwner,taskTitle] execVM "sectorModule.sqf";

// Variable Explination:

//              sectorMrk     	= name of the marker where the sector must be spawned. Ex "sectorMarker" **Critical Variable**

//              trgSize         = Size of the secor that should be spawned. **Optional, Default: 500**

//              side1 & side 2  = is the sides that will contend for the sector. **Optional, Default: east**

//              defaultOwner    = is the default owner the sector. "-1"= None, "0"= West, "1" = East, "2"= Indi **Optional, String, Default: "-1"**

//              costAir         = The cost for the side if an air unit is destroyed. **Optional, Default: "2"**

//              costInfantry    = Cost per infantry unit killed for side. **Optional, Default: "1"**

//              costPlayers     = Cost per player killed for side. **Optional, Default:"2"**

//              costTracked     = Cost per tracked,ie tanks, unit killed. **Optional, Default:"4"**

//              costWater       = Cost per water type unit killed. **Optional, Default:"0"**

//              costWheeled     = Cost per wheeled unit, ie Light Armor, killed. **Optional, Default:"2"**

//              designation     = Designation for the sector. **Optional, Default:"A"**

//              name            = Name for the sector. **Optional, Default:"Alpha"**

//              onOwnerChange   = Script/trigger to activate when ownership change. **Optional, Default:""**

//              ownerLimit      = **Optional, Default:"0"**

//              scoreReward     = **Optional, Default:"0"**

//              taskDescription = Task description. **Optional, Default:"Capture Alpha by eliminating the enemies"**

//              taskOwner       = To whom must the task be assigned. **Optional, Default:"3"**

//              taskTitle       = Title of task. **Optional, Default:"Capture Alpha"**

//

//

// Fixed : Atmo 23/04/2016 - need to add an area if you want to use SpawnAI SectorTactic

// Fixed : Atmo 23/04/2016 - call the module code to initiailize itself.

//

//===================================================================================================================

//Exit if we are not the server

if !( isServer ) exitWith {};

systemchat "In Delta.sqf";

private ["_pos","_trgSize","_side1","_side2","_defaultOwner","_costAir","_costInfantry",

  "_costPlayers","_costTracked","_costWater","_costWheeled","_designation",

  "_name","_onOwnerChange","_ownerLimit","_scoreReward","_taskDescription","_taskOwner","_taskTitle"];

//Default setting,  which are optional

_pos            = _this select 0;

_pos      		= _pos call BIS_fnc_position;

_trgSize        = [_this,1,50,[[],objNull,""],2] call BIS_fnc_param;   //A size for the trigger

_side1          = [_this,2,east,[[],objNull,""],1] call BIS_fnc_param;

_side2          = [_this,3,west,[[],objNull,""],1] call BIS_fnc_param;

_defaultOwner   = [_this,4,"-1",[[],objNull,""],1] call BIS_fnc_param;

_costAir        = [_this,5,"2",[[],objNull,""],1] call BIS_fnc_param;

_costInfantry   = [_this,6,"1",[[],objNull,""],1] call BIS_fnc_param;

_costPlayers    = [_this,7,"2",[[],objNull,""],1] call BIS_fnc_param;

_costTracked    = [_this,8,"4",[[],objNull,""],1] call BIS_fnc_param;

_costWater      = [_this,9,"0",[[],objNull,""],1] call BIS_fnc_param;

_costWheeled    = [_this,10,"2",[[],objNull,""],1] call BIS_fnc_param;

_designation    = [_this,11,"A",[[],objNull,""],1] call BIS_fnc_param;

_name           = [_this,12,"Alpha",[[],objNull,""],1] call BIS_fnc_param;

_onOwnerChange  = [_this,13,"",[[],objNull,""],1] call BIS_fnc_param;

_ownerLimit     = [_this,14,"0",[[],objNull,""],1] call BIS_fnc_param;

_scoreReward    = [_this,15,"0",[[],objNull,""],1] call BIS_fnc_param;

_taskDescription= [_this,16,"",[[],objNull,""],1] call BIS_fnc_param;

_taskOwner      = [_this,17,"3",[[],objNull,""],1] call BIS_fnc_param;

_taskTitle      = [_this,18,"",[[],objNull,""],1] call BIS_fnc_param;



//Create the sector logic

_logic = (createGroup sideLogic) createUnit ["ModuleSector_F",_pos,[],0,"NONE"];

// Creates area & side logics and trigger - we need to do this for SpawnAISector Tactic

// (it somehow misses the area created via the sectormodule and crashes with FindClosestSector.sqf)

_areaLogic = (createGroup sideLogic) createUnit ["LocationArea_F",_pos,[],0,"NONE"];

// Synchronizes the area

_logic synchronizeObjectsAdd [_areaLogic];



//Sector settings

_logic setVariable ["CostAir",_costAir];

_logic setVariable ["CostInfantry",_costInfantry];

_logic setVariable ["CostPlayers",_costPlayers];

_logic setVariable ["CostTracked",_costTracked];

_logic setVariable ["CostWater",_costWater];

_logic setVariable ["CostWheeled",_costWheeled];

_logic setVariable ["DefaultOwner",_defaultOwner];

_logic setVariable ["Designation",_designation];

_logic setVariable ["Name",_name];

_logic setVariable ["OnOwnerChange",_onOwnerChange];

_logic setVariable ["OwnerLimit",_ownerLimit];

_logic setVariable ["ScoreReward",_scoreReward];

_logic setVariable ["TaskDescription",_taskDescription];

_logic setVariable ["TaskOwner",_taskOwner];

_logic setVariable ["TaskTitle",_taskTitle];

//Set the sides for the sector

_logic setVariable ["sides",[ _side1, _side2 ]];

// Now call the module code and it will initialise itself

[_logic] call BIS_fnc_moduleSector;

//Wait until sector is initialised  waitUntil {

waitUntil {

    systemChat format["Here %1", time];

 !isNil { _logic getVariable [ "finalized", nil ] } &&

    { !( _logic getVariable [ "finalized", true ] ) }

};

//Set the trigger size on the sector

_logic setVariable [ "size", _trgSize ];

//Make the module update its trigger

[ _logic, [], true, "area" ] call BIS_fnc_moduleSector;

//Unfortunately the sector has not been written to also update its marker so..

//Get the modules trigger

_trg = ( _logic getVariable "areas" ) select 0;

//Get the triggers marker

_mrk = ( _trg getVariable "markers" ) select 0;

//Update the markers size

_mrk setMarkerSize [ _trgSize, _trgSize ];

 

 

My Aim and Intention for this script:

I am trying to create a Sector Control TvT Mission.  Where Sectors per side only appear once the previous sector has been taken - so linear.  I will achieve this by spawning a line of sectors with Tasks Owners BLUFOR only starting from their HQ and OVERLAPPING these will be a line of sectors with Tasks Owners OPFOR.  I am also looking at purely scripted sectors (script and markers) but there are complications around for Bleed Ticket Systems that as well as it is visually less tidy than the modules.

Share this post


Link to post
Share on other sites

Answered privately.... sent mission.. good luck!

Share this post


Link to post
Share on other sites
On ‎4‎/‎30‎/‎2018 at 11:09 PM, cklymowsky said:

HI All,

 

I am using Larrow's script from above and I can't figure out why the on-screen designation shows a "S" when I have designated it as "1"? What am I missing here?

 

_logic setVariable ["Designation","1"];
_logic setVariable ["Name","SECTOR 1"];

 

HI All, 

 

I set the following, so that all the sectors would be displayed on screen in a MP game by initializing with:

_logic remoteExecCall ["BIS_fnc_moduleSector", 0, FALSE];

 

createSector.sqf

//Exit if we are not the server
if !( isServer ) exitWith {};

params ["_pos",["_baseName","",[""]],["_side","",[EAST,""]]];
_pos = [_this,0,[],[[],objNull,""],3] call BIS_fnc_param;
_pos = _pos call BIS_fnc_position;


//Create the sector logic
_logic = (createGroup sideLogic) createUnit ["ModuleSector_F",_pos,[],0,"NONE"];	//ModuleSectorDummy_F	ModuleSector_F
_logic remoteExecCall ["BIS_fnc_moduleSector", 0, FALSE];

//Default setting,  which are optional
//_designation = "";
//if ((_baseName find "CONTROL POINT") >= 0) then {_designation = _baseName select [14,1]};
//_logic setVariable ["Designation",_designation, TRUE];	// ADD Sector Numbers only works when remoteExecCall on initializing, TESTING
_logic setVariable ["Designation","", TRUE];
_logic setVariable ["Name",_baseName, TRUE];

And noticed that the "Designation" variable now works! 

 

How ever I get the following error, yet it still works, how can I clear this error?

waituntil {|#|!isnil {_logic getvariable "finalized"}}>
Error position: <!isnil {_logic getvariable "finalized"}}>
Error Generic error in expression
File A3\modules_f\Multiplayer\functions\fn_moduleSector.sqf [BIS_fnc_moduleSector], line 70

 

Share this post


Link to post
Share on other sites

There is never ever any need to call the modules function for initialisation. It already does this by itself when the module is spawned via entries in its config.

There is never any need to remoteExec anything to clients as the module should only ever be created on the server and the module already takes care of handling clients and JIP for you.

 

The reason some of you maybe seeing problems is likely a timing issue between the module being spawned and the object variables being set.

Here is an updated version using TYPE createUnit ARRAY which allows for setting the variables in the object init. If the function is called anywhere but the server then it will remoteExec it to the server. I have also included a CfgRemoteExec section to make sure it can never be remoteExec'ed anywhere other than to the server.

See functions header of possible parameters LARs\spawnSector\functions\fn_spawnSector.sqf

Spoiler

/*****
******
    Original file: fn_spawnSector.sqf
    Written by Larrow
    Sunday, 3 June 2018
    Originally posted @:https://forums.bohemia.net/forums/topic/181264-sector-module-scripting/?do=findComment&comment=3294957
******
    You are free to modifiy and distribute this file as long as this header is kept intact
******
    Description: Spawn a module sector
******
    0: _pos (Array, Object, Marker, Group, Location) - Position to spawn sector at

    //Anything from here on are optional parameters

    1: _name (String) - Name of sector as shown on map
    2: _designation (String) - Designation shown on both map and in sectors ui
    3: _sectorArea (Array, Object "Trigger" or "LocationArea_F") - Sectors trigger area in [ radius X, radius Y, direction, isRectangle ] see setTriggerArea OR an existing trigger or locationArea_F( with trigger attached, same as a default setup in the editor )
    4: _sides (Array) - Array of sides that can capture the sector, if [] used sides will be [east,west,resistance,civilian], if nil defaults to [east,west], not available through editor attributes and is usually defined by syncing side logics to the sector module
    5: _defaultOwner (Number, Side) - Initial owner of the sector when created, for no owner use either sideUnknown or -1
    6: _onOwnerChange (String) - Code as STRING that runs when a sector is captured, code is passed [ _sector, _owner, _oldOwner ] in _this, code is also run at sector initialisation _owner will be default owner and _oldOwner will be sideUnknown

    //Score award
    7: _scoreReward (Number) - Score given to side for capturing sector

    //Tasks and rewards
    8: _taskOwner (Number) - 0 = no task, 1 = everyone, 2 = default owner, 3 = all but default owner
    9: _taskTitle (String) - Task title, use %1 to insert sector name
    10: _taskDescription (String) - Task Description, use %1 to inser sector name, %2 to insert sector rewards ( vehicles and respawn positions, these will need to be created seperately and synced with a existing trigger that is passed in param 3 ), %3 for capture costs description

    //Capture limits and coef cost, these are the same as the attributes that can be seen when viewing a sectors attributes in the editor
    11: _ownerLimit (Number) - Range <0-1> that a side must be dominent to cpature sector
    12: _costInfantry (Number) - Ratio of how fast Infantry will capture area
    13: _costWheeled (Number) - Ratio of how fast Wheeled vehicles will capture area
    14: _costTracked (Number) - Ratio of how fast Tracked vehicles will capture area
    15: _costWater (Number) - Ratio of how fast Naval vehicles will capture area
    16: _costAir (Number) - Ratio of how fast Air vehicles will capture area
    17: _costPlayers (Number) - Ratio of how fast Players will capture area

    //Values not available through editor attributes
    18: _captureCoef (Number) - ?Some Time based coef added to scores
******
******/

 

The example mission comes with several examples in the initPlayerLocal.sqf of which some use some utility functions in initServer.sqf to spawn triggers/locationArea_F.

Tested SP, MP hosted/dedicated and JIP. Should be good but have not put through extensive testing other than the examples available in the demo mission provided.

  • Like 4
  • 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

×