change height when carrying, fix most cases of floating objects

This commit is contained in:
commy2 2015-03-18 01:36:56 +01:00
parent dc7cfab06f
commit ab39608e4d
12 changed files with 101 additions and 50 deletions

View File

@ -20,8 +20,9 @@ if (hasInterface) then {
};
}] call FUNC(addEventhandler);
["fixCollision", FUNC(fixCollision)] call FUNC(addEventhandler);
["fixPosition", FUNC(fixPosition)] call FUNC(addEventhandler);
["fixCollision", DFUNC(fixCollision)] call FUNC(addEventhandler);
["fixFloating", DFUNC(fixFloating)] call FUNC(addEventhandler);
["fixPosition", DFUNC(fixPosition)] call FUNC(addEventhandler);
// hack to get PFH to work in briefing
[QGVAR(onBriefingPFH), "onEachFrame", {

View File

@ -56,6 +56,7 @@ PREP(execRemoteFnc);
PREP(executePersistent);
PREP(filter);
PREP(fixCollision);
PREP(fixFloating);
PREP(fixLoweredRifleAnimation);
PREP(fixPosition);
PREP(getAllDefinedSetVariables);

View File

@ -0,0 +1,32 @@
/*
* Author: commy2
* Attempt to fix floating physx with disabled damage after setPosXXX commands.
*
* Arguments:
* Physx object (Object)
*
* Return Value:
* Nothing
*
*/
#include "script_component.hpp"
private "_object";
_object = _this;
// setHitPointDamage requires local object
if (!local _object) exitWith {};
// save and restore hitpoints, see below why
private ["_hitPoints", "_hitPointDamages"];
_hitPoints = [_object] call FUNC(getHitpoints);
_hitPointDamages = [_hitPoints, {_object getHitPointDamage _this}] call FUNC(map);
// this prevents physx objects from floating when near other physx objects with allowDamage false
_object setDamage damage _object;
{
_object setHitPointDamage [_x, _hitPointDamages select _forEachIndex];
} forEach _hitPoints;

View File

@ -1,9 +1,7 @@
// by PabstMirror, commy2
#include "script_component.hpp"
GVAR(currentHeightChange) = 0;
//[{_this call DFUNC(handleScrollWheel)}] call FUNC(common,addScrollWheelEventHandler);
[{_this call DFUNC(handleScrollWheel)}] call EFUNC(common,addScrollWheelEventHandler);
if (isNil QGVAR(maxWeight)) then {
GVAR(maxWeight) = 800;

View File

@ -12,6 +12,7 @@ PREP(dragObject);
PREP(dragObjectPFH);
PREP(dropObject);
PREP(dropObject_carry);
PREP(handleScrollWheel);
PREP(initObject);
PREP(isObjectOnObject);
PREP(setCarryable);

View File

@ -5,7 +5,7 @@ class CfgPatches {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common","ace_interact_menu"};
requiredAddons[] = {"ace_common","ace_interaction","ace_interact_menu"};
author[] = {"https://github.com/commy2/"};
authorUrl = "";
VERSION_CONFIG;

View File

@ -6,25 +6,13 @@ private ["_unit", "_target"];
_unit = _this select 0 select 0;
_target = _this select 0 select 1;
// drop if the player is dead
if !([_unit] call EFUNC(common,isAlive)) exitWith {
[_unit, _target] call FUNC(dropObject_carry);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
// drop if the crate is destroyed
if !([_target] call EFUNC(common,isAlive)) exitWith {
[_unit, _target] call FUNC(dropObject_carry);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
// drop if not in carrying anim.
if (currentWeapon _unit != "") exitWith {
[_unit, _target] call FUNC(dropObject_carry);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
if !([_unit] call EFUNC(common,isPlayer)) exitWith {
if (
!([_unit] call EFUNC(common,isAlive)) // drop if the player is dead
|| {!([_target] call EFUNC(common,isAlive))} // drop if the crate is destroyed
|| {currentWeapon _unit != ""}
|| {stance _unit != "STAND"} // drop when crouching or inside a vehicle
|| {!([_unit] call EFUNC(common,isPlayer))}
) then {
[_unit, _target] call FUNC(dropObject_carry);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};

View File

@ -6,30 +6,13 @@ private ["_unit", "_target"];
_unit = _this select 0 select 0;
_target = _this select 0 select 1;
// drop if the player is dead
if !([_unit] call EFUNC(common,isAlive)) exitWith {
[_unit, _target] call FUNC(dropObject);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
// drop if the crate is destroyed
if !([_target] call EFUNC(common,isAlive)) exitWith {
[_unit, _target] call FUNC(dropObject);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
// drop if not in dragging anim. This also exits when entering a vehicle.
if !(animationState _unit in DRAG_ANIMATIONS) exitWith {
[_unit, _target] call FUNC(dropObject);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
if (currentWeapon _unit != primaryWeapon _unit) exitWith {
[_unit, _target] call FUNC(dropObject);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
if !([_unit] call EFUNC(common,isPlayer)) exitWith {
if (
!([_unit] call EFUNC(common,isAlive)) // drop if the player is dead
|| {!([_target] call EFUNC(common,isAlive))} // drop if the crate is destroyed
|| {!(animationState _unit in DRAG_ANIMATIONS)} // drop if not in dragging anim. This also exits when entering a vehicle.
|| {currentWeapon _unit != primaryWeapon _unit}
|| {!([_unit] call EFUNC(common,isPlayer))}
) then {
[_unit, _target] call FUNC(dropObject);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};

View File

@ -44,3 +44,4 @@ _unit setVariable [QGVAR(draggedObject), objNull, true];
[objNull, _target, true] call EFUNC(common,claim);
["fixPosition", _target, _target] call EFUNC(common,targetEvent);
["fixFloating", _target, _target] call EFUNC(common,targetEvent);

View File

@ -47,3 +47,4 @@ _unit setVariable [QGVAR(carriedObject), objNull, true];
[objNull, _target, true] call EFUNC(common,claim);
["fixPosition", _target, _target] call EFUNC(common,targetEvent);
["fixFloating", _target, _target] call EFUNC(common,targetEvent);

View File

@ -0,0 +1,45 @@
/*
* Author: L-H, commy2
*
* Handles raising and lowering the dragged weapon to be able to place it on top of objects.
*
* Argument:
* 0: Scroll amount (Number)
*
* Return value:
* Handled or not. (Bool)
*/
#include "script_component.hpp"
// requires modifier key to be hold down
if (GETMVAR(ACE_Modifier,0) == 0) exitWith {false};
private "_unit";
_unit = ACE_player;
// EH is always assigned. Exit and don't overwrite input if not carrying
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {false};
private "_scrollAmount";
_scrollAmount = _this select 0;
// move carried item 15 cm per scroll interval
_scrollAmount = _scrollAmount * 0.15;
private "_carriedItem";
_carriedItem = _unit getVariable [QGVAR(carriedObject),objNull];
private ["_position", "_maxHeight"];
_position = getPosATL _carriedItem;
_maxHeight = (_unit ModelToWorld [0,0,0]) select 2;
_position set [2, ((_position select 2) + _scrollAmount min (_maxHeight + 1.5)) max _maxHeight];
// move up/down object and reattach at current position
detach _carriedItem;
_carriedItem setPosATL _position;
_carriedItem attachTo [_unit];
true

View File

@ -53,7 +53,7 @@ GVAR(isOpeningDoor) = false;
["ACE3", QGVAR(modifierKey), localize "STR_ACE_Interaction_ModifierKey",
{
// Conditions: canInteract
if !([ACE_player, objNull, ["isNotDragging"]] call EGVAR(common,canInteractWith)) exitWith {false};
//if !([ACE_player, objNull, ["isNotDragging"]] call EGVAR(common,canInteractWith)) exitWith {false}; // not needed
// Statement
ACE_Modifier = 1;