Merge pull request #928 from acemod/AdjustUnloadPerson

Adjust unload person
This commit is contained in:
Glowbal 2015-04-30 20:55:17 +02:00
commit 349d723fea
5 changed files with 27 additions and 41 deletions

View File

@ -73,7 +73,7 @@ if (_currentVersion != _previousVersion) then {
// Synced ACE events
// Handle JIP scenario
if(!isServer) then {
["PlayerJip", {
["PlayerJip", {
diag_log text format["[ACE] * JIP event synchronization initialized"];
["SEH_all", [player]] call FUNC(serverEvent);
}] call FUNC(addEventHandler);
@ -112,7 +112,7 @@ enableCamShake true;
// Set the name for the current player
["playerChanged", {
EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer);
if (alive _newPlayer) then {
[_newPlayer] call FUNC(setName)
};
@ -227,6 +227,7 @@ GVAR(OldIsCamera) = false;
["displayTextStructured", FUNC(displayTextStructured)] call FUNC(addEventhandler);
["displayTextPicture", FUNC(displayTextPicture)] call FUNC(addEventhandler);
["medical_onUnconscious", {if (local (_this select 0) && {!(_this select 1)}) then {[ _this select 0, false, QUOTE(FUNC(loadPerson)), west /* dummy side */] call FUNC(switchToGroupSide);};}] call FUNC(addEventhandler);
["notOnMap", {!visibleMap}] call FUNC(addCanInteractWithCondition);
["isNotInside", {
@ -243,10 +244,10 @@ GVAR(OldIsCamera) = false;
if(isMultiplayer && { time > 0 || isNull player } ) then {
// We are jipping! Get ready and wait, and throw the event
[{
if(!(isNull player)) then {
if(!(isNull player)) then {
["PlayerJip", [player] ] call FUNC(localEvent);
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
};
}, 0, []] call cba_fnc_addPerFrameHandler;
};

View File

@ -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;

View File

@ -22,4 +22,4 @@ if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
// a static weapon has to be empty for dragging
if ((typeOf _target) isKindOf "StaticWeapon" && {count crew _target > 0}) exitWith {false};
alive _target && {_target getVariable [QGVAR(canCarry), false]} && {animationState _target in ["", "unconscious"] || (_target getvariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})}
alive _target && {vehicle _target == _target} && {_target getVariable [QGVAR(canCarry), false]} && {animationState _target in ["", "unconscious"] || (_target getvariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})}

View File

@ -22,4 +22,4 @@ if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
// a static weapon has to be empty for dragging
if ((typeOf _target) isKindOf "StaticWeapon" && {count crew _target > 0}) exitWith {false};
alive _target && {_target getVariable [QGVAR(canDrag), false]} && {animationState _target in ["", "unconscious"] || (_target getvariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})};
alive _target && {vehicle _target == _target} && {_target getVariable [QGVAR(canDrag), false]} && {animationState _target in ["", "unconscious"] || (_target getvariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})};

View File

@ -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