Skip to content

Commit

Permalink
Captives - Module to set handcuffing
Browse files Browse the repository at this point in the history
also add player check for GVAR(requireSurrender) in canApplyHandcuffes
  • Loading branch information
PabstMirror committed Oct 23, 2015
1 parent ef681e4 commit 1c26f6c
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 19 deletions.
22 changes: 19 additions & 3 deletions addons/captives/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,32 @@ class CfgVehicles {
class GVAR(ModuleSurrender): Module_F {
author = ECSTRING(common,ACETeam);
category = "ACE";
displayName = CSTRING(ModuleSurrender_DisplayName); //Make Unit Surrender
displayName = CSTRING(ModuleSurrender_DisplayName);
function = QFUNC(moduleSurrender);
scope = 2; //show in editor
isGlobal = 1; //run global
isGlobal = 0; //run on server
isTriggerActivated = 1; //Wait for triggers
icon = QUOTE(PATHTOF(UI\Icon_Module_Make_Unit_Surrender_ca.paa));
functionPriority = 0;
class Arguments {};
class ModuleDescription: ModuleDescription {
description = CSTRING(ModuleSurrender_Description); //Sync a unit to make them surrender.<br/>Source: ace_captives
description = CSTRING(ModuleSurrender_Description);
sync[] = {"AnyAI"};
};
};
class GVAR(ModuleHandcuffed): Module_F {
author = ECSTRING(common,ACETeam);
category = "ACE";
displayName = CSTRING(ModuleHandcuffed_DisplayName);
function = QFUNC(moduleHandcuffed);
scope = 2; //show in editor
isGlobal = 0; //run on server
isTriggerActivated = 1; //Wait for triggers
icon = QUOTE(PATHTOF(UI\Icon_Module_Make_Unit_Handcuffed_ca.paa));
functionPriority = 0;
class Arguments {};
class ModuleDescription: ModuleDescription {
description = CSTRING(ModuleHandcuffed_Description);
sync[] = {"AnyAI"};
};
};
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions addons/captives/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ PREP(handlePlayerChanged);
PREP(handleRespawn);
PREP(handleUnitInitPost);
PREP(handleZeusDisplayChanged);
PREP(moduleHandcuffed);
PREP(moduleSettings);
PREP(moduleSurrender);
PREP(setHandcuffed);
Expand Down
2 changes: 1 addition & 1 deletion addons/captives/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class CfgPatches {
class ADDON {
units[] = {QGVAR(ModuleSettings), QGVAR(ModuleSurrender)};
units[] = {QGVAR(ModuleSettings), QGVAR(ModuleSurrender), QGVAR(ModuleHandcuffed)};
weapons[] = {"ACE_CableTie"};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ACE_Interaction"};
Expand Down
3 changes: 2 additions & 1 deletion addons/captives/functions/fnc_canApplyHandcuffs.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ params ["_unit", "_target"];
//Check sides, Player has cableTie, target is alive and not already handcuffed

(GVAR(allowHandcuffOwnSide) || {(side _unit) != (side _target)}) &&
("ACE_CableTie" in (items _unit)) &&
{"ACE_CableTie" in (items _unit)} &&
{alive _target} &&
{!(_target getVariable [QGVAR(isHandcuffed), false])} &&
{
(_target getVariable ["ACE_isUnconscious", false]) || //isUnconscious
{!([_target] call EFUNC(common,isPlayer))} || //is an AI (not a player)
{GVAR(requireSurrender) == 0} || //or don't require surrendering
{_target getVariable [QGVAR(isSurrendering), false]} || //or is surrendering
{(GVAR(requireSurrender) == 2) && {(currentWeapon _target) == ""}} //or "SurrenderOrNoWeapon" and no weapon
Expand Down
35 changes: 35 additions & 0 deletions addons/captives/functions/fnc_moduleHandcuffed.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Author: PabstMirror
* Module Function to make a unit handcuffed (can be called from editor)
*
* Arguments:
* 0: The Module Logic <OBJECT>
* 1: synced objects <ARRAY>
* 2: Activated <BOOL>
*
* Return Value:
* Nothing
*
* Example:
* Called from module
*
* Public: No
*/
#include "script_component.hpp"

params ["_logic", "_units", "_activated"];

TRACE_3("params",_logic,_units,_activated);

if (!_activated) exitWith {};
if (!isServer) exitWith {};

//Modules run before postInit can instal the event handler, so we need to wait a little bit
[{
params ["_units"];
{
["SetHandcuffed", [_x], [_x, true]] call EFUNC(common,targetEvent);
} forEach _units;
}, [_units], 0.05] call EFUNC(common,waitAndExecute);

deleteVehicle _logic;
27 changes: 13 additions & 14 deletions addons/captives/functions/fnc_moduleSurrender.sqf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* Author: PabstMirror
* Module Function to make a unit surrender (can be called from editor, or placed with zeus)
* Module Function to make a unit surrender (can be called from editor)
*
* Arguments:
* 0: The Module Logic Object <OBJECT>
* 0: The Module Logic <OBJECT>
* 1: synced objects <ARRAY>
* 2: Activated <BOOL>
*
Expand All @@ -17,20 +17,19 @@
*/
#include "script_component.hpp"

private ["_bisMouseOver", "_mouseOverObject"];

params ["_logic", "_units", "_activated"];

TRACE_3("params",_logic,_units,_activated);

if (!_activated) exitWith {};
if (!isServer) exitWith {};

if (local _logic) then {
//Modules run before postInit can instal the event handler, so we need to wait a little bit
[{
params ["_units"];
{
["SetSurrendered", [_x], [_x, true]] call EFUNC(common,targetEvent);
} forEach _units;
}, [_units], 0.05]call EFUNC(common,waitAndExecute);
//Modules run before postInit can instal the event handler, so we need to wait a little bit
[{
params ["_units"];
{
["SetSurrendered", [_x], [_x, true]] call EFUNC(common,targetEvent);
} forEach _units;
}, [_units], 0.05] call EFUNC(common,waitAndExecute);

deleteVehicle _logic;
};
deleteVehicle _logic;
6 changes: 6 additions & 0 deletions addons/captives/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@
<Hungarian>Egység szinkronizálása, hogy kapituláljon.&lt;br /&gt;Forrás: ace_captives</Hungarian>
<Russian>Синхронизируйте с юнитами, чтобы сделать их пленными.&lt;br /&gt;Источник: ace_captives</Russian>
</Key>
<Key ID="STR_ACE_Captives_ModuleHandcuffed_DisplayName">
<English>Make Unit Handcuffed</English>
</Key>
<Key ID="STR_ACE_Captives_ModuleHandcuffed_Description">
<English>Sync a unit to make them handcuffed.&lt;br /&gt;Source: ace_captives</English>
</Key>
<Key ID="STR_ACE_Captives_ModuleSettings_DisplayName">
<English>Captives Settings</English>
<Polish>Ustawienia więźniów</Polish>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1c26f6c

Please sign in to comment.