mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
fix collisions when releasing, fix crate fliping in buildings
This commit is contained in:
parent
fef150cff2
commit
6d868d1bd1
@ -20,6 +20,7 @@ if (hasInterface) then {
|
||||
};
|
||||
}] call FUNC(addEventhandler);
|
||||
|
||||
["fixCollision", FUNC(fixCollision)] call FUNC(addEventhandler);
|
||||
["fixPosition", FUNC(fixPosition)] call FUNC(addEventhandler);
|
||||
|
||||
// hack to get PFH to work in briefing
|
||||
|
@ -55,7 +55,7 @@ PREP(execPersistentFnc);
|
||||
PREP(execRemoteFnc);
|
||||
PREP(executePersistent);
|
||||
PREP(filter);
|
||||
PREP(fixCollisions);
|
||||
PREP(fixCollision);
|
||||
PREP(fixLoweredRifleAnimation);
|
||||
PREP(fixPosition);
|
||||
PREP(getAllDefinedSetVariables);
|
||||
|
21
addons/common/functions/fnc_fixCollision.sqf
Normal file
21
addons/common/functions/fnc_fixCollision.sqf
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Attempt to fix physx collisions causing unreasonable impact forces and damage.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Object <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
// allowDamage requires local object
|
||||
if (!local _this) exitWith {};
|
||||
|
||||
// prevent collision damage, @todo allowDamage API
|
||||
_this allowDamage false;
|
||||
|
||||
// re-allow damage after 2 seconds
|
||||
[{_this allowDamage true}, _this, 2, 0] call EFUNC(common,waitAndExecute);
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Attempt to fix physx collisions causing unreasonable impact forces and damage.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Object <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_object";
|
||||
|
||||
_object = _this select 0;
|
||||
|
||||
if (!local _object) exitWith {};
|
||||
|
||||
// ignore collision damage
|
||||
_object setVariable [QGVAR(fixCollisionsDamage), damage _object];
|
||||
|
||||
private ["_ehID", "_vectorDirAndUp"];
|
||||
|
||||
_ehID = _object addEventHandler ["HandleDamage", {
|
||||
|
||||
if (isNull (_this select 3)) exitWith {
|
||||
(_this select 0) getVariable [QGVAR(fixCollisionsDamage), 0];
|
||||
};
|
||||
(_this select 0) setVariable [QGVAR(fixCollisionsDamage), _this select 2];
|
||||
|
||||
_this select 2
|
||||
|
||||
}];
|
||||
|
||||
_vectorDirAndUp = [vectorDir _object, vectorUp _object];
|
||||
|
||||
[{
|
||||
private ["_object", "_ehID", "_vectorDirAndUp", "_timeOut"];
|
||||
|
||||
_object = _this select 0 select 0;
|
||||
_ehID = _this select 0 select 1;
|
||||
_vectorDirAndUp = _this select 0 select 2;
|
||||
_timeOut = _this select 0 select 3;
|
||||
|
||||
// adjust vector to prevent fliping
|
||||
_object setVectorDirAndUp _vectorDirAndUp;systemChat str damage _object;//
|
||||
|
||||
if (time > _timeOut) exitWith {
|
||||
_object removeEventHandler ["HandleDamage", _ehID];hint str time;//
|
||||
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
}, 0, [_object, _ehID, _vectorDirAndUp, time + 2]] call CBA_fnc_addPerFrameHandler;
|
@ -8,6 +8,7 @@ PREP(dragObject);
|
||||
PREP(dragObjectPFH);
|
||||
PREP(dropObject);
|
||||
PREP(initObject);
|
||||
PREP(isObjectOnObject);
|
||||
PREP(setDraggable);
|
||||
PREP(startDrag);
|
||||
PREP(startDragPFH);
|
||||
|
@ -20,14 +20,24 @@ _target = _this select 1;
|
||||
// remove scroll wheel action
|
||||
_unit removeAction (_unit getVariable [QGVAR(ReleaseActionID), -1]);
|
||||
|
||||
private "_inBuilding";
|
||||
_inBuilding = [_unit] call FUNC(isObjectOnObject);
|
||||
|
||||
// play release animation
|
||||
_unit playAction "released";
|
||||
|
||||
// release object
|
||||
[_target] call EFUNC(common,fixCollisions);//"fixCollision"
|
||||
// prevent collision damage
|
||||
["fixCollision", _target, _target] call EFUNC(common,targetEvent);
|
||||
|
||||
// release object
|
||||
detach _target;
|
||||
|
||||
// prevent object from flipping inside buildings
|
||||
if (_inBuilding) then {
|
||||
_target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]);
|
||||
};
|
||||
|
||||
|
||||
_unit setVariable [QGVAR(isDragging), false, true];
|
||||
_unit setVariable [QGVAR(draggedObject), objNull, true];
|
||||
|
||||
|
6
addons/dragging/functions/fnc_isObjectOnObject.sqf
Normal file
6
addons/dragging/functions/fnc_isObjectOnObject.sqf
Normal file
@ -0,0 +1,6 @@
|
||||
// by commy2
|
||||
|
||||
private "_object";
|
||||
_object = _this select 0;
|
||||
|
||||
(getPosATL _object select 2) - (getPos _object select 2) > 1E-5
|
Loading…
Reference in New Issue
Block a user