Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Captives - Blindfold captive units #9361

Merged
merged 15 commits into from
Sep 24, 2023
Merged
6 changes: 6 additions & 0 deletions addons/captives/CfgGlasses.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class CfgGlasses {
class None;
class G_Blindfold_01_base_F: None {
GVAR(blindfold) = 1;
};
};
16 changes: 16 additions & 0 deletions addons/captives/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
mrschick marked this conversation as resolved.
Show resolved Hide resolved
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;
};
};
};

Expand Down
3 changes: 3 additions & 0 deletions addons/captives/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
PREP(addLoadCaptiveActions);
PREP(canApplyHandcuffs);
PREP(canBlindfoldCaptive);
PREP(canEscortCaptive);
PREP(canLoadCaptive);
mrschick marked this conversation as resolved.
Show resolved Hide resolved
PREP(canRemoveBlindfoldCaptive);
PREP(canRemoveHandcuffs);
PREP(canStopEscorting);
PREP(canSurrender);
PREP(canUnloadCaptive);
PREP(doApplyHandcuffs);
PREP(doBlindfoldCaptive);
PREP(doEscortCaptive);
PREP(doLoadCaptive);
PREP(doRemoveHandcuffs);
Expand Down
1 change: 1 addition & 0 deletions addons/captives/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 3 additions & 0 deletions addons/captives/XEH_preStart.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 [])];
1 change: 1 addition & 0 deletions addons/captives/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
28 changes: 28 additions & 0 deletions addons/captives/functions/fnc_canBlindfoldCaptive.sqf
Original file line number Diff line number Diff line change
@@ -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))}
8 changes: 4 additions & 4 deletions addons/captives/functions/fnc_canEscortCaptive.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)} &&
Expand Down
27 changes: 27 additions & 0 deletions addons/captives/functions/fnc_canRemoveBlindfoldCaptive.sqf
Original file line number Diff line number Diff line change
@@ -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)}
77 changes: 77 additions & 0 deletions addons/captives/functions/fnc_doBlindfoldCaptive.sqf
Original file line number Diff line number Diff line change
@@ -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"); };
mrschick marked this conversation as resolved.
Show resolved Hide resolved

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;

mrschick marked this conversation as resolved.
Show resolved Hide resolved
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];
};
13 changes: 13 additions & 0 deletions addons/captives/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
mrschick marked this conversation as resolved.
Show resolved Hide resolved
<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>
Expand Down