Captives - Blindfold captive units (#9361)

* Fixed typo

* Added "Blindfold Captive" interaction

* Changed comment readability as requested

* Better handling of captive goggle replacement

if the capturer's inventory cannot contain the captive's goggles, move them to the captive's inventory, if that also can't fit them, drop them on the ground.

* Removed extra new line

* Make "validBlindfolds" a CBA Setting

* Add remaining localizations

I speak German and Italian fluently and can also infer the proper sentence structure and conjugations in French/Spanish/Portuguese, the other eastern languages are completely foreign to me though and I have to trust Google/DeepL.

* Removed non-verified translations

* Use GVAR(blindfold) config entry

* Remove unused "_state" parameter

* Check if captive isn't already blindfolded before blindfolding

Co-Authored-By: johnb432 <58661205+johnb432@users.noreply.github.com>

* Added "remove blindfold" interaction

Co-Authored-By: johnb432 <58661205+johnb432@users.noreply.github.com>

* Correct Error Message

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Optimized duplicate code

* Apply suggestion to fix script_component includes

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

---------

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
This commit is contained in:
Fabio Schick 2023-09-24 23:45:43 +02:00 committed by GitHub
parent aee47c9bc6
commit 11bc2695f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 179 additions and 4 deletions

View File

@ -0,0 +1,6 @@
class CfgGlasses {
class None;
class G_Blindfold_01_base_F: None {
GVAR(blindfold) = 1;
};
};

View File

@ -57,6 +57,22 @@ class CfgVehicles {
statement = QUOTE([ARR_2(_player, _target)] call FUNC(doUnloadCaptive));
exceptions[] = {"isNotSwimming"};
};
class GVAR(BlindfoldCaptive) {
displayName = CSTRING(BlindfoldCaptive);
distance = 4;
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canBlindfoldCaptive));
statement = QUOTE([ARR_3(_player, _target, true)] call FUNC(doBlindfoldCaptive));
exceptions[] = {"isNotSwimming"};
showDisabled = 0;
};
class GVAR(RemoveBlindfoldCaptive) {
displayName = CSTRING(RemoveBlindfoldCaptive);
distance = 4;
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canRemoveBlindfoldCaptive));
statement = QUOTE([ARR_3(_player, _target, false)] call FUNC(doBlindfoldCaptive));
exceptions[] = {"isNotSwimming"};
showDisabled = 0;
};
};
};

View File

@ -1,12 +1,15 @@
PREP(addLoadCaptiveActions);
PREP(canApplyHandcuffs);
PREP(canBlindfoldCaptive);
PREP(canEscortCaptive);
PREP(canLoadCaptive);
PREP(canRemoveBlindfoldCaptive);
PREP(canRemoveHandcuffs);
PREP(canStopEscorting);
PREP(canSurrender);
PREP(canUnloadCaptive);
PREP(doApplyHandcuffs);
PREP(doBlindfoldCaptive);
PREP(doEscortCaptive);
PREP(doLoadCaptive);
PREP(doRemoveHandcuffs);

View File

@ -9,6 +9,7 @@ PREP_RECOMPILE_END;
GVAR(captivityEnabled) = false;
GVAR(restraints) = call (uiNamespace getVariable QGVAR(restraints));
GVAR(blindfolds) = keys (uiNamespace getVariable QGVAR(blindfolds));
#include "initSettings.sqf"

View File

@ -4,3 +4,6 @@
private _restraints = (QUOTE(getNumber (_x >> QQGVAR(restraint)) > 0) configClasses (configFile >> "CfgWeapons") apply {configName _x});
uiNamespace setVariable [QGVAR(restraints), compileFinal str _restraints];
private _blindfolds = (QUOTE(getNumber (_x >> QQGVAR(blindfold)) > 0) configClasses (configFile >> "CfgGlasses") apply {configName _x});
uiNamespace setVariable [QGVAR(blindfolds), compileFinal (_blindfolds createHashMapFromArray [])];

View File

