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);
@ -35,10 +35,34 @@ if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
if (!alive _target || {_unit distance _target > 10}) then {
TRACE_2("dead/distance",_unit,_target);
if ((_unit distance _target > 10) && {(CBA_missionTime - _startTime) < 1}) exitWith {
//attachTo seems to have some kind of network delay and target can return an odd position durring the first few frames,
//attachTo seems to have some kind of network delay and target can return an odd position durring the first few frames,
//so wait a full second to exit if out of range (this is critical as we would otherwise detach and set it's pos to weird pos)
TRACE_3("ignoring bad distance at start",_unit distance _target,_startTime,CBA_missionTime);
};
[_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

@ -35,7 +35,7 @@ if !(_unit getVariable [QGVAR(isDragging), false]) exitWith {
if (!alive _target || {_unit distance _target > 10}) then {
TRACE_2("dead/distance",_unit,_target);
if ((_unit distance _target > 10) && {(CBA_missionTime - _startTime) < 1}) exitWith {
//attachTo seems to have some kind of network delay and target can return an odd position durring the first few frames,
//attachTo seems to have some kind of network delay and target can return an odd position durring the first few frames,
//so wait a full second to exit if out of range (this is critical as we would otherwise detach and set it's pos to weird pos)
TRACE_3("ignoring bad distance at start",_unit distance _target,_startTime,CBA_missionTime);
};

View File

@ -2,7 +2,7 @@
#define COMPONENT_BEAUTIFIED Dragging
#include "\z\ace\addons\main\script_mod.hpp"
//#define DEBUG_ENABLED_DRAGGING
// #define DEBUG_ENABLED_DRAGGING
// #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS
@ -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