Skip to content

Commit

Permalink
Merge pull request #2783 from acemod/captivesStuff
Browse files Browse the repository at this point in the history
Captives Fix duplicate animEH and add handcuffing module
  • Loading branch information
PabstMirror committed Oct 28, 2015
2 parents 2cd2675 + 1c26f6c commit 10d17a8
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 27 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;
11 changes: 6 additions & 5 deletions addons/captives/functions/fnc_setHandcuffed.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ if (_state) then {

//Adds an animation changed eh
//If we get a change in animation then redo the animation (handles people vaulting to break the animation chain)
private "_animChangedEHID";

local _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1];
if (_animChangedEHID != -1) then {
TRACE_1("removing animChanged EH",_animChangedEHID);
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
};
_animChangedEHID = _unit addEventHandler ["AnimChanged", {
params ["_unit", "_newAnimation"];
TRACE_2("AnimChanged",_unit,_newAnimation);
Expand All @@ -67,7 +70,6 @@ if (_state) then {
[_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation);
};
} else {

_turretPath = [];
{
_x params ["_xUnit", "", "", "_xTurretPath"];
Expand All @@ -90,8 +92,7 @@ if (_state) then {
[_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus);

//remove AnimChanged EH
private "_animChangedEHID";
_animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1];
local _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1];
TRACE_1("removing animChanged EH",_animChangedEHID);
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
_unit setVariable [QGVAR(handcuffAnimEHID), -1];
Expand Down
9 changes: 6 additions & 3 deletions addons/captives/functions/fnc_setSurrendered.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ if (_state) then {
if (_unit getVariable [QGVAR(isSurrendering), false] && {(vehicle _unit) == _unit}) then {
//Adds an animation changed eh
//If we get a change in animation then redo the animation (handles people vaulting to break the animation chain)
private "_animChangedEHID";
local _animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1];
if (_animChangedEHID != -1) then {
TRACE_1("removing animChanged EH",_animChangedEHID);
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
};
_animChangedEHID = _unit addEventHandler ["AnimChanged", {
params ["_unit", "_newAnimation"];
if ((_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") && {!(_unit getVariable ["ACE_isUnconscious", false])}) then {
Expand All @@ -64,8 +68,7 @@ if (_state) then {
[_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus);

//remove AnimChanged EH
private "_animChangedEHID";
_animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1];
local _animChangedEHID = _unit getVariable [QGVAR(surrenderAnimEHID), -1];
_unit removeEventHandler ["AnimChanged", _animChangedEHID];
_unit setVariable [QGVAR(surrenderAnimEHID), -1];

Expand Down
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 10d17a8

Please sign in to comment.