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;