Skip to content

Instantly share code, notes, and snippets.

@Cuel
Created January 8, 2017 10:15
Show Gist options
  • Save Cuel/9dfdbd13a8bc420c3f77a6b2c907b3e0 to your computer and use it in GitHub Desktop.
Save Cuel/9dfdbd13a8bc420c3f77a6b2c907b3e0 to your computer and use it in GitHub Desktop.
// xeh
class Extended_InitPost_EventHandlers {
class CAManBase {
init = "[_this select 0] call FP_useTracers";
};
};
FP_sortTracers = {
params ["_searchTerm", "_magazines"];
private _found = [];
private _rest = [];
{
if ([_searchTerm, _x] call BIS_fnc_inString) then {
_found pushBack _x;
} else {
_rest pushBack _x
};
} forEach _magazines;
(_found + _rest)
};
FP_useTracers = {
params ["_unit"];
if (isPlayer _unit || {!(local _unit)} || {side _unit == blufor}) exitWith {};
private _continue = random 1 > 0.2;
private _rifle = primaryWeapon _unit;
if (!_continue || _rifle == "") exitWith {};
private _magazines = getArray (configFile >> "CfgWeapons" >> _rifle >> "magazines") apply {toLower _x};
private _tracers = _magazines select {getNumber (configFile >> "CfgMagazines" >> _x >> "tracersEvery") >= 1};
if (count _tracers == 0) exitWith {};
private _tracer = (["green", _tracers] call FP_sortTracers) select 0;
[{
params ["_unit", "_magazines", "_tracer", "_rifle"];
_unit removeWeapon _rifle;
{
if ((toLower _x) in _magazines) then {
_unit removeMagazine _x;
};
} forEach magazines _unit;
_unit addMagazines [_tracer, 8];
_unit addWeapon _rifle;
_unit selectWeapon _rifle;
}, [_unit, _magazines, _tracer, _rifle]] call CBA_fnc_execNextFrame;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment