Merge branch 'master' into dynamicInteractMenu

This commit is contained in:
Nicolás Badano 2015-03-19 15:09:31 -03:00
commit 49cdf6512e
47 changed files with 1208 additions and 14 deletions

View File

@ -17,7 +17,7 @@
</p>
<p align="center"><sup><strong>Requires the latest version of <a href="http://www.armaholic.com/page.php?id=18767">CBA A3</a> | <a href="#">BIF thread</a></strong></sup></p>
**ACE 3** is a joint effort by the teams behind **ACE2**, **AGM** and **CSE** to improve the realism and authenticity of Arma 3.
**ACE3** is a joint effort by the teams behind **ACE2**, **AGM** and **CSE** to improve the realism and authenticity of Arma 3.
This mod is entirely **open-source**, and everyone is free to propose changes or maintain their own, customized version as long as they make their changes open to the public in accordance with the GNU General Public License (for more information check the license file attached to this project).

View File

@ -7,14 +7,22 @@ class CfgWeapons {
simulation = "ItemMineDetector";
};
class Rifle_Base_F;
class Rifle;
class Rifle_Base_F: Rifle {
class WeaponSlotsInfo;
};
class ACE_FakePrimaryWeapon: Rifle_Base_F {
scope = 2;
displayName = "";
model = "";
picture = "";
magazines[] = {"ACE_FakeMagazine"};
discreteDistance[] = {};
discreteDistanceInitIndex = 0;
displayName = "";
picture = "";
model = "";
magazines[] = {"ACE_FakeMagazine"};
scope = 2;
class WeaponSlotsInfo: WeaponSlotsInfo {
mass = 0;
};
};
};

View File

@ -20,6 +20,19 @@ if (hasInterface) then {
};
}] call FUNC(addEventhandler);
["fixCollision", DFUNC(fixCollision)] call FUNC(addEventhandler);
["fixFloating", DFUNC(fixFloating)] call FUNC(addEventhandler);
["fixPosition", DFUNC(fixPosition)] call FUNC(addEventhandler);
["lockVehicle", {
_this setVariable [QGVAR(lockStatus), locked _this];
_this lock 2;
}] call FUNC(addEventhandler);
["unlockVehicle", {
_this lock (_this getVariable [QGVAR(lockStatus), locked _this]);
}] call FUNC(addEventhandler);
// hack to get PFH to work in briefing
[QGVAR(onBriefingPFH), "onEachFrame", {
if (time > 0) exitWith {
@ -86,6 +99,7 @@ GVAR(OldZeusDisplayIsOpen) = !(isNull findDisplay 312);
GVAR(OldCameraView) = cameraView;
GVAR(OldPlayerVehicle) = vehicle ACE_player;
GVAR(OldPlayerTurret) = [ACE_player] call FUNC(getTurretIndex);
GVAR(OldPlayerWeapon) = currentWeapon ACE_player;
// PFH to raise varios events
[{
@ -146,6 +160,14 @@ GVAR(OldPlayerTurret) = [ACE_player] call FUNC(getTurretIndex);
["playerTurretChanged", [ACE_player, _newPlayerTurret]] call FUNC(localEvent);
};
// "playerWeaponChanged" event
_newPlayerWeapon = currentWeapon ACE_player;
if (_newPlayerWeapon != GVAR(OldPlayerWeapon)) then {
// Raise ACE event locally
GVAR(OldPlayerWeapon) = _newPlayerWeapon;
["playerWeaponChanged", [ACE_player, _newPlayerWeapon]] call FUNC(localEvent);
};
}, 0, []] call cba_fnc_addPerFrameHandler;
[QGVAR(StateArrested),false,true,QUOTE(ADDON)] call FUNC(defineVariable);

View File

@ -55,7 +55,10 @@ PREP(execPersistentFnc);
PREP(execRemoteFnc);
PREP(executePersistent);
PREP(filter);
PREP(fixCollision);
PREP(fixFloating);
PREP(fixLoweredRifleAnimation);
PREP(fixPosition);
PREP(getAllDefinedSetVariables);
PREP(getAllGear);
PREP(getCaptivityStatus);

View File

@ -26,7 +26,7 @@ _exceptions = [_exceptions, {toLower _this}] call FUNC(map);
private "_owner";
_owner = _target getVariable [QGVAR(owner), objNull];
if (!isNull _owner && {_unit != _owner} && {!([_owner] call FUNC(isPlayer))}) exitWith {false};
if (!isNull _owner && {_unit != _owner}) exitWith {false};
// check general conditions

View 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);

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

@ -0,0 +1,29 @@
/*
* Author: commy2
*
* Fixes position of an object. E.g. moves object above ground and adjusts to terrain slope. Requires local object.
*
* Argument:
* Object (Object)
*
* Return value:
* NONE
*/
#include "script_component.hpp"
// setVectorUp requires local object
if (!local _this) exitWith {};
private "_position";
_position = getPos _this;
// don't place the object below the ground
if (_position select 2 < -0.1) then {
_position set [2, -0.1];
_this setPos _position;
};
// adjust position to sloped terrain, if placed on ground
if (getPosATL _this select 2 == _position select 2) then {
_this setVectorUp surfaceNormal _position;
};

View File

@ -0,0 +1 @@
z\ace\addons\dragging

View File

@ -0,0 +1,47 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
clientInit = QUOTE(call COMPILE_FILE(XEH_clientInit));
serverInit = QUOTE(call COMPILE_FILE(XEH_serverInit));
};
};
class Extended_Init_EventHandlers {
class StaticWeapon {
class ADDON {
init = QUOTE(_this call DFUNC(initObject));
};
};
class StaticMortar {
class ADDON {
init = QUOTE(_this call DFUNC(initObject));
};
};
class ReammoBox_F {
class ADDON {
init = QUOTE(_this call DFUNC(initObject));
};
};
};
class Extended_Killed_EventHandlers {
class CAManBase {
class ADDON {
killed = QUOTE(_this call DFUNC(handleKilled));
};
};
};
class Extended_AnimChanged_EventHandlers {
class CAManBase {
class ADDON {
animChanged = QUOTE(_this call DFUNC(handleAnimChanged));
};
};
};

View File

@ -0,0 +1,86 @@
class CfgVehicles {
// Static weapons
class LandVehicle;
class StaticWeapon: LandVehicle {
GVAR(canCarry) = 1;
GVAR(carryPosition[]) = {0,1.2,0};
GVAR(carryDirection) = 0;
GVAR(canDrag) = 1;
GVAR(dragPosition[]) = {0,1.2,0};
GVAR(dragDirection) = 0;
};
//remove actions from Taru Pods
class Pod_Heli_Transport_04_base_F: StaticWeapon {
GVAR(canCarry) = 0;
GVAR(canDrag) = 0;
};
class StaticMortar;
class Mortar_01_base_F: StaticMortar {
GVAR(canCarry) = 1;
GVAR(carryPosition[]) = {0,1.2,0};
GVAR(carryDirection) = 0;
GVAR(canDrag) = 1;
GVAR(dragPosition[]) = {0,1.2,0};
GVAR(dragDirection) = 0;
};
// ammo boxes
class ThingX;
class ReammoBox_F: ThingX {
XEH_ENABLED;
GVAR(canCarry) = 0;
GVAR(carryPosition[]) = {0,1,1};
GVAR(carryDirection) = 0;
GVAR(canDrag) = 0;
GVAR(dragPosition[]) = {0,1.2,0};
GVAR(dragDirection) = 0;
};
class Slingload_base_F: ReammoBox_F {
GVAR(canCarry) = 0;
GVAR(canDrag) = 0;
};
class EAST_Box_Base: ReammoBox_F {
GVAR(canCarry) = 1;
GVAR(canDrag) = 1;
};
class IND_Box_Base: ReammoBox_F {
GVAR(canCarry) = 1;
GVAR(canDrag) = 1;
};
/*class FIA_Box_Base_F: ReammoBox_F {
GVAR(canCarry) = 1;
GVAR(canDrag) = 1;
};*/
class NATO_Box_Base: ReammoBox_F {
GVAR(canCarry) = 1;
GVAR(canDrag) = 1;
};
// Remove Larger crate dragging support.
// Would be better to allow some sort of joint push/drag functionality
// Requiring 2 units to access the larger crates and attaching them together (a crappy method of doing it)
// in order to move the bigger ones. Currently simply remove support.
// I believe these crates are currently broken (hitbox doesn't work or something) in 1.22 (2014-07-04)
class Box_East_AmmoVeh_F: EAST_Box_Base {
GVAR(canCarry) = 0;
GVAR(canDrag) = 0;
};
class Box_NATO_AmmoVeh_F: NATO_Box_Base {
GVAR(canCarry) = 0;
GVAR(canDrag) = 0;
};
class Box_IND_AmmoVeh_F: IND_Box_Base {
GVAR(canCarry) = 0;
GVAR(canDrag) = 0;
};
};

