-
Notifications
You must be signed in to change notification settings - Fork 737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cargo load menu overhaul #4871
Cargo load menu overhaul #4871
Conversation
_action = [format ["%1", _x], _name, _icon, _statement, {true}, {}, [_x]] call ace_interact_menu_fnc_createAction; | ||
_actions pushBack [_action, [], _target]; | ||
false | ||
} count (_player nearEntities [["Car", "Air", "Tank", "Ship", "Cargo_base_F"], MAX_LOAD_DISTANCE]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all vehicles can load stuff. I don't see that filtered here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean by that, what happens if you're near a vehicle that is Car, but cannot load anything? (e.g. a Kart)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"could not be loaded" message appears as earlier in "Load" action. And I think it's OK, in RL you can't magically see which vehicles have enough room.
As for Kart - maybe it has sense to check vehicles cargo space config in show condition. But this behavior differs from current "Load" action, I didn't want to change it. If you insist I'll add it and remove "Load" action.
#include "script_component.hpp" | ||
|
||
params ["_target", "_player"]; | ||
private ["_statement", "_actions", "_name", "_ownerName", "_icon", "_action"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use private keyword
. The variables from L31 onwards aren't even in the same script instance!
I'd keep it.
I don't think so, as it has it's own action as well I think it's good as is.
That probably wouldn't be bad if you can sort by distance easily without losing on performance. |
TRACE_3("params",_player,_object,_vehicle); | ||
|
||
if (isNull _vehicle) then { | ||
_vehicle = [_player, _object] call FUNC(findNearestVehicle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't reuse variable names in this way. Name it differently and set it to private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean "_vehicle" I don't reuse it. I need it set to vehicle from parameters or from nearest vehicles.
If you mean something else I don't understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you mean I shouldn't reuse variable which is from params? OK, I'll fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I'll add new argument description.
_name = format ["%1 (%2)", _name, _ownerName]; | ||
}; | ||
private _icon = (getText (configFile >> "CfgVehicles" >> typeOf _x >> "icon")) call BIS_fnc_textureVehicleIcon; | ||
private _action = [format ["%1", _x], _name, _icon, _statement, {true}, {}, [_x]] call ace_interact_menu_fnc_createAction; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EFUNC(interact_menu,createAction)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad
if ((isNull _vehicle) || {_vehicle isKindOf "Cargo_Base_F"}) then { | ||
{ | ||
if ([_object, _x] call FUNC(canLoadItemIn)) exitWith {_vehicle = _x}; | ||
} forEach (nearestObjects [_player, ["Cargo_base_F", "Land_PaperBox_closed_F"], MAX_LOAD_DISTANCE]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a fan of magic numbers in code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not my code. I just put it inside if-then. Anyway I don't understand about magic numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard coded classnames like "Cargo_base_F"
and especially "Land_PaperBox_closed_F"
.
This will make it harder to add compatibility with new objects later, because you have to alter lines buried in the code instead of a separate config and it will make it almost impossible for 3rd party mods.
WIP |
All done, please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried this out and like it a lot
- Good simplification of the code, while adding a feature
- Also like how the base action "Load" still works and will just select the closest vehicle automatically (could possibly not show sub actions if there is only 1 vic in range, but that might be confusing as well?)
Yeah I'd definitely still show the sub action when only one is in range for consistency |
Vehicles with alive crew are suffixed with its name (in brackets).
There are also some questions to resolve: