mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #2086 from jokoho48/codeCleanUpDragging
Code cleanup of Dragging module
This commit is contained in:
commit
5bec26c721
@ -1,7 +1,7 @@
|
||||
// by PabstMirror, commy2
|
||||
#include "script_component.hpp"
|
||||
|
||||
[{_this call DFUNC(handleScrollWheel)}] call EFUNC(common,addScrollWheelEventHandler);
|
||||
[DFUNC(handleScrollWheel)] call EFUNC(common,addScrollWheelEventHandler);
|
||||
|
||||
if (isNil "ACE_maxWeightDrag") then {
|
||||
ACE_maxWeightDrag = 800;
|
||||
@ -15,11 +15,11 @@ if (isNil "ACE_maxWeightCarry") then {
|
||||
["isNotCarrying", {!((_this select 0) getVariable [QGVAR(isCarrying), false])}] call EFUNC(common,addCanInteractWithCondition);
|
||||
|
||||
// release object on player change. This does work when returning to lobby, but not when hard disconnecting.
|
||||
["playerChanged", {_this call DFUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler);
|
||||
["playerChanged", DFUNC(handlePlayerChanged)] call EFUNC(common,addEventhandler);
|
||||
["playerVehicleChanged", {[ACE_player, objNull] call DFUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler);
|
||||
["playerWeaponChanged", {_this call DFUNC(handlePlayerWeaponChanged)}] call EFUNC(common,addEventhandler);
|
||||
["playerWeaponChanged", DFUNC(handlePlayerWeaponChanged)] call EFUNC(common,addEventhandler);
|
||||
|
||||
// handle waking up dragged unit and falling unconscious while dragging
|
||||
["medical_onUnconscious", {_this call DFUNC(handleUnconscious)}] call EFUNC(common,addEventhandler);
|
||||
["medical_onUnconscious", DFUNC(handleUnconscious)] call EFUNC(common,addEventhandler);
|
||||
|
||||
//@todo Captivity?
|
||||
|
@ -2,4 +2,4 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
// release object on hard disconnection. Function is identical to killed
|
||||
addMissionEventHandler ["HandleDisconnect", {_this call DFUNC(handleKilled)}];
|
||||
addMissionEventHandler ["HandleDisconnect", DFUNC(handleKilled)];
|
||||
|
@ -3,19 +3,18 @@
|
||||
*
|
||||
* Check if unit can carry the object. Doesn't check weight.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit that should do the carrying (Object)
|
||||
* 1: Object to carry (Object)
|
||||
* Arguments:
|
||||
* 0: Unit that should do the carrying <OBJECT>
|
||||
* 1: Object to carry <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Can the unit carry the object? (Bool)
|
||||
* Return Value:
|
||||
* Can the unit carry the object? <BOOL>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_target"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_target = _this select 1;
|
||||
params ["_unit", "_target"];
|
||||
|
||||
if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
|
||||
|
@ -3,12 +3,14 @@
|
||||
*
|
||||
* Check if unit can drag the object. Doesn't check weight.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit that should do the dragging (Object)
|
||||
* 1: Object to drag (Object)
|
||||
* Arguments:
|
||||
* 0: Unit that should do the dragging <OBJECT>
|
||||
* 1: Object to drag <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Can the unit drag the object? (Bool)
|
||||
* Return Value:
|
||||
* Can the unit drag the object? <BOOL>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
@ -22,4 +24,4 @@ if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
// a static weapon has to be empty for dragging
|
||||
if ((typeOf _target) isKindOf "StaticWeapon" && {count crew _target > 0}) exitWith {false};
|
||||
|
||||
alive _target && {vehicle _target == _target} && {_target getVariable [QGVAR(canDrag), false]} && {animationState _target in ["", "unconscious"] || (_target getvariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})};
|
||||
alive _target && {vehicle _target == _target} && {_target getVariable [QGVAR(canDrag), false]} && {animationState _target in ["", "unconscious"] || (_target getvariable ["ACE_isUnconscious", false]) || (_target isKindOf "CAManBase" && {(_target getHitPointDamage "HitLegs") > 0.4})};
|
||||
|
@ -3,19 +3,18 @@
|
||||
*
|
||||
* Check if unit can drop the object.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit that currently drags a object (Object)
|
||||
* 1: Object that is dragged (Object)
|
||||
* Arguments:
|
||||
* 0: Unit that currently drags a object <OBJECT>
|
||||
* 1: Object that is dragged <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Can the unit drop the object? (Bool)
|
||||
* Return Value:
|
||||
* Can the unit drop the object? <BOOL>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_target"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_target = _this select 1;
|
||||
params ["_unit", "_target"];
|
||||
|
||||
if !([_unit, _target, ["isNotDragging"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
|
||||
|
@ -3,19 +3,18 @@
|
||||
*
|
||||
* Check if unit can drop the carried object.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit that currently carries a object (Object)
|
||||
* 1: Object that is carried (Object)
|
||||
* Arguments:
|
||||
* 0: Unit that currently carries a object <OBJECT>
|
||||
* 1: Object that is carried <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Can the unit drop the object? (Bool)
|
||||
* Return Value:
|
||||
* Can the unit drop the object? <BOOL>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_target"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_target = _this select 1;
|
||||
params ["_unit", "_target"];
|
||||
|
||||
if !([_unit, _target, ["isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
|
||||
|
@ -3,19 +3,18 @@
|
||||
*
|
||||
* Carry an object.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit that should do the carrying (Object)
|
||||
* 1: Object to carry (Object)
|
||||
* Arguments:
|
||||
* 0: Unit that should do the carrying <OBJECT>
|
||||
* 1: Object to carry <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* NONE.
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_target"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_target = _this select 1;
|
||||
params ["_unit", "_target"];
|
||||
|
||||
// get attachTo offset and direction.
|
||||
private ["_position", "_direction"];
|
||||
|
@ -1,21 +1,31 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* PFH for Carry Object
|
||||
*
|
||||
* Arguments:
|
||||
* ?
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
#ifdef DEBUG_ENABLED_DRAGGING
|
||||
systemChat format ["%1 carryObjectPFH running", ACE_time];
|
||||
#endif
|
||||
|
||||
private ["_unit", "_target"];
|
||||
|
||||
_unit = _this select 0 select 0;
|
||||
_target = _this select 0 select 1;
|
||||
params ["_args", "_idPFH"];
|
||||
_args params ["_unit","_target"];
|
||||
|
||||
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
// drop if the crate is destroyed OR (target moved away from carrier (weapon disasembled))
|
||||
if ((!([_target] call EFUNC(common,isAlive))) || {(_unit distance _target) > 10}) then {
|
||||
[_unit, _target] call FUNC(dropObject_carry);
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
@ -3,28 +3,25 @@
|
||||
*
|
||||
* Drag an object. Called from ace_dragging_fnc_startDrag
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit that should do the dragging (Object)
|
||||
* 1: Object to drag (Object)
|
||||
* Arguments:
|
||||
* 0: Unit that should do the dragging <OBJECT>
|
||||
* 1: Object to drag <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* NONE.
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_target"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_target = _this select 1;
|
||||
private ["_position", "_direction", "_offset", "_actionID"];
|
||||
params ["_unit", "_target"];
|
||||
|
||||
// get attachTo offset and direction.
|
||||
private ["_position", "_direction"];
|
||||
|
||||
_position = _target getVariable [QGVAR(dragPosition), [0, 0, 0]];
|
||||
_direction = _target getVariable [QGVAR(dragDirection), 0];
|
||||
|
||||
// add height offset of model
|
||||
private "_offset";
|
||||
_offset = (_target modelToWorldVisual [0, 0, 0] select 2) - (_unit modelToWorldVisual [0, 0, 0] select 2);
|
||||
|
||||
_position = _position vectorAdd [0, 0, _offset];
|
||||
@ -41,7 +38,6 @@ _unit setVariable [QGVAR(isDragging), true, true];
|
||||
_unit setVariable [QGVAR(draggedObject), _target, true];
|
||||
|
||||
// add scrollwheel action to release object
|
||||
private "_actionID";
|
||||
_actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
|
||||
|
||||
if (_actionID != -1) then {
|
||||
@ -50,7 +46,7 @@ if (_actionID != -1) then {
|
||||
|
||||
_actionID = _unit addAction [
|
||||
format ["<t color='#FF0000'>%1</t>", localize LSTRING(Drop)],
|
||||
QUOTE([ARR_2(_this select 0, (_this select 0) getVariable [ARR_2(QUOTE(QGVAR(draggedObject)),objNull)])] call FUNC(dropObject)),
|
||||
QUOTE(param ['_unit']; [ARR_2('_unit', ('_unit') getVariable [ARR_2(QUOTE(QGVAR(draggedObject)),objNull)])] call FUNC(dropObject)),
|
||||
nil,
|
||||
20,
|
||||
false,
|
||||
|
@ -1,21 +1,31 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* PFH for Drag Object
|
||||
*
|
||||
* Arguments:
|
||||
* ?
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
#ifdef DEBUG_ENABLED_DRAGGING
|
||||
systemChat format ["%1 dragObjectPFH running", ACE_time];
|
||||
#endif
|
||||
|
||||
private ["_unit", "_target"];
|
||||
|
||||
_unit = _this select 0 select 0;
|
||||
_target = _this select 0 select 1;
|
||||
params ["_args", "_idPFH"];
|
||||
_args params ["_unit", "_target"];
|
||||
|
||||
if !(_unit getVariable [QGVAR(isDragging), false]) exitWith {
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
// drop if the crate is destroyed OR (target moved away from carrier (weapon disasembled))
|
||||
if ((!([_target] call EFUNC(common,isAlive))) || {(_unit distance _target) > 10}) then {
|
||||
[_unit, _target] call FUNC(dropObject);
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
@ -3,19 +3,18 @@
|
||||
*
|
||||
* Drop a dragged object.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit that drags the other object (Object)
|
||||
* 1: Dragged object to drop (Object)
|
||||
* Arguments:
|
||||
* 0: Unit that drags the other object <OBJECT>
|
||||
* 1: Dragged object to drop <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* NONE.
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_target"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_target = _this select 1;
|
||||
params ["_unit", "_target"];
|
||||
|
||||
// remove scroll wheel action
|
||||
_unit removeAction (_unit getVariable [QGVAR(ReleaseActionID), -1]);
|
||||
|
@ -3,19 +3,18 @@
|
||||
*
|
||||
* Drop a carried object.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit that carries the other object (Object)
|
||||
* 1: Carried object to drop (Object)
|
||||
* Arguments:
|
||||
* 0: Unit that carries the other object <OBJECT>
|
||||
* 1: Carried object to drop <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* NONE.
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_target"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_target = _this select 1;
|
||||
params ["_unit", "_target"];
|
||||
|
||||
// remove scroll wheel action
|
||||
_unit removeAction (_unit getVariable [QGVAR(ReleaseActionID), -1]);
|
||||
|
@ -1,54 +1,45 @@
|
||||
/*
|
||||
Name: AGM_Drag_fnc_GetWeight
|
||||
|
||||
Author(s):
|
||||
L-H, edited by commy2
|
||||
|
||||
Description:
|
||||
Returns the weight of a crate.
|
||||
|
||||
Parameters:
|
||||
0: OBJECT - Crate to get weight of
|
||||
|
||||
Returns:
|
||||
NUMBER - Weight
|
||||
|
||||
Example:
|
||||
_weight = Crate1 call AGM_Drag_fnc_GetWeight;
|
||||
* Author: L-H, edited by commy2, rewritten by joko // Jonas
|
||||
*
|
||||
* Returns the weight of a crate.
|
||||
*
|
||||
* Arguments:
|
||||
* Crate to get weight of <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Total Weight <NUMBER>
|
||||
*
|
||||
* Example:
|
||||
* _weight = Crate1 call ace_dragging_fnc_getweight;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_object";
|
||||
private "_totalWeight";
|
||||
|
||||
_object = _this select 0;
|
||||
|
||||
private ["_totalWeight", "_fnc","_fnc_Extra"];
|
||||
// Initialize the total weight.
|
||||
_totalWeight = 0;
|
||||
_fnc_Extra = {
|
||||
private ["_weight", "_items"];
|
||||
_items = _this select 0;
|
||||
_weight = 0;
|
||||
{
|
||||
_weight = _weight + (getNumber (ConfigFile >> (_this select 1) >> _x >> (_this select 2) >> "mass") * ((_items select 1) select _foreachIndex));
|
||||
} foreach (_items select 0);
|
||||
|
||||
_weight
|
||||
};
|
||||
_fnc = {
|
||||
private ["_weight", "_items"];
|
||||
_items = _this select 0;
|
||||
_weight = 0;
|
||||
{
|
||||
_weight = _weight + (getNumber (ConfigFile >> (_this select 1) >> _x >> "mass") * ((_items select 1) select _foreachIndex));
|
||||
} foreach (_items select 0);
|
||||
|
||||
_weight
|
||||
};
|
||||
_totalWeight = ([getMagazineCargo _object, "CfgMagazines"] call _fnc);
|
||||
_totalWeight = _totalWeight + ([getItemCargo _object, "CfgWeapons", "ItemInfo"] call _fnc_Extra);
|
||||
_totalWeight = _totalWeight + ([getWeaponCargo _object, "CfgWeapons", "WeaponSlotsInfo"] call _fnc_Extra);
|
||||
_totalWeight = _totalWeight + ([getBackpackCargo _object, "CfgVehicles"] call _fnc);
|
||||
|
||||
_totalWeight = _totalWeight * 0.5; // Mass in Arma isn't an exact amount but rather a volume/weight value. This attempts to work around that by making it a usable value. (sort of).
|
||||
// Cycle through all item types with their assigned config paths.
|
||||
{
|
||||
_x params["_items","_getConfigCode"];
|
||||
_items params ["_item", "_count"]
|
||||
// Cycle through all items and read their mass out of the config.
|
||||
{
|
||||
// Multiply mass with amount of items and add the mass to the total weight.
|
||||
_totalWeight = _totalWeight + (getNumber ((call _getConfigCode) >> "mass") * (_count select _forEachIndex));
|
||||
} forEach _item;
|
||||
true
|
||||
} count [
|
||||
[getMagazineCargo _this, {configFile >> "CfgMagazines" >> _x}],
|
||||
[getBackpackCargo _this, {configFile >> "CfgVehicles" >> _x}],
|
||||
[getItemCargo _this, {configFile >> "CfgWeapons" >> _x >> "ItemInfo"}],
|
||||
[getWeaponCargo _this, {configFile >> "CfgWeapons" >> _x >> "WeaponSlotsInfo"}]
|
||||
];
|
||||
|
||||
_totalWeight
|
||||
// add Weight of create to totalWeight
|
||||
_totalWeight = _totalWeight + (getNumber (configFile >> "CfgVehicles" >> _this >> "mass"));
|
||||
|
||||
// Mass in Arma isn't an exact amount but rather a volume/weight value. This attempts to work around that by making it a usable value. (sort of).
|
||||
_totalWeight * 0.5
|
||||
|
@ -1,4 +1,20 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Handle the animaion for a Unit for Dragging Module
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: animaion <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [_unit, "amovpercmstpsnonwnondnon"] call ace_dragging_fnc_handleAnimChanged;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_anim"];
|
||||
|
@ -1,9 +1,22 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Handle death of the dragger
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [_unit] call ace_dragging_fnc_handleKilled;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_unit";
|
||||
|
||||
_unit = _this select 0;
|
||||
params ["_unit"];
|
||||
|
||||
if (_unit getVariable [QGVAR(isDragging), false]) then {
|
||||
private "_draggedObject";
|
||||
|
@ -1,10 +1,23 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Handle player changes.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: New Player Unit <OBJECT>
|
||||
* 1: Old Player Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [_unitNew, _unitOld] call ace_dragging_fnc_handlePlayerChanged;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_newPlayer", "_oldPlayer"];
|
||||
|
||||
_newPlayer = _this select 0;
|
||||
_oldPlayer = _this select 1;
|
||||
params ["_newPlayer", "_oldPlayer"];
|
||||
|
||||
{
|
||||
if (_x getVariable [QGVAR(isDragging), false]) then {
|
||||
|
@ -1,10 +1,23 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Handle the Weapon Changed Event
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Weapon <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [_unit, _currentWeapon] call ace_dragging_fnc_handlePlayerWeaponChanged;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_weapon"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_weapon = _this select 1;
|
||||
params ["_unit", "_weapon"];
|
||||
|
||||
if (_unit getVariable [QGVAR(isDragging), false]) then {
|
||||
|
||||
|
@ -3,38 +3,38 @@
|
||||
*
|
||||
* Handles raising and lowering the dragged weapon to be able to place it on top of objects.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Scroll amount (Number)
|
||||
* Arguments:
|
||||
* 0: Scroll amount <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* Handled or not. (Bool)
|
||||
* Return Value:
|
||||
* Handled or not. <BOOL>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
// requires modifier key to be hold down
|
||||
if (GETMVAR(ACE_Modifier,0) == 0) exitWith {false};
|
||||
private ["_unit", "_carriedItem", "_position", "_maxHeight"];
|
||||
|
||||
params ["_scrollAmount"];
|
||||
|
||||
// requires modifier key to be hold down
|
||||
if (missionNamespace getVariable ["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];
|
||||
|
||||
//disabled for persons
|
||||
if (_carriedItem isKindOf "CAManBase") exitWith {false};
|
||||
|
||||
private ["_position", "_maxHeight"];
|
||||
|
||||
_position = getPosATL _carriedItem;
|
||||
_maxHeight = (_unit modelToWorldVisual [0,0,0]) select 2;
|
||||
|
||||
|
@ -1,17 +1,29 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Handle the Unconscious of a Unit while Dragging
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [_unit] call ace_dragging_fnc_handleUnconscious;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_isUnconscious"];
|
||||
private ["_player", "_draggedObject", "_carriedObject"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_isUnconscious = _this select 1;
|
||||
params ["_unit"];
|
||||
|
||||
private "_player";
|
||||
_player = ACE_player;
|
||||
|
||||
if (_player getVariable [QGVAR(isDragging), false]) then {
|
||||
|
||||
private "_draggedObject";
|
||||
_draggedObject = _player getVariable [QGVAR(draggedObject), objNull];
|
||||
|
||||
// handle falling unconscious
|
||||
@ -28,7 +40,6 @@ if (_player getVariable [QGVAR(isDragging), false]) then {
|
||||
|
||||
if (_player getVariable [QGVAR(isCarrying), false]) then {
|
||||
|
||||
private "_carriedObject";
|
||||
_carriedObject = _player getVariable [QGVAR(carriedObject), objNull];
|
||||
|
||||
// handle falling unconscious
|
||||
|
@ -4,32 +4,29 @@
|
||||
* Initialize variables for drag or carryable objects. Called from init EH.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Any object (Object)
|
||||
* 0: Any object <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* NONE.
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_object";
|
||||
private ["_position", "_direction", "config"];
|
||||
|
||||
_object = _this select 0;
|
||||
params ["_object"];
|
||||
|
||||
private "_config";
|
||||
_config = configFile >> "CfgVehicles" >> typeOf _object;
|
||||
|
||||
if (getNumber (_config >> QGVAR(canDrag)) == 1) then {
|
||||
private ["_position", "_direction"];
|
||||
|
||||
_position = getArray (_config >> QGVAR(dragPosition));
|
||||
_direction = getNumber (_config >> QGVAR(dragDirection));
|
||||
|
||||
[_object, true, _position, _direction] call FUNC(setDraggable);
|
||||
};
|
||||
|
||||
if (getNumber (_config >> QGVAR(canCarry)) == 1) then {
|
||||
private ["_position", "_direction"];
|
||||
|
||||
if (getNumber (_config >> QGVAR(canCarry)) == 1) then
|
||||
_position = getArray (_config >> QGVAR(carryPosition));
|
||||
_direction = getNumber (_config >> QGVAR(carryDirection));
|
||||
|
||||
|
@ -4,16 +4,16 @@
|
||||
* Initialize variables for drag or carryable persons. Called from init EH.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Any Unit (Object)
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* NONE.
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private "_unit";
|
||||
|
||||
_unit = _this select 0;
|
||||
params ["_unit"];
|
||||
|
||||
[_unit, true, [0,1.1,0.092], 180] call FUNC(setDraggable);
|
||||
[_unit, true, [0.4,-0.1,-1.25], 195] call FUNC(setCarryable); // hard-coded selection: "LeftShoulder"
|
||||
|
@ -1,6 +1,16 @@
|
||||
// by commy2
|
||||
|
||||
private "_object";
|
||||
_object = _this select 0;
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Check if Object is Overlapping
|
||||
*
|
||||
* Argument:
|
||||
* 0: Object <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* <BOOL>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
params ["_object"];
|
||||
|
||||
(getPosATL _object select 2) - (getPos _object select 2) > 1E-5
|
||||
|
@ -4,25 +4,21 @@
|
||||
* Enable the object to be carried.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Any object (Object)
|
||||
* 1: true to enable carrying, false to disable (Bool)
|
||||
* 2: Position offset for attachTo command (Array, optinal; default: [0,1,1])
|
||||
* 3: Direction in degree to rotate the object after attachTo (Number, optional; default: 0)
|
||||
* 0: Any object <OBJECT>
|
||||
* 1: true to enable carrying, false to disable <BOOL>
|
||||
* 2: Position offset for attachTo command <ARRAY> (default: [0,1,1])
|
||||
* 3: Direction in degree to rotate the object after attachTo <NUMBER> (default: 0)
|
||||
*
|
||||
* Return value:
|
||||
* NONE.
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_carryAction", "_dropAction", "_object", "_enableCarry", "_position", "_direction"];
|
||||
//IGNORE_PRIVATE_WARNING("_player", "_target");
|
||||
private ["_carryAction", "_dropAction", "_type", "_initializedClasses"];
|
||||
|
||||
_this resize 4;
|
||||
|
||||
_object = _this select 0;
|
||||
_enableCarry = _this select 1;
|
||||
_position = _this select 2;
|
||||
_direction = _this select 3;
|
||||
params ["_object", "_enableCarry", "_position", "_direction"];
|
||||
|
||||
if (isNil "_position") then {
|
||||
_position = _object getVariable [QGVAR(carryPosition), [0,1,1]];
|
||||
@ -38,8 +34,6 @@ _object setVariable [QGVAR(carryPosition), _position];
|
||||
_object setVariable [QGVAR(carryDirection), _direction];
|
||||
|
||||
// add action to class if it is not already present
|
||||
private ["_type", "_initializedClasses"];
|
||||
|
||||
_type = typeOf _object;
|
||||
_initializedClasses = GETGVAR(initializedClasses_carry,[]);
|
||||
|
||||
|
@ -10,19 +10,15 @@
|
||||
* 3: Direction in degree to rotate the object after attachTo (Number, optional; default: 0)
|
||||
*
|
||||
* Return value:
|
||||
* NONE.
|
||||
* None
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_dragAction", "_dropAction", "_object", "_enableDrag", "_position", "_direction"];
|
||||
private ["_dragAction", "_dropAction", "_type", "_initializedClasses"];
|
||||
//IGNORE_PRIVATE_WARNING("_player", "_target");
|
||||
|
||||
_this resize 4;
|
||||
|
||||
_object = _this select 0;
|
||||
_enableDrag = _this select 1;
|
||||
_position = _this select 2;
|
||||
_direction = _this select 3;
|
||||
params ["_object", "_enableDrag", "_position", "_direction"];
|
||||
|
||||
if (isNil "_position") then {
|
||||
_position = _object getVariable [QGVAR(dragPosition), [0,0,0]];
|
||||
@ -38,8 +34,6 @@ _object setVariable [QGVAR(dragPosition), _position];
|
||||
_object setVariable [QGVAR(dragDirection), _direction];
|
||||
|
||||
// add action to class if it is not already present
|
||||
private ["_type", "_initializedClasses"];
|
||||
|
||||
_type = typeOf _object;
|
||||
_initializedClasses = GETGVAR(initializedClasses,[]);
|
||||
|
||||
|
@ -3,29 +3,28 @@
|
||||
*
|
||||
* Start the carrying process.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit that should do the carrying (Object)
|
||||
* 1: Object to carry (Object)
|
||||
* Arguments:
|
||||
* 0: Unit that should do the carrying <OBJECT>
|
||||
* 1: Object to carry <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* NONE.
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_target"];
|
||||
private ["_weight", "_timer"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_target = _this select 1;
|
||||
params ["_unit", "_target"];
|
||||
|
||||
// check weight
|
||||
private "_weight";
|
||||
_weight = [_target] call FUNC(getWeight);
|
||||
|
||||
if (_weight > GETMVAR(ACE_maxWeightCarry,1E11)) exitWith {
|
||||
if (_weight > missionNamespace getVariable ["ACE_maxWeightCarry", 1E11]) exitWith {
|
||||
[localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
||||
private "_timer";
|
||||
_timer = ACE_time + 5;
|
||||
|
||||
// handle objects vs persons
|
||||
|
@ -1,25 +1,34 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Carry PFH
|
||||
*
|
||||
* Arguments:
|
||||
* ?
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
#ifdef DEBUG_ENABLED_DRAGGING
|
||||
systemChat format ["%1 startCarryPFH running", ACE_time];
|
||||
#endif
|
||||
|
||||
private ["_unit", "_target", "_timeOut"];
|
||||
|
||||
_unit = _this select 0 select 0;
|
||||
_target = _this select 0 select 1;
|
||||
_timeOut = _this select 0 select 2;
|
||||
params ["_args", "_idPFH"];
|
||||
_args params ["_unit", "_target", "_timeOut"];
|
||||
|
||||
// handle aborting carry
|
||||
if !(_unit getVariable [QGVAR(isCarrying), false]) exitWith {
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
// same as dragObjectPFH, checks if object is deleted or dead OR (target moved away from carrier (weapon disasembled))
|
||||
if ((!([_target] call EFUNC(common,isAlive))) || {(_unit distance _target) > 10}) then {
|
||||
[_unit, _target] call FUNC(dropObject);
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
// handle persons vs objects
|
||||
@ -27,11 +36,11 @@ if (_target isKindOf "CAManBase") then {
|
||||
if (ACE_time > _timeOut) exitWith {
|
||||
[_unit, _target] call FUNC(carryObject);
|
||||
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
} else {
|
||||
if (ACE_time > _timeOut) exitWith {
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
|
||||
// drop if in timeout
|
||||
private "_draggedObject";
|
||||
@ -43,7 +52,7 @@ if (_target isKindOf "CAManBase") then {
|
||||
if (stance _unit == "STAND") exitWith {
|
||||
[_unit, _target] call FUNC(carryObject);
|
||||
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -4,24 +4,21 @@
|
||||
* Start the dragging process.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit that should do the dragging (Object)
|
||||
* 1: Object to drag (Object)
|
||||
* 0: Unit that should do the dragging <OBJECT>
|
||||
* 1: Object to drag <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* NONE.
|
||||
* None
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_target"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_target = _this select 1;
|
||||
params ["_unit", "_target"];
|
||||
|
||||
// check weight
|
||||
private "_weight";
|
||||
_weight = [_target] call FUNC(getWeight);
|
||||
|
||||
if (_weight > GETMVAR(ACE_maxWeightDrag,1E11)) exitWith {
|
||||
if (_weight > missionNamespace getVariable ["ACE_maxWeightDrag", 1E11]) exitWith {
|
||||
[localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
||||
|
@ -1,30 +1,39 @@
|
||||
// by commy2
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Drag PFH
|
||||
*
|
||||
* Arguments:
|
||||
* ?
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
#ifdef DEBUG_ENABLED_DRAGGING
|
||||
systemChat format ["%1 startDragPFH running", ACE_time];
|
||||
#endif
|
||||
|
||||
private ["_unit", "_target", "_timeOut"];
|
||||
|
||||
_unit = _this select 0 select 0;
|
||||
_target = _this select 0 select 1;
|
||||
_timeOut = _this select 0 select 2;
|
||||
params ["_args", "_idPFH"];
|
||||
_args params ["_unit", "_target", "_timeOut"];
|
||||
|
||||
// handle aborting drag
|
||||
if !(_unit getVariable [QGVAR(isDragging), false]) exitWith {
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
// same as dragObjectPFH, checks if object is deleted or dead OR (target moved away from carrier (weapon disasembled))
|
||||
if ((!([_target] call EFUNC(common,isAlive))) || {(_unit distance _target) > 10}) then {
|
||||
[_unit, _target] call FUNC(dropObject);
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
// timeout. Do nothing. Quit. ACE_time, because anim length is linked to ingame ACE_time.
|
||||
if (ACE_time > _timeOut) exitWith {
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
|
||||
// drop if in timeout
|
||||
private "_draggedObject";
|
||||
@ -36,5 +45,5 @@ if (ACE_time > _timeOut) exitWith {
|
||||
if (animationState _unit in DRAG_ANIMATIONS) exitWith {
|
||||
[_unit, _target] call FUNC(dragObject);
|
||||
|
||||
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
||||
[_idPFH] call CBA_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user