View File

@ -0,0 +1,19 @@
// by PabstMirror, commy2
#include "script_component.hpp"
[{_this call DFUNC(handleScrollWheel)}] call EFUNC(common,addScrollWheelEventHandler);
if (isNil "ACE_maxWeightDrag") then {
ACE_maxWeightDrag = 800;
};
if (isNil "ACE_maxWeightCarry") then {
ACE_maxWeightCarry = 600;
};
["isNotDragging", {!((_this select 0) getVariable [QGVAR(isDragging), false])}] call EFUNC(common,addCanInteractWithCondition);
["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);
["playerWeaponChanged", {_this call DFUNC(handlePlayerWeaponChanged)}] call EFUNC(common,addEventhandler);

View File

@ -0,0 +1,28 @@
#include "script_component.hpp"
ADDON = false;
PREP(canCarry);
PREP(canDrag);
PREP(canDrop);
PREP(canDrop_carry);
PREP(carryObject);
PREP(carryObjectPFH);
PREP(dragObject);
PREP(dragObjectPFH);
PREP(dropObject);
PREP(dropObject_carry);
PREP(getWeight);
PREP(handleAnimChanged);
PREP(handleKilled);
PREP(handlePlayerChanged);
PREP(handlePlayerWeaponChanged);
PREP(handleScrollWheel);
PREP(initObject);
PREP(isObjectOnObject);
PREP(setCarryable);
PREP(setDraggable);
PREP(startDrag);
PREP(startDragPFH);
ADDON = true;

View File

@ -0,0 +1,5 @@
// by commy2
#include "script_component.hpp"
// release object on hard disconnection. Function is identical to killed
addMissionEventHandler ["HandleDisconnect", {_this call DFUNC(handleKilled)}];

View File

@ -0,0 +1,16 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common","ace_interaction","ace_interact_menu"};
author[] = {"Garth 'L-H' de Wet","commy2"};
authorUrl = "https://github.com/commy2/";
VERSION_CONFIG;
};
};
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"

View File

@ -0,0 +1,25 @@
/*
* Author: commy2
*
* 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)
*
* Return value:
* Can the unit carry the object? (Bool)
*/
#include "script_component.hpp"
private ["_unit", "_target"];
_unit = _this select 0;
_target = _this select 1;
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 && {_target getVariable [QGVAR(canCarry), false]}

View File

@ -0,0 +1,25 @@
/*
* Author: commy2
*
* 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)
*
* Return value:
* Can the unit drag the object? (Bool)
*/
#include "script_component.hpp"
private ["_unit", "_target"];
_unit = _this select 0;
_target = _this select 1;
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 && {_target getVariable [QGVAR(canDrag), false]}

View File

@ -0,0 +1,22 @@
/*
* Author: commy2
*
* Check if unit can drop the object.
*
* Argument:
* 0: Unit that currently drags a object (Object)
* 1: Object that is dragged (Object)
*
* Return value:
* Can the unit drop the object? (Bool)
*/
#include "script_component.hpp"
private ["_unit", "_target"];
_unit = _this select 0;
_target = _this select 1;
if !([_unit, _target, ["isNotDragging"]] call EFUNC(common,canInteractWith)) exitWith {false};
_unit getVariable [QGVAR(draggedObject), objNull] == _target

View File

@ -0,0 +1,22 @@
/*
* Author: commy2
*
* Check if unit can drop the carried object.
*
* Argument:
* 0: Unit that currently carries a object (Object)
* 1: Object that is carried (Object)
*
* Return value:
* Can the unit drop the object? (Bool)
*/
#include "script_component.hpp"
private ["_unit", "_target"];
_unit = _this select 0;
_target = _this select 1;
if !([_unit, _target, ["isNotCarrying"]] call EFUNC(common,canInteractWith)) exitWith {false};
_unit getVariable [QGVAR(carriedObject), objNull] == _target

View File

