From 1f96a6e6253ac7ae58e8b3d7aae1110d44dd3942 Mon Sep 17 00:00:00 2001 From: "DESKTOP-UH65DCE\\MusTanG" Date: Sun, 11 Feb 2018 11:05:53 -0600 Subject: [PATCH] Shipwreck loot upgrade Configs: -Custom wrecks : ClassName string expected -Custom locations : Posistion Array{x,y,z} expected Description: -This upgrade was to provide maps without the built-in terrain objects "SHIPWRECK" to have this feature available with a few custom locations added to the servers config. Function Changes: -Custom Locations and Wrecks Classnames are pulled from the config variable. -Wrecks are created and added to the already gathered array of Terrain Objects "SHIPWRECK". -On Maps without these terrain objects, the original array will be empty[], and then the custom locations will populate it from there. -On Maps with these terrain objects, the custom locations are added to the already populated array of "SHIPWRECK"'s and will then become part of the random selection of all known shipwrecks and custom locations. Remember custom shipwrecks have a distance check and will stop a loot spawn if there is already another shipwreck within the configured amount. --- .../EPOCH_server_spawnBoatLoot.sqf | 24 +++++++++++++------ Sources/epoch_server_settings/config.cpp | 2 ++ 2 files changed, 19 insertions(+), 7 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 a7aac746..091506ad 100644 --- a/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf +++ b/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf @@ -13,22 +13,32 @@ https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnBoatLoot.sqf */ //[[[cog import generate_private_arrays ]]] -private ["_cfgEpoch", "_debug", "_worldSize", "_shipwrecks", "_total", "_count", "_distFromOthers", "_spawnedLoot","_tooClose", "_wreck", "_position", "_item", "_debugMkr", "_markers", "_originalColors", "_showMarkers", "_decayMarkerColor", "_compromisedColor", "_rEvents", "_thisEvent"]; +private ["_cfgEpoch", "_debug", "_worldSize", "_shipwrecks", "_customLocs", "_customWrecks", "_totalCustomLocs", "_customWreck", "_total", "_count", "_distFromOthers", "_spawnedLoot","_tooClose", "_wreck", "_position", "_item", "_debugMkr", "_markers", "_originalColors", "_showMarkers", "_decayMarkerColor", "_compromisedColor", "_rEvents", "_thisEvent"]; //[[[end]]] _cfgEpoch = configFile >> "CfgEpoch" >> worldname; _debug = if(getNumber(_cfgEpoch >> "debugShipwreckLoot") isEqualTo 1)then{true}else{false}; - +// Check for shipwreck loot allowed if (getNumber(_cfgEpoch >> "shipwreckLootEnabled") isEqualTo 1) then { + // Check for total shipwrecks allowed + _total = getNumber(_cfgEpoch >> "maxSpawnedShipwrecks"); + if(_total isEqualTo 0)exitWith{if(_debug)then{diag_log "EPOCHDebug: no shipwrecks allowed"}}; + // Load shipwrecks and custom locations _worldSize = worldSize/2; _shipwrecks = nearestTerrainObjects [ [_worldSize, _worldSize], ["SHIPWRECK"], _worldSize]; - _total = getNumber(_cfgEpoch >> "maxSpawnedShipwrecks"); - + _customLocs = getArray(_cfgEpoch >> "shipwreckCustomLocs"); + _customWrecks = getArray(_cfgEpoch >> "shipwreckCustomWrecks"); + _totalCustomLocs = count(_customLocs); + if(_totalCustomLocs > 0)then{ + for "_c" from 0 to _totalCustomLocs-1 do { + _customWreck = (selectRandom _customWrecks) createVehicle (_customLocs select _c); + _shipwrecks pushBack _customWreck; + }; + }; if(_shipwrecks isEqualTo [])exitWith{if(_debug)then{diag_log "EPOCHDebug: no shipwrecks found"}}; - if(_total isEqualTo 0)exitWith{if(_debug)then{diag_log "EPOCHDebug: no shipwrecks allowed"}}; - + // Check combined array count _count = count(_shipwrecks); if(_count < _total)then{if(_debug)then{diag_log "EPOCHDebug: not enough shipwrecks to fill your needs on this map, trying all available locations!"}}; - + // Start spawning loot _distFromOthers = getNumber(_cfgEpoch >> "distFromOtherShipwrecks"); _spawnedLoot = []; for "_i" from 1 to _total do { diff --git a/Sources/epoch_server_settings/config.cpp b/Sources/epoch_server_settings/config.cpp index 0c392b3d..6c966529 100644 --- a/Sources/epoch_server_settings/config.cpp +++ b/Sources/epoch_server_settings/config.cpp @@ -104,6 +104,8 @@ class CfgEpoch distFromOtherShipwrecks = 750; shipwreckDecayMarkerColor = "ColorBrown"; // decay changes icon (_markers select 2) shipwreckCompromisedColor = "ColorRed"; // compromised changes active surround (_markers select 0) + shipwreckCustomWrecks[] = {"Land_UWreck_FishingBoat_F", "Land_UWreck_Heli_Attack_02_F", "Land_UWreck_MV22_F"}; + shipwreckCustomLocs[] = {}; // Plant Spawner debugPlantSpawner = 0;