Disable collision with nearby players while carrying

This commit is contained in:
jonpas 2016-10-28 00:06:35 +02:00
parent e83791c246
commit e400a68427
4 changed files with 32 additions and 6 deletions

View File

@ -67,7 +67,7 @@ if (_target isKindOf "CAManBase") then {
};
// check everything
[FUNC(carryObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
[FUNC(carryObjectPFH), 0.5, [_unit, _target, CBA_missionTime, []]] call CBA_fnc_addPerFrameHandler;
// reset current dragging height.
GVAR(currentHeightChange) = 0;

View File

@ -1,5 +1,5 @@
/*
* Author: commy2
* Author: commy2, Jonpas
* PFH for Carry Object
*
* Arguments:
@ -24,7 +24,7 @@
#endif
params ["_args", "_idPFH"];
_args params ["_unit","_target", "_startTime"];
_args params ["_unit","_target", "_startTime", "_disabledCollisionObjects"];
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
TRACE_2("carry false",_unit,_target);
@ -42,3 +42,27 @@ if (!alive _target || {_unit distance _target > 10}) then {
[_unit, _target] call FUNC(dropObject_carry);
[_idPFH] call CBA_fnc_removePerFrameHandler;
};
// Disable collision with nearby players
TRACE_1("Disable collision objects",_disabledCollisionObjects);
private _nearUnits = _target nearObjects ["CAManBase", DISABLE_COLLISION_DISTANCE];
{
if !(_x in _disabledCollisionObjects) then {
TRACE_2("Adding disable collision object",_x,typeOf _x);
_target disableCollisionWith _x;
_disabledCollisionObjects pushBack _x;
};
} count _nearUnits;
_disabledCollisionObjects = _disabledCollisionObjects select {
if (_x in _nearUnits) then {
true
} else {
TRACE_2("Removing disable collision object",_x,typeOf _x);
_target enableCollisionWith _x;
false
};
};
_args set [3, _disabledCollisionObjects];

View File

@ -19,3 +19,5 @@
#define DRAG_ANIMATIONS ["amovpercmstpslowwrfldnon_acinpknlmwlkslowwrfldb_2", "amovpercmstpsraswpstdnon_acinpknlmwlksnonwpstdb_2", "amovpercmstpsnonwnondnon_acinpknlmwlksnonwnondb_2", "acinpknlmstpsraswrfldnon", "acinpknlmstpsnonwpstdnon", "acinpknlmstpsnonwnondnon", "acinpknlmwlksraswrfldb", "acinpknlmwlksnonwnondb"]
#define CARRY_ANIMATIONS ["acinpercmstpsnonwnondnon", "acinpknlmstpsnonwnondnon_acinpercmrunsnonwnondnon"]
#define DISABLE_COLLISION_DISTANCE 5