From e8ff66dc260826b4063625b192b62ea095e22196 Mon Sep 17 00:00:00 2001 From: "DESKTOP-UH65DCE\\MusTanG" Date: Sat, 28 Oct 2017 09:01:38 -0500 Subject: [PATCH] shipwrecks distance to others check and config --- .../EPOCH_server_spawnBoatLoot.sqf | 37 +++++++++++++++---- Sources/epoch_server_settings/config.cpp | 1 + 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf b/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf index 9c09808d..531c3d47 100644 --- a/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf +++ b/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf @@ -13,21 +13,42 @@ https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf */ //[[[cog import generate_private_arrays ]]] -private ["_shipwrecks","_item","_markers"]; +private ["_worldSize","_shipwrecks","_total","_count","_distFromOthers","_tooClose","_spawnedLoot","_wreck","_item","_markers"]; //[[[end]]] _cfgEpoch = configFile >> "CfgEpoch" >> worldname; if (getNumber(_cfgEpoch >> "shipwreckLootEnabled") isEqualTo 1) then { _worldSize = worldSize/2; _shipwrecks = nearestTerrainObjects [ [_worldSize, _worldSize], ["SHIPWRECK"], _worldSize]; _total = getNumber(_cfgEpoch >> "maxSpawnedShipwrecks"); - for "_i" from 1 to _total do { - if (_shipwrecks isEqualTo []) exitWith {}; + + if(_shipwrecks isEqualTo [])exitWith{diag_log "EPOCHDebug: no shipwrecks found"}; + if(_total isEqualTo 0)exitWith{diag_log "EPOCHDebug: no shipwrecks allowed"}; + _count = count(_shipwrecks); + if(_count < _total)then{diag_log "EPOCHDebug: not enough shipwrecks to fill your needs on this map, trying all available locations!"}; + + _distFromOthers = getNumber(_cfgEpoch >> "distFromOtherShipwrecks"); + _tooClose = false; + _spawnedLoot = []; + for "_i" from 1 to (_total min _count) do { _wreck = selectRandom _shipwrecks; + { + if(!(_spawnedLoot isEqualTo []) && ((_wreck distance _x) < _distFromOthers))exitWith{ + diag_log "EPOCHDebug: Shipwreck too close to another shipwreck"; + _tooClose = true; + _i = (_i - 1); + }; + }forEach _spawnedLoot; + _shipwrecks = _shipwrecks - [_wreck]; - _item = createVehicle["container_epoch", _wreck, [], 0, "NONE"]; - _item setMass 220; - if (EPOCH_SHOW_BOATLOOT) then { - _markers = ["Shipwreck",_wreck] call EPOCH_server_createGlobalMarkerSet; + if!(_tooClose)then{ + _item = createVehicle["container_epoch", _wreck, [], 0, "NONE"]; + _spawnedLoot pushback _wreck; + _item setMass 220; + + if (EPOCH_SHOW_BOATLOOT) then { + _markers = ["Shipwreck",_wreck] call EPOCH_server_createGlobalMarkerSet; + }; }; }; -}; + diag_log format["EPOCHDebug: Safely spawned %1 loot container(s) at these shipwreck locations:%2",count _spawnedLoot , _spawnedLoot]; +}; \ No newline at end of file diff --git a/Sources/epoch_server_settings/config.cpp b/Sources/epoch_server_settings/config.cpp index 39bbf3a2..3b80f5e4 100644 --- a/Sources/epoch_server_settings/config.cpp +++ b/Sources/epoch_server_settings/config.cpp @@ -82,6 +82,7 @@ class CfgEpoch // Shipwrecks shipwreckLootEnabled = 1; maxSpawnedShipwrecks = 12; + distFromOtherShipwrecks = 750; // Debug Box telePos[] = {};