@ -0,0 +1,80 @@
/*
* Author: commy2
*
* Carry an object.
*
* Argument:
* 0: Unit that should do the carrying (Object)
* 1: Object to carry (Object)
*
* Return value:
* NONE.
*/
#include "script_component.hpp"
private ["_unit", "_target"];
_unit = _this select 0;
_target = _this select 1;
// check weight
private "_weight";
_weight = [_target] call FUNC(getWeight);
if (_weight > GETMVAR(ACE_maxWeightCarry,1E11)) exitWith {
[localize "STR_ACE_Dragging_UnableToDrag"] call EFUNC(common,displayTextStructured);
};
// select no weapon and stop sprinting
_unit action ["SwitchWeapon", _unit, _unit, 99];
[_unit, "isDragging", true] call EFUNC(common,setforceWalkStatus);
// prevent multiple players from accessing the same object
[_unit, _target, true] call EFUNC(common,claim);
// get attachTo offset and direction.
private ["_position", "_direction"];
_position = _target getVariable [QGVAR(carryPosition), [0, 0, 0]];
_direction = _target getVariable [QGVAR(carryDirection), 0];
// add height offset of model
private "_offset";
_offset = (_target modelToWorld [0, 0, 0] select 2) - (_unit modelToWorld [0, 0, 0] select 2);
_position = _position vectorAdd [0, 0, _offset];
// attach object
_target attachTo [_unit, _position];
_target setDir _direction;
_unit setVariable [QGVAR(isCarrying), true, true];
_unit setVariable [QGVAR(carriedObject), _target, true];
// add scrollwheel action to release object
private "_actionID";
_actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
if (_actionID != -1) then {
_unit removeAction _actionID;
};
_actionID = _unit addAction [
format ["<t color='#FF0000'>%1</t>", localize "STR_ACE_Dragging_Drop"],
QUOTE([ARR_2(_this select 0, (_this select 0) getVariable [ARR_2(QUOTE(QGVAR(carriedObject)),objNull)])] call FUNC(dropObject_carry)),
nil,
20,
false,
true,
"",
QUOTE(!isNull (_this getVariable [ARR_2(QUOTE(QGVAR(carriedObject)),objNull)]))
];
_unit setVariable [QGVAR(ReleaseActionID), _actionID];
// check everything
[FUNC(carryObjectPFH), 0, [_unit, _target]] call CBA_fnc_addPerFrameHandler;
// reset current dragging height.
GVAR(currentHeightChange) = 0;

View File

@ -0,0 +1,13 @@
// by commy2
#include "script_component.hpp"
private ["_unit", "_target"];
_unit = _this select 0 select 0;
_target = _this select 0 select 1;
// drop if the crate is destroyed
if !([_target] call EFUNC(common,isAlive)) then {
[_unit, _target] call FUNC(dropObject_carry);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};

View File

@ -0,0 +1,64 @@
/*
* Author: commy2
*
* Drag an object. Called from ace_dragging_fnc_startDrag
*
* Argument:
* 0: Unit that should do the dragging (Object)
* 1: Object to drag (Object)
*
* Return value:
* NONE.
*/
#include "script_component.hpp"
private ["_unit", "_target"];
_unit = _this select 0;
_target = _this select 1;
// 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 modelToWorld [0, 0, 0] select 2) - (_unit modelToWorld [0, 0, 0] select 2);
_position = _position vectorAdd [0, 0, _offset];
// attach object
_target attachTo [_unit, _position];
_target setDir _direction;
_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 {
_unit removeAction _actionID;
};
_actionID = _unit addAction [
format ["<t color='#FF0000'>%1</t>", localize "STR_ACE_Dragging_Drop"],
QUOTE([ARR_2(_this select 0, (_this select 0) getVariable [ARR_2(QUOTE(QGVAR(draggedObject)),objNull)])] call FUNC(dropObject)),
nil,
20,
false,
true,
"",
QUOTE(!isNull (_this getVariable [ARR_2(QUOTE(QGVAR(draggedObject)),objNull)]))
];
_unit setVariable [QGVAR(ReleaseActionID), _actionID];
// check everything
[FUNC(dragObjectPFH), 0, [_unit, _target]] call CBA_fnc_addPerFrameHandler;
// reset current dragging height.
GVAR(currentHeightChange) = 0;

View File

