mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
carrying unconscious persons
This commit is contained in:
parent
4ae3c22642
commit
ebe9d7ed5f
@ -17,36 +17,33 @@ private ["_unit", "_target"];
|
||||
_unit = _this select 0;
|
||||
_target = _this select 1;
|
||||
|
||||
// check weight
|
||||
private "_weight";
|
||||
_weight = [_target] call FUNC(getWeight);
|
||||
|
||||
if (_weight > GETMVAR(ACE_maxWeightCarry,1E11)) exitWith {
|
||||
[localize "STR_ACE_Dragging_UnableToDrag"] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
||||
// select no weapon and stop sprinting
|
||||
_unit action ["SwitchWeapon", _unit, _unit, 99];
|
||||
|
||||
[_unit, "isDragging", true] call EFUNC(common,setforceWalkStatus);
|
||||
|
||||
// prevent multiple players from accessing the same object
|
||||
[_unit, _target, true] call EFUNC(common,claim);
|
||||
|
||||
// get attachTo offset and direction.
|
||||
private ["_position", "_direction"];
|
||||
|
||||
_position = _target getVariable [QGVAR(carryPosition), [0, 0, 0]];
|
||||
_direction = _target getVariable [QGVAR(carryDirection), 0];
|
||||
|
||||
// add height offset of model
|
||||
private "_offset";
|
||||
_offset = (_target modelToWorld [0, 0, 0] select 2) - (_unit modelToWorld [0, 0, 0] select 2);
|
||||
// handle objects vs persons
|
||||
if (_target isKindOf "CAManBase") then {
|
||||
|
||||
_position = _position vectorAdd [0, 0, _offset];
|
||||
[_unit, "AcinPercMstpSnonWnonDnon", 2, true] call EFUNC(common,doAnimation);
|
||||
[_target, "AinjPfalMstpSnonWnonDf_carried_dead", 2, true] call EFUNC(common,doAnimation);
|
||||
|
||||
// attach object
|
||||
_target attachTo [_unit, _position];
|
||||
// attach person
|
||||
_target attachTo [_unit, _position, "LeftShoulder"];
|
||||
|
||||
} else {
|
||||
|
||||
// add height offset of model
|
||||
private "_offset";
|
||||
_offset = (_target modelToWorld [0, 0, 0] select 2) - (_unit modelToWorld [0, 0, 0] select 2);
|
||||
|
||||
_position = _position vectorAdd [0, 0, _offset];
|
||||
|
||||
// attach object
|
||||
_target attachTo [_unit, _position];
|
||||
|
||||
};
|
||||
_target setDir _direction;
|
||||
|
||||
_unit setVariable [QGVAR(isCarrying), true, true];
|
||||
|
@ -40,6 +40,17 @@ if (_target isKindOf "CAManBase") then {
|
||||
};
|
||||
};
|
||||
|
||||
// fix anim when aborting carrying persons
|
||||
if (animationState _unit in CARRY_ANIMATIONS) then {
|
||||
[_unit, "", 2, true] call EFUNC(common,doAnimation);
|
||||
|
||||
if (_target getVariable ["ACE_isUnconscious", false]) then {
|
||||
[_target, "unconscious", 2, true] call EFUNC(common,doAnimation);
|
||||
} else {
|
||||
[_target, "", 2, true] call EFUNC(common,doAnimation);
|
||||
};
|
||||
};
|
||||
|
||||
// reselect weapon and re-enable sprint
|
||||
_unit selectWeapon primaryWeapon _unit;
|
||||
|
||||
|
@ -20,12 +20,21 @@ if (_unit getVariable [QGVAR(isDragging), false]) then {
|
||||
|
||||
if (_unit getVariable [QGVAR(isCarrying), false]) then {
|
||||
|
||||
// drop carried object when selecting any weapon
|
||||
if (_weapon != "") then {
|
||||
private "_carriedObject";
|
||||
_carriedObject = _unit getVariable [QGVAR(carriedObject), objNull];
|
||||
private "_carriedObject";
|
||||
_carriedObject = _unit getVariable [QGVAR(carriedObject), objNull];
|
||||
|
||||
if (_carriedObject isKindOf "CAManBase") then {
|
||||
|
||||
if (_weapon != primaryWeapon _unit) then {
|
||||
[_unit, _carriedObject] call FUNC(dropObject_carry);
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
// drop carried object when selecting any weapon
|
||||
if (_weapon != "") then {
|
||||
[_unit, _carriedObject] call FUNC(dropObject_carry);
|
||||
};
|
||||
|
||||
[_unit, _carriedObject] call FUNC(dropObject_carry);
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -28,7 +28,10 @@ _scrollAmount = _this select 0;
|
||||
_scrollAmount = _scrollAmount * 0.15;
|
||||
|
||||
private "_carriedItem";
|
||||
_carriedItem = _unit getVariable [QGVAR(carriedObject),objNull];
|
||||
_carriedItem = _unit getVariable [QGVAR(carriedObject), objNull];
|
||||
|
||||
//disabled for persons
|
||||
if (_carriedItem isKindOf "CAManBase") exitWith {false};
|
||||
|
||||
private ["_position", "_maxHeight"];
|
||||
|
||||
|
@ -9,17 +9,36 @@ _isUnconscious = _this select 1;
|
||||
private "_player";
|
||||
_player = ACE_player;
|
||||
|
||||
if !(_player getVariable [QGVAR(isDragging), false]) exitWith {};
|
||||
if (_player getVariable [QGVAR(isDragging), false]) then {
|
||||
|
||||
private "_draggedObject";
|
||||
_draggedObject = _player getVariable [QGVAR(draggedObject), objNull];
|
||||
private "_draggedObject";
|
||||
_draggedObject = _player getVariable [QGVAR(draggedObject), objNull];
|
||||
|
||||
// handle falling unconscious
|
||||
if (_unit == _player) then {
|
||||
[_unit, _draggedObject] call FUNC(dropObject);
|
||||
};
|
||||
|
||||
// handle waking up dragged unit
|
||||
if (_unit == _draggedObject) then {
|
||||
[_player, _draggedObject] call FUNC(dropObject);
|
||||
};
|
||||
|
||||
// handle falling unconscious
|
||||
if (_unit == _player) then {
|
||||
[_unit, _draggedObject] call FUNC(dropObject);
|
||||
};
|
||||
|
||||
// handle waking up dragged unit
|
||||
if (_unit == _draggedObject) then {
|
||||
[_player, _draggedObject] call FUNC(dropObject);
|
||||
if (_player getVariable [QGVAR(isCarrying), false]) then {
|
||||
|
||||
private "_carriedObject";
|
||||
_carriedObject = _player getVariable [QGVAR(carriedObject), objNull];
|
||||
|
||||
// handle falling unconscious
|
||||
if (_unit == _player) then {
|
||||
[_unit, _carriedObject] call FUNC(dropObject_carry);
|
||||
};
|
||||
|
||||
// handle waking up dragged unit
|
||||
if (_unit == _carriedObject) then {
|
||||
[_player, _carriedObject] call FUNC(dropObject_carry);
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ if (_type in _initializedClasses) exitWith {};
|
||||
_initializedClasses pushBack _type;
|
||||
GVAR(initializedClasses_carry) = _initializedClasses;
|
||||
|
||||
_carryAction = [QGVAR(carry), localize "STR_ACE_Dragging_Carry", "", {[_player, _target] call FUNC(carryObject)}, {[_player, _target] call FUNC(canCarry)}] call EFUNC(interact_menu,createAction);
|
||||
_carryAction = [QGVAR(carry), localize "STR_ACE_Dragging_Carry", "", {[_player, _target] call FUNC(startCarry)}, {[_player, _target] call FUNC(canCarry)}] call EFUNC(interact_menu,createAction);
|
||||
_dropAction = [QGVAR(drop_carry), localize "STR_ACE_Dragging_Drop", "", {[_player, _target] call FUNC(dropObject_carry)}, {[_player, _target] call FUNC(canDrop_carry)}] call EFUNC(interact_menu,createAction);
|
||||
|
||||
[_type, 0, ["ACE_MainActions"], _carryAction] call EFUNC(interact_menu,addActionToClass);
|
||||
|
@ -25,33 +25,46 @@ if (_weight > GETMVAR(ACE_maxWeightCarry,1E11)) exitWith {
|
||||
[localize "STR_ACE_Dragging_UnableToDrag"] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
||||
// select no weapon and stop sprinting
|
||||
_unit action ["SwitchWeapon", _unit, _unit, 99];
|
||||
|
||||
[_unit, "isDragging", true] call EFUNC(common,setforceWalkStatus);
|
||||
|
||||
// prevent multiple players from accessing the same object
|
||||
[_unit, _target, true] call EFUNC(common,claim);
|
||||
|
||||
private "_timer";
|
||||
_timer = 2;
|
||||
_timer = time + 2;
|
||||
|
||||
// can't play action that depends on weapon if it was added the same frame
|
||||
/*[{_this playActionNow "grabDrag";}, _unit] call EFUNC(common,execNextFrame);*/ //@todo
|
||||
|
||||
// move a bit closer and adjust direction when trying to pick up a person
|
||||
// handle objects vs persons
|
||||
if (_target isKindOf "CAManBase") then {
|
||||
/*[_target, "AinjPpneMrunSnonWnonDb_grab", 2, true] call EFUNC(common,doAnimation);
|
||||
|
||||
// add a primary weapon if the unit has none.
|
||||
if (primaryWeapon _unit == "") then {
|
||||
_unit addWeapon "ACE_FakePrimaryWeapon";
|
||||
};
|
||||
|
||||
// select primary, otherwise the drag animation actions don't work.
|
||||
_unit selectWeapon primaryWeapon _unit;
|
||||
|
||||
// move a bit closer and adjust direction when trying to pick up a person
|
||||
_target setDir (getDir _unit + 180);
|
||||
_target setPos (getPos _unit vectorAdd (vectorDir _unit vectorMultiply 1.5));*/
|
||||
_target setPos (getPos _unit vectorAdd vectorDir _unit);
|
||||
|
||||
_timer = 15;
|
||||
[_unit, "AcinPknlMstpSnonWnonDnon_AcinPercMrunSnonWnonDnon", 2, true] call EFUNC(common,doAnimation);
|
||||
[_target, "AinjPfalMstpSnonWrflDnon_carried_Up", 2, true] call EFUNC(common,doAnimation);
|
||||
|
||||
_timer = time + 15;
|
||||
|
||||
} else {
|
||||
|
||||
// select no weapon and stop sprinting
|
||||
_unit action ["SwitchWeapon", _unit, _unit, 99];
|
||||
[_unit, "AmovPercMstpSnonWnonDnon", 0] call EFUNC(common,doAnimation);
|
||||
|
||||
[_unit, "isDragging", true] call EFUNC(common,setforceWalkStatus);
|
||||
|
||||
// prevent multiple players from accessing the same object
|
||||
[_unit, _target, true] call EFUNC(common,claim);
|
||||
|
||||
//@todo
|
||||
};
|
||||
|
||||
// prevents draging and carrying at the same time
|
||||
_unit setVariable [QGVAR(isCarrying), true, true];
|
||||
|
||||
[FUNC(startCarryPFH), 0.2, [_unit, _target], _timer] call CBA_fnc_addPerFrameHandler;
|
||||
// required for aborting animation
|
||||
_unit setVariable [QGVAR(carriedObject), _target, true];
|
||||
|
||||
[FUNC(startCarryPFH), 0.2, [_unit, _target, _timer]] call CBA_fnc_addPerFrameHandler;
|
||||
|
@ -7,17 +7,20 @@ _unit = _this select 0 select 0;
|
||||
_target = _this select 0 select 1;
|
||||
_timeOut = _this select 0 select 2;
|
||||
|
||||
// same as dragObjectPFH, checks if object is deleted or dead.
|
||||
if !([_target] call EFUNC(common,isAlive)) then {
|
||||
[_unit, _target] call FUNC(dropObject);
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
// timeout. Done with lifting object. Start carrying process.
|
||||
if (time > _timeOut) exitWith {
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
|
||||
// drop if in timeout
|
||||
private "_carriedObject";
|
||||
_carriedObject = _unit getVariable [QGVAR(carriedObject), objNull];
|
||||
|
||||
if (!isNull _carriedObject) exitWith {
|
||||
[_unit, _carriedObject] call FUNC(dropObject);
|
||||
// handles aborting carry
|
||||
if (_unit getVariable [QGVAR(isCarrying), false]) then {
|
||||
[_unit, _target] call FUNC(carryObject);
|
||||
};
|
||||
|
||||
[_unit, _target] call FUNC(carryObject);
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
// @todo, wait for stance _unit == "STAND"
|
||||
|
@ -42,9 +42,10 @@ _unit selectWeapon primaryWeapon _unit;
|
||||
|
||||
// move a bit closer and adjust direction when trying to pick up a person
|
||||
if (_target isKindOf "CAManBase") then {
|
||||
[_target, "AinjPpneMrunSnonWnonDb_grab", 2, true] call EFUNC(common,doAnimation);
|
||||
_target setDir (getDir _unit + 180);
|
||||
_target setPos (getPos _unit vectorAdd (vectorDir _unit vectorMultiply 1.5));
|
||||
|
||||
[_target, "AinjPpneMrunSnonWnonDb_grab", 2, true] call EFUNC(common,doAnimation);
|
||||
};
|
||||
|
||||
// prevents draging and carrying at the same time
|
||||
|
@ -7,6 +7,12 @@ _unit = _this select 0 select 0;
|
||||
_target = _this select 0 select 1;
|
||||
_timeOut = _this select 0 select 2;
|
||||
|
||||
// same as dragObjectPFH, checks if object is deleted or dead.
|
||||
if !([_target] call EFUNC(common,isAlive)) then {
|
||||
[_unit, _target] call FUNC(dropObject);
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
// timeout. Do nothing. Quit. time, because anim length is linked to ingame time.
|
||||
if (time > _timeOut) exitWith {
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
@ -15,17 +21,15 @@ if (time > _timeOut) exitWith {
|
||||
private "_draggedObject";
|
||||
_draggedObject = _unit getVariable [QGVAR(draggedObject), objNull];
|
||||
|
||||
if (!isNull _draggedObject) exitWith {
|
||||
[_unit, _draggedObject] call FUNC(dropObject);
|
||||
};
|
||||
|
||||
// re-enable everything
|
||||
_unit setVariable [QGVAR(isDragging), false, true];
|
||||
[_unit, _draggedObject] call FUNC(dropObject);
|
||||
};
|
||||
|
||||
// unit is ready to start dragging
|
||||
if (animationState _unit in DRAG_ANIMATIONS) exitWith {
|
||||
[_unit, _target] call FUNC(dragObject);
|
||||
// handles aborting dragging
|
||||
if (_unit getVariable [QGVAR(isDragging), false]) then {
|
||||
[_unit, _target] call FUNC(dragObject);
|
||||
};
|
||||
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
@ -12,3 +12,4 @@
|
||||
#include "\z\ace\addons\main\script_macros.hpp"
|
||||
|
||||
#define DRAG_ANIMATIONS ["amovpercmstpslowwrfldnon_acinpknlmwlkslowwrfldb_2", "amovpercmstpsraswpstdnon_acinpknlmwlksnonwpstdb_2", "amovpercmstpsnonwnondnon_acinpknlmwlksnonwnondb_2", "acinpknlmstpsraswrfldnon", "acinpknlmstpsnonwpstdnon", "acinpknlmstpsnonwnondnon", "acinpknlmwlksraswrfldb", "acinpknlmwlksnonwnondb"]
|
||||
#define CARRY_ANIMATIONS ["acinpercmstpsnonwnondnon", "acinpknlmstpsnonwnondnon_acinpercmrunsnonwnondnon"]
|
||||
|
Loading…
Reference in New Issue
Block a user