shipwrecks distance to others check and config

This commit is contained in:
DESKTOP-UH65DCE\MusTanG 2017-10-28 09:01:38 -05:00
parent dfbbe9c273
commit e8ff66dc26
2 changed files with 30 additions and 8 deletions

View File

@ -13,21 +13,42 @@
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf
*/ */
//[[[cog import generate_private_arrays ]]] //[[[cog import generate_private_arrays ]]]
private ["_shipwrecks","_item","_markers"]; private ["_worldSize","_shipwrecks","_total","_count","_distFromOthers","_tooClose","_spawnedLoot","_wreck","_item","_markers"];
//[[[end]]] //[[[end]]]
_cfgEpoch = configFile >> "CfgEpoch" >> worldname; _cfgEpoch = configFile >> "CfgEpoch" >> worldname;
if (getNumber(_cfgEpoch >> "shipwreckLootEnabled") isEqualTo 1) then { if (getNumber(_cfgEpoch >> "shipwreckLootEnabled") isEqualTo 1) then {
_worldSize = worldSize/2; _worldSize = worldSize/2;
_shipwrecks = nearestTerrainObjects [ [_worldSize, _worldSize], ["SHIPWRECK"], _worldSize]; _shipwrecks = nearestTerrainObjects [ [_worldSize, _worldSize], ["SHIPWRECK"], _worldSize];
_total = getNumber(_cfgEpoch >> "maxSpawnedShipwrecks"); _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; _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]; _shipwrecks = _shipwrecks - [_wreck];
_item = createVehicle["container_epoch", _wreck, [], 0, "NONE"]; if!(_tooClose)then{
_item setMass 220; _item = createVehicle["container_epoch", _wreck, [], 0, "NONE"];
if (EPOCH_SHOW_BOATLOOT) then { _spawnedLoot pushback _wreck;
_markers = ["Shipwreck",_wreck] call EPOCH_server_createGlobalMarkerSet; _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];
};

View File

@ -82,6 +82,7 @@ class CfgEpoch
// Shipwrecks // Shipwrecks
shipwreckLootEnabled = 1; shipwreckLootEnabled = 1;
maxSpawnedShipwrecks = 12; maxSpawnedShipwrecks = 12;
distFromOtherShipwrecks = 750;
// Debug Box // Debug Box
telePos[] = {}; telePos[] = {};