mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
jamming
This commit is contained in:
@ -15,6 +15,10 @@ class CfgWeapons {
|
|||||||
|
|
||||||
class Rifle;
|
class Rifle;
|
||||||
class Rifle_Base_F : Rifle {
|
class Rifle_Base_F : Rifle {
|
||||||
|
ACE_MRBS = 3000;
|
||||||
|
ACE_Dispersion = 0;
|
||||||
|
ACE_SlowdownFactor = 1;
|
||||||
|
|
||||||
// Dispersion, SlowdownFactor and JamChance arrays have 4 values for different temperatures, which are interpolated between.
|
// Dispersion, SlowdownFactor and JamChance arrays have 4 values for different temperatures, which are interpolated between.
|
||||||
// These values correspond to temperatures Converted to real life values: 0: 0°C, 1: 333°C, 2: 666°C, 3: 1000°C.
|
// These values correspond to temperatures Converted to real life values: 0: 0°C, 1: 333°C, 2: 666°C, 3: 1000°C.
|
||||||
|
|
||||||
|
@ -18,30 +18,30 @@ EXPLODE_2_PVT(_this,_player,_weapon);
|
|||||||
private ["_temperature", "_scaledTemperature", "_color", "_count", "_string", "_text", "_picture"];
|
private ["_temperature", "_scaledTemperature", "_color", "_count", "_string", "_text", "_picture"];
|
||||||
|
|
||||||
// Calculate cool down of weapon since last shot
|
// Calculate cool down of weapon since last shot
|
||||||
_temperature = [_player, _weapon, 0] call FUNC(updateTemperature)
|
_temperature = [_player, _weapon, 0] call FUNC(updateTemperature);
|
||||||
_scaledTemperature = (_temperature / 1000) min 1;
|
_scaledTemperature = (_temperature / 1000) min 1;
|
||||||
|
|
||||||
_color = [
|
_color = [
|
||||||
2 * _scaledTemperature min 1,
|
2 * _scaledTemperature min 1,
|
||||||
2 * (1 - _scaledTemperature) min 1,
|
2 * (1 - _scaledTemperature) min 1,
|
||||||
00
|
00
|
||||||
];
|
];
|
||||||
|
|
||||||
_count = 2 + round (10 * _scaledTemperature);
|
_count = round (12 * _scaledTemperature);
|
||||||
_string = "";
|
_string = "";
|
||||||
for "_a" from 1 to _count do {
|
for "_a" from 1 to _count do {
|
||||||
_string = _string + "|";
|
_string = _string + "|";
|
||||||
};
|
};
|
||||||
_text = [_string, _color] call EFUNC(common,stringToColoredText);
|
_text = [_string, _color] call EFUNC(common,stringToColoredText);
|
||||||
|
|
||||||
_string = "";
|
_string = "";
|
||||||
for "_a" from (_count + 1) to 12 do {
|
for "_a" from (_count + 1) to 12 do {
|
||||||
_string = _string + "|";
|
_string = _string + "|";
|
||||||
};
|
};
|
||||||
|
|
||||||
_text = composeText [
|
_text = composeText [
|
||||||
_text,
|
_text,
|
||||||
[_string, [0.5, 0.5, 0.5]] call EFUNC(common,stringToColoredTex)t
|
[_string, [0.5, 0.5, 0.5]] call EFUNC(common,stringToColoredText)
|
||||||
];
|
];
|
||||||
|
|
||||||
_picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture");
|
_picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture");
|
||||||
|
@ -27,92 +27,89 @@ _weapon = _this select 1;
|
|||||||
|
|
||||||
// Compute new temperature if the unit is the local player
|
// Compute new temperature if the unit is the local player
|
||||||
if (_unit == ACE_player) then {
|
if (_unit == ACE_player) then {
|
||||||
_this call FUNC(overheat);
|
_this call FUNC(overheat);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get current temperature from the unit variable
|
// Get current temperature from the unit variable
|
||||||
_variableName = format [QGVAR(%1), _weapon];
|
_variableName = format [QGVAR(%1), _weapon];
|
||||||
_scaledTemperature = (((_unit getVariable [_variableName, [0,0]]) select 0) / 1000) min 1 max 0;
|
_scaledTemperature = (((_unit getVariable [_variableName, [0,0]]) select 0) / 1000) min 1 max 0;
|
||||||
|
|
||||||
|
//////////////////////////////// FIX
|
||||||
|
systemChat format ["%1", _scaledTemperature];
|
||||||
|
_scaledTemperature = random 1;
|
||||||
|
//////////////////////////////// FIX
|
||||||
|
|
||||||
// Smoke SFX, beginning at TEMP 0.15
|
// Smoke SFX, beginning at TEMP 0.15
|
||||||
private "_intensity";
|
private "_intensity";
|
||||||
|
|
||||||
_intensity = (_scaledTemperature - 0.2) * 1.25;
|
_intensity = (_scaledTemperature - 0.2) * 1.25;
|
||||||
if (_intensity > 0) then {
|
if (_intensity > 0) then {
|
||||||
private ["_position", "_direction"];
|
private ["_position", "_direction"];
|
||||||
|
|
||||||
_position = position _projectile;
|
_position = position _projectile;
|
||||||
_direction = (_unit weaponDirection _weapon) vectorMultiply 0.25;
|
_direction = (_unit weaponDirection _weapon) vectorMultiply 0.25;
|
||||||
|
|
||||||
drop [
|
|
||||||
"\A3\data_f\ParticleEffects\Universal\Refract",
|
|
||||||
"",
|
|
||||||
"Billboard",
|
|
||||||
1.1,
|
|
||||||
2,
|
|
||||||
_position,
|
|
||||||
_direction,
|
|
||||||
1,
|
|
||||||
1.2,
|
|
||||||
1.0,
|
|
||||||
0.1,
|
|
||||||
[0.1,0.15],
|
|
||||||
[[0.06,0.06,0.06,0.32*_scaledTemperature], [0.3,0.3,0.3,0.28*_scaledTemperature], [0.3,0.3,0.3,0.25*_scaledTemperature], [0.3,0.3,0.3,0.22*_scaledTemperature], [0.3,0.3,0.3,0.1*_scaledTemperature]],
|
|
||||||
[1,0],
|
|
||||||
0.1,
|
|
||||||
0.05,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
""
|
|
||||||
];
|
|
||||||
|
|
||||||
_intensity = (_scaledTemperature - 0.5) * 2;
|
|
||||||
if (_intensity > 0) then {
|
|
||||||
drop [
|
drop [
|
||||||
["\A3\data_f\ParticleEffects\Universal\Universal", 16, 12, 1, 16],
|
"\A3\data_f\ParticleEffects\Universal\Refract",
|
||||||
"",
|
"",
|
||||||
"Billboard",
|
"Billboard",
|
||||||
1,
|
1.1,
|
||||||
1.2,
|
2,
|
||||||
_position,
|
_position,
|
||||||
[0,0,0.25],
|
_direction,
|
||||||
0,
|
1,
|
||||||
1.275,
|
1.2,
|
||||||
1,
|
1.0,
|
||||||
0.025,
|
0.1,
|
||||||
[0.28,0.33,0.37],
|
[0.1,0.15],
|
||||||
[[0.6,0.6,0.6,0.3*_intensity]],
|
[[0.06,0.06,0.06,0.32*_scaledTemperature], [0.3,0.3,0.3,0.28*_scaledTemperature], [0.3,0.3,0.3,0.25*_scaledTemperature], [0.3,0.3,0.3,0.22*_scaledTemperature], [0.3,0.3,0.3,0.1*_scaledTemperature]],
|
||||||
[0.2],
|
[1,0],
|
||||||
1,
|
0.1,
|
||||||
0.04,
|
0.05,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
""
|
""
|
||||||
];
|
];
|
||||||
};
|
|
||||||
|
_intensity = (_scaledTemperature - 0.5) * 2;
|
||||||
|
if (_intensity > 0) then {
|
||||||
|
drop [
|
||||||
|
["\A3\data_f\ParticleEffects\Universal\Universal", 16, 12, 1, 16],
|
||||||
|
"",
|
||||||
|
"Billboard",
|
||||||
|
1,
|
||||||
|
1.2,
|
||||||
|
_position,
|
||||||
|
[0,0,0.25],
|
||||||
|
0,
|
||||||
|
1.275,
|
||||||
|
1,
|
||||||
|
0.025,
|
||||||
|
[0.28,0.33,0.37],
|
||||||
|
[[0.6,0.6,0.6,0.3*_intensity]],
|
||||||
|
[0.2],
|
||||||
|
1,
|
||||||
|
0.04,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
""
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Dispersion and bullet slow down
|
// Dispersion and bullet slow down
|
||||||
private ["_dispersion", "_slowdownFactor", "_count"];
|
private ["_dispersion", "_slowdownFactor", "_count"];
|
||||||
|
|
||||||
_dispersion = getArray (configFile >> "CfgWeapons" >> _weapon >> "ACE_Overheating_Dispersion");
|
_dispersion = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_Dispersion");
|
||||||
|
|
||||||
_count = count _dispersion;
|
_dispersion = ([[0*_dispersion,1*_dispersion,2*_dispersion,4*_dispersion], 3 * _scaledTemperature] call EFUNC(common,interpolateFromArray)) max 0;
|
||||||
if (_count > 0) then {
|
|
||||||
_dispersion = ([_dispersion, (_count - 1) * _scaledTemperature] call EFUNC(common,interpolateFromArray)) max 0;
|
|
||||||
} else {
|
|
||||||
_dispersion = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
_slowdownFactor = getArray (configFile >> "CfgWeapons" >> _weapon >> "ACE_Overheating_slowdownFactor");
|
_slowdownFactor = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_SlowdownFactor");
|
||||||
|
|
||||||
_count = count _slowdownFactor;
|
if (_slowdownFactor == 0) then {_slowdownFactor = 1};
|
||||||
if (_count > 0) then {
|
|
||||||
_slowdownFactor = ([_slowdownFactor, (_count - 1) * _scaledTemperature] call EFUNC(common,interpolateFromArray)) max 0;
|
_slowdownFactor = ([[1*_slowdownFactor,1*_slowdownFactor,1*_slowdownFactor,0.9*_slowdownFactor], 3 * _scaledTemperature] call EFUNC(common,interpolateFromArray)) max 0;
|
||||||
} else {
|
|
||||||
_slowdownFactor = 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Exit if GVAR(pseudoRandomList) isn't synced yet
|
// Exit if GVAR(pseudoRandomList) isn't synced yet
|
||||||
@ -130,34 +127,26 @@ _pseudoRandomPair = GVAR(pseudoRandomList) select ((_unit ammo _weapon) mod coun
|
|||||||
if (_unit != ACE_player) exitWith {};
|
if (_unit != ACE_player) exitWith {};
|
||||||
|
|
||||||
private "_jamChance";
|
private "_jamChance";
|
||||||
_jamChance = getArray (configFile >> "CfgWeapons" >> _weapon >> "ACE_Overheating_jamChance");
|
_jamChance = 1 / getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_MRBS"); // arma handles division by 0
|
||||||
|
|
||||||
_count = count _jamChance;
|
_jamChance = [[0.5*_jamChance,1.5*_jamChance,7.5*_jamChance,37.5*_jamChance], 3 * _scaledTemperature] call EFUNC(common,interpolateFromArray);
|
||||||
if (_count == 0) then {
|
|
||||||
_jamChance = [0];
|
|
||||||
_count = 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
_jamChance = [_jamChance, (_count - 1) * _scaledTemperature] call EFUNC(common,interpolateFromArray);
|
|
||||||
|
|
||||||
// increase jam chance on dusty grounds if prone
|
// increase jam chance on dusty grounds if prone
|
||||||
if (stance _unit == "PRONE") then {
|
if (stance _unit == "PRONE") then {
|
||||||
private "_surface";
|
private "_surface";
|
||||||
_surface = toArray (surfaceType getPosASL _unit);
|
_surface = toArray (surfaceType getPosASL _unit);
|
||||||
_surface deleteAt 0;
|
_surface deleteAt 0;
|
||||||
|
|
||||||
_surface = configFile >> "CfgSurfaces" >> toString _surface;
|
_surface = configFile >> "CfgSurfaces" >> toString _surface;
|
||||||
if (isClass _surface) then {
|
if (isClass _surface) then {
|
||||||
_jamChance = _jamChance + (getNumber (_surface >> "dust")) * _jamChance;
|
_jamChance = _jamChance + (getNumber (_surface >> "dust")) * _jamChance;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
if ("Jam" in (missionNamespace getvariable ["ACE_Debug", []])) then {
|
//_jamChance = 0.5;
|
||||||
_jamChance = 0.5;
|
|
||||||
};
|
|
||||||
|
|
||||||
["Overheating", [_temperature, _jamChance], {format ["Temperature: %1 - JamChance: %2", _this select 0, _this select 1]}] call EFUNC(common,log);
|
systemChat format ["Temperature: %1 - JamChance: %2", _scaledTemperature, _jamChance];
|
||||||
|
|
||||||
if (random 1 < _jamChance) then {
|
if (random 1 < _jamChance) then {
|
||||||
[_unit, _weapon] call FUNC(jamWeapon);
|
[_unit, _weapon] call FUNC(jamWeapon);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user