Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle script failure when no stashes were placed #94

Merged
merged 2 commits into from
Mar 21, 2024
Merged
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
7 changes: 6 additions & 1 deletion addons/killers/functions/fnc_initKillersStashes.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ private _stashes = +EGVAR(modules,killersStashes);
if (_stashes isEqualTo []) exitWith {};

private _stashesCount = count (_stashes);

if (_stashesCount isEqualTo 0) exitWith {
WARNING("No killer stashes found.");
};

// Number of stashes to randomly select and create (so around 75% of them should appear on average)
private _createStatshesCount = ceil (random [_stashesCount/2, _stashesCount/1.33, _stashesCount]);

// Initialize random stashes up to _createStatshesCount
for "_y" from 0 to _createStatshesCount step 1 do {
for "_y" from 0 to (_createStatshesCount - 1) step 1 do {
private _stash = _stashes deleteAt (floor (random (count (_stashes))));
private _stashPos = getPos _stash;
private _box = createVehicle [GVAR(stashBoxClassName), _stashPos, [], 0, "CAN_COLLIDE"];
Expand Down