Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mission/config/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ class CfgFunctions
class sites_init {};
class sites_load {};
class sites_teardown_site {};
class sites_check_standard_site_completed {};

//Specific types of site
class sites_create_aa_site {};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
File: fn_sites_check_standard_site_completed.sqf
Author: @dijksterhuis
Public: Yes

Description:

Standardised check for whether a site should be considered completed or not.

'Standardised' here basically means typical Mike Force sites where players need
to clear/destroy/spike certain objects to complete that site and progress.

The check also covers the cases where
* some 'arma' has happened, yeeting the object far away from the site
* a player has picked up a site object and walked away from the site
* a player has loaded a site object as vehicle cargo

Parameter(s):

* _objectsToCheck -- [ARRAY]: the objects in the site whose presence
needs to be checked
* _centrepointObjectOrPos -- [OBJECT/POSITION]: centrepoint for the area search.
either an object (usually the _siteStore simple
object), or a position array
* _checkRadius -- [NUMBER]: how far away from the site do we need to
check for the objects before considering them
"gone".
* _checkIsRectangle -- [BOOL]: whether the search area is an ellipse
(default) or rectangular

Returns:

true if site is completed, false otherwise

Example(s):

// circular area search using _storeStore object as centre
[
_siteStore getVariable ["aaGuns", []],
_siteStore,
20
] call vn_mf_fnc_sites_check_standard_site_completed;

// circular area search using some other position as centre
[
_siteStore getVariable ["staticMgs", []],
[0, 0, 0],
10,
false
] call vn_mf_fnc_sites_check_standard_site_completed;

// rectangular area search
[
_siteStore getVariable ["mortars", []],
_siteStore,
5,
true
] call vn_mf_fnc_sites_check_standard_site_completed;

*/

params [
"_objectsToCheck",
"_centrepointObjectOrPos",
"_checkRadius",
["_checkIsRectangle", false]
];

private _objectsInArea = _objectsToCheck inAreaArray [
_centrepointObjectOrPos,
_checkRadius,
_checkRadius,
0,
false
];

_objectsInArea findIf {alive _x} == -1
13 changes: 10 additions & 3 deletions mission/functions/systems/sites/fn_sites_create_aa_site.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ params ["_pos"];
private _objectives = [];
{
_objectives pushBack ([_x] call para_s_fnc_ai_obj_request_crew);
// site objects being placed in a vehicle's logistics inventory
// can result in strange side-effects / edge cases, including
// soft-locked sites and objects being deleted in front of players.
_x setVariable ["vn_log_enablePickup", false];
} forEach _guns;
_objectives pushBack ([_spawnPos, 2, 3] call para_s_fnc_ai_obj_request_defend);

Expand All @@ -88,8 +92,11 @@ params ["_pos"];
//Teardown condition
{
params ["_siteStore"];
//Teardown when all guns destroyed
(_siteStore getVariable "aaGuns" findIf {alive _x} == -1)
[
_siteStore getVariable ["aaGuns", []],
_siteStore,
20
] call vn_mf_fnc_sites_check_standard_site_completed;
},
//Teardown code
{
Expand All @@ -108,4 +115,4 @@ params ["_pos"];
[_x] call para_s_fnc_ai_obj_finish_objective;
} forEach (_siteStore getVariable ["aiObjectives", []]);
}
] call vn_mf_fnc_sites_create_site;
] call vn_mf_fnc_sites_create_site;
13 changes: 10 additions & 3 deletions mission/functions/systems/sites/fn_sites_create_artillery_site.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ params ["_pos"];
private _objectives = [];
{
_objectives pushBack ([_x] call para_s_fnc_ai_obj_request_crew);
// site objects being placed in a vehicle's logistics inventory
// can result in strange side-effects / edge cases, including
// soft-locked sites and objects being deleted in front of players.
_x setVariable ["vn_log_enablePickup", false];
} forEach _mortars;
_objectives pushBack ([_spawnPos, 1, 2] call para_s_fnc_ai_obj_request_defend);

Expand All @@ -81,8 +85,11 @@ params ["_pos"];
//Teardown condition
{
params ["_siteStore"];
//Teardown when all guns destroyed
(_siteStore getVariable "mortars" findIf {alive _x} == -1)
[
_siteStore getVariable ["mortars", []],
_siteStore,
20
] call vn_mf_fnc_sites_check_standard_site_completed;
},
//Teardown code
{
Expand All @@ -100,4 +107,4 @@ params ["_pos"];
[_x] call para_s_fnc_ai_obj_finish_objective;
} forEach (_siteStore getVariable ["aiObjectives", []]);
}
] call vn_mf_fnc_sites_create_site;
] call vn_mf_fnc_sites_create_site;
19 changes: 15 additions & 4 deletions mission/functions/systems/sites/fn_sites_create_hq.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@ params ["_pos"];
private _sitePos = getPos _siteStore;
private _spawnPos = _sitePos;

private _radius = 50;
_siteStore setVariable ["siteRadius", _radius];

//Hide all nearby terrain objects.
{
_x hideObjectGlobal true;
} forEach (nearestTerrainObjects [_spawnPos, ["TREE", "BUSH", "SMALL TREE", "ROCK", "ROCKS"], 50, false, true]);
} forEach (nearestTerrainObjects [_spawnPos, ["TREE", "BUSH", "SMALL TREE", "ROCK", "ROCKS"], _radius, false, true]);

private _hqObjects = [_spawnPos] call vn_mf_fnc_create_hq_buildings;
private _objectsToDestroy = _hqObjects select {_x isKindOf "land_vn_pavn_ammo"};

// site objects being placed in a vehicle's logistics inventory
// can result in strange side-effects / edge cases, including
// soft-locked sites and objects being deleted in front of players.
_objectsToDestroy apply {_x setVariable ["vn_log_enablePickup", false]};

{
[_x, true] call para_s_fnc_enable_dynamic_sim;
} forEach _hqObjects;
Expand Down Expand Up @@ -81,8 +89,11 @@ params ["_pos"];
//Teardown condition
{
params ["_siteStore"];
//Teardown when all guns destroyed
(_siteStore getVariable "objectsToDestroy" findIf {alive _x} == -1)
[
_siteStore getVariable ["objectsToDestroy", []],
_siteStore,
_siteStore getVariable ["siteRadius", 50]
] call vn_mf_fnc_sites_check_standard_site_completed;
},
//Teardown code
{
Expand All @@ -96,4 +107,4 @@ params ["_pos"];
[_x] call para_s_fnc_ai_obj_finish_objective;
} forEach (_siteStore getVariable ["aiObjectives", []]);
}
] call vn_mf_fnc_sites_create_site;
] call vn_mf_fnc_sites_create_site;