Does anyone know if there is a variable that holds information on which faction owns an objective. I want to make a script that will spawn in a HVT target, but only if the faction that HVT belongs to, owns the town i am trying to spawn him in.
Does anyone know if there is a variable that holds information on which faction owns an objective. I want to make a script that will spawn in a HVT target, but only if the faction that HVT belongs to, owns the town i am trying to spawn him in.
If you're only using one city (instead of dynamically finding cities that belong to a side), you can use this as a quick method to determine if one side has more groups nearby than the other.
Ex. using East and West
//-- Define necessary information _position = getPos player; //-- Town pos _distance = 500; //-- Distance to check for groups //-- Get nearby west groups _westInf = count ([_position, _distance, ["WEST","entity"]] call ALIVE_fnc_getNearProfiles); _westVeh = count ([_position, _distance, ["WEST","vehicle"]] call ALIVE_fnc_getNearProfiles); _west = _westInf + _westVeh; //-- Get nearby east groups _eastInf = count ([_position, _distance, ["EAST","entity"]] call ALIVE_fnc_getNearProfiles); _eastVeh = count ([_position, _distance, ["EAST","vehicle"]] call ALIVE_fnc_getNearProfiles); _east = _eastInf + _eastVeh; if (_west > _east) then {hint "West is in control of the area"} else {hint "East is in control of the area"};
Awesome. I don't suppose there is a way to do it, dynamically finding objectives that belong to a side? In case i decide to change the implementation in future?
It's possible but it'll require a bit more work to implement (can see method in action when using intel tablet and observing objective occupation).
I'm pretty sure there is an easier way to do this but I'm lazy too look for it atm so.. this should work. Note that this will be a bit more heavy on the performance.
(I also made a typo in the code from the above post, so if you use that, copy it again)
Put this inside a function and call it (Must be called on the server).
It will return a position that is occupied by the enemy force if any exists, otherwise it will return nil
You can call it by doing
_position = ["WEST","EAST",500] call functionname;
With
"WEST" being the friendly side
"EAST" being the enemy side
500 being the distance to check for nearby groups
private ["_chosenPosition"]; params [ ["_friendlySide","WEST"], ["_enemySide","EAST"], ["_distance",500] ]; _objectives = []; { _side = _x; { _opcom = _x; _opcomSide = [_opcom,"side"] call ALiVE_fnc_hashGet; if (_opcomSide == _side) then { _objectives pushBack ([_opcom,"objectives"] call ALiVE_fnc_hashGet); }; } forEach OPCOM_instances; } forEach [_enemySide,_friendlySide]; for "_x" from 0 to (count _objectives - 1) do { _objective = _objectives call BIS_fnc_selectRandom; _objectives = _objectives - [_objective]; _pos = [_objective,"center"] call ALiVE_fnc_hashGet; //-- Get nearby west groups _friendlyInf = count ([_pos, _distance, [_friendlySide,"entity"]] call ALIVE_fnc_getNearProfiles); _friendlyVeh = count ([_pos, _distance, [_friendlySide,"vehicle"]] call ALIVE_fnc_getNearProfiles); _friendly = _friendlyInf + _friendlyVeh; //-- Get nearby east groups _enemyInf = count ([_pos, _distance, [_enemySide,"entity"]] call ALIVE_fnc_getNearProfiles); _enemyVeh = count ([_pos, _distance, [_enemySide,"vehicle"]] call ALIVE_fnc_getNearProfiles); _enemy = _enemyInf + _enemyVeh; if (_friendly < enemy) exitWith {_chosenPosition = _pos}; }; _chosenPosition