From c35fc35eb34b80ae21a7df1dccc625f95948c183 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 14 Aug 2015 21:29:01 -0500 Subject: [PATCH 1/7] Captive FFV stuff --- addons/captives/XEH_postInit.sqf | 3 +- addons/captives/XEH_preInit.sqf | 1 + .../captives/functions/fnc_canLoadCaptive.sqf | 2 +- .../captives/functions/fnc_doFriskPerson.sqf | 1 - .../fnc_findEmptyNonFFVCargoSeat.sqf | 40 +++++++++++++++++++ .../captives/functions/fnc_handleGetOut.sqf | 1 + .../functions/fnc_handleUnitInitPost.sqf | 2 +- .../functions/fnc_moduleSurrender.sqf | 4 +- .../captives/functions/fnc_setHandcuffed.sqf | 39 +++++++++++++----- .../captives/functions/fnc_setSurrendered.sqf | 10 ++--- .../functions/fnc_vehicleCaptiveMoveIn.sqf | 6 ++- .../functions/fnc_vehicleCaptiveMoveOut.sqf | 1 + 12 files changed, 86 insertions(+), 24 deletions(-) create mode 100644 addons/captives/functions/fnc_findEmptyNonFFVCargoSeat.sqf diff --git a/addons/captives/XEH_postInit.sqf b/addons/captives/XEH_postInit.sqf index da2192d3d6..1372b4e10a 100644 --- a/addons/captives/XEH_postInit.sqf +++ b/addons/captives/XEH_postInit.sqf @@ -6,12 +6,11 @@ if (isServer) then { addMissionEventHandler ["HandleDisconnect", { - PARAMS_1(_disconnectedPlayer); + params ["_disconnectedPlayer"]; private "_escortedUnit"; _escortedUnit = _disconnectedPlayer getVariable [QGVAR(escortedUnit), objNull]; if ((!isNull _escortedUnit) && {(attachedTo _escortedUnit) == _disconnectedPlayer}) then { detach _escortedUnit; - //systemChat "debug: DC detach"; }; if (_disconnectedPlayer getVariable [QGVAR(isEscorting), false]) then { _disconnectedPlayer setVariable [QGVAR(isEscorting), false, true]; diff --git a/addons/captives/XEH_preInit.sqf b/addons/captives/XEH_preInit.sqf index 31bcbe8e02..d2b5b615bb 100644 --- a/addons/captives/XEH_preInit.sqf +++ b/addons/captives/XEH_preInit.sqf @@ -16,6 +16,7 @@ PREP(doFriskPerson); PREP(doLoadCaptive); PREP(doRemoveHandcuffs); PREP(doUnloadCaptive); +PREP(findEmptyNonFFVCargoSeat); PREP(handleGetIn); PREP(handleGetOut); PREP(handleKilled); diff --git a/addons/captives/functions/fnc_canLoadCaptive.sqf b/addons/captives/functions/fnc_canLoadCaptive.sqf index 0e028ac1ec..1cdc4d86a1 100644 --- a/addons/captives/functions/fnc_canLoadCaptive.sqf +++ b/addons/captives/functions/fnc_canLoadCaptive.sqf @@ -35,4 +35,4 @@ if (isNull _vehicle) then { && {!isNull _vehicle} && {_unit getVariable [QGVAR(isEscorting), false]} && {_target getVariable [QGVAR(isHandcuffed), false]} -&& {_vehicle emptyPositions "cargo" > 0} +&& {([_vehicle] call FUNC(findEmptyNonFFVCargoSeat)) != -1} diff --git a/addons/captives/functions/fnc_doFriskPerson.sqf b/addons/captives/functions/fnc_doFriskPerson.sqf index e14025b88f..9a8a423dc3 100644 --- a/addons/captives/functions/fnc_doFriskPerson.sqf +++ b/addons/captives/functions/fnc_doFriskPerson.sqf @@ -18,7 +18,6 @@ private ["_weapon", "_listedItemClasses", "_actions", "_allGear"]; -PARAMS_2(_player,_unit); params ["_player", "_unit"]; _weapon = currentWeapon _player; diff --git a/addons/captives/functions/fnc_findEmptyNonFFVCargoSeat.sqf b/addons/captives/functions/fnc_findEmptyNonFFVCargoSeat.sqf new file mode 100644 index 0000000000..a6bd625870 --- /dev/null +++ b/addons/captives/functions/fnc_findEmptyNonFFVCargoSeat.sqf @@ -0,0 +1,40 @@ +#include "script_component.hpp" + +params ["_vehicle"]; + +_vehicleConfig = configFile >> "CfgVehicles" >> (typeOf _vehicle); + +_proxyOrder = getArray (_vehicleConfig >> "getInProxyOrder"); +_transportSoldier = getNumber (_vehicleConfig >> "transportSoldier"); +_realCargoCount = if (isArray (_vehicleConfig >> "getInProxyOrder")) then {count _proxyOrder} else {_transportSoldier}; + +//Find FFV turrets: +_ffvCargoIndexes = []; +{ + _turretConfig = [_vehicleConfig, _x] call EFUNC(common,getTurretConfigPath); + _isCargoProxy = ((getText (_turretConfig >> "proxyType")) == "CPCargo") && {isNumber (_turretConfig >> "proxyIndex")}; + + if (_isCargoProxy) then { + _proxyCargoIndex = getNumber (_turretConfig >> "proxyIndex"); + _cargoIndex = _proxyOrder find _proxyCargoIndex; + _ffvCargoIndexes pushBack _cargoIndex; + }; +} forEach (allTurrets [_vehicle, true]); + +//Find Empty Seats: +_occupiedSeats = []; +{ + _x params ["", "", "_xIndex"]; + if (_xIndex > -1) then {_occupiedSeats pushBack _xIndex;}; +} forEach (fullCrew _vehicle); + +TRACE_3("Searching for empty seat",_realCargoCount,_ffvCargoIndexes,_occupiedSeats); + +_emptyCargoSeatReturn = -1; +for "_index" from 0 to (_realCargoCount - 1) do { + if ((!(_index in _ffvCargoIndexes)) && {!(_index in _occupiedSeats)}) exitWith { + _emptyCargoSeatReturn = _index; + }; +}; + +_emptyCargoSeatReturn diff --git a/addons/captives/functions/fnc_handleGetOut.sqf b/addons/captives/functions/fnc_handleGetOut.sqf index daf88b7e34..756c14ec10 100644 --- a/addons/captives/functions/fnc_handleGetOut.sqf +++ b/addons/captives/functions/fnc_handleGetOut.sqf @@ -30,4 +30,5 @@ if ((local _unit) && {_unit getVariable [QGVAR(isHandcuffed), false]}) then { }; [_unit, "ACE_AmovPercMstpScapWnonDnon", 2] call EFUNC(common,doAnimation); + [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); }; diff --git a/addons/captives/functions/fnc_handleUnitInitPost.sqf b/addons/captives/functions/fnc_handleUnitInitPost.sqf index 66cbcff794..52957acd68 100644 --- a/addons/captives/functions/fnc_handleUnitInitPost.sqf +++ b/addons/captives/functions/fnc_handleUnitInitPost.sqf @@ -18,7 +18,7 @@ params ["_unit"]; // prevent players from throwing grenades (added to all units) -[_unit, "Throw", {((_this select 1) getVariable [QGVAR(isHandcuffed), false]) || {(_this select 1) getVariable [QGVAR(isSurrendering), false]}}, {}] call EFUNC(common,addActionEventhandler); +// [_unit, "Throw", {systemChat "a"; ((_this select 1) getVariable [QGVAR(isHandcuffed), false]) || {(_this select 1) getVariable [QGVAR(isSurrendering), false]}; true}, {systemChat "b";}] call EFUNC(common,addActionEventhandler); if (local _unit) then { // reset status on mission start diff --git a/addons/captives/functions/fnc_moduleSurrender.sqf b/addons/captives/functions/fnc_moduleSurrender.sqf index 64c80af35c..bdb0f7c1b5 100644 --- a/addons/captives/functions/fnc_moduleSurrender.sqf +++ b/addons/captives/functions/fnc_moduleSurrender.sqf @@ -26,11 +26,11 @@ if (!_activated) exitWith {}; if (local _logic) then { //Modules run before postInit can instal the event handler, so we need to wait a little bit [{ - PARAMS_1(_units); + params ["_units"]; { ["SetSurrendered", [_x], [_x, true]] call EFUNC(common,targetEvent); } forEach _units; - }, [_units], 0.05, 0.05]call EFUNC(common,waitAndExecute); + }, [_units], 0.05]call EFUNC(common,waitAndExecute); deleteVehicle _logic; }; diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index 9bde3b399d..413e3d59b5 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -43,24 +43,43 @@ if (_state) then { // fix anim on mission start (should work on dedicated servers) [{ params ["_unit"]; - if (_unit getVariable [QGVAR(isHandcuffed), false] && {vehicle _unit == _unit}) then { + if (!(_unit getVariable [QGVAR(isHandcuffed), false])) exitWith {}; + + if ((vehicle _unit) == _unit) then { [_unit] call EFUNC(common,fixLoweredRifleAnimation); [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); + }; - //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"; - _animChangedEHID = _unit addEventHandler ["AnimChanged", { - PARAMS_2(_unit,_newAnimation); + //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"; + TRACE_1("Adding animChangedEH",_unit); + _animChangedEHID = _unit addEventHandler ["AnimChanged", { + params ["_unit", "_newAnimation"]; + TRACE_2("AnimChanged",_unit,_newAnimation); + if (_unit == (vehicle _unit)) then { if ((_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") && {!(_unit getVariable ["ACE_isUnconscious", false])}) then { TRACE_1("Handcuff animation interrupted",_newAnimation); [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); }; - }]; - _unit setVariable [QGVAR(handcuffAnimEHID), _animChangedEHID]; + } else { + // _turretPath = []; + // { + // _x params ["_xUnit", "", "", "_xTurretPath"]; + // if (_unit == _xUnit) exitWith {_turretPath = _xTurretPath}; + // } forEach (fullCrew (vehicle _unit)); + // TRACE_1("turret Path",_turretPath); + // if (_turretPath isEqualTo []) exitWith {}; + // _turretConfig = [(configFile >> "CfgVehicles" >> (typeOf (vehicle _unit))), _turretPath] call EFUNC(common,getTurretConfigPath); + // _gunnerAction = getText (_turretConfig >> "gunnerAction"); + // TRACE_1("reseting to",_gunnerAction); + // [_unit, "ACE_HandcuffedFFV", 2] call EFUNC(common,doAnimation); + // [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); + }; + }]; + _unit setVariable [QGVAR(handcuffAnimEHID), _animChangedEHID]; - }; - }, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute); + }, [_unit], 0.01] call EFUNC(common,waitAndExecute); } else { _unit setVariable [QGVAR(isHandcuffed), false, true]; [_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus); diff --git a/addons/captives/functions/fnc_setSurrendered.sqf b/addons/captives/functions/fnc_setSurrendered.sqf index 4fad2d3853..22736c8e59 100644 --- a/addons/captives/functions/fnc_setSurrendered.sqf +++ b/addons/captives/functions/fnc_setSurrendered.sqf @@ -43,13 +43,13 @@ if (_state) then { // fix anim on mission start (should work on dedicated servers) [{ - PARAMS_1(_unit); + params ["_unit"]; 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"; _animChangedEHID = _unit addEventHandler ["AnimChanged", { - PARAMS_2(_unit,_newAnimation); + params ["_unit", "_newAnimation"]; if ((_newAnimation != "ACE_AmovPercMstpSsurWnonDnon") && {!(_unit getVariable ["ACE_isUnconscious", false])}) then { TRACE_1("Surrender animation interrupted",_newAnimation); [_unit, "ACE_AmovPercMstpSsurWnonDnon", 1] call EFUNC(common,doAnimation); @@ -57,7 +57,7 @@ if (_state) then { }]; _unit setVariable [QGVAR(surrenderAnimEHID), _animChangedEHID]; }; - }, [_unit], 0.01, 0] call EFUNC(common,waitAndExecute); + }, [_unit], 0.01] call EFUNC(common,waitAndExecute); } else { _unit setVariable [QGVAR(isSurrendering), false, true]; [_unit, QGVAR(Surrendered), false] call EFUNC(common,setCaptivityStatus); @@ -85,8 +85,8 @@ if (_state) then { //spin up a PFEH, to watching animationState for the next 20 seconds to make sure we don't enter "hands up" //Handles long animation chains [{ - PARAMS_2(_args,_pfID); - EXPLODE_2_PVT(_args,_unit,_maxTime); + params ["_args", "_pfID"]; + _args params ["_unit", "_maxTime"]; //If waited long enough or they re-surrendered or they are unconscious, exit loop if ((ACE_time > _maxTime) || {_unit getVariable [QGVAR(isSurrendering), false]} || {_unit getVariable ["ACE_isUnconscious", false]}) exitWith { [_pfID] call CBA_fnc_removePerFrameHandler; diff --git a/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf b/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf index 7e30fe4af4..6e79725242 100644 --- a/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf +++ b/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf @@ -20,7 +20,9 @@ private ["_cargoIndex"]; params ["_target","_vehicle"]; -_target moveInCargo _vehicle; +_cargoIndex = [_vehicle] call FUNC(findEmptyNonFFVCargoSeat); +if (_cargoIndex < 0) exitWith {ERROR("No Seat Avail");}; + +_target moveInCargo [_vehicle, _cargoIndex]; _target assignAsCargo _vehicle; -_cargoIndex = _vehicle getCargoIndex _target; _target setVariable [QGVAR(CargoIndex), _cargoIndex, true]; diff --git a/addons/captives/functions/fnc_vehicleCaptiveMoveOut.sqf b/addons/captives/functions/fnc_vehicleCaptiveMoveOut.sqf index 000d5ef568..db8a7bd12e 100644 --- a/addons/captives/functions/fnc_vehicleCaptiveMoveOut.sqf +++ b/addons/captives/functions/fnc_vehicleCaptiveMoveOut.sqf @@ -20,4 +20,5 @@ _unit setVariable [QGVAR(CargoIndex), -1, true]; moveOut _unit; [_unit, "ACE_AmovPercMstpScapWnonDnon", 2] call EFUNC(common,doAnimation); +[_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); unassignVehicle _unit; From 645e8a63efc42038ba7e11c83645003e1c5dacdb Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 20 Aug 2015 04:20:46 -0500 Subject: [PATCH 2/7] Captive FFV Lock Animation --- addons/captives/CfgMoves.hpp | 13 ++++++ .../captives/functions/fnc_canLoadCaptive.sqf | 33 +++++++++------ .../captives/functions/fnc_doLoadCaptive.sqf | 40 ++++++++++++------- .../captives/functions/fnc_setHandcuffed.sqf | 12 +++++- .../functions/fnc_vehicleCaptiveMoveIn.sqf | 13 ++++-- addons/captives/script_component.hpp | 2 + 6 files changed, 81 insertions(+), 32 deletions(-) diff --git a/addons/captives/CfgMoves.hpp b/addons/captives/CfgMoves.hpp index aa64e85e22..6c0bfc3ce9 100644 --- a/addons/captives/CfgMoves.hpp +++ b/addons/captives/CfgMoves.hpp @@ -18,6 +18,11 @@ class CfgMovesBasic { default = "ACE_AmovPercMstpSsurWnonDnon"; PutDown = ""; }; + class ACE_CivilHandCuffedFFVActions: ACE_CivilStandHandcuffedActions { + stop = "ACE_HandcuffedFFV"; + StopRelaxed = "ACE_HandcuffedFFV"; + default = "ACE_HandcuffedFFV"; + }; }; }; @@ -55,6 +60,14 @@ class CfgMovesMaleSdr: CfgMovesBasic { InterpolateTo[] = {"Unconscious",0.01,"ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpScapWnonDnon",0.1}; }; + //Handcuffed-FFV: + class ACE_HandcuffedFFV: ACE_AmovPercMstpScapWnonDnon { + file = "\A3\cargoposes_F_heli\anim\passenger_flatground_3idleunarmed.rtm"; + actions = "ACE_CivilHandCuffedFFVActions"; + ConnectTo[] = {"ACE_AmovPercMstpScapWnonDnon",0.1}; + }; + + //Surrender Anims: class ACE_AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon: CutSceneAnimationBase { actions = "ACE_CivilStandSurrenderActions"; diff --git a/addons/captives/functions/fnc_canLoadCaptive.sqf b/addons/captives/functions/fnc_canLoadCaptive.sqf index 1cdc4d86a1..254f0de693 100644 --- a/addons/captives/functions/fnc_canLoadCaptive.sqf +++ b/addons/captives/functions/fnc_canLoadCaptive.sqf @@ -17,22 +17,31 @@ */ #include "script_component.hpp" -private ["_objects"]; params ["_unit", "_target","_vehicle"]; -if (isNull _target) then { - _objects = attachedObjects _unit; - _objects = [_objects, {_this getVariable [QGVAR(isHandcuffed), false]}] call EFUNC(common,filter); - if ((count _objects) > 0) then {_target = _objects select 0;}; +if ((isNull _target) && {_unit getVariable [QGVAR(isEscorting), false]}) then { + //Looking at a vehicle while escorting, get target from attached objects: + { + if (_x getVariable [QGVAR(isHandcuffed), false]) exitWith { + _target = _x; + }; + } forEach (attachedObjects _unit); }; +if ((isNull _target) || {(vehicle _target) != _target} || {!(_target getVariable [QGVAR(isHandcuffed), false])}) exitWith {false}; if (isNull _vehicle) then { - _objects = nearestObjects [_unit, ["Car", "Tank", "Helicopter", "Plane", "Ship"], 10]; - if ((count _objects) > 0) then {_vehicle = _objects select 0;}; + //Looking at a captive unit, search for nearby vehicles with valid seats: + { + // if (([_x] call FUNC(findEmptyNonFFVCargoSeat)) != -1) exitWith { + if ((_x emptyPositions "cargo") > 0) exitWith { + _vehicle = _x; + }; + } forEach (nearestObjects [_unit, ["Car", "Tank", "Helicopter", "Plane", "Ship"], 10]); +} else { + // if (([_vehicle] call FUNC(findEmptyNonFFVCargoSeat)) == -1) then { + if ((_vehicle emptyPositions "cargo") == 0) then { + _vehicle = objNull; + }; }; -(!isNull _target) -&& {!isNull _vehicle} -&& {_unit getVariable [QGVAR(isEscorting), false]} -&& {_target getVariable [QGVAR(isHandcuffed), false]} -&& {([_vehicle] call FUNC(findEmptyNonFFVCargoSeat)) != -1} +(!isNull _vehicle) diff --git a/addons/captives/functions/fnc_doLoadCaptive.sqf b/addons/captives/functions/fnc_doLoadCaptive.sqf index d7df42eb0a..a4d7df8892 100644 --- a/addons/captives/functions/fnc_doLoadCaptive.sqf +++ b/addons/captives/functions/fnc_doLoadCaptive.sqf @@ -1,6 +1,6 @@ /* * Author: commy2 - * Unit loads the target object into a vehicle. + * Unit loads the target object into a vehicle. (logic same as canLoadCaptive) * * Arguments: * 0: Unit that wants to load a captive @@ -17,24 +17,34 @@ */ #include "script_component.hpp" -private "_objects"; - params ["_unit", "_target","_vehicle"]; -if (isNull _target) then { - _objects = attachedObjects _unit; - _objects = [_objects, {_this getVariable [QGVAR(isHandcuffed), false]}] call EFUNC(common,filter); - if ((count _objects) > 0) then {_target = _objects select 0;}; +if ((isNull _target) && {_unit getVariable [QGVAR(isEscorting), false]}) then { + //Looking at a vehicle while escorting, get target from attached objects: + { + if (_x getVariable [QGVAR(isHandcuffed), false]) exitWith { + _target = _x; + }; + } forEach (attachedObjects _unit); }; -if (isNull _target) exitWith {}; +if ((isNull _target) || {(vehicle _target) != _target} || {!(_target getVariable [QGVAR(isHandcuffed), false])}) exitWith {ERROR("");}; if (isNull _vehicle) then { - _objects = nearestObjects [_unit, ["Car", "Tank", "Helicopter", "Plane", "Ship"], 10]; - if ((count _objects) > 0) then {_vehicle = _objects select 0;}; + //Looking at a captive unit, search for nearby vehicles with valid seats: + { + // if (([_x] call FUNC(findEmptyNonFFVCargoSeat)) != -1) exitWith { + if ((_x emptyPositions "cargo") > 0) exitWith { + _vehicle = _x; + }; + } forEach (nearestObjects [_unit, ["Car", "Tank", "Helicopter", "Plane", "Ship"], 10]); +} else { + // if (([_vehicle] call FUNC(findEmptyNonFFVCargoSeat)) == -1) then { + if ((_vehicle emptyPositions "cargo") == 0) then { + _vehicle = objNull; + }; }; -if (isNull _vehicle) exitWith {}; -if ((!isNil "_target") && {!isNil "_vehicle"}) then { - _unit setVariable [QGVAR(isEscorting), false, true]; - ["MoveInCaptive", [_target], [_target, _vehicle]] call EFUNC(common,targetEvent); -}; +if (isNull _vehicle) exitWith {ERROR("");}; + +_unit setVariable [QGVAR(isEscorting), false, true]; +["MoveInCaptive", [_target], [_target, _vehicle]] call EFUNC(common,targetEvent); diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index 413e3d59b5..e1f06e2b61 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -48,6 +48,9 @@ if (_state) then { if ((vehicle _unit) == _unit) then { [_unit] call EFUNC(common,fixLoweredRifleAnimation); [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); + } else { + [_unit, "ACE_HandcuffedFFV", 2] call EFUNC(common,doAnimation); + [_unit, "ACE_HandcuffedFFV", 1] call EFUNC(common,doAnimation); }; //Adds an animation changed eh @@ -63,10 +66,11 @@ if (_state) then { [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); }; } else { + // _turretPath = []; // { - // _x params ["_xUnit", "", "", "_xTurretPath"]; - // if (_unit == _xUnit) exitWith {_turretPath = _xTurretPath}; + // _x params ["_xUnit", "", "", "_xTurretPath"]; + // if (_unit == _xUnit) exitWith {_turretPath = _xTurretPath}; // } forEach (fullCrew (vehicle _unit)); // TRACE_1("turret Path",_turretPath); // if (_turretPath isEqualTo []) exitWith {}; @@ -75,6 +79,10 @@ if (_state) then { // TRACE_1("reseting to",_gunnerAction); // [_unit, "ACE_HandcuffedFFV", 2] call EFUNC(common,doAnimation); // [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); + + + [_unit, "ACE_HandcuffedFFV", 2] call EFUNC(common,doAnimation); + [_unit, "ACE_HandcuffedFFV", 1] call EFUNC(common,doAnimation); }; }]; _unit setVariable [QGVAR(handcuffAnimEHID), _animChangedEHID]; diff --git a/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf b/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf index 6e79725242..cb1c2fd37a 100644 --- a/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf +++ b/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf @@ -20,9 +20,16 @@ private ["_cargoIndex"]; params ["_target","_vehicle"]; -_cargoIndex = [_vehicle] call FUNC(findEmptyNonFFVCargoSeat); -if (_cargoIndex < 0) exitWith {ERROR("No Seat Avail");}; +// _cargoIndex = [_vehicle] call FUNC(findEmptyNonFFVCargoSeat); +// if (_cargoIndex < 0) exitWith {ERROR("No Seat Avail");}; +// _target moveInCargo [_vehicle, _cargoIndex]; + +_target moveInCargo _vehicle; -_target moveInCargo [_vehicle, _cargoIndex]; _target assignAsCargo _vehicle; + +_cargoIndex = _vehicle getCargoIndex _target; _target setVariable [QGVAR(CargoIndex), _cargoIndex, true]; + +[_target, "ACE_HandcuffedFFV", 2] call EFUNC(common,doAnimation); +[_target, "ACE_HandcuffedFFV", 1] call EFUNC(common,doAnimation); diff --git a/addons/captives/script_component.hpp b/addons/captives/script_component.hpp index e68eb19d2f..375c956129 100644 --- a/addons/captives/script_component.hpp +++ b/addons/captives/script_component.hpp @@ -1,6 +1,8 @@ #define COMPONENT captives #include "\z\ace\addons\main\script_mod.hpp" +// #define DEBUG_MODE_FULL + #ifdef DEBUG_ENABLED_CAPTIVES #define DEBUG_MODE_FULL #endif From 51a8cb79749f2a89aa4ad6cb511bbba01c6ec637 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 20 Aug 2015 23:58:06 -0500 Subject: [PATCH 3/7] Only force Animation for FFV Cargo Seats --- addons/captives/CfgMoves.hpp | 2 +- .../captives/functions/fnc_setHandcuffed.sqf | 21 +++++++------------ .../functions/fnc_vehicleCaptiveMoveIn.sqf | 11 ++++++++++ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/addons/captives/CfgMoves.hpp b/addons/captives/CfgMoves.hpp index 6c0bfc3ce9..161fcce9a4 100644 --- a/addons/captives/CfgMoves.hpp +++ b/addons/captives/CfgMoves.hpp @@ -64,7 +64,7 @@ class CfgMovesMaleSdr: CfgMovesBasic { class ACE_HandcuffedFFV: ACE_AmovPercMstpScapWnonDnon { file = "\A3\cargoposes_F_heli\anim\passenger_flatground_3idleunarmed.rtm"; actions = "ACE_CivilHandCuffedFFVActions"; - ConnectTo[] = {"ACE_AmovPercMstpScapWnonDnon",0.1}; + ConnectTo[] = {}; }; diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index e1f06e2b61..c4bde3a839 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -67,20 +67,15 @@ if (_state) then { }; } else { - // _turretPath = []; - // { - // _x params ["_xUnit", "", "", "_xTurretPath"]; - // if (_unit == _xUnit) exitWith {_turretPath = _xTurretPath}; - // } forEach (fullCrew (vehicle _unit)); - // TRACE_1("turret Path",_turretPath); - // if (_turretPath isEqualTo []) exitWith {}; - // _turretConfig = [(configFile >> "CfgVehicles" >> (typeOf (vehicle _unit))), _turretPath] call EFUNC(common,getTurretConfigPath); - // _gunnerAction = getText (_turretConfig >> "gunnerAction"); - // TRACE_1("reseting to",_gunnerAction); - // [_unit, "ACE_HandcuffedFFV", 2] call EFUNC(common,doAnimation); - // [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); - + _turretPath = []; + { + _x params ["_xUnit", "", "", "_xTurretPath"]; + if (_unit == _xUnit) exitWith {_turretPath = _xTurretPath}; + } forEach (fullCrew (vehicle _unit)); + TRACE_1("turret Path",_turretPath); + if (_turretPath isEqualTo []) exitWith {}; + TRACE_1("Handcuff (FFV) animation interrupted",_newAnimation); [_unit, "ACE_HandcuffedFFV", 2] call EFUNC(common,doAnimation); [_unit, "ACE_HandcuffedFFV", 1] call EFUNC(common,doAnimation); }; diff --git a/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf b/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf index cb1c2fd37a..959bbd71b9 100644 --- a/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf +++ b/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf @@ -31,5 +31,16 @@ _target assignAsCargo _vehicle; _cargoIndex = _vehicle getCargoIndex _target; _target setVariable [QGVAR(CargoIndex), _cargoIndex, true]; +//Check if is a FFV turret: +_turretPath = []; +{ + _x params ["_xUnit", "", "", "_xTurretPath"]; + if (_target == _xUnit) exitWith {_turretPath = _xTurretPath}; +} forEach (fullCrew (vehicle _target)); +TRACE_1("turret Path",_turretPath); +if (_turretPath isEqualTo []) exitWith {}; + +TRACE_1("Setting FFV Animation",_newAnimation); + [_target, "ACE_HandcuffedFFV", 2] call EFUNC(common,doAnimation); [_target, "ACE_HandcuffedFFV", 1] call EFUNC(common,doAnimation); From 69df301e677056ea2801a2f81fc8a1922f3d824b Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 23 Aug 2015 02:29:51 -0500 Subject: [PATCH 4/7] Replace one more macro --- addons/captives/functions/fnc_doEscortCaptive.sqf | 4 +++- addons/captives/functions/fnc_setHandcuffed.sqf | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/captives/functions/fnc_doEscortCaptive.sqf b/addons/captives/functions/fnc_doEscortCaptive.sqf index bb070b057a..08b64195f3 100644 --- a/addons/captives/functions/fnc_doEscortCaptive.sqf +++ b/addons/captives/functions/fnc_doEscortCaptive.sqf @@ -35,7 +35,9 @@ if (_state) then { nil, 20, false, true, "", QUOTE(!isNull (GETVAR(_target,QGVAR(escortedUnit),objNull)))]; [{ - EXPLODE_3_PVT((_this select 0),_unit,_target,_actionID); + params ["_args", "_pfID"]; + _args params ["_unit", "_target", "_actionID"]; + if (_unit getVariable [QGVAR(isEscorting), false]) then { if (!alive _target || {!alive _unit} || {!canStand _target} || {!canStand _unit} || {_target getVariable ["ACE_isUnconscious", false]} || {_unit getVariable ["ACE_isUnconscious", false]} || {!isNull (attachedTo _unit)}) then { _unit setVariable [QGVAR(isEscorting), false, true]; diff --git a/addons/captives/functions/fnc_setHandcuffed.sqf b/addons/captives/functions/fnc_setHandcuffed.sqf index c4bde3a839..a8c8e02fd4 100644 --- a/addons/captives/functions/fnc_setHandcuffed.sqf +++ b/addons/captives/functions/fnc_setHandcuffed.sqf @@ -17,6 +17,7 @@ #include "script_component.hpp" params ["_unit","_state"]; +TRACE_2("params",_unit,_state); if (!local _unit) exitwith { ERROR("running setHandcuffed on remote unit"); @@ -56,7 +57,7 @@ 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"; - TRACE_1("Adding animChangedEH",_unit); + _animChangedEHID = _unit addEventHandler ["AnimChanged", { params ["_unit", "_newAnimation"]; TRACE_2("AnimChanged",_unit,_newAnimation); @@ -80,6 +81,7 @@ if (_state) then { [_unit, "ACE_HandcuffedFFV", 1] call EFUNC(common,doAnimation); }; }]; + TRACE_2("Adding animChangedEH",_unit,_animChangedEHID); _unit setVariable [QGVAR(handcuffAnimEHID), _animChangedEHID]; }, [_unit], 0.01] call EFUNC(common,waitAndExecute); @@ -90,6 +92,7 @@ if (_state) then { //remove AnimChanged EH private "_animChangedEHID"; _animChangedEHID = _unit getVariable [QGVAR(handcuffAnimEHID), -1]; + TRACE_1("removing animChanged EH",_animChangedEHID); _unit removeEventHandler ["AnimChanged", _animChangedEHID]; _unit setVariable [QGVAR(handcuffAnimEHID), -1]; From 8ca06a9a76f14348dd0df65db05cf09807cc8737 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 23 Aug 2015 12:32:46 -0500 Subject: [PATCH 5/7] More FFV animation stuff --- .../fnc_findEmptyNonFFVCargoSeat.sqf | 31 ++++++++++++++++-- addons/captives/functions/fnc_handleGetIn.sqf | 21 ++++++++++-- .../captives/functions/fnc_handleGetOut.sqf | 19 ++++++----- .../captives/functions/fnc_setSurrendered.sqf | 1 + .../functions/fnc_vehicleCaptiveMoveIn.sqf | 32 ++++++------------- .../functions/fnc_vehicleCaptiveMoveOut.sqf | 2 ++ 6 files changed, 70 insertions(+), 36 deletions(-) diff --git a/addons/captives/functions/fnc_findEmptyNonFFVCargoSeat.sqf b/addons/captives/functions/fnc_findEmptyNonFFVCargoSeat.sqf index a6bd625870..cf67614f91 100644 --- a/addons/captives/functions/fnc_findEmptyNonFFVCargoSeat.sqf +++ b/addons/captives/functions/fnc_findEmptyNonFFVCargoSeat.sqf @@ -1,6 +1,22 @@ +/* + * Author: PabstMirror + * Finds a free cargo seat, searching non FFV first + * + * Arguments: + * 0: The Vehicle + * + * Return Value: + * ARRAY [seat index , is FFV ] + * + * Example: + * [car1] call ACE_captives_fnc_findEmptyNonFFVCargoSeat + * + * Public: No + */ #include "script_component.hpp" params ["_vehicle"]; +TRACE_1("params", _vehicle); _vehicleConfig = configFile >> "CfgVehicles" >> (typeOf _vehicle); @@ -30,10 +46,21 @@ _occupiedSeats = []; TRACE_3("Searching for empty seat",_realCargoCount,_ffvCargoIndexes,_occupiedSeats); -_emptyCargoSeatReturn = -1; +_emptyCargoSeatReturn = [-1, false]; + +//First seach for non-ffv seats: for "_index" from 0 to (_realCargoCount - 1) do { if ((!(_index in _ffvCargoIndexes)) && {!(_index in _occupiedSeats)}) exitWith { - _emptyCargoSeatReturn = _index; + _emptyCargoSeatReturn = [_index, false]; + }; +}; + +//Only use FFV if none found: +if (_emptyCargoSeatReturn isEqualTo [-1, false]) then { + for "_index" from 0 to (_realCargoCount - 1) do { + if (!(_index in _occupiedSeats)) exitWith { + _emptyCargoSeatReturn = [_index, true]; + }; }; }; diff --git a/addons/captives/functions/fnc_handleGetIn.sqf b/addons/captives/functions/fnc_handleGetIn.sqf index 487e7d4179..5476073b38 100644 --- a/addons/captives/functions/fnc_handleGetIn.sqf +++ b/addons/captives/functions/fnc_handleGetIn.sqf @@ -4,8 +4,8 @@ * * Arguments: * 0: _vehicle - * 2: dunno - * 1: _unit + * 1: dunno + * 2: _unit * * Return Value: * The return value @@ -17,7 +17,8 @@ */ #include "script_component.hpp" -params ["_vehicle", "_dontcare","_unit"]; +params ["_vehicle", "","_unit"]; +TRACE_2("params",_vehicle,_unit); if (local _unit) then { if (_unit getVariable [QGVAR(isEscorting), false]) then { @@ -27,4 +28,18 @@ if (local _unit) then { if (_unit getVariable [QGVAR(isSurrendering), false]) then { [_unit, false] call FUNC(setSurrender); }; + + if (_unit getVariable [QGVAR(isHandcuffed), false]) then { + //Need to force animation for FFV turrets + _turretPath = []; + { + _x params ["_xUnit", "", "", "_xTurretPath"]; + if (_unit == _xUnit) exitWith {_turretPath = _xTurretPath}; + } forEach (fullCrew (vehicle _unit)); + if (!(_turretPath isEqualTo [])) then { + TRACE_1("Setting FFV Handcuffed Animation",_turretPath); + [_unit, "ACE_HandcuffedFFV", 2] call EFUNC(common,doAnimation); + [_unit, "ACE_HandcuffedFFV", 1] call EFUNC(common,doAnimation); + }; + }; }; diff --git a/addons/captives/functions/fnc_handleGetOut.sqf b/addons/captives/functions/fnc_handleGetOut.sqf index 756c14ec10..dea97eb600 100644 --- a/addons/captives/functions/fnc_handleGetOut.sqf +++ b/addons/captives/functions/fnc_handleGetOut.sqf @@ -4,8 +4,8 @@ * * Arguments: * 0: _vehicle - * 2: dunno - * 1: _unit + * 1: dunno + * 2: _unit * * Return Value: * The return value @@ -17,18 +17,21 @@ */ #include "script_component.hpp" -params ["_vehicle", "_dontcare","_unit"]; +params ["_vehicle", "", "_unit"]; +TRACE_2("params",_vehicle,_unit); if ((local _unit) && {_unit getVariable [QGVAR(isHandcuffed), false]}) then { private ["_cargoIndex"]; _cargoIndex = _unit getVariable [QGVAR(CargoIndex), -1]; - //If captive was not "unloaded", then move them back into the vehicle. - if (_cargoIndex != -1) exitWith { + if (_cargoIndex != -1) then { + //If captive was not "unloaded", then move them back into the vehicle. + TRACE_1("forcing back into vehicle",_cargoIndex); _unit moveInCargo [_vehicle, _cargoIndex]; + } else { + //Getting out of vehicle: + [_unit, "ACE_AmovPercMstpScapWnonDnon", 2] call EFUNC(common,doAnimation); + [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); }; - - [_unit, "ACE_AmovPercMstpScapWnonDnon", 2] call EFUNC(common,doAnimation); - [_unit, "ACE_AmovPercMstpScapWnonDnon", 1] call EFUNC(common,doAnimation); }; diff --git a/addons/captives/functions/fnc_setSurrendered.sqf b/addons/captives/functions/fnc_setSurrendered.sqf index 22736c8e59..dd9ac417c5 100644 --- a/addons/captives/functions/fnc_setSurrendered.sqf +++ b/addons/captives/functions/fnc_setSurrendered.sqf @@ -17,6 +17,7 @@ #include "script_component.hpp" params ["_unit","_state"]; +TRACE_2("params",_unit,_state); if (!local _unit) exitwith { ERROR("running surrender on remote unit"); diff --git a/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf b/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf index 959bbd71b9..0839c61ea1 100644 --- a/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf +++ b/addons/captives/functions/fnc_vehicleCaptiveMoveIn.sqf @@ -16,31 +16,17 @@ */ #include "script_component.hpp" +params ["_target","_vehicle"]; +TRACE_2("params",_target,_vehicle); + private ["_cargoIndex"]; -params ["_target","_vehicle"]; +_getSeat = [_vehicle] call FUNC(findEmptyNonFFVCargoSeat); +TRACE_1("free cargo seat",_getSeat); +_cargoIndex = _getSeat select 0; +if (_cargoIndex == -1) exitWith {ERROR("cargo index -1");}; -// _cargoIndex = [_vehicle] call FUNC(findEmptyNonFFVCargoSeat); -// if (_cargoIndex < 0) exitWith {ERROR("No Seat Avail");}; -// _target moveInCargo [_vehicle, _cargoIndex]; +_target moveInCargo [_vehicle, _cargoIndex]; +_target assignAsCargoIndex [_vehicle, _cargoIndex]; -_target moveInCargo _vehicle; - -_target assignAsCargo _vehicle; - -_cargoIndex = _vehicle getCargoIndex _target; _target setVariable [QGVAR(CargoIndex), _cargoIndex, true]; - -//Check if is a FFV turret: -_turretPath = []; -{ - _x params ["_xUnit", "", "", "_xTurretPath"]; - if (_target == _xUnit) exitWith {_turretPath = _xTurretPath}; -} forEach (fullCrew (vehicle _target)); -TRACE_1("turret Path",_turretPath); -if (_turretPath isEqualTo []) exitWith {}; - -TRACE_1("Setting FFV Animation",_newAnimation); - -[_target, "ACE_HandcuffedFFV", 2] call EFUNC(common,doAnimation); -[_target, "ACE_HandcuffedFFV", 1] call EFUNC(common,doAnimation); diff --git a/addons/captives/functions/fnc_vehicleCaptiveMoveOut.sqf b/addons/captives/functions/fnc_vehicleCaptiveMoveOut.sqf index db8a7bd12e..ce44b5926f 100644 --- a/addons/captives/functions/fnc_vehicleCaptiveMoveOut.sqf +++ b/addons/captives/functions/fnc_vehicleCaptiveMoveOut.sqf @@ -16,6 +16,8 @@ #include "script_component.hpp" params ["_unit"]; +TRACE_1("params",_unit); + _unit setVariable [QGVAR(CargoIndex), -1, true]; moveOut _unit; From 40634318f00977c5047945cf7f2e09cea9ee8e04 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 23 Aug 2015 23:41:35 -0500 Subject: [PATCH 6/7] Move RemoveHandcuffs to Main (always blocked by hands) --- addons/captives/CfgVehicles.hpp | 32 +++++++++---------- .../functions/fnc_canRemoveHandcuffs.sqf | 3 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/addons/captives/CfgVehicles.hpp b/addons/captives/CfgVehicles.hpp index 774ecf87e3..afda86cfda 100644 --- a/addons/captives/CfgVehicles.hpp +++ b/addons/captives/CfgVehicles.hpp @@ -12,17 +12,17 @@ class CfgVehicles { exceptions[] = {}; icon = QUOTE(PATHTOF(UI\handcuff_ca.paa)); }; - class ACE_RemoveHandcuffs { - displayName = CSTRING(ReleaseCaptive); - selection = "righthand"; - distance = 2; - condition = QUOTE([ARR_2(_player, _target)] call FUNC(canRemoveHandcuffs)); - statement = QUOTE([ARR_2(_player, _target)] call FUNC(doRemoveHandcuffs)); - exceptions[] = {}; - icon = QUOTE(PATHTOF(UI\handcuff_ca.paa)); - }; class ACE_MainActions { + class ACE_RemoveHandcuffs { + displayName = CSTRING(ReleaseCaptive); + selection = "righthand"; + distance = 2; + condition = QUOTE([ARR_2(_player, _target)] call FUNC(canRemoveHandcuffs)); + statement = QUOTE([ARR_2(_player, _target)] call FUNC(doRemoveHandcuffs)); + exceptions[] = {}; + icon = QUOTE(PATHTOF(UI\handcuff_ca.paa)); + }; class ACE_EscortCaptive { displayName = CSTRING(EscortCaptive); distance = 4; @@ -97,7 +97,7 @@ class CfgVehicles { }; }; -#define MACRO_LOADUNLOADCAPTIVE \ +#define MACRO_LOADCAPTIVE \ class ACE_Actions { \ class ACE_MainActions { \ class GVAR(LoadCaptive) { \ @@ -113,27 +113,27 @@ class CfgVehicles { class LandVehicle; class Car: LandVehicle { - MACRO_LOADUNLOADCAPTIVE + MACRO_LOADCAPTIVE }; class Tank: LandVehicle { - MACRO_LOADUNLOADCAPTIVE + MACRO_LOADCAPTIVE }; class Air; class Helicopter: Air { - MACRO_LOADUNLOADCAPTIVE + MACRO_LOADCAPTIVE }; class Plane: Air { - MACRO_LOADUNLOADCAPTIVE + MACRO_LOADCAPTIVE }; class Ship; class Ship_F: Ship { - MACRO_LOADUNLOADCAPTIVE + MACRO_LOADCAPTIVE }; class StaticWeapon: LandVehicle { - MACRO_LOADUNLOADCAPTIVE + MACRO_LOADCAPTIVE }; class Box_NATO_Support_F; diff --git a/addons/captives/functions/fnc_canRemoveHandcuffs.sqf b/addons/captives/functions/fnc_canRemoveHandcuffs.sqf index e8bbe3b50e..e36ba5cd5b 100644 --- a/addons/captives/functions/fnc_canRemoveHandcuffs.sqf +++ b/addons/captives/functions/fnc_canRemoveHandcuffs.sqf @@ -20,4 +20,5 @@ params ["_unit", "_target"]; //Unit is handcuffed and not currently being escorted _target getVariable [QGVAR(isHandcuffed), false] && -{isNull (attachedTo _target)} +{isNull (attachedTo _target)} && +{(vehicle _target) == _target} From d3db5ad2ed58f1fbffd0de40f68b414134963a27 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 24 Aug 2015 00:07:40 -0500 Subject: [PATCH 7/7] Cleanup --- addons/captives/functions/fnc_canLoadCaptive.sqf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/captives/functions/fnc_canLoadCaptive.sqf b/addons/captives/functions/fnc_canLoadCaptive.sqf index 254f0de693..a59c2e3be6 100644 --- a/addons/captives/functions/fnc_canLoadCaptive.sqf +++ b/addons/captives/functions/fnc_canLoadCaptive.sqf @@ -11,7 +11,7 @@ * The return value * * Example: - * [player, bob] call ACE_captives_fnc_canLoadCaptive + * [player, bob, car] call ACE_captives_fnc_canLoadCaptive * * Public: No */ @@ -32,13 +32,12 @@ if ((isNull _target) || {(vehicle _target) != _target} || {!(_target getVariable if (isNull _vehicle) then { //Looking at a captive unit, search for nearby vehicles with valid seats: { - // if (([_x] call FUNC(findEmptyNonFFVCargoSeat)) != -1) exitWith { if ((_x emptyPositions "cargo") > 0) exitWith { _vehicle = _x; }; } forEach (nearestObjects [_unit, ["Car", "Tank", "Helicopter", "Plane", "Ship"], 10]); } else { - // if (([_vehicle] call FUNC(findEmptyNonFFVCargoSeat)) == -1) then { + //We have a vehicle picked, make sure it has empty seats: if ((_vehicle emptyPositions "cargo") == 0) then { _vehicle = objNull; };