Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 16 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 @@ -88,8 +88,21 @@ params ["_pos"];
//Teardown condition
{
params ["_siteStore"];
//Teardown when all guns destroyed
(_siteStore getVariable "aaGuns" findIf {alive _x} == -1)

private _pos = getPos _siteStore;
Comment thread
dijksterhuis marked this conversation as resolved.
Outdated
private _objects = _siteStore getVariable ["aaGuns", []];

/*
Teardown when all guns are either
- destroyed
- no longer with 20m radius of site centre point
*/

private _objectsAreAliveInRadius = _objects findIf {
(alive _x) && (count ([_x] inAreaArray [_pos, 20, 20, 0, false]) > 0)
};

_objectsAreAliveInRadius == -1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be way faster to execute inAreaArray once, it also accepts an object as a centre pos, which I understand the _siteStore is (not familiar with MF internals).

Below code should be faster on average:

Suggested change
private _pos = getPos _siteStore;
private _objects = _siteStore getVariable ["aaGuns", []];
/*
Teardown when all guns are either
- destroyed
- no longer with 20m radius of site centre point
*/
private _objectsAreAliveInRadius = _objects findIf {
(alive _x) && (count ([_x] inAreaArray [_pos, 20, 20, 0, false]) > 0)
};
_objectsAreAliveInRadius == -1
/*
Teardown when all guns are either
- destroyed
- no longer with 20m radius of site centre point
*/
((_siteStore getVariable "aaGuns") inAreaArray [_siteStore, 20, 20, 0, false]) findIf {alive _x} == -1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aye i see what you're saying, will do.

@dijksterhuis dijksterhuis Oct 8, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@veteran29


I was working on an additional check for when players have loaded the site object into a vehicle with the Advanced Logistics module, as that can causes site/zone soft-locks too -- see: cd97f17

But there's at least three downstream edge cases to take into account, beyond the teardown condition check

  • do not delete object when player is carrying object (object deletion in front of player)
  • do not delete object when in a vehicle logistics inventory (object will no longer exist in logistics inventory)
  • do not delete object if ever has been in a vehicle logistics inventory (object deletion in front of player)

Simplest / cleanest option seems to be to just to disable the ability to load these objects into vehicles, so that's the latest version.

},
//Teardown code
{
Expand All @@ -108,4 +121,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: 16 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 @@ -81,8 +81,21 @@ params ["_pos"];
//Teardown condition
{
params ["_siteStore"];
//Teardown when all guns destroyed
(_siteStore getVariable "mortars" findIf {alive _x} == -1)

private _pos = getPos _siteStore;
private _objects = _siteStore getVariable ["mortars", []];

/*
Teardown when all guns are either
- destroyed
- no longer with 20m radius of site cetnre point
*/

private _objectsAreAliveInRadius = _objects findIf {
(alive _x) && (count ([_x] inAreaArray [_pos, 20, 20, 0, false]) > 0)
};

_objectsAreAliveInRadius == -1
},
//Teardown code
{
Expand All @@ -100,4 +113,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;
25 changes: 21 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,10 +28,13 @@ 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"};
Expand Down Expand Up @@ -81,8 +84,22 @@ params ["_pos"];
//Teardown condition
{
params ["_siteStore"];
//Teardown when all guns destroyed
(_siteStore getVariable "objectsToDestroy" findIf {alive _x} == -1)

private _pos = getPos _siteStore;
private _radius = _siteStore getVariable ["siteRadius", 50];
private _objects = _siteStore getVariable ["objectsToDestroy", []];

/*
Teardown when all ammo crates are either
- destroyed
- no longer within radius of site
*/

private _objectsAreAliveInRadius = _objects findIf {
(alive _x) && (count ([_x] inAreaArray [_pos, _, _radius, 0, false]) > 0)
};

_objectsAreAliveInRadius == -1
},
//Teardown code
{
Expand All @@ -96,4 +113,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;