mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
setMass method to disable collisions
This commit is contained in:
parent
cea1599112
commit
6ac2906aba
@ -83,6 +83,11 @@
|
|||||||
_vehicle engineOn false;
|
_vehicle engineOn false;
|
||||||
}] call CBA_fnc_addEventHandler;
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
|
[QGVAR(setMass), {
|
||||||
|
params ["_object", "_mass"];
|
||||||
|
_object setMass _mass;
|
||||||
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
|
||||||
//Add a fix for BIS's zeus remoteControl module not reseting variables on DC when RC a unit
|
//Add a fix for BIS's zeus remoteControl module not reseting variables on DC when RC a unit
|
||||||
//This variable is used for isPlayer checks
|
//This variable is used for isPlayer checks
|
||||||
if (isServer) then {
|
if (isServer) then {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
/*
|
/*
|
||||||
* Author: commy2, Jonpas
|
* Author: commy2
|
||||||
* PFH for Carry Object
|
* PFH for Carry Object
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
@ -24,7 +24,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
params ["_args", "_idPFH"];
|
params ["_args", "_idPFH"];
|
||||||
_args params ["_unit","_target", "_startTime"];
|
_args params ["_unit", "_target", "_startTime"];
|
||||||
|
|
||||||
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
|
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
|
||||||
TRACE_2("carry false",_unit,_target);
|
TRACE_2("carry false",_unit,_target);
|
||||||
@ -35,37 +35,10 @@ if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
|
|||||||
if (!alive _target || {_unit distance _target > 10}) then {
|
if (!alive _target || {_unit distance _target > 10}) then {
|
||||||
TRACE_2("dead/distance",_unit,_target);
|
TRACE_2("dead/distance",_unit,_target);
|
||||||
if ((_unit distance _target > 10) && {(CBA_missionTime - _startTime) < 1}) exitWith {
|
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 during 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)
|
//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);
|
TRACE_3("ignoring bad distance at start",_unit distance _target,_startTime,CBA_missionTime);
|
||||||
};
|
};
|
||||||
[_unit, _target] call FUNC(dropObject_carry);
|
[_unit, _target] call FUNC(dropObject_carry);
|
||||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Disable collision with nearby players
|
|
||||||
private _disabledCollisionObjects = _target getVariable [QGVAR(disabledCollisionObjects), []];
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
false
|
|
||||||
} 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
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
_target setVariable [QGVAR(disabledCollisionObjects), _disabledCollisionObjects];
|
|
||||||
|
@ -76,3 +76,10 @@ if (_unit getVariable ["ACE_isUnconscious", false]) then {
|
|||||||
if (_target getVariable [QGVAR(isUAV), false]) then {
|
if (_target getVariable [QGVAR(isUAV), false]) then {
|
||||||
createVehicleCrew _target;
|
createVehicleCrew _target;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// reset mass
|
||||||
|
private _mass = _target getVariable [QGVAR(originalMass), 0];
|
||||||
|
|
||||||
|
if (_mass != 0) then {
|
||||||
|
[QEGVAR(setMass), [_target, _mass], _target] call CBA_fnc_targetEvent;
|
||||||
|
};
|
||||||
|
@ -77,7 +77,9 @@ if (_target getVariable [QGVAR(isUAV), false]) then {
|
|||||||
createVehicleCrew _target;
|
createVehicleCrew _target;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Reenable collision with nearby objects
|
// reset mass
|
||||||
{
|
private _mass = _target getVariable [QGVAR(originalMass), 0];
|
||||||
_target enableCollisionWith _x;
|
|
||||||
} forEach (_target getVariable [QGVAR(disabledCollisionObjects), []]);
|
if (_mass != 0) then {
|
||||||
|
[QEGVAR(setMass), [_target, _mass], _target] call CBA_fnc_targetEvent;
|
||||||
|
};
|
||||||
|
@ -73,3 +73,11 @@ _unit setVariable [QGVAR(isCarrying), true, true];
|
|||||||
_unit setVariable [QGVAR(carriedObject), _target, true];
|
_unit setVariable [QGVAR(carriedObject), _target, true];
|
||||||
|
|
||||||
[FUNC(startCarryPFH), 0.2, [_unit, _target, _timer]] call CBA_fnc_addPerFrameHandler;
|
[FUNC(startCarryPFH), 0.2, [_unit, _target, _timer]] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
|
// disable collisions by setting the physx mass to almost zero
|
||||||
|
private _mass = getMass _target;
|
||||||
|
|
||||||
|
if (_mass > 1) then {
|
||||||
|
_target setVariable [QGVAR(originalMass), _mass, true];
|
||||||
|
[QEGVAR(setMass), [_target, 1e-12], _target] call CBA_fnc_targetEvent;
|
||||||
|
};
|
||||||
|
@ -61,3 +61,11 @@ if (_target isKindOf "CAManBase") then {
|
|||||||
_unit setVariable [QGVAR(isDragging), true, true];
|
_unit setVariable [QGVAR(isDragging), true, true];
|
||||||
|
|
||||||
[FUNC(startDragPFH), 0.2, [_unit, _target, CBA_missionTime + 5]] call CBA_fnc_addPerFrameHandler;
|
[FUNC(startDragPFH), 0.2, [_unit, _target, CBA_missionTime + 5]] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
|
// disable collisions by setting the physx mass to almost zero
|
||||||
|
private _mass = getMass _target;
|
||||||
|
|
||||||
|
if (_mass > 1) then {
|
||||||
|
_target setVariable [QGVAR(originalMass), _mass, true];
|
||||||
|
[QEGVAR(setMass), [_target, 1e-12], _target] call CBA_fnc_targetEvent;
|
||||||
|
};
|
||||||
|
@ -19,5 +19,3 @@
|
|||||||
|
|
||||||
#define DRAG_ANIMATIONS ["amovpercmstpslowwrfldnon_acinpknlmwlkslowwrfldb_2", "amovpercmstpsraswpstdnon_acinpknlmwlksnonwpstdb_2", "amovpercmstpsnonwnondnon_acinpknlmwlksnonwnondb_2", "acinpknlmstpsraswrfldnon", "acinpknlmstpsnonwpstdnon", "acinpknlmstpsnonwnondnon", "acinpknlmwlksraswrfldb", "acinpknlmwlksnonwnondb"]
|
#define DRAG_ANIMATIONS ["amovpercmstpslowwrfldnon_acinpknlmwlkslowwrfldb_2", "amovpercmstpsraswpstdnon_acinpknlmwlksnonwpstdb_2", "amovpercmstpsnonwnondnon_acinpknlmwlksnonwnondb_2", "acinpknlmstpsraswrfldnon", "acinpknlmstpsnonwpstdnon", "acinpknlmstpsnonwnondnon", "acinpknlmwlksraswrfldb", "acinpknlmwlksnonwnondb"]
|
||||||
#define CARRY_ANIMATIONS ["acinpercmstpsnonwnondnon", "acinpknlmstpsnonwnondnon_acinpercmrunsnonwnondnon"]
|
#define CARRY_ANIMATIONS ["acinpercmstpsnonwnondnon", "acinpknlmstpsnonwnondnon_acinpercmrunsnonwnondnon"]
|
||||||
|
|
||||||
#define DISABLE_COLLISION_DISTANCE 5
|
|
||||||
|
Loading…
Reference in New Issue
Block a user