@ -0,0 +1,13 @@
// by commy2
#include "script_component.hpp"
private ["_unit", "_target"];
_unit = _this select 0 select 0;
_target = _this select 0 select 1;
// drop if the crate is destroyed
if !([_target] call EFUNC(common,isAlive)) then {
[_unit, _target] call FUNC(dropObject);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};

View File

@ -0,0 +1,50 @@
/*
* Author: commy2
*
* Drop a dragged object.
*
* Argument:
* 0: Unit that drags the other object (Object)
* 1: Dragged object to drop (Object)
*
* Return value:
* NONE.
*/
#include "script_component.hpp"
private ["_unit", "_target"];
_unit = _this select 0;
_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";
// prevent collision damage
["fixCollision", _unit, _unit] call EFUNC(common,targetEvent);
["fixCollision", _target, _target] call EFUNC(common,targetEvent);
// release object
detach _target;
_unit removeWeapon "ACE_FakePrimaryWeapon";
// 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];
// make object accesable for other units
[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,50 @@
/*
* Author: commy2
*
* Drop a carried object.
*
* Argument:
* 0: Unit that carries the other object (Object)
* 1: Carried object to drop (Object)
*
* Return value:
* NONE.
*/
#include "script_component.hpp"
private ["_unit", "_target"];
_unit = _this select 0;
_target = _this select 1;
// remove scroll wheel action
_unit removeAction (_unit getVariable [QGVAR(ReleaseActionID), -1]);
private "_inBuilding";
_inBuilding = [_unit] call FUNC(isObjectOnObject);
// prevent collision damage
["fixCollision", _unit, _unit] call EFUNC(common,targetEvent);
["fixCollision", _target, _target] call EFUNC(common,targetEvent);
// release object
detach _target;
// reselect weapon and re-enable sprint
_unit selectWeapon primaryWeapon _unit;
[_unit, "isDragging", false] call EFUNC(common,setforceWalkStatus);
// prevent object from flipping inside buildings
if (_inBuilding) then {
_target setPosASL (getPosASL _target vectorAdd [0, 0, 0.05]);
};
_unit setVariable [QGVAR(isCarrying), false, true];
_unit setVariable [QGVAR(carriedObject), objNull, true];
// make object accesable for other units
[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,54 @@
/*
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;
*/
#include "script_component.hpp"
private "_object";
_object = _this select 0;
private ["_totalWeight", "_fnc","_fnc_Extra"];
_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).
_totalWeight

View File

@ -0,0 +1,31 @@
// by commy2
#include "script_component.hpp"
private ["_unit", "_anim"];
_unit = _this select 0;
_anim = _this select 1;
if (_unit getVariable [QGVAR(isDragging), false]) then {
// drop dragged object when not in valid animation
if !(_anim in DRAG_ANIMATIONS) then {
private "_draggedObject";
_draggedObject = _unit getVariable [QGVAR(draggedObject), objNull];
[_unit, _draggedObject] call FUNC(dropObject);
};
};
if (_unit getVariable [QGVAR(isCarrying), false]) then {
// drop carried object when not standing
if (stance _unit != "STAND") then {
private "_carriedObject";
_carriedObject = _unit getVariable [QGVAR(carriedObject), objNull];
[_unit, _carriedObject] call FUNC(dropObject_carry);
};
};

View File

@ -0,0 +1,20 @@
// by commy2
#include "script_component.hpp"
private "_unit";
_unit = _this select 0;
if (_unit getVariable [QGVAR(isDragging), false]) then {
private "_draggedObject";
_draggedObject = _unit getVariable [QGVAR(draggedObject), objNull];
[_unit, _draggedObject] call FUNC(dropObject);
};
if (_unit getVariable [QGVAR(isCarrying), false]) then {
private "_carriedObject";
_carriedObject = _unit getVariable [QGVAR(carriedObject), objNull];
[_unit, _carriedObject] call FUNC(dropObject_carry);
};

View File

@ -0,0 +1,17 @@
// by commy2
#include "script_component.hpp"
private ["_newPlayer", "_oldPlayer"];
_newPlayer = _this select 0;
_oldPlayer = _this select 1;
{
if (_x getVariable [QGVAR(isDragging), false]) then {
[_x, _x getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject);
};
if (_x getVariable [QGVAR(isCarrying), false]) then {
[_x, _x getVariable [QGVAR(carriedObject), objNull]] call FUNC(dropObject_carry);
};
} forEach [_newPlayer, _oldPlayer];

View File

@ -0,0 +1,31 @@
// by commy2
#include "script_component.hpp"
private ["_unit", "_weapon"];
_unit = _this select 0;
_weapon = _this select 1;
if (_unit getVariable [QGVAR(isDragging), false]) then {
// drop dragged object when selecting a non-primary weapon
if (_weapon != primaryWeapon _unit) then {
private "_draggedObject";
_draggedObject = _unit getVariable [QGVAR(draggedObject), objNull];
[_unit, _draggedObject] call FUNC(dropObject);
};
};
if (_unit getVariable [QGVAR(isCarrying), false]) then {
// drop carried object when selecting any weapon
if (_weapon != "") then {
private "_carriedObject";
_carriedObject = _unit getVariable [QGVAR(carriedObject), objNull];
[_unit, _carriedObject] call FUNC(dropObject_carry);
};
};

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

@ -0,0 +1,37 @@
/*
* Author: commy2
*
* Initialize variables for drag or carryable objects. Called from init EH.
*
* Argument:
* 0: Any object (Object)
*
* Return value:
* NONE.
*/
#include "script_component.hpp"
private "_object";
_object = _this select 0;
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"];
_position = getArray (_config >> QGVAR(carryPosition));
_direction = getNumber (_config >> QGVAR(carryDirection));
[_object, true, _position, _direction] call FUNC(setCarryable);
};

