Merge pull request #243 from KoffeinFlummi/mediccarry

refining carrying injured persons
This commit is contained in:
commy2 2015-03-26 18:04:35 +01:00
commit 9fcb193064
38 changed files with 408 additions and 1341 deletions

View File

@ -1,5 +1,6 @@
class CfgActions {
// fixes pick up action on mine detectors, because all ACE items are of that simulationClass and BI doesn't seem to care
class None;
class TakeWeapon: None {
show = 0;

View File

@ -42,19 +42,3 @@ class Extended_Respawn_EventHandlers {
};
};
};
class Extended_Killed_EventHandlers {
class CAManBase {
class GVAR(dropObject) {
Killed = QUOTE(if (local (_this select 0)) then {[ARR_2(_this select 0, ObjNull)] call FUNC(carryObj)};);
};
};
};
class Extended_GetIn_EventHandlers {
class CAManBase {
class GVAR(dropObject) {
GetIn = QUOTE(if (local (_this select 0)) then {[ARR_2(_this select 0, ObjNull)] call FUNC(carryObj)};);
};
};
};

View File

@ -0,0 +1,76 @@
class CfgMovesBasic {
class Default;
class Actions {
// fixes grab animation with equipped pistol
class NoActions;
class PistolStandActions: NoActions {
grabDrag = "AmovPercMstpSlowWrflDnon_AcinPknlMwlkSlowWrflDb_2";
};
class LauncherKneelActions: NoActions {
grabDrag = "AmovPercMstpSlowWrflDnon_AcinPknlMwlkSlowWrflDb_2";
};
class CivilStandActions: NoActions {
grabDrag = "AmovPercMstpSlowWrflDnon_AcinPknlMwlkSlowWrflDb_2";
};
};
};
class CfgMovesMaleSdr: CfgMovesBasic {
class AgonyBase;
class AgonyBaseRfl;
class StandBase;
class HealBase;
class States {
// fixes being able to reload in some animations, can't remember now what exactly
class AinjPfalMstpSnonWnonDnon_carried_Down: AgonyBase {
canReload = 0;
};
class AinjPfalMstpSnonWnonDnon_carried_Up: AgonyBase {
canReload = 0;
};
class AinjPfalMstpSnonWrflDnon_carried_Down: AgonyBase {
canReload = 0;
};
class AinjPfalMstpSnonWrflDnon_carried_Up: AgonyBaseRfl {
canReload = 0;
};
class AmovPpneMstpSnonWnonDnon_injured;
class AinjPpneMstpSnonWnonDnon: AmovPpneMstpSnonWnonDnon_injured {
canReload = 0;
};
class AmovPpneMstpSrasWrflDnon_injured;
class AinjPpneMstpSnonWrflDnon: AmovPpneMstpSrasWrflDnon_injured {
canReload = 0;
};
// mark as on ladder animation
class LadderCivilStatic: StandBase {
ACE_isLadder = 1;
};
// dunno, important
class AmovPercMstpSnonWnonDnon_AcinPknlMwlkSnonWnonDb_1;
class AcinPknlMstpSnonWnonDnon: AmovPercMstpSnonWnonDnon_AcinPknlMwlkSnonWnonDb_1 {
enableDirectControl = 1;
};
class AcinPknlMwlkSnonWnonDb: AmovPercMstpSnonWnonDnon_AcinPknlMwlkSnonWnonDb_1 {
enableDirectControl = 1;
};
// fix falling back to unconsciousness animation and disable rotating in that state
class Unconscious: Default {
ConnectTo[] = {};
head = "headNo";
forceAim = 1;
static = 1;
};
// idk. Flummi?
class AinvPknlMstpSnonWnonDnon_medic0: HealBase {
variantsPlayer[] = {};
};
};
};

View File

