First draft of carry and drop unit

This commit is contained in:
Glowbal 2015-03-12 21:16:49 +01:00
parent e86270d03b
commit 4ce524ed3c
9 changed files with 197 additions and 3 deletions

View File

@ -11,6 +11,8 @@ PREP(actionPlaceInBodyBag);
PREP(actionRemoveTourniquet);
PREP(actionLoadUnit);
PREP(actionUnloadUnit);
PREP(actionCarryUnit);
PREP(actionDropUnit);
PREP(addHeartRateAdjustment);
PREP(addToInjuredCollection);
PREP(addToLog);
@ -49,6 +51,7 @@ PREP(isMedicalVehicle);
PREP(onMedicationUsage);
PREP(onWoundUpdateRequest);
PREP(onPropagateWound);
PREP(onCarryObjectDropped);
PREP(parseConfigForInjuries);
PREP(playInjuredSound);
PREP(reactionToDamage);

View File

@ -0,0 +1,83 @@
/*
* Author: Glowbal
* makes the calling unit start carrying the specified unit
*
* Arguments:
* 0: The caller <OBJECT>
* 1: The target <OBJECT>
* 2: Carry object. True is carry, false is dragging <BOOL>
*
* Return Value:
* NONE
*
* Public: No
*/
#include "script_component.hpp"
private ["_caller", "_target", "_positionUnit", "_carry"];
_caller = _this select 0;
_target = _this select 1;
_carry = _this select 2;
if (!(_target isKindOf "CaManBase") || !(_caller isKindOf "CaManBase")) exitwith{ };
if (vehicle _caller != _caller || vehicle _target != _target) exitwith {};
if (!([_caller] call EFUNC(common,canInteract)) || {_caller == _target} || {(([_target] call EFUNC(common,isAwake)))}) exitwith {};
_caller action ["WeaponOnBack", _caller];
if (!alive _target) exitwith {
if (missionNamespace getvariable [QGVAR(allowDeadbodyMovement), false]) then {
[{
_this call FUNC(actionCarryUnit);
}, [_caller, ([_target,_caller] call FUNC(makeCopyOfBody)), _carry], 0.25, 0.25] call EFUNC(common,waitAndExecute);
};
};
if !([_caller,_target] call EFUNC(common,carryObj)) exitwith {};
if (primaryWeapon _caller == "") then {
_caller addWeapon "ACE_FakePrimaryWeapon";
};
_caller selectWeapon (primaryWeapon _caller);
if (_carry) then {
_target attachTo [_caller, [0.1, -0.1, -1.25], "LeftShoulder"];
[_target, "AinjPfalMstpSnonWnonDf_carried_dead", 2, true] call EFUNC(common,doAnimation);
[_caller, "acinpercmstpsraswrfldnon", 1] call EFUNC(common,doAnimation);
} else {
_target attachTo [_caller, [0.125, 1.007, 0]];
_target setDir (getDir _target + 180) % 360;
_target setPos ((getPos _target) vectorAdd ((vectorDir _caller) vectorMultiply 1.5));
};
[
2,
[_caller, _target, _carry],
{
private ["_caller","_target"];
_caller = _this select 0;
_target = _this select 1;
_carry = _this select 2;
_target setvariable [QGVAR(beingCarried), _caller, true];
_caller setvariable [QGVAR(carrying), _target, true];
_caller setvariable [QGVAR(isCarrying), if (_carry) then {1} else {0}, true];
// Removing any old drop scroll wheel actions
// TODO Do we still want scroll wheel actions?
if (!isnil QGVAR(DROP_ADDACTION)) then {
_caller removeAction GVAR(DROP_ADDACTION);
GVAR(DROP_ADDACTION) = nil;
};
// Adding the drop scroll wheel action.
GVAR(DROP_ADDACTION) = _caller addAction [format["Drop %1",[_target] call EFUNC(common,getName)], {[_this select 1, _this select 2] call FUNC(actionDropUnit);}];
[_target, true] call EFUNC(common,disableAI);
},
{
[(_this select 0), objNull,[0, 0, 0]] call EFUNC(common,carryObj);
// TODO reset animations..
},
if (_carry) then {localize "STR_ACE_MEDICAL_ACTION_CARRY"} else {localize "STR_ACE_MEDICAL_ACTION_DRAG"},
{true}
] call EFUNC(common,progressBar);

View File

@ -11,7 +11,9 @@
*
* Public: No
*/
#include "script_component.hpp"
private ["_caller","_target"];
_caller = _this select 0;
_target = _this select 1;

View File

