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>
This commit is contained in:
Filip Maciejewski 2021-10-26 14:09:45 +02:00 committed by GitHub
parent 5468f180f0
commit 08dff76593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 93 additions and 47 deletions

View File

@ -1440,6 +1440,10 @@
<Chinese>只限玩家</Chinese>
<Turkish>Sadece oyuncular</Turkish>
</Key>
<Key ID="STR_ACE_Common_aiOnly">
<English>AI only</English>
<Polish>Tylko dla AI</Polish>
</Key>
<Key ID="STR_ACE_Common_playersAndAI">
<English>Players and AI</English>
<Russian>Игроков и ботов</Russian>

View File

@ -2,6 +2,7 @@ PREP(burn);
PREP(isBurning);
PREP(isPlant);
PREP(burnIndicator);
PREP(burnReaction);
PREP(fireManagerPFH);
PREP(medical_progress);

View File

@ -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;

View File

@ -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 <OBJECT>
*
* 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;

View File

@ -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;

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="Fire">
<Key ID="STR_ACE_Fire_category_displayName">
<Key ID="STR_ACE_Fire_Category_DisplayName">
<English>ACE Fire</English>
<Japanese>ACE 火災</Japanese>
<French>ACE Feu</French>
@ -22,26 +22,34 @@
<Russian>Тушение</Russian>
<Polish>Gaszenie ognia</Polish>
</Key>
<Key ID="STR_ACE_Fire_setting_description">
<Key ID="STR_ACE_Fire_Setting_Description">
<English>Allow units to catch fire</English>
<Japanese>ユニットへ着火を許可</Japanese>
<French>Définit si les unités peuvent prendre feu ou non.</French>
<Russian>Включает возгорание</Russian>
<Polish>Zezwól jednostkom na zapalenie się</Polish>
</Key>
<Key ID="STR_ACE_Fire_setting_flareEnable">
<Key ID="STR_ACE_Fire_Setting_FlareEnable">
<English>Enable fire-flare at night</English>
<Japanese>夜間にフレア効果を有効化</Japanese>
<French>Halo lumineux la nuit</French>
<Russian>Включает сверкание пламени</Russian>
<Polish>Włącza efekt flary od ognia w nocy</Polish>
</Key>
<Key ID="STR_ACE_Fire_setting_flareDescription">
<Key ID="STR_ACE_Fire_Setting_FlareDescription">
<English>Uses a flare effect to increase fire intensity at night</English>
<Japanese>夜間に火災の強さを上昇させるフレア効果を有効化します。</Japanese>
<French>Ajoute un effet de halo lumineux afin d'accroitre l'intensité du feu durant la nuit.</French>
<Russian>Включает ореол пламени для большей интенсивности ночью</Russian>
<Polish>Używa efektu flary, aby zwiększyć jasność w nocy</Polish>
</Key>
<Key ID="STR_ACE_Fire_Setting_DropWeapon">
<English>Drop Weapons When on Fire</English>
<Polish>Włącz wyrzucanie broni podczas płonięcia</Polish>
</Key>
<Key ID="STR_ACE_Fire_Setting_DropWeapon_Description">
<English>Controls whether units drop their weapons when on fire.</English>
<Polish>Powoduje że jednostki wyrzucają swoją broń gdy płoną.</Polish>
</Key>
</Package>
</Project>