Skip to content

Commit

Permalink
Prevent explosions on police vehicle spawn (#80)
Browse files Browse the repository at this point in the history
* Find empty position on police spawner instead of forcing spawner center

* Preload spawners for findEmptyPosition
  • Loading branch information
3Mydlo3 authored Mar 7, 2024
1 parent fbd7a7f commit 2d03bb6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions addons/police/functions/fnc_initSpawner.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ _spawner setVariable [QGVAR(vehicleActions), true call CBA_fnc_createNamespace,
private _spawnPoints = (allMissionObjects "VR_Area_01_circle_4_grey_F") inAreaArray _baseArea;
private _helipads = (allMissionObjects "Helipad_base_F") inAreaArray _baseArea;

// Preload
{
getPos _x findEmptyPositionReady [0, SPAWNPOINT_SAFEZONE];
} forEach (_spawnPoints + _helipads);

// Assign found spawn points for easier access
_spawner setVariable [QGVAR(spawnPoints), _spawnPoints, true];
_spawner setVariable [QGVAR(helipads), _helipads, true];
6 changes: 4 additions & 2 deletions addons/police/functions/fnc_spawnVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* Public: No
*/

#define SPAWNPOINT_SAFEZONE 5

params ["_vehicleClassname", "_spawner"];

private _vehicleType = (_vehicleClassname call BIS_fnc_objectType) select 1;
Expand Down Expand Up @@ -65,6 +63,10 @@ if (_emptySpawnPointIndex isNotEqualTo -1) then {
};
};

if (_position isNotEqualTo []) then {
_position = _position findEmptyPosition [0, SPAWNPOINT_SAFEZONE, _vehicleClassname];
};

// Show message if no empty spawn position
if (_position isEqualTo []) exitWith {
private _baseName = (_spawner getVariable "policeStation") getVariable "LocationName";
Expand Down
3 changes: 3 additions & 0 deletions addons/police/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
#endif

#include "\z\afsk\addons\main\script_macros.hpp"

// Safezone for vehicle spawn points
#define SPAWNPOINT_SAFEZONE 5

0 comments on commit 2d03bb6

Please sign in to comment.