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 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";
distance = 4;
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)};
showDisabled = 0;
icon = QUOTE(PATHTOF(UI\captive_ca.paa));
@ -61,7 +61,7 @@ class CfgVehicles {
displayName = "$STR_ACE_Captives_FriskPerson";
distance = 2;
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;
//icon = ""; //@todo
priority = 3;
@ -97,7 +97,7 @@ class CfgVehicles {
displayName = "$STR_ACE_Captives_LoadCaptive"; \
distance = 4; \
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)}; \
showDisabled = 0; \
priority = 1.2; \
@ -107,7 +107,7 @@ class CfgVehicles {
displayName = "$STR_ACE_Captives_UnloadCaptive"; \
distance = 4; \
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; \
priority = 1.2; \
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

@ -4,8 +4,8 @@
*
* Arguments:
* 0: Unit that wants to load a captive <OBJECT>
* 1: A captive. ObjNull for the first escorted captive <OBJECT>
* 2: Vehicle to load the captive into. ObjNull for the nearest vehicle <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 (may be null) <OBJECT>
*
* Return Value:
* The return value <BOOL>
@ -24,15 +24,16 @@ PARAMS_3(_unit,_target,_vehicle);
if (isNull _target) then {
_objects = attachedObjects _unit;
_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 {
_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]
&& {!isNil "_target"}
&& {!isNil "_vehicle"}
(!isNull _target)
&& {!isNull _vehicle}
&& {_unit getVariable [QGVAR(isEscorting), false]}
&& {_target getVariable [QGVAR(isHandcuffed), false]}
&& {_vehicle emptyPositions "cargo" > 0}

View File

@ -34,21 +34,25 @@ if (_state) then {
{[(_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)))];
[_unit, _target, _actionID] spawn {
PARAMS_3(_unit,_target,_actionID);
while {_unit getVariable [QGVAR(isEscorting), false]} do {
sleep 0.2;
private "_escortFnc";
_escortFnc = {
EXPLODE_3_PVT((_this select 0),_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];
};
};
[objNull, _target] call EFUNC(common,claim);
detach _target;
_unit removeAction _actionID;
if (!(_unit getVariable [QGVAR(isEscorting), false])) then {
[(_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 {
_unit setVariable [QGVAR(isEscorting), false, true];
_unit setVariable [QGVAR(escortedUnit), objNull, true];

View File

@ -22,7 +22,7 @@ PARAMS_3(_vehicle,_dontcare,_unit);
if ((local _unit) && {_unit getVariable [QGVAR(isHandcuffed), false]}) then {
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 (_cargoIndex != -1) exitWith {

View File

@ -1,6 +1,6 @@
/*
* 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:
* 0: _oldUnit <OBJECT>
@ -22,5 +22,5 @@ if (_oldUnit getVariable [QGVAR(isHandcuffed), 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
* TODO
* Handles playerChanged. Resets "showHUD" based on handcuff status
*
* Arguments:
* 0: _unit <OBJECT>
* 0: _newUnit <OBJECT>
* 1: _oldUnit <OBJECT>
*
* Return Value:
@ -16,9 +16,9 @@
*/
#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;
} else {
showHUD true;

View File

@ -1,24 +1,24 @@
/*
* Author: commy2
* handle captive and unconsciousness state and prevent grenades
*
* Arguments:
* 0: _unit <OBJECT>
*
* Return Value:
* The return value <BOOL>
*
* Example:
* TODO
*
* Public: No
*/
* Author: commy2
* handle captive and unconsciousness state and prevent grenades
*
* Arguments:
* 0: _unit <OBJECT>
*
* Return Value:
* The return value <BOOL>
*
* Example:
* TODO
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_1(_unit);
// 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 {
// reset status on mission start

View File

@ -29,31 +29,34 @@ if (_state isEqualTo (_unit getVariable [QGVAR(isHandcuffed), false])) exitWith
if (_state) then {
_unit setVariable [QGVAR(isHandcuffed), true, true];
[_unit, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus);
// 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 {
[_this] call EFUNC(common,fixLoweredRifleAnimation);
[_this, "ACE_AmovPercMstpScapWnonDnon", 0] spawn EFUNC(common,doAnimation);
_fixAnimationFnc = {
PARAMS_1(_unit);
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 {
showHUD false;
};
} else {
_unit setVariable [QGVAR(isHandcuffed), false, true];
[_unit, QGVAR(Handcuffed), true] call EFUNC(common,setCaptivityStatus);
if (vehicle _unit == _unit) then {
[_unit, QGVAR(Handcuffed), false] call EFUNC(common,setCaptivityStatus);
if ((vehicle _unit) == _unit) then {
[_unit, "ACE_AmovPercMstpScapWnonDnon_AmovPercMstpSnonWnonDnon", 2] call EFUNC(common,doAnimation);
};
if (_unit getVariable ["ACE_Captives_CargoIndex", -1] != -1) then {
_unit setVariable ["ACE_Captives_CargoIndex", -1, true];
if (_unit getVariable [QGVAR(CargoIndex), -1] != -1) then {
_unit setVariable [QGVAR(CargoIndex), -1, true];
};
if (_unit == ACE_player) then {

View File

@ -26,38 +26,31 @@ if (_state) then {
_unit setVariable [QGVAR(isSurrender), true, true];
[_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 {
sleep 0.001; //sleep in UI
if (isPlayer _this) then {showHUD false};
if (!alive _this || {_this getVariable ["ACE_isUnconscious", false]}) then {
_this setVariable [QGVAR(isSurrender), false, true];
private "_surrenderFnc";
_surrenderFnc = {
EXPLODE_1_PVT((_this select 0),_unit);
if (_unit getVariable [QGVAR(isSurrender), false]) then {
if ((!alive _unit) || {_unit getVariable ["ACE_isUnconscious", false]} || {_unit getVariable [QGVAR(isHandcuffed), false]}) then {
_unit setVariable [QGVAR(isSurrender), false, true];
} else {
_this playMove "amovpercmstpsnonwnondnon_amovpercmstpssurwnondnon";
[_unit, "amovpercmstpsnonwnondnon_amovpercmstpssurwnondnon", 0] call EFUNC(common,doAnimation);
};
};
if !(_this getVariable ["ACE_isUnconscious", false]) then {
_this playMoveNow "AmovPercMstpSsurWnonDnon_AmovPercMstpSnonWnonDnon";
} else {
_this playMoveNow "unconscious";
if (!(_unit getVariable [QGVAR(isSurrender), false])) then {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
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 {
_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 assignAsCargo _vehicle;
_cargoIndex = _vehicle getCargoIndex _target;
_target setVariable ["ACE_Captives_CargoIndex", _cargoIndex, true];
_target setVariable [QGVAR(CargoIndex), _cargoIndex, true];
TRACE_3("moveinEH",_target,_vehicle,_cargoIndex);

View File

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