From 05ececddc1a4507e117240f38b47c3358a0ce099 Mon Sep 17 00:00:00 2001 From: He-Man Date: Tue, 24 Sep 2019 21:23:46 +0200 Subject: [PATCH] Animated Heli Crashes --- .../@epochhive/epochconfig.hpp | 1 + .../epoch_config/Configs/CfgMarkerSets.hpp | 4 +- .../epoch_server/EPOCH_serverLootObject.sqf | 12 +- .../EpochEvents/HeliCrash.sqf | 141 ++++++++++++++++++ Sources/epoch_server_settings/config.cpp | 3 +- .../configs/CfgMainTable.h | 25 ++++ 6 files changed, 180 insertions(+), 6 deletions(-) create mode 100644 Sources/epoch_server_events/EpochEvents/HeliCrash.sqf diff --git a/Server_Install_Pack/@epochhive/epochconfig.hpp b/Server_Install_Pack/@epochhive/epochconfig.hpp index e4bd9570..7f65535a 100644 --- a/Server_Install_Pack/@epochhive/epochconfig.hpp +++ b/Server_Install_Pack/@epochhive/epochconfig.hpp @@ -26,6 +26,7 @@ forceRestartTime = 14400; // 4 hour restarts }, // { 1800, "PaydayEvent", 0, 2}, // { 1200, "MessageServer", 0, 2}, + { 1200, "HeliCrash", 0 , 2, -1, {} ,{"VR"}}, { 2700, "AirDrop", 0 , 2, -1, {} ,{"VR"}}, { 2400, "EarthQuake", 0 , 2, -1, {} ,{"VR"}}, { 2700, "Satellite", 0 , 2, -1, {} ,{"VR"}}, diff --git a/Sources/epoch_config/Configs/CfgMarkerSets.hpp b/Sources/epoch_config/Configs/CfgMarkerSets.hpp index 19c56450..84d01604 100644 --- a/Sources/epoch_config/Configs/CfgMarkerSets.hpp +++ b/Sources/epoch_config/Configs/CfgMarkerSets.hpp @@ -216,9 +216,9 @@ class CfgMarkerSets }; class HeliCrash { markerArray[] = { - {"","ICON","EpochActive_Circle","ColorOrange",1,{0.6,0.6}}, + {"","ICON","EpochActive_Circle","ColorYellow",1,{0.6,0.6}}, {"","ICON","EpochBG_Circle","ColorWhite",0.15,{0.6,0.6}}, - {"","ICON","EpochHeli2","ColorOrange",1,{0.5,0.5}} + {"","ICON","EpochHeli2","ColorYellow",1,{0.5,0.5}} }; }; }; diff --git a/Sources/epoch_server/compile/epoch_server/EPOCH_serverLootObject.sqf b/Sources/epoch_server/compile/epoch_server/EPOCH_serverLootObject.sqf index e1f9cd4d..b552c9bb 100644 --- a/Sources/epoch_server/compile/epoch_server/EPOCH_serverLootObject.sqf +++ b/Sources/epoch_server/compile/epoch_server/EPOCH_serverLootObject.sqf @@ -15,7 +15,7 @@ //[[[cog import generate_private_arrays ]]] private ["_config","_debug","_exit","_loop","_lootItemArray","_lootItemWeightedArray","_lootTable","_lootTableClass","_lootTableIndex","_loots","_magazineSize","_mags","_maxLoot","_maxPayout","_minLoot","_pricingConfig","_quan","_randomItem","_randomItemArray","_randomizeMagazineAmmoCount","_weightedItemArray"]; //[[[end]]] -params ["_object","_type",["_forceSpawn",false],["_pos",[]] ]; +params ["_object","_type",["_forceSpawn",false],["_pos",[]],["_scatter",[]]]; _debug = true; _pricingConfig = 'CfgPricing' call EPOCH_returnConfig; @@ -25,11 +25,12 @@ if !(EPOCH_forcedLootSpawnTable isEqualTo "") then { _lootTableClass = EPOCH_forcedLootSpawnTable; }; _randomizeMagazineAmmoCount = ["CfgEpochClient", "randomizeMagazineAmmoCount", true] call EPOCH_fnc_returnConfigEntryV2; -if (isnull _object && !(_pos isequalto [])) then { +if (isnull _object && !(_pos isequalto []) && (_scatter isequalto [])) then { _object = createVehicle ["groundWeaponHolder",_pos,[],0,"CAN_COLLIDE"]; _object setPosATL _pos; }; -if !(isNull _object) then{ +if (!isNull _object || !(_scatter isequalto [])) then{ + _scatter params [["_doScatter",false],["_ScatterRadiusArr",[6,12]]]; _lootTable = ["CfgMainTable", _type, "tables"] call EPOCH_fnc_weightedArray; if !(_lootTable isEqualTo []) then { _loots = []; @@ -41,6 +42,11 @@ if !(isNull _object) then{ _loots pushBack (selectRandomWeighted _lootTable); }; { + if (_doScatter) then { + _randomPos = [_pos,_ScatterRadiusArr call BIS_fnc_randomInt,[0,359] call BIS_fnc_randomInt] call BIS_fnc_relPos; + _object = createVehicle ["groundweaponholder",_randomPos,[],0,"CAN_COLLIDE"]; + _object setPosATL [_randomPos select 0, _randomPos select 1, 0.1]; + }; _lootItemWeightedArray = [_lootTableClass, _x, "items"] call EPOCH_fnc_weightedArray; if !(_lootItemWeightedArray isEqualTo[]) then { _randomItemArray = selectRandomWeighted _lootItemWeightedArray; diff --git a/Sources/epoch_server_events/EpochEvents/HeliCrash.sqf b/Sources/epoch_server_events/EpochEvents/HeliCrash.sqf new file mode 100644 index 00000000..c85a6510 --- /dev/null +++ b/Sources/epoch_server_events/EpochEvents/HeliCrash.sqf @@ -0,0 +1,141 @@ +_cfgEpoch = configFile >> "CfgEpoch" >> worldname; +_debug = if(getNumber(_cfgEpoch >> "debugHeliCrashes") isEqualTo 1)then{true}else{false}; +_limit = getNumber(_cfgEpoch >> "maxSpawnedHeliCrashes"); +_counter = missionNameSpace getVariable["EPOCH_HeliCrashCounter",0]; +_others = missionNameSpace getVariable["EPOCH_HeliCrashes", [[0,0,0]] ]; +_distFromOthers = getNumber(_cfgEpoch >> "distFromOtherHeliCrashes"); + +//STOP THE SCRIPT AND EXIT IF THE COUNTER IS TOO HIGH. +if (_counter >= _limit) exitWith { + if (_debug) then {diag_log "DEBUG: suppressed HELICRASH spawn over limit"}; +}; + +// decrease chance with more players +if (count (allplayers select {alive _x}) == 0) exitwith {}; +_chance = 0.1 + (linearConversion [1, 100, (count allPlayers), 0, 0.5, true]); +if ((random 1) < _chance) then { + _position = [0,0,0]; + for "_i" from 0 to 100 step 1 do { + _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 5, 0, 1000, 0] call BIS_fnc_findSafePos; + _goodPos = true; + _goodPos = [_position, true, true, false, _others, _distFromOthers] call EPOCH_server_isNearChecks; + if(_goodPos)then{ + _i = 100; + }else{ + _position = []; + }; + }; + + if ((count _position) == 2) then{ + _values = getArray(_cfgEpoch >> "availableHeliCrashes"); + if (_values isEqualTo []) exitwith { + if (_debug) then {diag_log "DEBUG: suppressed HELICRASH no HeliClasses defined"}; + }; + _veharray = selectrandom _values; + _startpos = [_position, 0, 3000, 5, 0, 1000, 0] call BIS_fnc_findSafePos; + if ((count _startpos) > 2) then { + _startpos = [3000,3000]; + }; + _startpos set [2,600]; + _veh = createVehicle [_veharray select 0, _startpos, [], 0, "FLY"]; + _veh setpos _startpos; + _veh call EPOCH_server_setVToken; + _group = creategroup east; + _unit = _group createUnit["I_Soldier_EPOCH", [0,0,0], [], 0, "FORM"]; + _unit moveInDriver _veh; + _veh flyinheight 200; + for '_i' from 0 to 3 do { + _group move _position; + uisleep 30; + }; + _time = diag_ticktime; + waituntil {uisleep 0.5; !(surfaceiswater (getpos _veh)) || diag_ticktime - _time > 60}; + deletevehicle _unit; + uisleep 2; + _veh setdamage 1; + _starttime = diag_ticktime; + waituntil {uisleep 0.25; ((getpos _veh) select 2) < 2 || diag_ticktime > _starttime+30}; + _pos = getposatl _veh; + _pos set [2,0]; + deletevehicle _veh; + uisleep 0.5; + if !(surfaceiswater _pos) then { + _veh = createVehicle [_veharray select 1, _pos, [], 0, "CAN_COLLIDE"]; + _veh setvectorup [0,0,1]; + _veh setPosatl _pos; + [objnull,"HeliCrash",false,_pos,[true,[6,12]]] call EPOCH_serverLootObject; + // Place markers and get decay, compromised and original colors + _markers = []; + _originalColors = []; + _showMarkers = if(getNumber(_cfgEpoch >> "showHeliCrashMarkers") isEqualTo 1)then{true}else{false}; + _decayMarkerColor = getText(_cfgEpoch >> "heliCrashDecayMarkerColor"); + _compromisedColor = getText(_cfgEpoch >> "heliCrashCompromisedColor"); + if (_showMarkers) then{ + _markers = ["HeliCrash",_pos] call EPOCH_server_createGlobalMarkerSet; + { + _originalColors pushBack (getMarkerColor _x); + }forEach _markers; + + // Check for HeightenedPlayerVsPlayer false and remove comprimised coloring + if!(getNumber(_cfgEpoch >> "HeightenedPlayerVsPlayer") isEqualTo 1)then{ + _compromisedColor = getMarkerColor (_markers select 0); + }; + }; + + // Tick Counter +1 + _counter = _counter + 1; + missionNameSpace setVariable["EPOCH_HeliCrashCounter",_counter]; + + // ADD POSITION TO OTHERS ARRAY + missionNameSpace setVariable["EPOCH_HeliCrashes", _others + [_pos]]; + + // SEND EVENT TO MONITOR + _decayTime = getNumber(_cfgEpoch >> "HeliCrashDecayTime"); + _serverSettingsConfig = configFile >> "CfgEpochServer"; + _timeMultiplier = ([_serverSettingsConfig, "timeMultiplier", 1] call EPOCH_fnc_returnConfigEntry); + _rEvents = missionNameSpace getVariable["EPOCH_RunningEvents",[]]; + _thisEvent = [_pos, [_veh], [], "EPOCH_HeliCrashCounter", diag_tickTime, (_decayTime * _timeMultiplier), _showMarkers, _markers, _originalColors, _decayMarkerColor, _compromisedColor]; + missionNameSpace setVariable["EPOCH_RunningEvents",_rEvents + [_thisEvent]]; + + _effects = []; + { + _x params ["_distance","_effect","_sleep"]; + { + if (!isnull _x) then { + deletevehicle _x; + }; + } foreach _effects; + if (isnull _veh) exitwith {}; + _effects = []; + _fireArray = switch _effect do { + case "FIRE_BIG": { + ["BigDestructionFire","BigDestructionSmoke"] + }; + case "SMOKE_MID": { + ["","MediumSmoke"] + }; + case "SMOKE_BIG": { + ["","BigDestructionSmoke"] + }; + default {[]}; + }; + if !(_fireArray isEqualTo []) then { + _fireArray params ["_fire","_smoke"]; + if (_fire != "") then { + _eFire = "#particlesource" createVehicle (position _veh) ; + _eFire setParticleClass _fire; + _eFire attachto [_veh, [0,0,-1]]; + _effects pushback _eFire; + }; + if (_smoke != "") then { + _eSmoke = "#particlesource" createVehicle (position _veh); + _eSmoke setParticleClass _smoke; + _eSmoke attachto [_veh, [0,0,-1]]; + _effects pushback _eSmoke; + }; + }; + waituntil {uisleep _sleep; !((_pos nearentities _distance) select {isplayer _x} isequalto []) || isnull _veh}; + } foreach [[200,"FIRE_BIG",15],[100,"SMOKE_BIG",5],[50,"SMOKE_MID",2]]; + }; + }; +}; diff --git a/Sources/epoch_server_settings/config.cpp b/Sources/epoch_server_settings/config.cpp index bbc8364e..c0843ca4 100644 --- a/Sources/epoch_server_settings/config.cpp +++ b/Sources/epoch_server_settings/config.cpp @@ -183,9 +183,10 @@ class CfgEpoch showHeliCrashMarkers = 1; maxSpawnedHeliCrashes = 4; distFromOtherHeliCrashes = 2000; + HeliCrashDecayTime = 2400; heliCrashDecayMarkerColor = "ColorBrown"; // decay changes icon (_markers select 2) heliCrashCompromisedColor = "ColorRed"; // compromised changes active surround (_markers select 0) - availableHeliCrashes[] = {"Land_Wreck_Heli_Attack_01_F","Land_Wreck_Heli_Attack_02_F"}; + availableHeliCrashes[] = {{"O_Heli_Attack_02_F","Land_Wreck_Heli_Attack_02_F"},{"B_Heli_Attack_01_F","Land_Wreck_Heli_Attack_01_F"}}; heliCrashCustomLocs[] = {}; propsPos[] = { diff --git a/Sources/epoch_server_settings/configs/CfgMainTable.h b/Sources/epoch_server_settings/configs/CfgMainTable.h index e78ecaff..7ef3ca0b 100644 --- a/Sources/epoch_server_settings/configs/CfgMainTable.h +++ b/Sources/epoch_server_settings/configs/CfgMainTable.h @@ -598,6 +598,31 @@ class CfgMainTable { "Grenades", 2 } }; }; + class HeliCrash + { + lootMin = 10; + LootMax = 20; + tables[] = { + { "SniperRifle", 1 }, + { "Generic", 5 }, + { "Sodas", 4 }, + { "CanFood", 4 }, + { "Rifle", 3 }, + { "Machinegun", 2 }, + { "Tools", 2 }, + { "Pistols", 3 }, + { "Scopes", 2 }, + { "Bipods", 2 }, + { "Muzzles", 2 }, + { "Medical", 2 }, + { "Explosives", 2 }, + { "HighExplosives", 1 }, + { "Backpack", 1 }, + { "Uniforms", 1 }, + { "Vests", 1 }, + { "HeadgearArmored", 2 } + }; + }; class Mission_Payout1 { lootMin = 4;