View File

@ -0,0 +1,6 @@
// by commy2
private "_object";
_object = _this select 0;
(getPosATL _object select 2) - (getPos _object select 2) > 1E-5

View File

@ -0,0 +1,52 @@
/*
* Author: commy2
*
* 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)
*
* Return value:
* NONE.
*/
#include "script_component.hpp"
private ["_object", "_enableCarry", "_position", "_direction"];
_this resize 4;
_object = _this select 0;
_enableCarry = _this select 1;
_position = _this select 2;
_direction = _this select 3;
if (isNil "_position") then {
_position = _object getVariable [QGVAR(carryPosition), [0,1,1]];
};
if (isNil "_direction") then {
_direction = _object getVariable [QGVAR(carryDirection), 0];
};
// update variables
_object setVariable [QGVAR(canCarry), _enableCarry];
_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,[]);
// do nothing if the class is already initialized
if (_type in _initializedClasses) exitWith {};
_initializedClasses pushBack _type;
GVAR(initializedClasses_carry) = _initializedClasses;
[_type, 0, ["ACE_MainActions", QGVAR(carry)], localize "STR_ACE_Dragging_Carry", "", "", {[_player, _target] call FUNC(carryObject)}, {[_player, _target] call FUNC(canCarry)}, 2] call EFUNC(interact_menu,addClassAction);
[_type, 0, ["ACE_MainActions", QGVAR(drop_carry)], localize "STR_ACE_Dragging_Drop", "", "", {[_player, _target] call FUNC(dropObject_carry)}, {[_player, _target] call FUNC(canDrop_carry)}, 2] call EFUNC(interact_menu,addClassAction);

View File

@ -0,0 +1,52 @@
/*
* Author: commy2
*
* Enable the object to be dragged.
*
* Argument:
* 0: Any object (Object)
* 1: true to enable dragging, false to disable (Bool)
* 2: Position offset for attachTo command (Array, optinal; default: [0,0,0])
* 3: Direction in degree to rotate the object after attachTo (Number, optional; default: 0)
*
* Return value:
* NONE.
*/
#include "script_component.hpp"
private ["_object", "_enableDrag", "_position", "_direction"];
_this resize 4;
_object = _this select 0;
_enableDrag = _this select 1;
_position = _this select 2;
_direction = _this select 3;
if (isNil "_position") then {
_position = _object getVariable [QGVAR(dragPosition), [0,0,0]];
};
if (isNil "_direction") then {
_direction = _object getVariable [QGVAR(dragDirection), 0];
};
// update variables
_object setVariable [QGVAR(canDrag), _enableDrag];
_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,[]);
// do nothing if the class is already initialized
if (_type in _initializedClasses) exitWith {};
_initializedClasses pushBack _type;
GVAR(initializedClasses) = _initializedClasses;
[_type, 0, ["ACE_MainActions", QGVAR(drag)], localize "STR_ACE_Dragging_Drag", "", "", {[_player, _target] call FUNC(startDrag)}, {[_player, _target] call FUNC(canDrag)}, 2] call EFUNC(interact_menu,addClassAction);
[_type, 0, ["ACE_MainActions", QGVAR(drop)], localize "STR_ACE_Dragging_Drop", "", "", {[_player, _target] call FUNC(dropObject)}, {[_player, _target] call FUNC(canDrop)}, 2] call EFUNC(interact_menu,addClassAction);