@ -11,7 +11,9 @@
*
* Public: No
*/
#include "script_component.hpp"
private ["_caller","_target","_title","_content"];
_caller = _this select 0;
_target = _this select 1;

View File

@ -0,0 +1,23 @@
/*
* Author: Glowbal
* Drop a unit if the caller nit is currently dragging or carrying a unit
*
* Arguments:
* 0: The caller <OBJECT>
*
* Return Value:
* NONE
*
* Public: No
*/
#include "script_component.hpp"
private "_caller";
_caller = _this select 0;
if (!isnil QGVAR(DROP_ADDACTION)) then {
[_caller,objNull] call EFUNC(common,carryObj);
_caller removeAction GVAR(DROP_ADDACTION);
GVAR(DROP_ADDACTION) = nil;
};

View File

@ -12,10 +12,8 @@
* Public: No
*/
#include "script_component.hpp"
private ["_caller", "_target","_vehicle", "_loaded"];
_caller = _this select 0;
_target = _this select 1;

View File

@ -27,7 +27,7 @@ if (([_target] call cse_fnc_isAwake)) exitwith {};
if ([_caller, _target] call EFUNC(common,unloadPerson)) then {
if (_drag) then {
if ((vehicle _caller) == _caller) then {
[[_caller, _target], QUOTE(DFUNC(actionDragUnit)), _caller, false] call BIS_fnc_MP;
[[_caller, _target, true], QUOTE(DFUNC(actionDragUnit)), _caller, false] call EFUNC(common,execRemoteFnc); // TODO replace by event
};
};
};

View File

@ -0,0 +1,71 @@
/*
* Author: Glowbal
* Called on event CarryObjectDropped
*
* Arguments:
* 0: The caller <OBJECT>
*
* Return Value:
* NONE
*
* Public: No
*/
#include "script_component.hpp"
private ["_unit","_params"];
_caller = _this select 0;
_target = _caller getvariable [QGVAR(carrying), objNull];
_carrying = _caller getvariable [QGVAR(isCarrying), -1];
if (_carrying >= 0) then {
_caller setvariable [QGVAR(isCarrying), -1, true];
if (primaryWeapon _caller == "ACE_FakePrimaryWeapon") then {
_caller removeWeapon "ACE_FakePrimaryWeapon";
};
[_target, false] call EFUNC(common,disableAI);
_caller setvariable[QGVAR(onStartMovingUnitParams), nil];
// handle the drag & carry administration
if (_dragging) then {
_target setvariable [QGVAR(beingDragged), nil, true];
_caller setvariable [QGVAR(dragging), nil, true];
} else {
_target setvariable [QGVAR(beingCarried), nil, true];
_caller setvariable [QGVAR(carrying), nil, true];
};
// handle the drag & carry animiations
if ([_caller] call EFUNC(common,isAwake) && (vehicle _caller == _caller)) then {
[_caller,"amovpercmstpsraswrfldnon_amovpknlmstpslowwrfldnon", 1] call EFUNC(common,doAnimation);
};
if (vehicle _target == _target) then {
if (_dragging) then {
[_target,"AinjPpneMstpSnonWrflDb_release", 2, true] call EFUNC(common,doAnimation);
} else {
[_target,"AinjPfalMstpSnonWrflDnon_carried_Down", 2, true] call EFUNC(common,doAnimation);
};
} else {
if ([_target] call EFUNC(common,isAwake)) then {
[_target,"", 2] call EFUNC(common,doAnimation); // TODO play animation for the current seat instead
} else {
// this might not work properly
[_target,([_target] call EFUNC(common,getDeathAnim)), 1] 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);
if (vehicle _target == _target && (vehicle _caller == _caller)) then {
// This will set the target body/unit on the correct position, so it doesn't fall through floors.
_positionUnit = getPosATL _target;
_positionUnit set [2, (getPosATL _caller) select 2];
_target setPosATL _positionUnit;
};
}, [_caller,_target], 0.5, 0.5] call EFUNC(common,waitAndExecute);
};
};

View File

@ -556,6 +556,18 @@
<Russian>%1 проводит вам интубацию</Russian>
<Spanish>%1 te está intubando</Spanish>
</Key>
<Key ID="STR_ACE_MEDICAL_CARRY">
<Original>Carry Patient</Original>
</Key>
<Key ID="STR_ACE_MEDICAL_DRAG">
<Original>Drag Patient</Original>
</Key>
<Key ID="STR_ACE_MEDICAL_LOAD">
<Original>Load Patient</Original>
</Key>
<Key ID="STR_ACE_MEDICAL_UNLOAD">
<Original>Unload Patient</Original>
</Key>
</Container>
</Package>