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) = [];
|
||||
|
||||
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;
|
||||
|
@ -6,26 +6,26 @@
|
||||
* 0: Object <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Can load <BOOL>
|
||||
* Vehicle that is in Distance <OBJECT>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_vehicle"];
|
||||
private ["_loadCar", "_loadHelicopter", "_loadTank", "_loadShip"];
|
||||
params ["_unit"];
|
||||
|
||||
_vehicle = nearestObject [_unit, "car"];
|
||||
_loadCar = nearestObject [_unit, "car"];
|
||||
if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle};
|
||||
|
||||
_loadhelicopter = nearestObject [_unit, "air"];
|
||||
if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle};
|
||||
_loadHelicopter = nearestObject [_unit, "air"];
|
||||
if (_unit distance _loadHelicopter <= MAX_LOAD_DISTANCE) exitwith {_loadHelicopter};
|
||||
|
||||
_loadtank = nearestObject [_unit, "tank"];
|
||||
if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle};
|
||||
_loadTank = nearestObject [_unit, "tank"];
|
||||
if (_unit distance _loadTank <= MAX_LOAD_DISTANCE) exitwith {_loadTank};
|
||||
|
||||
_loadtank = nearestObject [_unit, "ship"];
|
||||
if (_unit distance _vehicle <= MAX_LOAD_DISTANCE) exitwith {_vehicle};
|
||||
_loadShip = nearestObject [_unit, "ship"];
|
||||
if (_unit distance _loadShip <= MAX_LOAD_DISTANCE) exitwith {_loadShip};
|
||||
|
||||
objNull;
|
||||
|
@ -6,15 +6,16 @@
|
||||
* 0: Object <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Cargo size. -1 is not a size defined <NUMBER>
|
||||
* Cargo size. <NUMBER> (default: -1)
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_item"];
|
||||
if (isNumber (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size))) exitwith {
|
||||
_item getvariable [QGVAR(size), getNumber (configFile >> "CfgVehicles" >> typeof _item >> QGVAR(size))];
|
||||
params ["_item", "_config"];
|
||||
_config = (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?
|
||||
deleteVehicle _x;
|
||||
//_x setDamage 1;
|
||||
}foreach _loaded;
|
||||
} count _loaded;
|
||||
|
||||
[_vehicle] call FUNC(validateCargoSpace);
|
||||
|
@ -28,8 +28,8 @@ if (isServer) then {
|
||||
_className = getText (_x >> "type");
|
||||
_amount = getNumber (_x >> "amount");
|
||||
_position = getPos _vehicle;
|
||||
_position set [2, (_position select 2) + 7.5];
|
||||
_position set [1, (_position select 1) + 1];
|
||||
_position set [2, (_position select 2) + 7.5];
|
||||
for "_i" from 1 to _amount do {
|
||||
_object = createVehicle [_className, _position, [], 0, "CAN_COLLIDE"];
|
||||
if !([_object, _vehicle] call FUNC(loadItem)) exitwith {
|
||||
@ -38,7 +38,7 @@ if (isServer) then {
|
||||
};
|
||||
};
|
||||
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;
|
||||
{
|
||||
_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)];
|
||||
}, 0, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
@ -13,19 +13,20 @@
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_display", "_loaded", "_ctrl", "_selected", "_item"];
|
||||
private ["_display", "_loaded", "_loadedCount", "_ctrl", "_selected", "_item"];
|
||||
disableSerialization;
|
||||
_display = uiNamespace getvariable QGVAR(menuDisplay);
|
||||
if (isnil "_display") exitwith {};
|
||||
|
||||
_loaded = GVAR(interactionVehicle) getvariable [QGVAR(loaded), []];
|
||||
if (count _loaded == 0) exitwith {};
|
||||
_loadedCount = count _loaded;
|
||||
if (_loadedCount == 0) exitwith {};
|
||||
|
||||
_ctrl = _display displayCtrl 100;
|
||||
|
||||
_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, GVAR(interactionVehicle)] call FUNC(unloadItem);
|
||||
|
@ -44,7 +44,7 @@ if (_vehicle isKindOf "Ship" ) then {
|
||||
TRACE_1("getPosASL Vehicle Check", getPosASL _vehicle);
|
||||
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 = _loaded - [_item];
|
||||
@ -52,7 +52,7 @@ _vehicle setvariable [QGVAR(loaded), _loaded, true];
|
||||
|
||||
_space = [_vehicle] call FUNC(getCargoSpaceLeft);
|
||||
_itemSize = [_item] call FUNC(getSizeItem);
|
||||
_vehicle setvariable [QGVAR(space), _space + _itemSize, true];
|
||||
_vehicle setvariable [QGVAR(space), (_space + _itemSize), true];
|
||||
|
||||
detach _item;
|
||||
_item setPosASL (_emptyPos call EFUNC(common,PositiontoASL));
|
||||
|
@ -23,7 +23,8 @@ _totalSpaceOccupied = 0;
|
||||
_newLoaded pushback _x;
|
||||
_totalSpaceOccupied = _totalSpaceOccupied + ([_x] call FUNC(getSizeItem));
|
||||
};
|
||||
}foreach _loaded;
|
||||
true
|
||||
} count _loaded;
|
||||
|
||||
if (count _loaded != count _newLoaded) then {
|
||||
_vehicle setvariable [QGVAR(loaded), _newLoaded, true];
|
||||
|
Loading…
Reference in New Issue
Block a user