From 81722abeac020654531ad853dda2ee8aa7b8d9f2 Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Fri, 29 Dec 2017 01:08:11 +0000 Subject: [PATCH] Use engine command to select weighted spall size (#5985) * Use engine command to select weighted spall size * Remove multi-line macro --- addons/frag/functions/fnc_doSpall.sqf | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/addons/frag/functions/fnc_doSpall.sqf b/addons/frag/functions/fnc_doSpall.sqf index dcc1759648..65b9327d5a 100644 --- a/addons/frag/functions/fnc_doSpall.sqf +++ b/addons/frag/functions/fnc_doSpall.sqf @@ -13,10 +13,9 @@ * * Public: No */ - -//fnc_doSpall.sqf #include "script_component.hpp" -// ACE_player sideChat "WAAAAAAAAAAAAAAAAAAAAA"; + +#define WEIGHTED_SIZE [QGVAR(spall_small), 4, QGVAR(spall_medium), 3, QGVAR(spall_large), 2, QGVAR(spall_huge), 1] params ["_hitData", "_hitPartDataIndex"]; private _initialData = GVAR(spallHPData) select (_hitData select 0); @@ -51,6 +50,7 @@ if (alive _round) then { }; }; if (_exit) exitWith {}; + private _unitDir = vectorNormalized _velocity; private _pos = _hpData select 3; private _spallPos = []; @@ -88,14 +88,6 @@ if (_explosive > 0) then { _spallPolar set [0, _fragPower * 0.66]; }; -private _fragTypes = [ - QGVAR(spall_small), QGVAR(spall_small), QGVAR(spall_small), - QGVAR(spall_small),QGVAR(spall_medium),QGVAR(spall_medium),QGVAR(spall_medium), - QGVAR(spall_medium), QGVAR(spall_large), QGVAR(spall_large), QGVAR(spall_huge), - QGVAR(spall_huge) - -]; - // diag_log text format ["SPALL POWER: %1", _spallPolar select 0]; private _spread = 15 + (random 25); private _spallCount = 5 + (random 10); @@ -110,8 +102,7 @@ for "_i" from 1 to _spallCount do { _vel = (_vel - (_vel * 0.25)) + (random (_vel * 0.5)); private _spallFragVect = [_vel, _dir, _elev] call CBA_fnc_polar2vect; - private _fragType = round (random ((count _fragTypes) - 1)); - private _fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000]; + private _fragment = (selectRandomWeighted WEIGHTED_SIZE) createVehicleLocal [0,0,10000]; _fragment setPosASL _spallPos; _fragment setVelocity _spallFragVect; @@ -133,8 +124,7 @@ for "_i" from 1 to _spallCount do { _vel = (_vel - (_vel * 0.25)) + (random (_vel * 0.5)); private _spallFragVect = [_vel, _dir, _elev] call CBA_fnc_polar2vect; - private _fragType = round (random ((count _fragTypes) - 1)); - private _fragment = (_fragTypes select _fragType) createVehicleLocal [0, 0, 10000]; + private _fragment = (selectRandomWeighted WEIGHTED_SIZE) createVehicleLocal [0, 0, 10000]; _fragment setPosASL _spallPos; _fragment setVelocity _spallFragVect;