diff --git a/addons/captives/CfgGlasses.hpp b/addons/captives/CfgGlasses.hpp new file mode 100644 index 00000000000..5bebfb830ca --- /dev/null +++ b/addons/captives/CfgGlasses.hpp @@ -0,0 +1,6 @@ +class CfgGlasses { + class None; + class G_Blindfold_01_base_F: None { + GVAR(blindfold) = 1; + }; +}; diff --git a/addons/captives/CfgVehicles.hpp b/addons/captives/CfgVehicles.hpp index 8fe05963387..831ee0dff83 100644 --- a/addons/captives/CfgVehicles.hpp +++ b/addons/captives/CfgVehicles.hpp @@ -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; + }; }; }; diff --git a/addons/captives/XEH_PREP.hpp b/addons/captives/XEH_PREP.hpp index 6157a1e33e9..9769fe78554 100644 --- a/addons/captives/XEH_PREP.hpp +++ b/addons/captives/XEH_PREP.hpp @@ -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); diff --git a/addons/captives/XEH_preInit.sqf b/addons/captives/XEH_preInit.sqf index 8ec915e4f2d..d66df57f007 100644 --- a/addons/captives/XEH_preInit.sqf +++ b/addons/captives/XEH_preInit.sqf @@ -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" diff --git a/addons/captives/XEH_preStart.sqf b/addons/captives/XEH_preStart.sqf index 75cbb90ef98..7cc9038599e 100644 --- a/addons/captives/XEH_preStart.sqf +++ b/addons/captives/XEH_preStart.sqf @@ -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 [])]; diff --git a/addons/captives/config.cpp b/addons/captives/config.cpp index 0b8dae014a3..c28a88559d1 100644 --- a/addons/captives/config.cpp +++ b/addons/captives/config.cpp @@ -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" diff --git a/addons/captives/functions/fnc_canBlindfoldCaptive.sqf b/addons/captives/functions/fnc_canBlindfoldCaptive.sqf new file mode 100644 index 00000000000..892ed5b5df2 --- /dev/null +++ b/addons/captives/functions/fnc_canBlindfoldCaptive.sqf @@ -0,0 +1,28 @@ +#include "..\script_component.hpp" +/* + * Author: mrschick + * Checks if caller can blindfold the captive. + * + * Arguments: + * 0: Caller (player) + * 1: Target + * + * Return Value: + * Can blindfold + * + * 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))} diff --git a/addons/captives/functions/fnc_canEscortCaptive.sqf b/addons/captives/functions/fnc_canEscortCaptive.sqf index cb5fdd49729..7ae4fb53c0a 100644 --- a/addons/captives/functions/fnc_canEscortCaptive.sqf +++ b/addons/captives/functions/fnc_canEscortCaptive.sqf @@ -4,11 +4,11 @@ * Tests if can escort target (attach) * * Arguments: - * 0: caller (player) - * 1: target + * 0: Caller (player) + * 1: Target * * Return Value: - * The return value + * Can escort * * 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)} && diff --git a/addons/captives/functions/fnc_canRemoveBlindfoldCaptive.sqf b/addons/captives/functions/fnc_canRemoveBlindfoldCaptive.sqf new file mode 100644 index 00000000000..b509197feaf --- /dev/null +++ b/addons/captives/functions/fnc_canRemoveBlindfoldCaptive.sqf @@ -0,0 +1,27 @@ +#include "..\script_component.hpp" +/* + * Author: johnb43 + * Checks if caller can remove blindfold from the captive. + * + * Arguments: + * 0: Caller (player) + * 1: Target + * + * Return Value: + * Can remove blindfold + * + * 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)} diff --git a/addons/captives/functions/fnc_doBlindfoldCaptive.sqf b/addons/captives/functions/fnc_doBlindfoldCaptive.sqf new file mode 100644 index 00000000000..aff7444909a --- /dev/null +++ b/addons/captives/functions/fnc_doBlindfoldCaptive.sqf @@ -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 + * 1: Target + * 2: Put on (true) or take off (false) + * + * 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]; +}; diff --git a/addons/captives/stringtable.xml b/addons/captives/stringtable.xml index 8c4f85db067..99b0c38ec16 100644 --- a/addons/captives/stringtable.xml +++ b/addons/captives/stringtable.xml @@ -136,6 +136,19 @@ 将俘虏带出载具 Tutukluyu indir + + Blindfold Captive + Augen verbinden + Bandeau sur les yeux du captif + Vendar prisioneiro + Benda gli occhi + + + Remove blindfold + Augenbinde entfernen + Enlever bandeau sur les yeux + Rimuovi la benda per gli occhi + Cable Tie Kabelbinder