@ -218,6 +218,7 @@ class CfgVoice {
displayName = "$STR_ACE_Common_NoVoice";
};
};
class CfgVoiceTypes {
class ACE_NoVoice {
name = "$STR_ACE_Common_NoVoice";

File diff suppressed because it is too large Load Diff

View File

@ -1,35 +0,0 @@
class CfgMovesBasic;
class CfgMovesMaleSdr: CfgMovesBasic {
class AgonyBase;
class AgonyBaseRfl;
class StandBase;
class States {
class AinjPfalMstpSnonWnonDnon_carried_Down: AgonyBase {
canReload = 0;
};
class AinjPfalMstpSnonWnonDnon_carried_Up: AgonyBase {
canReload = 0;
};
class AinjPfalMstpSnonWrflDnon_carried_Down: AgonyBase {
canReload = 0;
};
class AinjPfalMstpSnonWrflDnon_carried_Up: AgonyBaseRfl {
canReload = 0;
};
class AmovPpneMstpSnonWnonDnon_injured;
class AinjPpneMstpSnonWnonDnon: AmovPpneMstpSnonWnonDnon_injured {
canReload = 0;
};
class AmovPpneMstpSrasWrflDnon_injured;
class AinjPpneMstpSnonWrflDnon: AmovPpneMstpSrasWrflDnon_injured {
canReload = 0;
};
class LadderCivilStatic: StandBase {
ACE_isLadder = 1;
};
};
};

View File

@ -33,6 +33,8 @@ if (hasInterface) then {
_this lock (_this getVariable [QGVAR(lockStatus), locked _this]);
}] call FUNC(addEventhandler);
["setDir", {(_this select 0) setDir (_this select 1)}] call FUNC(addEventhandler);
// hack to get PFH to work in briefing
[QGVAR(onBriefingPFH), "onEachFrame", {
if (time > 0) exitWith {
@ -171,8 +173,6 @@ GVAR(OldPlayerWeapon) = currentWeapon ACE_player;
}, 0, []] call cba_fnc_addPerFrameHandler;
[QGVAR(StateArrested),false,true,QUOTE(ADDON)] call FUNC(defineVariable);
[QGVAR(carriedBy),objNull,false,QUOTE(ADDON)] call FUNC(defineVariable);
[QGVAR(carriedObj),objNull,false,QUOTE(ADDON)] call FUNC(defineVariable);
["VehicleSetFuel", {
PARAMS_2(_vehicle,_fuelLevel);

View File

@ -15,7 +15,6 @@ PREP(adminKick);
PREP(ambientBrightness);
PREP(applyForceWalkStatus);
PREP(ASLToPosition);
PREP(beingCarried);
PREP(binarizeNumber);
PREP(blurScreen);
PREP(cachedCall);
@ -23,8 +22,6 @@ PREP(canGetInPosition);
PREP(canInteract);
PREP(canInteractWith);
PREP(canUseWeapon);
PREP(carriedByObj);
PREP(carryObj);
PREP(changeProjectileDirection);
PREP(checkPBOs);
PREP(claim);
@ -58,8 +55,6 @@ PREP(fixPosition);
PREP(getAllDefinedSetVariables);
PREP(getAllGear);
PREP(getCaptivityStatus);
PREP(getCarriedBy);
PREP(getCarriedObj);
PREP(getConfigCommander);
PREP(getConfigGunner);
PREP(getDeathAnim);
@ -122,7 +117,6 @@ PREP(isModLoaded);
PREP(isPlayer);
PREP(isTurnedOut);
PREP(letterToCode);
PREP(limitMovementSpeed);
PREP(loadPerson);
PREP(loadPersonLocal);
PREP(loadSettingsFromProfile);
@ -160,7 +154,6 @@ PREP(serverLog);
PREP(setArrestState);
PREP(setCanInteract);
PREP(setCaptivityStatus);
PREP(setCarriedBy);
PREP(setDefinedVariable);
PREP(setDisableUserInputStatus);
PREP(setForceWalkStatus);

View File

@ -13,11 +13,16 @@ class CfgPatches {
};
#include "CfgEventHandlers.hpp"
#include "CfgSounds.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"
#include "CfgMagazines.hpp"
#include "CfgActions.hpp"
#include "CfgMoves.hpp"
#include "CfgVoice.hpp"
class ACE_Rsc_Display_Base {
idd = -1;
type = 0;
@ -126,9 +131,6 @@ class ACE_Settings {
#include <ProgressScreen.hpp>
#include <HintConfig.hpp>
#include <RscInfoType.hpp>
#include <FixPickup.hpp>
#include <FixAnimations.hpp>
#include <NoVoice.hpp>
class CfgUIGrids {
class IGUI {

View File

@ -1,12 +0,0 @@
/**
* fn_beingCarried.sqf
* @Descr: Check if object is being carried
* @Author: Glowbal
*
* @Arguments: [object OBJECT]
* @Return: BOOL True if object is being carried
* @PublicAPI: true
*/
#include "script_component.hpp"
!(isNull ([_this select 0] call FUNC(getCarriedObj)));

View File

@ -1,13 +0,0 @@
/**
* fn_carriedByObj.sqf
* @Descr: Check if object A is being carried by object B.
* @Author: Glowbal
*
* @Arguments: [object OBJECT, unit OBJECT]
* @Return: BOOL True if B is carrying A.
* @PublicAPI: true
*/
#include "script_component.hpp"
([(_this select 0)] call FUNC(getCarriedBy) == [(_this select 1)] call FUNC(getCarriedBy));

View File

@ -1,72 +0,0 @@
/**
* fn_carryObj.sqf
* @Descr: Have a unit carry an object. Use ObjNull for second parameter if you want the unit to carry nothing
* @Author: Glowbal
*
* @Arguments: [unit OBJECT, objectToCarry OBJECT, attachToVector ARRAY (Optional)]
* @Return: BOOL Returns true if succesful
* @PublicAPI: true
*/
#include "script_component.hpp"
private ["_unit","_to","_return", "_fallDown", "_carriedObj", "_positionUnit"];
_unit = [_this, 0,ObjNull, [ObjNull]] call bis_fnc_param;
_to = [_this, 1,ObjNull, [ObjNull]] call bis_fnc_param;
_fallDown = false;
if (count _this > 3) then {
_fallDown = _this select 3;
};
_return = false;
[format["fnc_carryObj - UNIT: %1 ATTEMPTS TO CARRY %2",_unit,_to],2] call FUNC(debug);
if (((typeName _to) == "OBJECT" && (isNull ([_unit] call FUNC(getCarriedObj)))) || isNull _to) then {
if (vehicle _unit != _unit) exitwith {};
if (!isNull _to) then {
if ((isNull ([_to] call FUNC(getCarriedObj))) && ([_unit] call FUNC(canInteract))) then {
_return = true;
_unit setvariable [QGVAR(carriedObj),_to,true];
if (_fallDown) then {
// [_unit,_fallDown] call FUNC(limitMovementSpeed);
};
[_to, _unit] call FUNC(setCarriedBy);
if (count _this > 2) then {
if (count (_this select 2) == 3) then {
_to attachTo [_unit,(_this select 2)];
[format["fnc_carryObj - UNIT: %1 TO %2 - attachTo offset: %3",_unit,_to,(_this select 2)],2] call FUNC(debug);
};
};
["carryObject", [_unit], [_unit, _to, _fallDown]] call EFUNC(common,targetEvent);
// ["carryObject", [_unit, _to, _fallDown]] call ace_common_fnc_localEvent;
};
} else {
if (!isNull ([_unit] call FUNC(getCarriedObj))) then {
[format["fnc_carryObj - UNIT: %1 DROPING CARRIED OBJECT",_unit],2] call FUNC(debug);
_carriedObj = ([_unit] call FUNC(getCarriedObj));
detach _carriedObj;
//_carriedObj setPosATL [(getPosATL _carriedObj) select 0, (getPosATL _carriedObj) select 1,0];
if (!surfaceIsWater getPos _unit) then {
_positionUnit = getPosATL _carriedObj;
_positionUnit set [2, ((getPosATL _unit) select 2) + 0.1];
_carriedObj setPosATL _positionUnit;
} else {
_positionUnit = getPosASL _carriedObj;
_positionUnit set [2, ((getPosASL _unit) select 2) + 0.1];
_carriedObj setPosASL _positionUnit;
};
[[_unit] call FUNC(getCarriedObj), objNull] call FUNC(setCarriedBy);
_unit setvariable [QGVAR(carriedObj),_to,true];
_return = true;
["carryObjectDropped", [_unit], [_unit, _to, _fallDown]] call EFUNC(common,targetEvent);
// ["carryObjectDropped", [_unit, _to, _fallDown]] call ace_common_fnc_localEvent;
};
};
} else {
[format["fnc_carryObj - UNIT: %1 FAILED TO CARRY %2 - not an object or already carrying",_unit,_to],2] call FUNC(debug);
};
_return

View File

@ -1,13 +0,0 @@
/**
* fn_getCarriedBy.sqf
* @Descr: Get the object that is carrying given unit or object
* @Author: Glowbal
*
* @Arguments: [unit OBJECT]
* @Return: OBJECT Returns the object that is carrying the unit. Otherwise returns ObjNull
* @PublicAPI: true
*/
#include "script_component.hpp"
((_this select 0) getvariable [QGVAR(carriedBy),objNull]);

View File

@ -1,13 +0,0 @@
/**
* fn_getCarriedObj.sqf
* @Descr: Grab the registered carried object
* @Author: Glowbal
*
* @Arguments: [unit OBJECT]
* @Return: OBJECT Returns the object that the unit is currently carrying. If not carrying, returns ObjNull
* @PublicAPI: true
*/
#include "script_component.hpp"
((_this select 0) getvariable [QGVAR(carriedObj),objNull]);

View File

@ -1,53 +0,0 @@
/**
* fn_limitMovementSpeed.sqf
* @Descr: Limits the movement speed of a unit
* @Author: Glowbal
*
* @Arguments: [unit OBJECT, fallDown BOOL (Optional)]
* @Return: void
* @PublicAPI: true
*/
#include "script_component.hpp"
private ["_unit","_carriedObj"];
_unit = _this select 0;
_fallDown = false;
if (count _this > 1) then {
_fallDown = _this select 1;
};
if ((_unit getvariable [QGVAR(limitMovementSpeed),false])) exitwith {
_unit setvariable [QGVAR(limitMovementSpeed),nil,true];
};
[{
private["_unit","_fallDown","_carriedObj"];
_unit = (_this select 0) select 0;
_fallDown = (_this select 0) select 1;
_carriedObj = [_unit] call FUNC(getCarriedObj);
if !(_unit getvariable [QGVAR(limitMovementSpeed),false]) exitwith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
if !((!isNull _carriedObj) && (alive _unit)) exitwith {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
if (speed _unit > 12 && vehicle _unit == _unit && isTouchingGround _unit) then {
_unit setVelocity [0,0,0];
if (_fallDown) then {
_unit playMove "amovppnemstpsraswrfldnon";
};
if (_carriedObj isKindOf "Man") then {
hint "You can not move this fast while transporting this person.";
} else {
hint "You can not move this fast while carrying this object";
};
[_unit,ObjNull] call FUNC(carryObj);
};
}, 0.5, [_unit,_fallDown] ] call CBA_fnc_addPerFrameHandler;

View File

@ -35,8 +35,6 @@ if (_unit distance _loadcar <= 10) then {
};
if (!isNull _vehicle) then {
[_unit, true, GROUP_SWITCH_ID, side group _caller] call FUNC(switchToGroupSide);
[_caller,objNull] call FUNC(carryObj);
[_unit,objNull] call FUNC(carryObj);
[[_unit, _vehicle,_caller], QUOTE(FUNC(loadPersonLocal)), _unit, false] call EFUNC(common,execRemoteFnc);
};
_vehicle

View File

@ -1,21 +0,0 @@
/**
* fn_setCarriedBy.sqf
* @Descr: Registers an object being carried by another object
* @Author: Glowbal
*
* @Arguments: [unitToBeCarried OBJECT, objectCarrying OBJECT]
* @Return: BOOL True if succesfully registered
* @PublicAPI: false
*/
#include "script_component.hpp"
private ["_unit","_to","_return"];
_unit = [_this, 0, ObjNull,[ObjNull]] call BIS_fnc_Param;
_to = [_this, 1, ObjNull,[ObjNull]] call BIS_fnc_Param;
_return = false;
if ((isNull ([_unit] call FUNC(getCarriedBy))) || isNull _to) then {
_return = true;
_unit setvariable [QGVAR(carriedBy),_to,true];
};
_return

View File

@ -13,6 +13,11 @@ class Extended_PostInit_EventHandlers {
};
class Extended_Init_EventHandlers {
class CAManBase {
class ADDON {
init = QUOTE(_this call DFUNC(initPerson));
};
};
class StaticWeapon {
class ADDON {
init = QUOTE(_this call DFUNC(initObject));

View File

@ -16,4 +16,10 @@ if (isNil "ACE_maxWeightCarry") then {
// release object on player change. This does work when returning to lobby, but not when hard disconnecting.
["playerChanged", {_this call DFUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler);
["playerVehicleChanged", {[ACE_player, objNull] call DFUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler);
["playerWeaponChanged", {_this call DFUNC(handlePlayerWeaponChanged)}] call EFUNC(common,addEventhandler);
// handle waking up dragged unit and falling unconscious while dragging
["medical_onUnconscious", {_this call DFUNC(handleUnconscious)}] call EFUNC(common,addEventhandler);
//@todo Captivity?

View File

@ -18,10 +18,14 @@ PREP(handleKilled);
PREP(handlePlayerChanged);
PREP(handlePlayerWeaponChanged);
PREP(handleScrollWheel);
PREP(handleUnconscious);
PREP(initObject);
PREP(initPerson);
PREP(isObjectOnObject);
PREP(setCarryable);
PREP(setDraggable);
PREP(startCarry);
PREP(startCarryPFH);
PREP(startDrag);
PREP(startDragPFH);

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]}
alive _target && {_target getVariable [QGVAR(canCarry), false]} && {animationState _target in ["", "unconscious"]}

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]}
alive _target && {_target getVariable [QGVAR(canDrag), false]} && {animationState _target in ["", "unconscious"]}

View File

@ -17,37 +17,34 @@ 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];
_target setDir _direction;
// 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];
};
["setDir", _target, [_target, _direction]] call EFUNC(common,targetEvent);
_unit setVariable [QGVAR(isCarrying), true, true];
_unit setVariable [QGVAR(carriedObject), _target, true];
@ -74,7 +71,7 @@ _actionID = _unit addAction [
_unit setVariable [QGVAR(ReleaseActionID), _actionID];
// check everything
[FUNC(carryObjectPFH), 0, [_unit, _target]] call CBA_fnc_addPerFrameHandler;
[FUNC(carryObjectPFH), 0.5, [_unit, _target]] call CBA_fnc_addPerFrameHandler;
// reset current dragging height.
GVAR(currentHeightChange) = 0;

View File

@ -1,11 +1,19 @@
// by commy2
#include "script_component.hpp"
#ifdef DEBUG_ENABLED_DRAGGING
systemChat format ["%1 carryObjectPFH running", time];
#endif
private ["_unit", "_target"];
_unit = _this select 0 select 0;
_target = _this select 0 select 1;
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
// drop if the crate is destroyed
if !([_target] call EFUNC(common,isAlive)) then {
[_unit, _target] call FUNC(dropObject_carry);

View File

@ -31,7 +31,11 @@ _position = _position vectorAdd [0, 0, _offset];
// attach object
_target attachTo [_unit, _position];
_target setDir _direction;
["setDir", _target, [_target, _direction]] call EFUNC(common,targetEvent);
if (_target isKindOf "CAManBase") then {
[_target, "AinjPpneMrunSnonWnonDb_still", 0, true] call EFUNC(common,doAnimation);
};
_unit setVariable [QGVAR(isDragging), true, true];
_unit setVariable [QGVAR(draggedObject), _target, true];
@ -58,7 +62,7 @@ _actionID = _unit addAction [
_unit setVariable [QGVAR(ReleaseActionID), _actionID];
// check everything
[FUNC(dragObjectPFH), 0, [_unit, _target]] call CBA_fnc_addPerFrameHandler;
[FUNC(dragObjectPFH), 0.5, [_unit, _target]] call CBA_fnc_addPerFrameHandler;
// reset current dragging height.
GVAR(currentHeightChange) = 0;

View File

@ -1,11 +1,19 @@
// by commy2
#include "script_component.hpp"
#ifdef DEBUG_ENABLED_DRAGGING
systemChat format ["%1 dragObjectPFH running", time];
#endif
private ["_unit", "_target"];
_unit = _this select 0 select 0;
_target = _this select 0 select 1;
if !(_unit getVariable [QGVAR(isDragging), false]) exitWith {
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
// drop if the crate is destroyed
if !([_target] call EFUNC(common,isAlive)) then {
[_unit, _target] call FUNC(dropObject);

View File

@ -27,12 +27,20 @@ _inBuilding = [_unit] call FUNC(isObjectOnObject);
_unit playAction "released";
// prevent collision damage
["fixCollision", _unit, _unit] call EFUNC(common,targetEvent);
["fixCollision", _unit] call EFUNC(common,localEvent);
["fixCollision", _target, _target] call EFUNC(common,targetEvent);
// release object
detach _target;
if (_target isKindOf "CAManBase") then {
if (_target getVariable ["ACE_isUnconscious", false]) then {
[_target, "unconscious", 2, true] call EFUNC(common,doAnimation);
} else {
[_target, "", 2, true] call EFUNC(common,doAnimation); //@todo "AinjPpneMrunSnonWnonDb_release" seems to fall back to unconsciousness anim.
};
};
_unit removeWeapon "ACE_FakePrimaryWeapon";
// prevent object from flipping inside buildings
@ -46,5 +54,7 @@ _unit setVariable [QGVAR(draggedObject), objNull, true];
// make object accesable for other units
[objNull, _target, true] call EFUNC(common,claim);
["fixPosition", _target, _target] call EFUNC(common,targetEvent);
["fixFloating", _target, _target] call EFUNC(common,targetEvent);
if !(_target isKindOf "CAManBase") then {
["fixPosition", _target, _target] call EFUNC(common,targetEvent);
["fixFloating", _target, _target] call EFUNC(common,targetEvent);
};

View File

@ -24,12 +24,28 @@ private "_inBuilding";
_inBuilding = [_unit] call FUNC(isObjectOnObject);
// prevent collision damage
["fixCollision", _unit, _unit] call EFUNC(common,targetEvent);
["fixCollision", _unit] call EFUNC(common,localEvent);
["fixCollision", _target, _target] call EFUNC(common,targetEvent);
// release object
detach _target;
// fix anim when aborting carrying persons
if (_target isKindOf "CAManBase" || {animationState _unit in CARRY_ANIMATIONS}) then {
if (vehicle _unit == _unit) 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); //@todo
};
};
// properly remove fake weapon
_unit removeWeapon "ACE_FakePrimaryWeapon";
// reselect weapon and re-enable sprint
_unit selectWeapon primaryWeapon _unit;
@ -46,5 +62,7 @@ _unit setVariable [QGVAR(carriedObject), objNull, true];
// make object accesable for other units
[objNull, _target, true] call EFUNC(common,claim);
["fixPosition", _target, _target] call EFUNC(common,targetEvent);
["fixFloating", _target, _target] call EFUNC(common,targetEvent);
if !(_target isKindOf "CAManBase") then {
["fixPosition", _target, _target] call EFUNC(common,targetEvent);
["fixFloating", _target, _target] call EFUNC(common,targetEvent);
};

View File

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

View File

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

View File

@ -0,0 +1,44 @@
// by commy2
#include "script_component.hpp"
private ["_unit", "_isUnconscious"];
_unit = _this select 0;
_isUnconscious = _this select 1;
private "_player";
_player = ACE_player;
if (_player getVariable [QGVAR(isDragging), false]) then {
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);
};
};
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);
};
};

View File

@ -0,0 +1,19 @@
/*
* Author: commy2
*
* Initialize variables for drag or carryable persons. Called from init EH.
*
* Argument:
* 0: Any Unit (Object)
*
* Return value:
* NONE.
*/
#include "script_component.hpp"
private "_unit";
_unit = _this select 0;
[_unit, true, [0,1.1,0.092], 180] call FUNC(setDraggable);
[_unit, true, [0.4,-0.1,-1.25], 195] call FUNC(setCarryable); // hard-coded selection: "LeftShoulder"

View File

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

View File

@ -0,0 +1,70 @@
/*
* Author: commy2
*
* Start the carrying process.
*
* Argument:
* 0: Unit that should do the carrying (Object)
* 1: Object to carry (Object)
*
* Return value:
* NONE.
*/
#include "script_component.hpp"
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);
};
private "_timer";
_timer = time + 5;
// handle objects vs persons
if (_target isKindOf "CAManBase") then {
// 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);
[_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);
};
// prevents draging and carrying at the same time
_unit setVariable [QGVAR(isCarrying), true, true];
// required for aborting animation
_unit setVariable [QGVAR(carriedObject), _target, true];
[FUNC(startCarryPFH), 0.2, [_unit, _target, _timer]] call CBA_fnc_addPerFrameHandler;

View File

@ -0,0 +1,49 @@
// by commy2
#include "script_component.hpp"
#ifdef DEBUG_ENABLED_DRAGGING
systemChat format ["%1 startCarryPFH running", time];
#endif
private ["_unit", "_target", "_timeOut"];
_unit = _this select 0 select 0;
_target = _this select 0 select 1;
_timeOut = _this select 0 select 2;
// handle aborting carry
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
// 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;
};
// handle persons vs objects
if (_target isKindOf "CAManBase") then {
if (time > _timeOut) exitWith {
[_unit, _target] call FUNC(carryObject);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
} else {
if (time > _timeOut) exitWith {
[_this select 1] call CBA_fnc_removePerFrameHandler;
// drop if in timeout
private "_draggedObject";
_draggedObject = _unit getVariable [QGVAR(draggedObject), objNull];
[_unit, _draggedObject] call FUNC(dropObject);
};
// wait for the unit to stand up
if (stance _unit == "STAND") exitWith {
[_unit, _target] call FUNC(carryObject);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
};

View File

@ -40,6 +40,14 @@ _unit selectWeapon primaryWeapon _unit;
// can't play action that depends on weapon if it was added the same frame
[{_this playActionNow "grabDrag";}, _unit] call EFUNC(common,execNextFrame);
// move a bit closer and adjust direction when trying to pick up a person
if (_target isKindOf "CAManBase") then {
_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
_unit setVariable [QGVAR(isDragging), true, true];

View File

@ -1,12 +1,27 @@
// by commy2
#include "script_component.hpp"
#ifdef DEBUG_ENABLED_DRAGGING
systemChat format ["%1 startDragPFH running", time];
#endif
private ["_unit", "_target", "_timeOut"];
_unit = _this select 0 select 0;
_target = _this select 0 select 1;
_timeOut = _this select 0 select 2;
// handle aborting drag
if !(_unit getVariable [QGVAR(isDragging), false]) exitWith {
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
// 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;
@ -14,13 +29,7 @@ if (time > _timeOut) exitWith {
// drop if in timeout
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

View File

@ -1,6 +1,8 @@
#define COMPONENT dragging
#include "\z\ace\addons\main\script_mod.hpp"
//#define DEBUG_ENABLED_DRAGGING
#ifdef DEBUG_ENABLED_DRAGGING
#define DEBUG_MODE_FULL
#endif
@ -12,3 +14,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"]