View File

@ -0,0 +1,43 @@
/*
* Author: commy2
*
* Start the dragging process.
*
* Argument:
* 0: Unit that should do the dragging (Object)
* 1: Object to drag (Object)
*
* Return value:
* NONE.
*/
#include "script_component.hpp"
private ["_unit", "_target"];
_unit = _this select 0;
_target = _this select 1;
// check weight
private "_weight";
_weight = [_target] call FUNC(getWeight);
if (_weight > GETMVAR(ACE_maxWeightDrag,1E11)) exitWith {
[localize "STR_ACE_Dragging_UnableToDrag"] call EFUNC(common,displayTextStructured);
};
// add a primary weapon if the unit has none.
// @todo prevent opening inventory when equipped with a fake weapon
if (primaryWeapon _unit == "") then {
_unit addWeapon "ACE_FakePrimaryWeapon";
};
// select primary, otherwise the drag animation actions don't work.
_unit selectWeapon primaryWeapon _unit;
// prevent multiple players from accessing the same object
[_unit, _target, true] call EFUNC(common,claim);
// can't play action that depends on weapon if it was added the same frame
[{_this playActionNow "grabDrag";}, _unit] call EFUNC(common,execNextFrame);
[FUNC(startDragPFH), 0.2, [_unit, _target, time + 5]] call CBA_fnc_addPerFrameHandler;

View File

@ -0,0 +1,20 @@
// by commy2
#include "script_component.hpp"
private ["_unit", "_target", "_timeOut"];
_unit = _this select 0 select 0;
_target = _this select 0 select 1;
_timeOut = _this select 0 select 2;
// timeout. Do nothing. Quit. time, because anim length is linked to ingame time.
if (time > _timeOut) exitWith {
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
// unit is ready to start dragging
if (animationState _unit in DRAG_ANIMATIONS) exitWith {
[_unit, _target] call FUNC(dragObject);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};

View File

@ -0,0 +1 @@
#include "\z\ace\addons\dragging\script_component.hpp"

View File

@ -0,0 +1,14 @@
#define COMPONENT dragging
#include "\z\ace\addons\main\script_mod.hpp"
#ifdef DEBUG_ENABLED_DRAGGING
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_ENABLED_DRAGGING
#define DEBUG_SETTINGS DEBUG_ENABLED_DRAGGING
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#define DRAG_ANIMATIONS ["amovpercmstpslowwrfldnon_acinpknlmwlkslowwrfldb_2", "amovpercmstpsraswpstdnon_acinpknlmwlksnonwpstdb_2", "amovpercmstpsnonwnondnon_acinpknlmwlksnonwnondb_2", "acinpknlmstpsraswrfldnon", "acinpknlmstpsnonwpstdnon", "acinpknlmstpsnonwnondnon", "acinpknlmwlksraswrfldb", "acinpknlmwlksnonwnondb"]

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Edited with tabler - 2014-12-21 -->
<Project name="ACE">
<Package name="Dragging">
<Key ID="STR_ACE_Dragging_Drag">
<English>Drag</English>
<Russian>Тащить</Russian>
<Spanish>Arrastrar</Spanish>
<Polish>Ciągnij</Polish>
<Czech>Táhnout</Czech>
<French>Tracter</French>
<German>Ziehen</German>
<Portuguese>Arrastar</Portuguese>
<Italian>Trascina</Italian>
<Hungarian>Húzás</Hungarian>
</Key>
<Key ID="STR_ACE_Dragging_Drop">
<English>Release</English>
<Russian>Отпустить</Russian>
<Spanish>Soltar</Spanish>
<Polish>Puść</Polish>
<Czech>Položit</Czech>
<French>Lâcher</French>
<German>Loslassen</German>
<Portuguese>Largar</Portuguese>
<Italian>Lascia</Italian>
<Hungarian>Elengedés</Hungarian>
</Key>
<Key ID="STR_ACE_Dragging_UnableToDrag">
<English>Item to heavy</English>
<German>Gegenstand zu schwer</German>
<!-- <English>Unable to drag item due to weight</English>
<Russian>Слишком тяжелый предмет</Russian>
<Spanish>No se puede arrastrar el objeto debido a su peso</Spanish>
<Polish>Nie można ciągnąć tego przedmiotu z powodu jego wagi</Polish>
<Czech>Předmět je příliž těžký!</Czech>
<French>Trop lourd pour être tracté</French>
<German>Dieser Gegenstand kann nicht gezogen werden, da er zu schwer ist.</German>
<Portuguese>Não é possível carregar o item devido a seu peso</Portuguese>
<Italian>Non è possibile trascinare l'oggetto a causa del suo peso</Italian>
<Hungarian>Túl nehéz ahhoz, hogy elhúzd</Hungarian> -->
</Key>
<Key ID="STR_ACE_Dragging_Carry">
<English>Carry</English>
<German>Tragen</German>
<Spanish>Portar</Spanish>
<Polish>Nieś</Polish>
<French>Porter</French>
<Czech>Nést</Czech>
<Portuguese>Carregar</Portuguese>
<Italian>Trascina</Italian>
<Hungarian>Felvesz</Hungarian>
<Russian>Нести</Russian>
</Key>
</Package>
</Project>

View File

@ -36,6 +36,11 @@ class Extended_Init_EventHandlers {
serverInit = QUOTE(_this call FUNC(vehicleInit));
};
};
class StaticWeapon {
class ADDON {
serverInit = QUOTE(_this call FUNC(vehicleInit));
};
};
};
class Extended_Respawn_EventHandlers {
@ -64,6 +69,11 @@ class Extended_Respawn_EventHandlers {
respawn = QUOTE(_this call FUNC(vehicleInit));
};
};
class StaticWeapon {
class ADDON {
respawn = QUOTE(_this call FUNC(vehicleInit));
};
};
};
class Extended_FiredBIS_EventHandlers {
@ -92,4 +102,9 @@ class Extended_FiredBIS_EventHandlers {
firedBIS = QUOTE(_this call FUNC(firedEH));
};
};
class StaticWeapon {
class ADDON {
firedBIS = QUOTE(_this call FUNC(firedEH));
};
};
};

