replace spawns

This commit is contained in:
PabstMirror 2015-02-06 03:38:27 -06:00
parent 82a8fc8ca3
commit 7a3029b9fd
18 changed files with 123 additions and 106 deletions

View File

@ -6,7 +6,7 @@ class Extended_PreInit_EventHandlers {
class Extended_PostInit_EventHandlers { class Extended_PostInit_EventHandlers {
class ADDON { class ADDON {
clientInit = QUOTE(call COMPILE_FILE(XEH_postInitClient)); init = QUOTE(call COMPILE_FILE(XEH_postInit));
}; };
}; };

View File

@ -50,7 +50,7 @@ class CfgVehicles {
displayName = "$STR_ACE_Captives_LoadCaptive"; displayName = "$STR_ACE_Captives_LoadCaptive";
distance = 4; distance = 4;
condition = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(canLoadCaptive)); condition = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(canLoadCaptive));
statement = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(loadCaptive)); statement = QUOTE([ARR_3(_player, _target, objNull)] call FUNC(doLoadCaptive));
exceptions[] = {QGVAR(isNotEscorting)}; exceptions[] = {QGVAR(isNotEscorting)};
showDisabled = 0; showDisabled = 0;
icon = QUOTE(PATHTOF(UI\captive_ca.paa)); icon = QUOTE(PATHTOF(UI\captive_ca.paa));
@ -61,7 +61,7 @@ class CfgVehicles {
displayName = "$STR_ACE_Captives_FriskPerson"; displayName = "$STR_ACE_Captives_FriskPerson";
distance = 2; distance = 2;
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canFriskPerson)); condition = QUOTE([ARR_2(_player, _target)] call FUNC(canFriskPerson));
statement = QUOTE([ARR_2(_player, _target)] call FUNC(openFriskMenu)); statement = QUOTE([ARR_2(_player, _target)] call FUNC(doFriskPerson));
showDisabled = 0; showDisabled = 0;
//icon = ""; //@todo //icon = ""; //@todo
priority = 3; priority = 3;
@ -97,7 +97,7 @@ class CfgVehicles {
displayName = "$STR_ACE_Captives_LoadCaptive"; \ displayName = "$STR_ACE_Captives_LoadCaptive"; \
distance = 4; \ distance = 4; \
condition = QUOTE([ARR_3(_player, objNull, _target)] call FUNC(canLoadCaptive)); \ condition = QUOTE([ARR_3(_player, objNull, _target)] call FUNC(canLoadCaptive)); \
statement = QUOTE([ARR_3(_player, objNull, _target)] call FUNC(loadCaptive)); \ statement = QUOTE([ARR_3(_player, objNull, _target)] call FUNC(doLoadCaptive)); \
exceptions[] = {QGVAR(isNotEscorting)}; \ exceptions[] = {QGVAR(isNotEscorting)}; \
showDisabled = 0; \ showDisabled = 0; \
priority = 1.2; \ priority = 1.2; \
@ -107,7 +107,7 @@ class CfgVehicles {
displayName = "$STR_ACE_Captives_UnloadCaptive"; \ displayName = "$STR_ACE_Captives_UnloadCaptive"; \
distance = 4; \ distance = 4; \
condition = QUOTE([ARR_2(_player, _target)] call FUNC(canUnloadCaptive)); \ condition = QUOTE([ARR_2(_player, _target)] call FUNC(canUnloadCaptive)); \
statement = QUOTE([ARR_2(_player, _target)] call FUNC(unloadCaptive)); \ statement = QUOTE([ARR_2(_player, _target)] call FUNC(doUnloadCaptive)); \
showDisabled = 0; \ showDisabled = 0; \
priority = 1.2; \ priority = 1.2; \
hotkey = "C"; \ hotkey = "C"; \

View File

@ -0,0 +1,32 @@
#include "script_component.hpp"
["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler);
["MoveInCaptive", {_this call FUNC(vehicleCaptiveMoveIn)}] call EFUNC(common,addEventHandler);
["MoveOutCaptive", {_this call FUNC(vehicleCaptiveMoveOut)}] call EFUNC(common,addEventHandler);
["SetHandcuffed", {_this call FUNC(setHandcuffed)}] call EFUNC(common,addEventHandler);
//Handles when someone starts escorting and then disconnects, leaving the captive attached
//This is normaly handled by the PFEH in doEscortCaptive, but that won't be running if they DC
if (isServer) then {
addMissionEventHandler ["HandleDisconnect", {
PARAMS_1(_disconnectedPlayer);
_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];
};
}];
};
//TODO: Medical Integration Events???
// [_unit, "knockedOut", {
// if (local (_this select 0)) then {_this call ACE_Captives_fnc_handleKnockedOut};
// }] call ACE_Core_fnc_addCustomEventhandler;
// [_unit, "wokeUp", {
// if (local (_this select 0)) then {_this call ACE_Captives_fnc_handleWokeUp};
// }] call ACE_Core_fnc_addCustomEventhandler;

View File

@ -1,16 +0,0 @@
#include "script_component.hpp"
["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler);
["MoveInCaptive", {_this call FUNC(vehicleCaptiveMoveIn)}] call EFUNC(common,addEventHandler);
["MoveOutCaptive", {_this call FUNC(vehicleCaptiveMoveOut)}] call EFUNC(common,addEventHandler);
["SetHandcuffed", {_this call FUNC(setHandcuffed)}] call EFUNC(common,addEventHandler);
//TODO: Medical Integration Events???
// [_unit, "knockedOut", {
// if (local (_this select 0)) then {_this call ACE_Captives_fnc_handleKnockedOut};
// }] call ACE_Core_fnc_addCustomEventhandler;
// [_unit, "wokeUp", {
// if (local (_this select 0)) then {_this call ACE_Captives_fnc_handleWokeUp};
// }] call ACE_Core_fnc_addCustomEventhandler;

View File

@ -20,6 +20,6 @@ PARAMS_2(_unit,_target);
//Player has cableTie, target is alive and not already handcuffed //Player has cableTie, target is alive and not already handcuffed
("ACE_CableTie" in (items _unit)) && ("ACE_CableTie" in (items _unit)) &&
{alive _target} && {alive _target} &&
{!(_target getVariable [QGVAR(isHandcuffed), false])} {!(_target getVariable [QGVAR(isHandcuffed), false])}

View File

@ -20,7 +20,7 @@ PARAMS_2(_unit,_target);
//Alive, handcuffed, not being escored, and not unconsious //Alive, handcuffed, not being escored, and not unconsious
(_target getVariable [QGVAR(isHandcuffed), false]) && (_target getVariable [QGVAR(isHandcuffed), false]) &&
{isNull (attachedTo _target)} && {isNull (attachedTo _target)} &&
{alive _target} && {alive _target} &&
{!(_target getVariable [QGVAR(ACE_isUnconscious), false])} {!(_target getVariable [QGVAR(ACE_isUnconscious), false])}

View File

@ -4,8 +4,8 @@
* *
* Arguments: * Arguments:
* 0: Unit that wants to load a captive <OBJECT> * 0: Unit that wants to load a captive <OBJECT>
* 1: A captive. ObjNull for the first escorted captive <OBJECT> * 1: A captive. ObjNull for the first escorted captive (may be null) <OBJECT>
* 2: Vehicle to load the captive into. ObjNull for the nearest vehicle <OBJECT> * 2: Vehicle to load the captive into. ObjNull for the nearest vehicle (may be null) <OBJECT>
* *
* Return Value: * Return Value:
* The return value <BOOL> * The return value <BOOL>
@ -24,15 +24,16 @@ PARAMS_3(_unit,_target,_vehicle);
if (isNull _target) then { if (isNull _target) then {
_objects = attachedObjects _unit; _objects = attachedObjects _unit;
_objects = [_objects, {_this getVariable [QGVAR(isHandcuffed), false]}] call EFUNC(common,filter); _objects = [_objects, {_this getVariable [QGVAR(isHandcuffed), false]}] call EFUNC(common,filter);
_target = _objects select 0; if ((count _objects) > 0) then {_target = _objects select 0;};
}; };
if (isNull _vehicle) then { if (isNull _vehicle) then {
_objects = nearestObjects [_unit, ["Car", "Tank", "Helicopter", "Plane", "Ship_F"], 10]; _objects = nearestObjects [_unit, ["Car", "Tank", "Helicopter", "Plane", "Ship_F"], 10];
_vehicle = _objects select 0; if ((count _objects) > 0) then {_vehicle = _objects select 0;};
}; };
_unit getVariable [QGVAR(isEscorting), false] (!isNull _target)
&& {!isNil "_target"} && {!isNull _vehicle}
&& {!isNil "_vehicle"} && {_unit getVariable [QGVAR(isEscorting), false]}
&& {_target getVariable [QGVAR(isHandcuffed), false]}
&& {_vehicle emptyPositions "cargo" > 0} && {_vehicle emptyPositions "cargo" > 0}

View File

@ -19,5 +19,5 @@
PARAMS_2(_unit,_target); PARAMS_2(_unit,_target);
//Unit is handcuffed and not currently being escorted //Unit is handcuffed and not currently being escorted
_target getVariable [QGVAR(isHandcuffed), false] && _target getVariable [QGVAR(isHandcuffed), false] &&
{isNull (attachedTo _target)} {isNull (attachedTo _target)}

View File

@ -18,5 +18,5 @@
PARAMS_2(_unit,_target); PARAMS_2(_unit,_target);
_unit removeItem "ACE_CableTie"; _unit removeItem "ACE_CableTie";
["SetHandcuffed", [_target], [_target, true]] call EFUNC(common,targetEvent); ["SetHandcuffed", [_target], [_target, true]] call EFUNC(common,targetEvent);

View File

@ -34,21 +34,25 @@ if (_state) then {
{[(_this select 0), ((_this select 0) getVariable [QGVAR(escortedUnit), objNull]), false] call FUNC(doEscortCaptive);}, {[(_this select 0), ((_this select 0) getVariable [QGVAR(escortedUnit), objNull]), false] call FUNC(doEscortCaptive);},
nil, 20, false, true, "", QUOTE(!isNull (GETVAR(_target,QGVAR(escortedUnit),objNull)))]; nil, 20, false, true, "", QUOTE(!isNull (GETVAR(_target,QGVAR(escortedUnit),objNull)))];
[_unit, _target, _actionID] spawn { private "_escortFnc";
PARAMS_3(_unit,_target,_actionID); _escortFnc = {
EXPLODE_3_PVT((_this select 0),_unit,_target,_actionID);
while {_unit getVariable [QGVAR(isEscorting), false]} do { if (_unit getVariable [QGVAR(isEscorting), false]) then {
sleep 0.2;
if (!alive _target || {!alive _unit} || {!canStand _target} || {!canStand _unit} || {_target getVariable ["ACE_isUnconscious", false]} || {_unit getVariable ["ACE_isUnconscious", false]} || {!isNull (attachedTo _unit)}) 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]; _unit setVariable [QGVAR(isEscorting), false, true];
}; };
}; };
[objNull, _target] call EFUNC(common,claim);
detach _target; if (!(_unit getVariable [QGVAR(isEscorting), false])) then {
_unit removeAction _actionID; [(_this select 1)] call cba_fnc_removePerFrameHandler;
[objNull, _target] call EFUNC(common,claim);
detach _target;
_unit removeAction _actionID;
_unit setVariable [QGVAR(escortedUnit), objNull, true];
};
}; };
[_escortFnc, 0.2, [_unit, _target, _actionID]] call CBA_fnc_addPerFrameHandler;
} else { } else {
_unit setVariable [QGVAR(isEscorting), false, true]; _unit setVariable [QGVAR(isEscorting), false, true];
_unit setVariable [QGVAR(escortedUnit), objNull, true]; _unit setVariable [QGVAR(escortedUnit), objNull, true];

View File

@ -21,9 +21,9 @@ PARAMS_3(_vehicle,_dontcare,_unit);
if ((local _unit) && {_unit getVariable [QGVAR(isHandcuffed), false]}) then { if ((local _unit) && {_unit getVariable [QGVAR(isHandcuffed), false]}) then {
private ["_cargoIndex"]; private ["_cargoIndex"];
_cargoIndex = _unit getVariable ["ACE_Captives_CargoIndex", -1]; _cargoIndex = _unit getVariable [QGVAR(CargoIndex), -1];
//If captive was not "unloaded", then move them back into the vehicle. //If captive was not "unloaded", then move them back into the vehicle.
if (_cargoIndex != -1) exitWith { if (_cargoIndex != -1) exitWith {
_unit moveInCargo [_vehicle, _cargoIndex]; _unit moveInCargo [_vehicle, _cargoIndex];

View File

@ -1,6 +1,6 @@
/* /*
* Author: PabstMirror * Author: PabstMirror
* Handles when a unit is kill. Reset captivity and escorting status when getting killed * Handles when a unit is kill. Reset captivity and escorting status
* *
* Arguments: * Arguments:
* 0: _oldUnit <OBJECT> * 0: _oldUnit <OBJECT>
@ -22,5 +22,5 @@ if (_oldUnit getVariable [QGVAR(isHandcuffed), false]) then {
}; };
if (_oldUnit getVariable [QGVAR(isEscorting), false]) then { if (_oldUnit getVariable [QGVAR(isEscorting), false]) then {
_oldUnit setVariable [QGVAR(isEscorting), false, true] _oldUnit setVariable [QGVAR(isEscorting), false, true];
}; };

View File

@ -1,9 +1,9 @@
/* /*
* Author: commy2 * Author: commy2
* TODO * Handles playerChanged. Resets "showHUD" based on handcuff status
* *
* Arguments: * Arguments:
* 0: _unit <OBJECT> * 0: _newUnit <OBJECT>
* 1: _oldUnit <OBJECT> * 1: _oldUnit <OBJECT>
* *
* Return Value: * Return Value:
@ -16,9 +16,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_unit,_oldUnit); PARAMS_2(_newUnit,_oldUnit);
if (_unit getVariable [QGVAR(isHandcuffed), false]) then { if (_newUnit getVariable [QGVAR(isHandcuffed), false]) then {
showHUD false; showHUD false;
} else { } else {
showHUD true; showHUD true;

View File

@ -1,24 +1,24 @@
/* /*
* Author: commy2 * Author: commy2
* handle captive and unconsciousness state and prevent grenades * handle captive and unconsciousness state and prevent grenades
* *
* Arguments: * Arguments:
* 0: _unit <OBJECT> * 0: _unit <OBJECT>
* *
* Return Value: * Return Value:
* The return value <BOOL> * The return value <BOOL>
* *
* Example: * Example:
* TODO * TODO
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_unit); PARAMS_1(_unit);
// prevent players from throwing grenades (added to all units) // prevent players from throwing grenades (added to all units)
[_unit, "Throw", {(_this select 1) getVariable [QGVAR(isHandcuffed), false]}, {}] call EFUNC(common,addActionEventhandler); [_unit, "Throw", {(_this select 1) getVariable [QGVAR(isHandcuffed), false]}, {hint format ["%1 - debug throw prevented",time];}] call EFUNC(common,addActionEventhandler);
if (local _unit) then { if (local _unit) then {
// reset status on mission start // reset status on mission start

View File

@ -29,31 +29,34 @@ if (_state isEqualTo (_unit getVariable [QGVAR(isHandcuffed), false])) exitWith
if (_state) then { if (_state) then {
_unit setVariable [QGVAR(isHandcuffed), true, true]; _unit setVariable [QGVAR(isHandcuffed), true, true];
[_unit, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus);
// fix anim on mission start (should work on dedicated servers) // fix anim on mission start (should work on dedicated servers)
_unit spawn {
[_this, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus);
if (_this getVariable [QGVAR(isHandcuffed), false] && {vehicle _this == _this}) then { _fixAnimationFnc = {
[_this] call EFUNC(common,fixLoweredRifleAnimation); PARAMS_1(_unit);
[_this, "ACE_AmovPercMstpScapWnonDnon", 0] spawn EFUNC(common,doAnimation); if (_unit getVariable [QGVAR(isHandcuffed), false] && {vehicle _unit == _unit}) then {
[_unit] call EFUNC(common,fixLoweredRifleAnimation);
[_unit, "ACE_AmovPercMstpScapWnonDnon", 0] call EFUNC(common,doAnimation);
}; };
}; };
_unit setVariable ["ACE_Captives_CargoIndex", vehicle _unit getCargoIndex _unit, true]; [_fixAnimationFnc, [_unit], 0.05, 0] call EFUNC(common,waitAndExecute);
_unit setVariable [QGVAR(CargoIndex), ((vehicle _unit) getCargoIndex _unit), true];
if (_unit == ACE_player) then { if (_unit == ACE_player) then {
showHUD false; showHUD false;
}; };
} else { } else {
_unit setVariable [QGVAR(isHandcuffed), false, true]; _unit setVariable [QGVAR(isHandcuffed), false, true];
[_unit, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus); [_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus);
if (vehicle _unit == _unit) then { if ((vehicle _unit) == _unit) then {
[_unit, "ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation); [_unit, "ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation);
}; };
if (_unit getVariable ["ACE_Captives_CargoIndex", -1] != -1) then { if (_unit getVariable [QGVAR(CargoIndex), -1] != -1) then {
_unit setVariable ["ACE_Captives_CargoIndex", -1, true]; _unit setVariable [QGVAR(CargoIndex), -1, true];
}; };
if (_unit == ACE_player) then { if (_unit == ACE_player) then {

View File

@ -26,38 +26,31 @@ if (_state) then {
_unit setVariable [QGVAR(isSurrender), true, true]; _unit setVariable [QGVAR(isSurrender), true, true];
[_unit, "ACE_Surrendered", true] call EFUNC(common,setCaptivityStatus); [_unit, "ACE_Surrendered", true] call EFUNC(common,setCaptivityStatus);
_unit spawn {
// fix for lowered rifle animation glitch
if (currentWeapon _this != "" && {currentWeapon _this == primaryWeapon _this} && {weaponLowered _this} && {stance _this == "STAND"}) then {
_this playMove "amovpercmstpsraswrfldnon";
};
while {_this getVariable [QGVAR(isSurrender), false]} do { private "_surrenderFnc";
sleep 0.001; //sleep in UI _surrenderFnc = {
EXPLODE_1_PVT((_this select 0),_unit);
if (isPlayer _this) then {showHUD false}; if (_unit getVariable [QGVAR(isSurrender), false]) then {
if ((!alive _unit) || {_unit getVariable ["ACE_isUnconscious", false]} || {_unit getVariable [QGVAR(isHandcuffed), false]}) then {
if (!alive _this || {_this getVariable ["ACE_isUnconscious", false]}) then { _unit setVariable [QGVAR(isSurrender), false, true];
_this setVariable [QGVAR(isSurrender), false, true];
} else { } else {
_this playMove "amovpercmstpsnonwnondnon_amovpercmstpssurwnondnon"; [_unit, "amovpercmstpsnonwnondnon_amovpercmstpssurwnondnon", 0] call EFUNC(common,doAnimation);
}; };
}; };
if !(_this getVariable ["ACE_isUnconscious", false]) then {
_this playMoveNow "AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon"; if (!(_unit getVariable [QGVAR(isSurrender), false])) then {
} else { [(_this select 1)] call cba_fnc_removePerFrameHandler;
_this playMoveNow "unconscious";
if !(_unit getVariable ["ACE_isUnconscious", false]) then {
[_unit, "AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon", 1] call EFUNC(common,doAnimation);
} else {
[_unit, "unconscious", 1] call EFUNC(common,doAnimation);
};
[_unit, "ACE_Surrendered", false] call EFUNC(common,setCaptivityStatus);
if (isPlayer _unit) then {showHUD true};
}; };
[_this, "ACE_Surrendered", false] call EFUNC(common,setCaptivityStatus);
if (isPlayer _this) then {showHUD true};
}; };
[_surrenderFnc, 0.0, [_unit]] call CBA_fnc_addPerFrameHandler;
} else { } else {
_unit setVariable [QGVAR(isSurrender), false, true]; _unit setVariable [QGVAR(isSurrender), false, true];
}; };
/*
player playMove "AmovPercMstpSsurWnonDnon"
player switchMove "AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon"
*/

View File

@ -23,6 +23,6 @@ private ["_cargoIndex"];
_target moveInCargo _vehicle; _target moveInCargo _vehicle;
_target assignAsCargo _vehicle; _target assignAsCargo _vehicle;
_cargoIndex = _vehicle getCargoIndex _target; _cargoIndex = _vehicle getCargoIndex _target;
_target setVariable ["ACE_Captives_CargoIndex", _cargoIndex, true]; _target setVariable [QGVAR(CargoIndex), _cargoIndex, true];
TRACE_3("moveinEH",_target,_vehicle,_cargoIndex); TRACE_3("moveinEH",_target,_vehicle,_cargoIndex);

View File

@ -17,7 +17,7 @@
PARAMS_1(_unit); PARAMS_1(_unit);
_unit setVariable ["ACE_Captives_CargoIndex", -1, true]; _unit setVariable [QGVAR(CargoIndex), -1, true];
moveOut _unit; moveOut _unit;
[_unit, "ACE_AmovPercMstpScapWnonDnon", 2] call EFUNC(common,doAnimation); [_unit, "ACE_AmovPercMstpScapWnonDnon", 2] call EFUNC(common,doAnimation);