Jump to content
target_practice

Checking the ownership of a sector defined by the sector module.

Recommended Posts

I need to be able to check if a sector belongs to a certain faction, so it can be used as the condition for a trigger.

For instance if a certain sector belongs to BLUFOR/WEST, then a trigger will be fired.

 

I ask because although I am aware of the 'expression' variable in the module, it seems to trigger at mission start and when a sector starts to be captured.

 

EDIT: Also does anyone know what the sector (dummy) module does? The only behavior I have observed is that it becomes capturable as a sector if you sync it to another sector (from which it appears to inherit parameters).

  • Like 1

Share this post


Link to post
Share on other sites

To check the ownership of a sector, you'll need to do something of the sort:

SectorName getVariable "owner" == WEST

This would be placed in something like a trigger condition.

So, it'd return true or false.

So, whatever you need to do in the activation field will be activated once any blufor faction takes it.

you can change WEST to EAST

or WEST to Civilian

or WEST to  independent 

 

make sure to change the SectorName to your variable name of your sector module. 

 

  • Like 2

Share this post


Link to post
Share on other sites

When a sector changes side it fires off a scripted event handler called "ownerChanged". With this there is no need for the trigger as you can just subscribe to this event. The only thing you will want to handle, as per your note on the module expression, is that it fires at mission start. This is easily handled by excluding sideUnknown if the sector does not have a default side.

[ mySectorsName, "ownerChanged", {
    params[ "_sector", "_owner", "_ownerOld" ];
    
    if !( _owner isEqualTo sideUnknown ) then {
        //Do Stuff when sector changes side
    };
}] call BIS_fnc_addScriptedEventHandler;

The sector dummy is just as you describe a sector that does not need setting up and will inherit its parameters from another sector it is synced to.

  • Like 2

Share this post


Link to post
Share on other sites

When a sector changes side it fires off a scripted event handler called "ownerChanged". With this there is no need for the trigger as you can just subscribe to this event. The only thing you will want to handle, as per your note on the module expression, is that it fires at mission start. This is easily handled by excluding sideUnknown if the sector does not have a default side.

[ mySectorsName, "ownerChanged", {
    params[ "_sector", "_owner", "_ownerOld" ];
    
    if !( _owner isEqualTo sideUnknown ) then {
        //Do Stuff when sector changes side
    };
}] call BIS_fnc_addScriptedEventHandler;

The sector dummy is just as you describe a sector that does not need setting up and will inherit its parameters from another sector it is synced to.

Right, good example. 

Share this post


Link to post
Share on other sites

@Larrow

Could I pick your brain on an old thread? 

Using the above information, I have managed to fire the handler when it has taken by east (the easy part!), I thought if I created an array then it would apply to all sectors, obviously there is a clear error. Could I ask for some guidance?

 

Spoiler

AllSectors = [Sector1, Sector2];
 

[ AllSectors, "ownerChanged", {
    params[ "_sector", "_owner", "_ownerOld" ];
    
    if ( _owner isEqualTo EAST ) then {
        Hint "SectorChange"
    };
}] call BIS_fnc_addScriptedEventHandler;


Essentially the plan is everytime owner is changed to East on any sector - Reinforcement's would head to that sector as a waypoint,

This script will be called in the above If/Then. Would I need to use _this select 0 to call the sector module in the below?

Spoiler

_Sector_Reinforcements = [(Sector1 getpos [500,30]), WEST, (configFile >> "CfgGroups" >> "INDEP" >> "IND_C_F" >> "Infantry" >> "BanditCombatGroup")] call BIS_fnc_spawnGroup;
_Sector_Reinforcements_Waypoint =_Sector_Reinforcements addWaypoint [position Sector1, 0];

*Sector1 is a placeholder for testing the above, obviously it won't work with the array Allsectors.

 

Share this post


Link to post
Share on other sites

You have to add the event to each sector individually. The sectors can be got through calling BIS_fnc_moduleSector or by the missionNamespace variable BIS_fnc_moduleSector_sectors.

//Loop through all sectors in the mission
{
	//Add the SEH to each sector
	[ _x, "ownerChanged", {
		params[ "_sector", "_owner", "_ownerOld" ];

		if ( _owner isEqualTo EAST ) then {
			_Sector_Reinforcements = [ _sector getPos[ 500, 30] , west, (configFile >> "CfgGroups" >> "INDEP" >> "IND_C_F" >> "Infantry" >> "BanditCombatGroup")] call BIS_fnc_spawnGroup;
			_Sector_Reinforcements_Waypoint =_Sector_Reinforcements addWaypoint [ getPosATL _sector, 0 ];
		};
	}] call BIS_fnc_addScriptedEventHandler; 
}forEach ( true call BIS_fnc_moduleSector );

 

  • Like 2

Share this post


Link to post
Share on other sites

Thanks Larrow,

So instead of using the Array, I should've been calling ForEach.

Thanks Man!

Share this post


Link to post
Share on other sites

@Larrow could you tell me what the command to change a sector area would be? (setTriggerArea does not work) In the editor I set the size of 4 out of 6 sectors to 0,0,0 (making them uncapturable) the other 2 are (400,400,0).  When the first sector (which is set a 400,400,0) gets captured I want to set the size of the next one to (400,400,0).  I went here https://community.bistudio.com/wiki/BIS_fnc_moduleSector but as you can see, there's nothing... Thanks!

Share this post


Link to post
Share on other sites
_size = 0;
_sector = mySector;

_areas = _sector getVariable[ "areas", [] ];
{
	_x setTriggerActivation[ "any", "present", false ];
	_x setTriggerStatements[ "false", "", "" ];
	_x setTriggerType "none";
	_x setTriggerArea[ _size, _size, 0, false ];
	{
		if ( markerType _x == "" ) then {
			_x setMarkerSize[ _size, _size ];
		};
	}forEach ( _x getVariable[ "markers", [] ] );
}forEach _areas;

 

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

×