From 5c5e0ad49a3213af0426ab65735ef1523356132c Mon Sep 17 00:00:00 2001 From: vbawol Date: Sun, 18 Jun 2017 07:17:33 -0500 Subject: [PATCH] fixes for #759 --- .../addons/epoch_server_debris_event.pbo | Bin 7700 -> 8171 bytes .../EpochEvents/DynamicDebris.sqf | 71 +++++++++++------- Sources/epoch_server_debris_event/build.hpp | 2 +- build.txt | 2 +- 4 files changed, 44 insertions(+), 31 deletions(-) diff --git a/Server_Install_Pack/@epochhive/addons/epoch_server_debris_event.pbo b/Server_Install_Pack/@epochhive/addons/epoch_server_debris_event.pbo index 7c895086ff3d77cc9553fc32fafde0cfb84c24d8..a81f77ca12c26130918475dcac18b06c21e3881c 100644 GIT binary patch delta 735 zcmbPY^V)twsOuJ6*GLxz28N{4%$yXxjDi9n8v#6QTqF5`+~oYcw9It9WHf1z=5|&F zhRF>qvJCX7nLZ*0`1yt$HT$MY;Iw>*^{@Nnb|SeXYx^jwt8MJ1tbukmx^K&&=inJ zYH$0H(8r1wAz2PFE;S%}GrzQ83a}&{Z%5xfa#EAh*XugSZ$J zmaz)j3UJ+%ABqSYBczK{OBAAwbg-JPtze8WeR89)DJNXt?hJN z`ILwjkZ(6xOVoFAv8cr4c2T3rJYqbPB_%Z`zZ6vmvP~x2h}i;Z{>d$3dXv|QUZP3X+ll+yrYe&ve* delta 402 zcmaEDKgDK3sHo z!{i1Q*@@eE*({D5M?M#xc*>d?sBtm}W1ysok)gSzk~J?^EfBxoy&r6it+|Ee<|4*o z_Q`)ZA||JEc5eQ|S;Mq>J`W2cvx%wM=4HI)%&g)0ML8*x6$INRdx-N)_7YN={7#5t za+Qz`kQSVLT1Xy98-v+q!itllg#{+(3!6?}A*?z1s<7Oo{Bt nHzceli%Z&U&X&w!6FKO5`!D~Yt7p7UZVP_cuE{R_Bd`?!E6INv diff --git a/Sources/epoch_server_debris_event/EpochEvents/DynamicDebris.sqf b/Sources/epoch_server_debris_event/EpochEvents/DynamicDebris.sqf index 5f5a7161..c6f35c10 100644 --- a/Sources/epoch_server_debris_event/EpochEvents/DynamicDebris.sqf +++ b/Sources/epoch_server_debris_event/EpochEvents/DynamicDebris.sqf @@ -9,7 +9,7 @@ https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server_settings/EpochEvents/DebrisSpawner.sqf */ //[[[cog import generate_private_arrays ]]] -private ["_allRoads","_allowDebris","_debris","_debrisCounter","_debrisLocations","_debrisLocationsKey","_debrisLocationsTMP","_debug","_expiresDebris","_export","_instanceID","_intersections","_marker","_maxDebrisLimit","_newDebrisCounter","_object","_offsetX","_offsetY","_position","_response","_rng","_rngChance","_scriptHiveKey","_seed","_selectedDebris","_worldSize"]; +private ["_allRoads","_allowDebris","_debris","_debrisCounter","_debrisLocations","_debrisLocationsKey","_debrisLocationsTMP","_debug","_disallowedLocations","_expiresDebris","_export","_instanceID","_intersections","_marker","_maxDebrisLimit","_nearbyLocations","_newDebrisCounter","_object","_offsetX","_offsetY","_position","_response","_rng","_rngChance","_scriptHiveKey","_seed","_selectedDebris","_upperPos","_worldSize"]; //[[[end]]] _debug = false; _expiresDebris = 604800; @@ -34,13 +34,16 @@ _debris = [ "Land_Wreck_Truck_dropside_F", "Land_Wreck_HMMWV_F" ]; +_disallowedLocations = ["Airport"]; + _debrisCounter = 0; _newDebrisCounter = 0; _worldSize = worldSize/2; _instanceID = call EPOCH_fn_InstanceID; + _maxDebrisLimit = 500; // max total objects to spawn _rngChance = 0.95; // Lower this to spawn more positions -_scriptHiveKey = "EPOCH:DynamicDebris456"; // change this to force a new seed to be generated. +_scriptHiveKey = "EPOCH:DynamicDebris789"; // change this to force a new seed to be generated. _debrisLocationsKey = format ["%1:%2", _instanceID, worldname]; _response = [_scriptHiveKey, _debrisLocationsKey] call EPOCH_fnc_server_hiveGETRANGE; @@ -59,37 +62,47 @@ if (_status == 1 && _data isEqualType [] && !(_data isEqualTo [])) then { diag_log format["DEBUG: Generating new Debris Locations... with seed %1.",_seed]; { if (_newDebrisCounter >= _maxDebrisLimit) exitWith {}; - _position = getPosWorld _x; + _position = getPosASL _x; _position params ["_posX","_posY"]; _rng = _seed random [_posX,_posY]; if (_rng > _rngChance) then { - if (_debug) then { - _marker = createMarker[str(_position), _position]; - _marker setMarkerShape "ICON"; - _marker setMarkerType "waypoint"; - _marker setMarkerColor "ColorGreen"; - }; - _selectedDebris = selectRandom _debris; - _offsetX = (random 10) - 5; - _offsetY = (random 10) - 5; - _position set [0,(_position select 0) + _offsetX]; - _position set [1,(_position select 1) + _offsetY]; - _position set [2,0]; - _intersections = lineIntersectsSurfaces [[_position select 0,_position select 1,1000], _position, objNull, objNull, true, 1]; - if !(_intersections isEqualTo []) then { - (_intersections select 0) params ["_intersectPosASL","_surfaceNormal","_intersectObject","_parentObject"]; - _allowDebris = true; - if !(isNull _intersectObject) then { - _allowDebris = !((typeOf _intersectObject) in _debris); + + _nearbyLocations = nearestLocations [_position, _disallowedLocations, 100]; + if (_nearbyLocations isEqualTo []) then { + + if (_debug) then { + _marker = createMarker[str(_position), _position]; + _marker setMarkerShape "ICON"; + _marker setMarkerType "waypoint"; + _marker setMarkerColor "ColorGreen"; }; - if (_allowDebris) then { - _object = createSimpleObject [_selectedDebris, _intersectPosASL]; - _object setDir random 360; - _object setVectorUp _surfaceNormal; - _object setPosASL _intersectPosASL; - _export = [_selectedDebris,getPosWorld _object, vectorDir _object, vectorUp _object]; - _debrisLocationsTMP pushBack _export; - _newDebrisCounter = _newDebrisCounter + 1; + _selectedDebris = selectRandom _debris; + _offsetX = (random 10) - 5; + _offsetY = (random 10) - 5; + + _position set [0,(_position select 0) + _offsetX]; + _position set [1,(_position select 1) + _offsetY]; + _position set [2,(_position select 2) - 1]; + + _upperPos = [] + _position; + _upperPos set [2,(_position select 2) + 3]; + + _intersections = lineIntersectsSurfaces [_upperPos, _position, objNull, objNull, true, 1]; + if !(_intersections isEqualTo []) then { + (_intersections select 0) params ["_intersectPosASL","_surfaceNormal","_intersectObject","_parentObject"]; + _allowDebris = true; + if !(isNull _intersectObject) then { + _allowDebris = !((typeOf _intersectObject) in _debris); + }; + if (_allowDebris) then { + _object = createSimpleObject [_selectedDebris, _intersectPosASL]; + _object setDir random 360; + _object setVectorUp _surfaceNormal; + _object setPosASL _intersectPosASL; + _export = [_selectedDebris,getPosWorld _object, vectorDir _object, vectorUp _object]; + _debrisLocationsTMP pushBack _export; + _newDebrisCounter = _newDebrisCounter + 1; + }; }; }; }; diff --git a/Sources/epoch_server_debris_event/build.hpp b/Sources/epoch_server_debris_event/build.hpp index 36de2a38..71138e07 100644 --- a/Sources/epoch_server_debris_event/build.hpp +++ b/Sources/epoch_server_debris_event/build.hpp @@ -1 +1 @@ -build=790; +build=794; diff --git a/build.txt b/build.txt index 4c8cda60..a8ccafc1 100644 --- a/build.txt +++ b/build.txt @@ -1 +1 @@ -790 +794