mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Improved drag and carry actions.
This commit is contained in:
parent
bbf9ce61f0
commit
7e5806b834
@ -204,28 +204,28 @@ ADD_TREATMENT_MEDICATION("STR_ACE_ACTION_EPINEPHRINE","STR_ACE_ACTION_EPINEPHRIN
|
||||
_caller = _this select 0;
|
||||
_target = _this select 1;
|
||||
|
||||
(isNull ([_caller] call EFUNC(common,getCarriedObj)) && isNull ([_target] call EFUNC(common,getCarriedObj)) && (vehicle _caller == _caller) && (vehicle _target == _target));
|
||||
(isNull ([_caller] call EFUNC(common,getCarriedObj)) && isNull ([_target] call EFUNC(common,getCarriedObj)) && (_caller != _target) && (vehicle _target == _target));
|
||||
}, {[_this select 0,_this select 1] call FUNC(actionDragUnit)},'drag'] call FUNC(addTreatmentOption);
|
||||
|
||||
["STR_ACE_ACTION_CARRY_PATIENT","STR_ACE_ACTION_CARRY_PATIENT_TOOLTIP",{
|
||||
_caller = _this select 0;
|
||||
_target = _this select 1;
|
||||
|
||||
(isNull ([_caller] call EFUNC(common,getCarriedObj)) && isNull ([_target] call EFUNC(common,getCarriedObj)) && (vehicle _caller == _caller) && (vehicle _target == _target));
|
||||
(isNull ([_caller] call EFUNC(common,getCarriedObj)) && isNull ([_target] call EFUNC(common,getCarriedObj)) && (_caller != _target) && (vehicle _target == _target));
|
||||
}, {[_this select 0,_this select 1] call FUNC(actionCarryUnit)},'drag'] call FUNC(addTreatmentOption);
|
||||
|
||||
["STR_ACE_ACTION_DRAG_PATIENT","STR_ACE_ACTION_DRAG_PATIENT_TOOLTIP",{
|
||||
["STR_ACE_ACTION_BODYBAG","STR_ACE_ACTION_BODYBAG_TOOLTIP",{
|
||||
_caller = _this select 0;
|
||||
_target = _this select 1;
|
||||
|
||||
(isNull ([_caller] call EFUNC(common,getCarriedObj)) && isNull ([_target] call EFUNC(common,getCarriedObj)) && (vehicle _caller == _caller) && (vehicle _target == _target) && ([_caller, _target] call FUNC(canPutInBodyBag)));
|
||||
(isNull ([_caller] call EFUNC(common,getCarriedObj)) && isNull ([_target] call EFUNC(common,getCarriedObj)) && (_caller != _target) && (vehicle _target == _target) && ([_caller, _target] call FUNC(canPutInBodyBag)));
|
||||
}, {[_this select 0,_this select 1] call FUNC(actionPlaceInBodyBag)},'drag'] call FUNC(addTreatmentOption);
|
||||
|
||||
["STR_ACE_ACTION_DROP_PATIENT","STR_ACE_ACTION_DROP_PATIENT_TOOLTIP",{
|
||||
_caller = _this select 0;
|
||||
_target = _this select 1;
|
||||
|
||||
(!(isNull ([_caller] call EFUNC(common,getCarriedObj))) && (vehicle _caller == _caller));
|
||||
(!(isNull ([_caller] call EFUNC(common,getCarriedObj))) && ([_caller] call FUNC(isMovingUnit)));
|
||||
}, {[_this select 0,_this select 1] call FUNC(actionDropUnit)},'drag'] call FUNC(addTreatmentOption);
|
||||
|
||||
["STR_ACE_ACTION_LOAD_PATIENT","STR_ACE_ACTION_LOAD_PATIENT_TOOLTIP",{
|
||||
|
@ -91,6 +91,8 @@ PREP(inMedicalFacility);
|
||||
PREP(isMedic);
|
||||
PREP(isMedicalVehicle);
|
||||
PREP(isSetTreatmentMutex);
|
||||
PREP(isMovingUnit);
|
||||
|
||||
|
||||
PREP(moduleAssignMedicalEquipment);
|
||||
PREP(moduleAssignMedicalFacility);
|
||||
|
@ -18,6 +18,7 @@
|
||||
private ["_caller", "_unit", "_positionUnit", "_killOnDrop"];
|
||||
_caller = [_this, 0, objNull, [objNull]] call BIS_fnc_param;
|
||||
_unit = [_this, 1, objNull, [objNull]] call BIS_fnc_param;
|
||||
_killOnDrop = [_this, 2, false, [false]] call BIS_fnc_param;
|
||||
|
||||
["FUNC(actionDragUnit) has been called",2] call EFUNC(common,debug);
|
||||
|
||||
@ -37,23 +38,29 @@ if (([_caller] call EFUNC(common,getCarriedObj)) != _unit && !(isNull ([_caller]
|
||||
};
|
||||
_caller action ["WeaponOnBack", _caller];
|
||||
_killOnDrop = false;
|
||||
if (!alive _unit) then {
|
||||
_unit = [_unit,_caller] call EFUNC(common,makeCopyOfBody_F);
|
||||
_killOnDrop = true;
|
||||
if (!alive _unit) exitwith {
|
||||
[_caller, false] call FUNC(treatmentMutex);
|
||||
[{
|
||||
_this call FUNC(actionCarryUnit);
|
||||
}, [_caller, ([_unit,_caller] call EFUNC(common,makeCopyOfBody_F)), _killOnDrop], 0.2, 0.2] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
|
||||
if !([_caller,_unit] call EFUNC(common,carryObj)) exitwith {
|
||||
["couldn't carry object!"] call EFUNC(common,debug); [_caller,"release"] call FUNC(treatmentMutex);
|
||||
};
|
||||
|
||||
if (primaryWeapon _caller == "") then {
|
||||
_caller addWeapon "ACE_FakePrimaryWeapon";
|
||||
};
|
||||
_caller selectWeapon (primaryWeapon _caller);
|
||||
|
||||
[_caller,"acinpercmstpsraswrfldnon",1] call EFUNC(common,doAnimation);
|
||||
_unit attachTo [_caller, [0.1, -0.1, -1.25], "LeftShoulder"];
|
||||
[_unit,"AinjPfalMstpSnonWnonDf_carried_dead",1] call EFUNC(common,doAnimation);
|
||||
|
||||
[_unit,"AinjPfalMstpSnonWnonDf_carried_dead", 1, true] call EFUNC(common,doAnimation);
|
||||
[_caller,"acinpercmstpsraswrfldnon", 1] call EFUNC(common,doAnimation);
|
||||
|
||||
_caller setvariable [QGVAR(StartingPositionHandleTreatment), getPos _caller];
|
||||
[1,
|
||||
[2,
|
||||
{((vehicle (_this select 0) != (_this select 0)) ||((getPos (_this select 0)) distance ((_this select 0) getvariable QGVAR(StartingPositionHandleTreatment)) < 1.5))}, // the condition
|
||||
{
|
||||
private ["_caller","_target"];
|
||||
|
@ -17,6 +17,7 @@ Executes: call
|
||||
private ["_caller", "_unit", "_positionUnit", "_killOnDrop"];
|
||||
_caller = [_this, 0, objNull, [objNull]] call BIS_fnc_param;
|
||||
_unit = [_this, 1, objNull, [objNull]] call BIS_fnc_param;
|
||||
_killOnDrop = [_this, 2, false, [false]] call BIS_fnc_param;
|
||||
|
||||
["FUNC(actionDragUnit) has been called",2] call EFUNC(common,debug);
|
||||
|
||||
@ -34,19 +35,30 @@ if (([_caller] call EFUNC(common,getCarriedObj)) != _unit && !(isNull ([_caller]
|
||||
[_caller,objNull] call EFUNC(common,carryObj);
|
||||
[_caller, false] call FUNC(treatmentMutex);
|
||||
};
|
||||
_caller action ["WeaponOnBack", _caller];
|
||||
_killOnDrop = false;
|
||||
if (!alive _unit) then {
|
||||
_unit = [_unit,_caller] call EFUNC(common,makeCopyOfBody_F);
|
||||
_killOnDrop = true;
|
||||
|
||||
if (!alive _unit) exitwith {
|
||||
[_caller, false] call FUNC(treatmentMutex);
|
||||
[{
|
||||
_this call FUNC(actionDragUnit);
|
||||
}, [_caller, ([_unit,_caller] call EFUNC(common,makeCopyOfBody_F)), _killOnDrop], 0.2, 0.2] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
|
||||
|
||||
if (primaryWeapon _caller == "") then {
|
||||
_caller addWeapon "ACE_FakePrimaryWeapon";
|
||||
};
|
||||
_caller selectWeapon (primaryWeapon _unit);
|
||||
|
||||
_unit setDir (getDir _unit + 180) % 360;
|
||||
_unit setPos ((getPos _unit) vectorAdd ((vectorDir _caller) vectorMultiply 1.5));
|
||||
|
||||
if !([_caller,_unit,[0.125, 1.007, 0]] call EFUNC(common,carryObj)) exitwith {
|
||||
[_caller, false] call FUNC(treatmentMutex);
|
||||
// well something went horribly wrong here, should never reach this, since we do checks above..
|
||||
|
||||
};
|
||||
|
||||
_unit setDir 180;
|
||||
[_unit,"AinjPpneMstpSnonWrflDb",true] call EFUNC(common,doAnimation);
|
||||
[_unit,"AinjPpneMstpSnonWrflDb", 1, true] call EFUNC(common,doAnimation);
|
||||
|
||||
_caller selectWeapon (primaryWeapon _caller); // if no primairy weapon, add a fake one first
|
||||
if (currentWeapon _caller == primaryWeapon _caller) then {
|
||||
@ -55,8 +67,9 @@ if (currentWeapon _caller == primaryWeapon _caller) then {
|
||||
[_caller,"AcinPknlMstpSnonWnonDnon", 1] call EFUNC(common,doAnimation);
|
||||
};
|
||||
|
||||
|
||||
_caller setvariable [QGVAR(StartingPositionHandleTreatment), getPos _caller];
|
||||
[1,
|
||||
[2,
|
||||
{((vehicle (_this select 0) != (_this select 0)) ||((getPos (_this select 0)) distance ((_this select 0) getvariable QGVAR(StartingPositionHandleTreatment)) < 1.5))}, // the condition
|
||||
{
|
||||
private ["_caller","_target"];
|
||||
|
@ -16,7 +16,7 @@ _caller = _this select 0;
|
||||
_target = _this select 1;
|
||||
_category = _this select 2;
|
||||
|
||||
if ((_category == "advanced" || _category == "airway" || _category == "drag") && (_caller == _target)) exitwith {
|
||||
if ((_category == "advanced" || _category == "airway") && (_caller == _target)) exitwith {
|
||||
[];
|
||||
};
|
||||
|
||||
|
@ -22,12 +22,11 @@ _dragging = _params select 3;
|
||||
|
||||
if ((isNull ([_caller] call EFUNC(common,getCarriedObj))) || !([_caller] call EFUNC(common,isAwake)) || (vehicle _caller != _caller)) then {
|
||||
|
||||
if (primaryWeapon _caller == "ACE_FakePrimaryWeapon") then {
|
||||
_caller removeWeapon "ACE_FakePrimaryWeapon";
|
||||
};
|
||||
|
||||
[_target, false] call EFUNC(common,disableAI_f);
|
||||
|
||||
[format["fnc_handleDropUnit: %1 - additional dropping of object", _caller]] call EFUNC(common,debug);
|
||||
[_caller,ObjNull] call EFUNC(common,carryObj);
|
||||
|
||||
[format["fnc_handleDropUnit: %1 - Clearing parameters", _caller]] call EFUNC(common,debug);
|
||||
_caller setvariable[QGVAR(onStartMovingUnitParams), nil];
|
||||
|
||||
// handle the drag & carry administration
|
||||
@ -39,32 +38,30 @@ if ((isNull ([_caller] call EFUNC(common,getCarriedObj))) || !([_caller] call EF
|
||||
_caller setvariable [QGVAR(carrying),nil,true];
|
||||
};
|
||||
|
||||
[format["fnc_handleDropUnit: %1 - Reset the variables", _caller]] call EFUNC(common,debug);
|
||||
// This is for good messure, the object should already have been dropped if it ever reaches this
|
||||
[_caller,ObjNull] call EFUNC(common,carryObj);
|
||||
|
||||
// handle the drag & carry animiations
|
||||
if ([_caller] call EFUNC(common,isAwake) && (vehicle _caller == _caller)) then {
|
||||
if (vehicle _caller == _caller) then {
|
||||
[_caller,"amovpercmstpsraswrfldnon_amovpknlmstpslowwrfldnon", 1] call EFUNC(common,doAnimation);
|
||||
[format["Placing animation: getting normal again", _caller]] call EFUNC(common,debug);
|
||||
};
|
||||
[_caller,"amovpercmstpsraswrfldnon_amovpknlmstpslowwrfldnon", 1] call EFUNC(common,doAnimation);
|
||||
};
|
||||
|
||||
if ([_target] call EFUNC(common,isAwake)) then {
|
||||
if (vehicle _target == _target) then {
|
||||
if (_dragging) then {
|
||||
[_target,"AinjPpneMstpSnonWrflDb_release",1] call EFUNC(common,doAnimation);
|
||||
} else {
|
||||
[_target,"",1] call EFUNC(common,doAnimation);
|
||||
};
|
||||
if (vehicle _target == _target) then {
|
||||
if (_dragging) then {
|
||||
[_target,"AinjPpneMstpSnonWrflDb_release", 1, true] call EFUNC(common,doAnimation);
|
||||
} else {
|
||||
[_target,"", 1] call EFUNC(common,doAnimation); // TODO play animation for the current seat instead
|
||||
[_target,"AinjPfalMstpSnonWrflDnon_carried_Down", 1, true] call EFUNC(common,doAnimation);
|
||||
};
|
||||
} else {
|
||||
// TODO play animation for dropping first.
|
||||
[_target,([_target] call EFUNC(common,getDeathAnim)), 1] call EFUNC(common,doAnimation);
|
||||
if ([_target] call EFUNC(common,isAwake)) then {
|
||||
[_target,"", 1] call EFUNC(common,doAnimation); // TODO play animation for the current seat instead
|
||||
} else {
|
||||
// this might not work properly
|
||||
[_target,([_target] call EFUNC(common,getDeathAnim)), 0] call EFUNC(common,doAnimation);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// Ensure that the unit does not get dropped through the floor of a building
|
||||
if (!surfaceIsWater getPos _caller) then {
|
||||
[{
|
||||
EXPLODE_3_PVT(_this,_caller,_target,_killOnDrop);
|
||||
@ -78,9 +75,8 @@ if ((isNull ([_caller] call EFUNC(common,getCarriedObj))) || !([_caller] call EF
|
||||
if (_killOnDrop) then {
|
||||
_unit setDamage 1;
|
||||
};
|
||||
|
||||
[format["fnc_handleDropUnit: %1 - passed setPosATL fix", _caller]] call EFUNC(common,debug);
|
||||
}, [_caller,_target,_killOnDrop], 0.5, 0.5] call EFUNC(common,waitAndExecute);
|
||||
|
||||
} else {
|
||||
if (_killOnDrop) then {
|
||||
_unit setDamage 1;
|
||||
|
16
addons/medical/functions/fnc_isMovingUnit.sqf
Normal file
16
addons/medical/functions/fnc_isMovingUnit.sqf
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* fnc_isMovingUnit.sqf
|
||||
* @Descr: N/A
|
||||
* @Author: Glowbal
|
||||
*
|
||||
* @Arguments: []
|
||||
* @Return:
|
||||
* @PublicAPI: false
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_unit";
|
||||
_unit = _this select 0;
|
||||
|
||||
(!(isNull(_unit getvariable [QGVAR(carrying),objNull])) || !(isNull(_unit getvariable [QGVAR(dragging),objNull])))
|
@ -16,7 +16,11 @@ _target = _this select 1;
|
||||
_selectionName = _this select 2;
|
||||
_removeItem = _this select 3;
|
||||
|
||||
if (primaryWeapon _caller == "ACE_FakePrimaryWeapon") then {
|
||||
_caller removeWeapon "ACE_FakePrimaryWeapon";
|
||||
};
|
||||
|
||||
[_caller,false] call FUNC(treatmentMutex);
|
||||
|
||||
// TODO: BUG: if AI finishes treatment, it will also hide the icon for the player
|
||||
[QGVAR(treatmentIconID), false, "", [1,1,1,1]] call EFUNC(gui,displayIcon);
|
||||
[QGVAR(treatmentIconID), false, "", [1,1,1,1]] call EFUNC(gui,displayIcon);
|
||||
|
Loading…
Reference in New Issue
Block a user