@ -16,6 +16,7 @@ class CfgPatches {
#include "ACE_Settings.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgGlasses.hpp"
#include "CfgMoves.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"

View File

@ -0,0 +1,28 @@
#include "..\script_component.hpp"
/*
* Author: mrschick
* Checks if caller can blindfold the captive.
*
* Arguments:
* 0: Caller (player) <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* Can blindfold <BOOL>
*
* Example:
* [player, cursorTarget] call ace_captives_fnc_canBlindfoldCaptive
*
* Public: No
*/
params ["_unit", "_target"];
// Alive, handcuffed, not being escorted, caller has a blindfold in their inventory and target isn't already wearing a blindfold
(_target getVariable [QGVAR(isHandcuffed), false]) &&
{isNull (attachedTo _target)} &&
{alive _target} &&
{isNull objectParent _unit} &&
{isNull objectParent _target} &&
{(GVAR(blindfolds) findAny (_unit call EFUNC(common,uniqueItems))) != -1} &&
{!((goggles _target) in GVAR(blindfolds))}

View File

@ -4,11 +4,11 @@
* Tests if can escort target (attach)
*
* Arguments:
* 0: caller (player) <OBJECT>
* 1: target <OBJECT>
* 0: Caller (player) <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* The return value <BOOL>
* Can escort <BOOL>
*
* Example:
* [player, bob] call ACE_captives_fnc_canEscortCaptive
@ -17,7 +17,7 @@
*/
params ["_unit", "_target"];
//Alive, handcuffed, not being escored, and not unconscious
// Alive, handcuffed, not being escorted, and not unconscious
(_target getVariable [QGVAR(isHandcuffed), false]) &&
{isNull (attachedTo _target)} &&

View File

@ -0,0 +1,27 @@
#include "..\script_component.hpp"
/*
* Author: johnb43
* Checks if caller can remove blindfold from the captive.
*
* Arguments:
* 0: Caller (player) <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* Can remove blindfold <BOOL>
*
* Example:
* [player, cursorTarget] call ace_captives_fnc_canRemoveBlindfoldCaptive
*
* Public: No
*/
params ["_unit", "_target"];
// Alive, handcuffed, not being escorted, and target is wearing a blindfold
(_target getVariable [QGVAR(isHandcuffed), false]) &&
{isNull (attachedTo _target)} &&
{alive _target} &&
{isNull objectParent _unit} &&
{isNull objectParent _target} &&
{(goggles _target) in GVAR(blindfolds)}

View File

@ -0,0 +1,77 @@
#include "..\script_component.hpp"
/*
* Author: mrschick, johnb43
* Puts a blindfold on a captive unit if the player has a blindfold in their inventory.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Target <OBJECT>
* 2: Put on (true) or take off (false) <BOOL>
*
* Return Value:
* None
*
* Example:
* [player, cursorTarget, true] call ace_captives_fnc_doBlindfoldCaptive
*
* Public: No
*/
params ["_unit", "_target", "_state"];
private _dropGoggles = false;
private _previousGoggles = "";
if (_state) then { // Blindfold target
// Check if _unit has a blindfold in its inventory, abort otherwise.
private _carriedBlindfoldIdx = GVAR(blindfolds) findAny (_unit call EFUNC(common,uniqueItems));
if (_carriedBlindfoldIdx == -1) exitWith { ERROR("no blindfold"); };
private _blindfold = GVAR(blindfolds) select _carriedBlindfoldIdx;
_unit removeItem _blindfold;
// Remove target's goggles if it is wearing any and move them to unit's or target's inventory (if they can hold them)
_previousGoggles = goggles _target;
if (_previousGoggles != "") then {
if ([_unit, _previousGoggles] call CBA_fnc_canAddItem) exitWith {
removeGoggles _target;
_unit addItem _previousGoggles;
};
if ([_target, _previousGoggles] call CBA_fnc_canAddItem) exitWith {
removeGoggles _target;
_target addItem _previousGoggles;
};
// If the target's goggles can fit in neither unit's nor target's inventory, drop them on the ground
_dropGoggles = true;
};
_target addGoggles _blindfold;
} else { // Remove blindfold from target
_previousGoggles = goggles _target;
// Abort if already not wearing a blindfold
if !(_previousGoggles in GVAR(blindfolds)) exitWith { ERROR("no blindfold"); };
if ([_unit, _previousGoggles] call CBA_fnc_canAddItem) exitWith {
removeGoggles _target;
_unit addItem _previousGoggles;
};
if ([_target, _previousGoggles] call CBA_fnc_canAddItem) exitWith {
removeGoggles _target;
_target addItem _previousGoggles;
};
// If the target's blindfold can fit in neither unit's nor target's inventory, drop it on the ground
_dropGoggles = true;
removeGoggles _target;
};
// Handle for things that need to be dropped to the ground
if (_dropGoggles) then {
private _weaponHolder = nearestObject [_target, "WeaponHolder"];
if (isNull _weaponHolder || {_target distance _weaponHolder > 2}) then {
_weaponHolder = createVehicle ["GroundWeaponHolder", [0, 0, 0], [], 0, "NONE"];
_weaponHolder setPosASL getPosASL _target;
};
_weaponHolder addItemCargoGlobal [_previousGoggles, 1];
};

View File

@ -136,6 +136,19 @@
<Chinesesimp>将俘虏带出载具</Chinesesimp>
<Turkish>Tutukluyu indir</Turkish>
</Key>
<Key ID="STR_ACE_Captives_BlindfoldCaptive">
<English>Blindfold Captive</English>
<German>Augen verbinden</German>
<French>Bandeau sur les yeux du captif</French>
<Portuguese>Vendar prisioneiro</Portuguese>
<Italian>Benda gli occhi</Italian>
</Key>
<Key ID="STR_ACE_Captives_RemoveBlindfoldCaptive">
<English>Remove blindfold</English>
<German>Augenbinde entfernen</German>
<French>Enlever bandeau sur les yeux</French>
<Italian>Rimuovi la benda per gli occhi</Italian>
</Key>
<Key ID="STR_ACE_Captives_CableTie">
<English>Cable Tie</English>
<German>Kabelbinder</German>