Jump to content

Recommended Posts

Hello everyone,

I've created this 2 scripts/functions because I was bored to find (for an hour) and kill the last enemy in a sector to get control of it, even though I had a hundred allies in it.

I recommend to use both scripts as functions and not scripts, because both can be called multiple times and having functions can be a lot more handy if you guys are scripting.


Does it work in multiplayer?

Yes, MultiPlayer and SinglePlayer.


What does this script/function do?

This script accepts 2 parameters:

- Position (center position of the sector)

- Range (Ellipse range in meters)

It calculates (by counting infantry of each side inside the sector) which side is owning the given sector and returns it as text.


How does it calculate the infantry inside?

It calls a second script which is getUnitsCountThis script can be also called by itself if you need it somewhere else, it accepts 3 parameters:

- Position

- Range

- Side → of which you want to get the units count inside the area.

If AI vehicles are inside the area, crew will be calculated.

getUnitsCount returns the sum of the units, therefore an integer value.


Return values
- "west" → If BLUFOR are owning the sector;

- "east" → If OPFOR are owning the sector;

- "independent" → If Independents are owning the sector;

- "civilian" → If no-one is owning the sector, which means not a single west, east or independent unit is inside the area, therefore civilians own it or it's currently contended (same units for each side)


How do I call the script?

[_positionParameter, _rangeInMeters] execVM "getCurrentOwnership.sqf";

How do I use it in a trigger?

Simply put a trigger with the following condition, obviously on the right hand side instead of west you can use civilian, independent or east if you'd like to check if the given side has ownership of the area.

It can be also called from other script if you like to do so.

Make sure the trigger is ServerOnly!!!!!

([_positionParameter, _rangeInMeters] execVM "getCurrentOwnership.sqf") == "west"

----------------- SCRIPTS -----------------


//Uncomment following if using as function
//params [ "_position", "_distance", "_side" ];
//Uncomment following if using as script
_position = _this select 0; _distance = _this select 1; _side = _this select 3;

_infantrycount = 0; _countedvehicles = 0; _vehiclecrewcount = 0;
_infantrycount = _side countSide ( [ _position nearEntities [ "Man", _distance],{ !(captive _x) && ((getpos _x) select 2 < 100) }] call BIS_fnc_conditionalSelect );
_countedvehicles =  [ ( _position nearEntities [ ["Car", "Tank", "Air"], _distance] ), { ((getpos _x) select 2 < 750) && count (crew _x) > 0 } ] call BIS_fnc_conditionalSelect;
_vehiclecrewcount = 0;
{ _vehiclecrewcount = _vehiclecrewcount + (_side countSide (crew _x)) } foreach _countedvehicles;
//Return value
(_infantrycount + _vehiclecrewcount)


//Uncomment following if using as function
//Uncomment following if using as script
_position = _this select 0; _range = _this select 1;

_westCount = [_position, _range, west] call OFF_fnc_getUnitsCount;
_eastCount = [_position, _range, east] call OFF_fnc_getUnitsCount;
_indeCount = [_position, _range, independent] call OFF_fnc_getUnitsCount;
_result = 0;
if (_westCount > _eastCount && _westCount > _indeCount) then { _result = "west"; };
if (_westCount > _eastCount && _westCount < _indeCount) then { _result = "independent"; };
if (_eastCount > _westCount && _eastCount > _indeCount) then { _result = "east"; };
if (_eastCount > _westCount && _eastCount < _indeCount) then { _result = "independent"; };
if (_eastCount == _westCount && _westCount == _indeCount) then { _result = "civilian"; };


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