View File

@ -497,4 +497,17 @@ class CfgVehicles {
class ACE_SelfActions {};
};
class thingX;
class ReammoBox_F: thingX {
class ACE_Actions {
class ACE_MainActions {
displayName = "$STR_ACE_Interaction_MainAction";
selection = "";
distance = 2;
condition = "true";
};
};
class ACE_SelfActions {};
};
};

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;

View File

@ -1,4 +1,5 @@
#include "\x\cba\addons\main\script_macros_common.hpp"
#include "\x\cba\addons\xeh\script_xeh.hpp"
// Default versioning level
#define DEFAULT_VERSIONING_LEVEL 2

View File

@ -43,4 +43,9 @@ class Extended_FiredBIS_EventHandlers {
firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireOverpressureZone)});
};
};
class StaticWeapons {
class ADDON {
firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireOverpressureZone)});
};
};
};

View File

@ -13,7 +13,7 @@
EXPLODE_2_PVT(_this,_player,_target);
// Return true for static weapons if they have been fired once
// Return true for static weapons if they have been fired once, @todo 1.40 this work-around doesn't work anymore
if (_target isKindOf "StaticWeapon") exitWith {
(currentMagazine _target) != ""
};

View File

@ -13,7 +13,7 @@
// Statement
["azimuth"] call FUNC(onKeyDown);
true
false
},
{
// prevent holding down
@ -24,7 +24,7 @@
// Statement
["azimuth"] call FUNC(onKeyUp);
true
false
},
[15, [false, false, false]], false, 0] call CBA_fnc_addKeybind; //Tab Key
@ -42,7 +42,7 @@
// Statement
["distance"] call FUNC(onKeyDown);
true
false
},
{
// prevent holding down
@ -53,6 +53,6 @@
// Statement
["distance"] call FUNC(onKeyUp);
true
false
},
[19, [false, false, false]], false] call CBA_fnc_addKeybind; //R Key