fix authors, add weight checks

This commit is contained in:
commy2 2015-03-18 14:14:16 +01:00
parent c23c0788f6
commit ec6496ed2f
7 changed files with 82 additions and 8 deletions

View File

@ -3,8 +3,12 @@
[{_this call DFUNC(handleScrollWheel)}] call EFUNC(common,addScrollWheelEventHandler);
if (isNil QGVAR(maxWeight)) then {
GVAR(maxWeight) = 800;
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);

View File

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

View File

@ -6,8 +6,8 @@ class CfgPatches {
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common","ace_interaction","ace_interact_menu"};
author[] = {"https://github.com/commy2/"};
authorUrl = "";
author[] = {"Garth 'L-H' de Wet","commy2"};
authorUrl = "https://github.com/commy2/";
VERSION_CONFIG;
};
};

View File

@ -17,6 +17,14 @@ 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];

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

@ -17,8 +17,13 @@ private ["_unit", "_target"];
_unit = _this select 0;
_target = _this select 1;
// @todo check weight
//_ableToDrag = ((_draggedObject call AGM_Drag_fnc_GetWeight) <= AGM_Drag_MaxWeight);
// 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

View File

@ -27,7 +27,9 @@
<Hungarian>Elengedés</Hungarian>
</Key>
<Key ID="STR_ACE_Dragging_UnableToDrag">
<English>Unable to drag item due to weight</English>
<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>
@ -36,7 +38,7 @@
<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>
<Hungarian>Túl nehéz ahhoz, hogy elhúzd</Hungarian> -->
</Key>
<Key ID="STR_ACE_Dragging_Carry">
<English>Carry</English>