From 08dff7659394da38625489e52ba668c6ad315f77 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Tue, 26 Oct 2021 14:09:45 +0200 Subject: [PATCH] Fire - Add drop weapon setting (#8578) * Fix casing of stringtable keys * Use CBA_fnc_addSetting * Move burn reactions to function, add setting for weapon throwing * Fix stringtable keys in settings * Use stringtable entries from common component * Update addons/fire/stringtable.xml Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com> * Update addons/fire/stringtable.xml Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com> Co-authored-by: mharis001 <34453221+mharis001@users.noreply.github.com> --- addons/common/stringtable.xml | 4 ++ addons/fire/XEH_PREP.hpp | 1 + addons/fire/functions/fnc_burn.sqf | 68 ++++++++++------------ addons/fire/functions/fnc_burnReaction.sqf | 27 +++++++++ addons/fire/initSettings.sqf | 24 ++++++-- addons/fire/stringtable.xml | 16 +++-- 6 files changed, 93 insertions(+), 47 deletions(-) create mode 100644 addons/fire/functions/fnc_burnReaction.sqf diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index d9a0cb21bb..a781243f52 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -1440,6 +1440,10 @@ 只限玩家 Sadece oyuncular + + AI only + Tylko dla AI + Players and AI Игроков и ботов diff --git a/addons/fire/XEH_PREP.hpp b/addons/fire/XEH_PREP.hpp index 511c9c0bb6..d9eacfdee0 100644 --- a/addons/fire/XEH_PREP.hpp +++ b/addons/fire/XEH_PREP.hpp @@ -2,6 +2,7 @@ PREP(burn); PREP(isBurning); PREP(isPlant); PREP(burnIndicator); +PREP(burnReaction); PREP(fireManagerPFH); PREP(medical_progress); diff --git a/addons/fire/functions/fnc_burn.sqf b/addons/fire/functions/fnc_burn.sqf index e520880966..98f87fbcf9 100644 --- a/addons/fire/functions/fnc_burn.sqf +++ b/addons/fire/functions/fnc_burn.sqf @@ -37,13 +37,13 @@ if (_isBurning) exitWith {}; // looped function (_this getVariable "params") params ["_unit", "", "_instigator"]; private _unitPos = getPosASL _unit; - + _intensity = _unit getVariable [QGVAR(intensity), 0]; - + if (surfaceIsWater _unitPos && {(_unitPos#2) < 1}) then { _intensity = 0; }; - + _fireParticle setDropInterval (0.01 max linearConversion [MAX_INTENSITY, MIN_INTENSITY, _intensity, 0.03, 0.1, false]); _fireParticle setParticleParams [ ["\A3\data_f\ParticleEffects\Universal\Universal", 16, 10, 32], // sprite sheet values @@ -86,7 +86,7 @@ if (_isBurning) exitWith {}; 0, // random direction period 0 // random direction intensity ]; - + _smokeParticle setParticleCircle [0, [0, 0, 0]]; _smokeParticle setParticleRandom [ 0, // life time @@ -124,18 +124,18 @@ if (_isBurning) exitWith {}; _unit // particle source ]; _smokeParticle setDropInterval 0.15; - + _fireLight setLightBrightness ((_intensity * 3) / 10); _lightFlare setLightBrightness (_intensity / 30); - + private _distanceToUnit = (_unit distance ace_player); _fireLight setLightAttenuation [1, 10 max (5 min (10 - _intensity)), 0, 15]; _lightFlare setLightFlareSize (_intensity * (3 / 4)) * FLARE_SIZE_MODIFIER; - + if (!GVAR(enableFlare)) then { _lightFlare setLightFlareSize 0; }; - + // always keep flare visible to perceiving unit as long as it isnt the player if !(_unit isEqualTo ace_player) then { private _relativeAttachPoint = [0, 0, 0.3]; @@ -145,14 +145,14 @@ if (_isBurning) exitWith {}; }; _lightFlare attachTo [_unit, _relativeAttachPoint]; }; - + if (!isGamePaused) then { // If the unit goes to spectator alive _unit == true and they will be on fire and still take damage // Only workaround I could think of, kinda clunky if (_isThisUnitAlive) then { _isThisUnitAlive = (alive _unit) && { getNumber ((configOf _unit) >> "isPlayableLogic") != 1 }; }; - + // propagate fire if ((CBA_missionTime - _lastPropogateUpdate) >= BURN_PROPOGATE_UPDATE) then { _lastPropogateUpdate = CBA_missionTime; @@ -178,7 +178,7 @@ if (_isBurning) exitWith {}; }; }; }; - + // update intensity/fire reactions if ((CBA_missionTime - _lastIntensityUpdate) >= INTENSITY_UPDATE) then { _lastIntensityUpdate = CBA_missionTime; @@ -203,7 +203,7 @@ if (_isBurning) exitWith {}; } else { private _group = (group _unit); private _vehicle = vehicle _unit; - + if (_vehicle != _unit) then { TRACE_1("Ejecting", _unit); _unit leaveVehicle _vehicle; @@ -227,16 +227,10 @@ if (_isBurning) exitWith {}; _intensity = _intensity - (1 / _intensity); }; }; - - if ((_unit isEqualTo vehicle _unit) && { !(currentWeapon _unit isEqualTo "") }) then { - [_unit] call EFUNC(hitreactions,throwWeapon); - }; - - private _soundID = floor (1 + random 15); - private _sound = format [QGVAR(scream_%1), _soundID]; - [QGVAR(playScream), [_sound, _unit]] call CBA_fnc_globalEvent; + + [_unit] call FUNC(burnReaction); }; - + // Common burn areas are the hands and face https://www.ncbi.nlm.nih.gov/pubmed/16899341/ private _woundSelection = ["Head", "Body", "LeftArm", "RightArm", "LeftLeg", "RightLeg"] selectRandomWeighted [0.77, 0.5, 0.8, 0.8, 0.3, 0.3]; if (GET_PAIN_PERCEIVED(_unit) < (PAIN_UNCONSCIOUS + random 0.2)) then { @@ -249,7 +243,7 @@ if (_isBurning) exitWith {}; _unit setVariable [QGVAR(intensity), _intensity, true]; // globally sync intensity across all clients to make sure simulation is deterministic }; }; - + private _burnIndicatorPFH = _unit getVariable [QGVAR(burnUIPFH), -1]; if (_unit isEqualTo ace_player && { _isThisUnitAlive } && { _burnIndicatorPFH < 0 }) then { _burnIndicatorPFH = [FUNC(burnIndicator), 1, _unit] call CBA_fnc_addPerFrameHandler; @@ -261,30 +255,30 @@ if (_isBurning) exitWith {}; // init function private _params = _this getVariable "params"; _params params ["_unit", "_startingIntensity"]; - + _intensity = _startingIntensity; private _unitPos = getPos _unit; - + _fireParticle = "#particlesource" createVehicleLocal _unitPos; _fireParticle attachTo [_unit, [0, 0, 0]]; _fireParticle setDropInterval 0.03; - + _smokeParticle = "#particlesource" createVehicleLocal _unitPos; - + _fireLight = "#lightpoint" createVehicleLocal _unitPos; _fireLight setLightIntensity 0; _fireLight setLightAmbient [0.8, 0.6, 0.2]; _fireLight setLightColor [1, 0.5, 0.4]; _fireLight attachTo [_unit, [0, 0, 0]]; _fireLight setLightDayLight false; - + _lightFlare = "#lightpoint" createVehicleLocal _unitPos; _lightFlare setLightIntensity 0; _lightFlare setLightColor [1, 0.8, 0.8]; _lightFlare setLightUseFlare true; _lightFlare setLightFlareMaxDistance 100; _lightFlare setLightFlareSize 0; - + if !(_unit isEqualTo ace_player) then { private _relativeAttachPoint = (vectorNormalized (_unit worldToModelVisual (getPos ace_player))) vectorMultiply 1; _relativeAttachPoint set [2, 0.5]; @@ -292,30 +286,30 @@ if (_isBurning) exitWith {}; } else { _lightFlare attachTo [_unit, [0, 0, 0.3]]; }; - + if (isServer) then { _fireSound = createSoundSource ["Sound_Fire", _unitPos, [], 0]; _fireSound attachTo [_unit, [0, 0, 0], "destructionEffect1"]; }; - + _unit setVariable [QGVAR(burning), true]; _unit setVariable [QGVAR(intensity), _intensity]; _unit setVariable [QGVAR(burnUIPFH), -1]; - + if (local _unit) then { if (_unit isEqualTo ace_player) then { private _burnIndicatorPFH = [FUNC(burnIndicator), 1, _unit] call CBA_fnc_addPerFrameHandler; _unit setVariable [QGVAR(burnUIPFH), _burnIndicatorPFH]; }; - + private _soundID = floor (1 + random 15); private _sound = format [QGVAR(scream_%1), _soundID]; [QGVAR(playScream), [_sound, _unit]] call CBA_fnc_globalEvent; }; - + _lastIntensityUpdate = 0; _lastPropogateUpdate = 0; - + _isThisUnitAlive = true; }, { (_this getVariable "params") params ["_unit"]; @@ -326,7 +320,7 @@ if (_isBurning) exitWith {}; deleteVehicle _fireLight; deleteVehicle _lightFlare; deleteVehicle _fireSound; - + if (local _unit) then { if (!isPlayer _unit) then { _unit setUnitPos "AUTO"; @@ -340,9 +334,9 @@ if (_isBurning) exitWith {}; }, { // exit condition (_this getVariable "params") params ["_unit"]; - + private _unitAlive = (alive _unit) && { getNumber ((configOf _unit) >> "isPlayableLogic") != 1 }; private _unitIsUnit = { (_unit != vehicle _unit) && { isNull vehicle _unit } }; - + !_unitAlive || _unitIsUnit || { _intensity <= MIN_INTENSITY } || { !([_unit] call FUNC(isBurning)) } }, ["_intensity", "_fireParticle", "_smokeParticle", "_fireLight", "_fireSound", "_lightFlare", "_lastIntensityUpdate", "_lastPropogateUpdate", "_isThisUnitAlive"]] call CBA_fnc_createPerFrameHandlerObject; diff --git a/addons/fire/functions/fnc_burnReaction.sqf b/addons/fire/functions/fnc_burnReaction.sqf new file mode 100644 index 0000000000..3d21c091b9 --- /dev/null +++ b/addons/fire/functions/fnc_burnReaction.sqf @@ -0,0 +1,27 @@ +#include "script_component.hpp" +/* + * Author: Brandon (TCVM), veteran29 + * Handles burning reactions of an unit, like screaming or throwing the weapons away due to pain. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Public: No + */ + +params ["_unit"]; + +if ( + GVAR(dropWeapon) > 0 + && {_unit in _unit && { !(currentWeapon _unit isEqualTo "") }} + && {!isPlayer _unit || GVAR(dropWeapon >= 2)} +) then { + [_unit] call EFUNC(hitreactions,throwWeapon); +}; + +private _soundID = floor (1 + random 15); +private _sound = format [QGVAR(scream_%1), _soundID]; +[QGVAR(playScream), [_sound, _unit]] call CBA_fnc_globalEvent; diff --git a/addons/fire/initSettings.sqf b/addons/fire/initSettings.sqf index 6919c35f10..c6855e9ae8 100644 --- a/addons/fire/initSettings.sqf +++ b/addons/fire/initSettings.sqf @@ -1,19 +1,31 @@ [ QGVAR(enabled), "CHECKBOX", - ["STR_A3_OPTIONS_ENABLED", LSTRING(setting_description)], - LSTRING(category_displayName), + ["STR_A3_OPTIONS_ENABLED", LSTRING(Setting_Description)], + LSTRING(Category_DisplayName), true, // default value true, // isGlobal {[QGVAR(fireEnabled), _this] call EFUNC(common,cbaSettings_settingChanged)}, true // Needs mission restart -] call CBA_settings_fnc_init; +] call CBA_fnc_addSetting; [ QGVAR(enableFlare), "CHECKBOX", - [LSTRING(setting_flareEnable), LSTRING(setting_flareDescription)], - LSTRING(category_displayName), + [LSTRING(Setting_FlareEnable), LSTRING(Setting_FlareDescription)], + LSTRING(Category_DisplayName), false, // default value true, // isGlobal {[QGVAR(flareEnabled), _this] call EFUNC(common,cbaSettings_settingChanged)}, true // Needs mission restart -] call CBA_settings_fnc_init; +] call CBA_fnc_addSetting; + +[ + QGVAR(dropWeapon), "LIST", + [LSTRING(Setting_DropWeapon), LSTRING(Setting_DropWeapon_Description)], + LSTRING(Category_DisplayName), + [ + [0,1,2], + [localize "STR_A3_OPTIONS_DISABLED", ELSTRING(common,aiOnly), ELSTRING(common,playersAndAI)], + 1 + ], + true // isGlobal +] call CBA_fnc_addSetting; diff --git a/addons/fire/stringtable.xml b/addons/fire/stringtable.xml index 53c02671b7..6693ca4f80 100644 --- a/addons/fire/stringtable.xml +++ b/addons/fire/stringtable.xml @@ -1,7 +1,7 @@ - + ACE Fire ACE 火災 ACE Feu @@ -22,26 +22,34 @@ Тушение Gaszenie ognia - + Allow units to catch fire ユニットへ着火を許可 Définit si les unités peuvent prendre feu ou non. Включает возгорание Zezwól jednostkom na zapalenie się - + Enable fire-flare at night 夜間にフレア効果を有効化 Halo lumineux la nuit Включает сверкание пламени Włącza efekt flary od ognia w nocy - + Uses a flare effect to increase fire intensity at night 夜間に火災の強さを上昇させるフレア効果を有効化します。 Ajoute un effet de halo lumineux afin d'accroitre l'intensité du feu durant la nuit. Включает ореол пламени для большей интенсивности ночью Używa efektu flary, aby zwiększyć jasność w nocy + + Drop Weapons When on Fire + Włącz wyrzucanie broni podczas płonięcia + + + Controls whether units drop their weapons when on fire. + Powoduje że jednostki wyrzucają swoją broń gdy płoną. +