mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Improved unloadPerson function
Removed caller parameter.
This commit is contained in:
parent
9c02f915ec
commit
432a0102e8
@ -1,59 +1,44 @@
|
||||
/**
|
||||
* fn_unloadPerson_f.sqf
|
||||
* @Descr: Unload a person from a vehicle
|
||||
* @Author: Glowbal
|
||||
/*
|
||||
* Author: Glowbal
|
||||
* Unload a person from a vehicle
|
||||
*
|
||||
* @Arguments: [caller OBJECT, unit OBJECT]
|
||||
* @Return: BOOL Returns true if succesfully unloaded person
|
||||
* @PublicAPI: true
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Returns true if succesfully unloaded person <BOOL>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
#define GROUP_SWITCH_ID QUOTE(FUNC(loadPerson))
|
||||
|
||||
private ["_caller", "_unit","_vehicle", "_loaded"];
|
||||
_caller = [_this, 0, ObjNull,[ObjNull]] call BIS_fnc_Param;
|
||||
_unit = [_this, 1, ObjNull,[ObjNull]] call BIS_fnc_Param;
|
||||
private ["_unit","_vehicle", "_loaded", "_emptyPos"];
|
||||
_unit = _this select 0;
|
||||
_vehicle = vehicle _unit;
|
||||
|
||||
if (_vehicle == _unit) exitwith {false;};
|
||||
if !(speed _vehicle <1 && (((getpos _vehicle) select 2) < 2)) exitwith {false;};
|
||||
if (!([_caller] call FUNC(isAwake))) exitwith{false;};
|
||||
|
||||
moveOut _unit;
|
||||
_emptyPos = ((getPos _vehicle) findEmptyPosition [0, 10, typeof _unit]);
|
||||
if (count _emptyPos == 0) exitwith {false};
|
||||
|
||||
_unit setPos _emptyPos;
|
||||
unassignVehicle _unit;
|
||||
if (!alive _unit) then {
|
||||
_unit action ["Eject", vehicle _unit];
|
||||
};
|
||||
|
||||
[_unit, false, GROUP_SWITCH_ID, side group _caller] call FUNC(switchToGroupSide);
|
||||
[_unit, false, GROUP_SWITCH_ID, side group _unit] call FUNC(switchToGroupSide);
|
||||
|
||||
_loaded = _vehicle getvariable [QGVAR(loaded_persons),[]];
|
||||
_loaded = _loaded - [_unit];
|
||||
_vehicle setvariable [QGVAR(loaded_persons),_loaded,true];
|
||||
|
||||
if (!([_unit] call FUNC(isAwake))) then {
|
||||
_handle = [_unit,_vehicle] spawn {
|
||||
private ["_unit","_vehicle"];
|
||||
_unit = _this select 0;
|
||||
_vehicle = _this select 1;
|
||||
waituntil {vehicle _unit != _vehicle};
|
||||
[_unit,([_unit] call FUNC(getDeathAnim)), 1, true] call FUNC(doAnimation);
|
||||
[format["Unit should move into death anim: %1", _unit]] call FUNC(debug);
|
||||
};
|
||||
} else {
|
||||
if ([_unit] call FUNC(isArrested)) then {
|
||||
_handle = [_unit,_vehicle] spawn {
|
||||
_unit = _this select 0;
|
||||
_vehicle = _this select 1;
|
||||
waituntil {vehicle _unit != _vehicle};
|
||||
[_unit,"UnaErcPoslechVelitele2", 1] call FUNC(doAnimation);
|
||||
[format["Unit should move into arrested anim: %1", _unit]] call FUNC(debug);
|
||||
};
|
||||
} else {
|
||||
[format["Unit should move into normal anim: %1", _unit]] call FUNC(debug);
|
||||
};
|
||||
[_unit,([_unit] call FUNC(getDeathAnim)), 1, true] call FUNC(doAnimation);
|
||||
};
|
||||
|
||||
true;
|
||||
true;
|
||||
|
@ -24,7 +24,7 @@ _drag = if (count _this > 2) then {_this select 2} else {false};
|
||||
if (vehicle _target == _target) exitwith {};
|
||||
if (([_target] call cse_fnc_isAwake)) exitwith {};
|
||||
|
||||
if ([_caller, _target] call EFUNC(common,unloadPerson)) then {
|
||||
if ([_target] call EFUNC(common,unloadPerson)) then {
|
||||
if (_drag) then {
|
||||
if ((vehicle _caller) == _caller) then {
|
||||
[[_caller, _target, true], QUOTE(DFUNC(actionDragUnit)), _caller, false] call EFUNC(common,execRemoteFnc); // TODO replace by event
|
||||
|
Loading…
Reference in New Issue
Block a user