mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Fix findNearestVehicle dont return BOOL
Fix that findNearestVehicle dont return any time the nearest car Small Performance Improvement in getSizeItem/handleDestroyed/startUnload Enhance Some legibility
This commit is contained in:
parent
abc732ac35
commit
c4ed18f39f
@ -20,7 +20,7 @@ PREP(startUnload);
|
|||||||
GVAR(initializedItemClasses) = [];
|
GVAR(initializedItemClasses) = [];
|
||||||
|
|
||||||
if (isServer) then {
|
if (isServer) then {
|
||||||
["cargo_hideItem", {(_this select 0) hideObjectGlobal (_this select 1);}] call EFUNC(common,addEventHandler);
|
["cargo_hideItem", {params ["_object", "_status"]; _object hideObjectGlobal _status;}] call EFUNC(common,addEventHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
ADDON = true;
|
ADDON = true;
|
||||||
|
@ -6,26 +6,26 @@
|
|||||||
* 0: Object <OBJECT>
|
* 0: Object <OBJECT>
|
||||||
*
|
*
|
||||||
* Return value:
|
* Return value:
|
||||||
* Can load <BOOL>
|
* Vehicle that is in Distance <OBJECT>
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_vehicle"];
|
private ["_loadCar", "_loadHelicopter", "_loadTank", "_loadShip"];
|
||||||
params ["_unit"];
|
params ["_unit"];
|
||||||
|
|
||||||
_vehicle = nearestObject [_unit, "car"];
|
_loadCar = nearestObject [_unit, "car"];
|
||||||
if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle};
|
if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle};
|
||||||
|
|
||||||
_loadhelicopter = nearestObject [_unit, "air"];
|
_loadHelicopter = nearestObject [_unit, "air"];
|
||||||
if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle};
|
if (_unit distance _loadHelicopter <= MAX_LOAD_DISTANCE) exitwith {_loadHelicopter};
|
||||||
|
|
||||||
_loadtank = nearestObject [_unit, "tank"];
|
_loadTank = nearestObject [_unit, "tank"];
|
||||||
if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle};
|
if (_unit distance _loadTank <= MAX_LOAD_DISTANCE) exitwith {_loadTank};
|
||||||
|
|
||||||
_loadtank = nearestObject [_unit, "ship"];
|
_loadShip = nearestObject [_unit, "ship"];
|
||||||
if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle};
|
if (_unit distance _loadShip <= MAX_LOAD_DISTANCE) exitwith {_loadShip};
|
||||||
|
|
||||||
objNull;
|
objNull;
|
||||||
|
@ -6,15 +6,16 @@
|
|||||||
* 0: Object <OBJECT>
|
* 0: Object <OBJECT>
|
||||||
*
|
*
|
||||||
* Return value:
|
* Return value:
|
||||||
* Cargo size. -1 is not a size defined <NUMBER>
|
* Cargo size. <NUMBER> (default: -1)
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
params ["_item"];
|
params ["_item", "_config"];
|
||||||
if (isNumber (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size))) exitwith {
|
_config = (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size));
|
||||||
_item getvariable [QGVAR(size), getNumber (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size))];
|
if (isNumber (_config)) exitwith {
|
||||||
|
_item getvariable [QGVAR(size), getNumber (_config)];
|
||||||
};
|
};
|
||||||
-1;
|
-1
|
||||||
|
@ -22,6 +22,6 @@ if (count _loaded == 0) exitwith {};
|
|||||||
// TODO deleteVehicle or just delete vehicle? Do we want to be able to recover destroyed equipment?
|
// TODO deleteVehicle or just delete vehicle? Do we want to be able to recover destroyed equipment?
|
||||||
deleteVehicle _x;
|
deleteVehicle _x;
|
||||||
//_x setDamage 1;
|
//_x setDamage 1;
|
||||||
}foreach _loaded;
|
} count _loaded;
|
||||||
|
|
||||||
[_vehicle] call FUNC(validateCargoSpace);
|
[_vehicle] call FUNC(validateCargoSpace);
|
||||||
|
@ -28,8 +28,8 @@ if (isServer) then {
|
|||||||
_className = getText (_x >> "type");
|
_className = getText (_x >> "type");
|
||||||
_amount = getNumber (_x >> "amount");
|
_amount = getNumber (_x >> "amount");
|
||||||
_position = getPos _vehicle;
|
_position = getPos _vehicle;
|
||||||
_position set [2, (_position select 2) + 7.5];
|
|
||||||
_position set [1, (_position select 1) + 1];
|
_position set [1, (_position select 1) + 1];
|
||||||
|
_position set [2, (_position select 2) + 7.5];
|
||||||
for "_i" from 1 to _amount do {
|
for "_i" from 1 to _amount do {
|
||||||
_object = createVehicle [_className, _position, [], 0, "CAN_COLLIDE"];
|
_object = createVehicle [_className, _position, [], 0, "CAN_COLLIDE"];
|
||||||
if !([_object, _vehicle] call FUNC(loadItem)) exitwith {
|
if !([_object, _vehicle] call FUNC(loadItem)) exitwith {
|
||||||
@ -38,7 +38,7 @@ if (isServer) then {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
nil
|
nil
|
||||||
}count ("true" configClasses (configFile >> "CfgVehicles" >> _type >> "ACE_Cargo" >> "Cargo"));
|
} count ("true" configClasses (configFile >> "CfgVehicles" >> _type >> "ACE_Cargo" >> "Cargo"));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,8 @@ uiNamespace setvariable [QGVAR(menuDisplay), _display];
|
|||||||
lbClear _ctrl;
|
lbClear _ctrl;
|
||||||
{
|
{
|
||||||
_ctrl lbAdd (getText(configfile >> "CfgVehicles" >> typeOf _x >> "displayName"));
|
_ctrl lbAdd (getText(configfile >> "CfgVehicles" >> typeOf _x >> "displayName"));
|
||||||
}foreach _loaded;
|
true
|
||||||
|
} count _loaded;
|
||||||
|
|
||||||
_label ctrlSetText format[localize "STR_ACE_Cargo_labelSpace", [GVAR(interactionVehicle)] call DFUNC(getCargoSpaceLeft)];
|
_label ctrlSetText format[localize "STR_ACE_Cargo_labelSpace", [GVAR(interactionVehicle)] call DFUNC(getCargoSpaceLeft)];
|
||||||
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
||||||
|
@ -13,19 +13,20 @@
|
|||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_display", "_loaded", "_ctrl", "_selected", "_item"];
|
private ["_display", "_loaded", "_loadedCount", "_ctrl", "_selected", "_item"];
|
||||||
disableSerialization;
|
disableSerialization;
|
||||||
_display = uiNamespace getvariable QGVAR(menuDisplay);
|
_display = uiNamespace getvariable QGVAR(menuDisplay);
|
||||||
if (isnil "_display") exitwith {};
|
if (isnil "_display") exitwith {};
|
||||||
|
|
||||||
_loaded = GVAR(interactionVehicle) getvariable [QGVAR(loaded), []];
|
_loaded = GVAR(interactionVehicle) getvariable [QGVAR(loaded), []];
|
||||||
if (count _loaded == 0) exitwith {};
|
_loadedCount = count _loaded;
|
||||||
|
if (_loadedCount == 0) exitwith {};
|
||||||
|
|
||||||
_ctrl = _display displayCtrl 100;
|
_ctrl = _display displayCtrl 100;
|
||||||
|
|
||||||
_selected = (lbCurSel _ctrl) max 0;
|
_selected = (lbCurSel _ctrl) max 0;
|
||||||
|
|
||||||
if (count _loaded <= _selected) exitwith {systemChat format["count: %1 %2", count _loaded, _selected]};
|
if (_loadedCount <= _selected) exitwith {systemChat format["count: %1 %2", _loadedCount, _selected]};
|
||||||
_item = _loaded select _selected;
|
_item = _loaded select _selected;
|
||||||
|
|
||||||
[_item, GVAR(interactionVehicle)] call FUNC(unloadItem);
|
[_item, GVAR(interactionVehicle)] call FUNC(unloadItem);
|
||||||
|
@ -44,7 +44,7 @@ if (_vehicle isKindOf "Ship" ) then {
|
|||||||
TRACE_1("getPosASL Vehicle Check", getPosASL _vehicle);
|
TRACE_1("getPosASL Vehicle Check", getPosASL _vehicle);
|
||||||
if (!_validVehiclestate) exitwith { false };
|
if (!_validVehiclestate) exitwith { false };
|
||||||
|
|
||||||
if (count _emptyPos == 0) exitwith { false}; //consider displaying text saying there are no safe places to exit the vehicle
|
if (count _emptyPos == 0) exitwith { false }; //consider displaying text saying there are no safe places to exit the vehicle
|
||||||
|
|
||||||
_loaded = _vehicle getvariable [QGVAR(loaded), []];
|
_loaded = _vehicle getvariable [QGVAR(loaded), []];
|
||||||
_loaded = _loaded - [_item];
|
_loaded = _loaded - [_item];
|
||||||
@ -52,7 +52,7 @@ _vehicle setvariable [QGVAR(loaded), _loaded, true];
|
|||||||
|
|
||||||
_space = [_vehicle] call FUNC(getCargoSpaceLeft);
|
_space = [_vehicle] call FUNC(getCargoSpaceLeft);
|
||||||
_itemSize = [_item] call FUNC(getSizeItem);
|
_itemSize = [_item] call FUNC(getSizeItem);
|
||||||
_vehicle setvariable [QGVAR(space), _space + _itemSize, true];
|
_vehicle setvariable [QGVAR(space), (_space + _itemSize), true];
|
||||||
|
|
||||||
detach _item;
|
detach _item;
|
||||||
_item setPosASL (_emptyPos call EFUNC(common,PositiontoASL));
|
_item setPosASL (_emptyPos call EFUNC(common,PositiontoASL));
|
||||||
|
@ -23,7 +23,8 @@ _totalSpaceOccupied = 0;
|
|||||||
_newLoaded pushback _x;
|
_newLoaded pushback _x;
|
||||||
_totalSpaceOccupied = _totalSpaceOccupied + ([_x] call FUNC(getSizeItem));
|
_totalSpaceOccupied = _totalSpaceOccupied + ([_x] call FUNC(getSizeItem));
|
||||||
};
|
};
|
||||||
}foreach _loaded;
|
true
|
||||||
|
} count _loaded;
|
||||||
|
|
||||||
if (count _loaded != count _newLoaded) then {
|
if (count _loaded != count _newLoaded) then {
|
||||||
_vehicle setvariable [QGVAR(loaded), _newLoaded, true];
|
_vehicle setvariable [QGVAR(loaded), _newLoaded, true];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user