Skip to content
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

AI Logistics - Vehicles with route pickets #803

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

AnAngrySalad1
Copy link
Contributor

When merged this pull request will:

  • Adds the initial code for review.
  • Runs off a wait and execute.
  • Known issues:
    • Creates 1 visible agent and doesn't delete the agent.
    • Randomly occurring script error around an '==' check in an IF statement but does seem to work still.

Copy link
Member

@tbeswick96 tbeswick96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start, some changes needed however.

Randomly occurring script error around an '==' check in an IF statement but does seem to work still

This is never ok. Script errors that appear to still work can't be written off as known issues.
(The error here is an undefined variable)

// TODO: Change this to use a common component for spawned AI deletion

(_leader getVariable [QEGVAR(common,assignedVehicle), objNull]) call CBA_fnc_deleteEntity;
(vehicle _leader) call CBA_fnc_deleteEntity;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this changed? This is designed to delete the vehicle given to the unit at spawn, to cover cases where the unit is no longer inside the vehicle

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I first looked at it, I didn't remember assigning the vehicle with a setVar so thought it would return nothing. I've reverted it back.

addons/ailogistics/CfgVehicles.hpp Outdated Show resolved Hide resolved
addons/ailogistics/README.md Outdated Show resolved Hide resolved
addons/ailogistics/CfgVehicles.hpp Outdated Show resolved Hide resolved
addons/ailogistics/XEH_PREP.hpp Outdated Show resolved Hide resolved
addons/ailogistics/functions/fnc_logisticsMain.sqf Outdated Show resolved Hide resolved
addons/ailogistics/functions/fnc_logisticsMain.sqf Outdated Show resolved Hide resolved
addons/ailogistics/functions/fnc_logisticsMain.sqf Outdated Show resolved Hide resolved
addons/ailogistics/functions/fnc_logisticsMain.sqf Outdated Show resolved Hide resolved
addons/ailogistics/functions/fnc_logisticsMain.sqf Outdated Show resolved Hide resolved
@tbeswick96 tbeswick96 changed the title Initial commit of V1, couple of issues that need fixing. AI Logistics Mar 17, 2021
@tbeswick96 tbeswick96 changed the title AI Logistics AI Logistics - Vehicles with route pickets Mar 17, 2021
@tbeswick96 tbeswick96 added this to the 5.19.18 milestone Mar 17, 2021
@tbeswick96
Copy link
Member

Also think using synchronized picket modules instead of the path calculation might be better and give greater control to the mission maker.
To ensure the vehicle still routes via each picket location, you could add a waypoint to each picket in turn (or to the nearest road if the picket is on the side of a hill for example)

@AnAngrySalad1
Copy link
Contributor Author

Also think using synchronized picket modules instead of the path calculation might be better and give greater control to the mission maker.
To ensure the vehicle still routes via each picket location, you could add a waypoint to each picket in turn (or to the nearest road if the picket is on the side of a hill for example)

I actually really like this, probably alot easier to. Might be able to change the picket behaviour to by using LAMBs camp or garrison.

@tbeswick96 tbeswick96 modified the milestones: 5.19.18, 5.18.19, 5.19.19, 5.20.1, 5.20.2 Mar 27, 2021
- Various fixes
- Correcting merge mistakes
@AnAngrySalad1
Copy link
Contributor Author

I've added code to make the logistics vehicle drive to the picket locations. It tries to find the nearest road to the picket location. If empty it'll just go to the picket location. An issue with this I can forsee is that if a picket is placed between say a fork and ends up travelling down a different road than mission maker intended so will require a degree of intelligent placement, not sure we could script for that outcome.

Copy link
Member

@tbeswick96 tbeswick96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some previously resolved things marked as unresolved.

Few things highlighted in one place only (params ordering, changes to side), make sure changed in all relevant places

[{
params ["_module"];
[_module] call FUNC(createLogisticVehicle);
}, [_module], random _time] call cba_fnc_waitAndExecute;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This random _time needs to be considered with a minimum. This will currently resolve from 0 to _time.
If you want variance in the timeout, consider adding the base timeout to some random value. e.g
_time + random 60 or _time + random (_time / 10)

};
};
};
class GVAR(logisticsPicketGroup) : GVAR(module) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad indentation

Comment on lines +9 to +16
GVAR(unitPoolString) = [];
GVAR(logisticVehiclePoolString) = [];
GVAR(routePickets) = false;
GVAR(picketLocations) = [];
GVAR(picketUnitPoolString) = [];
GVAR(picketGroupSize) = 0;
GVAR(logisticsObject) = ObjNull;
GVAR(logisticalVehicleNumber) = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these variables are not used, remove them. Looks like everything is done via the module variables?


if (!isServer) exitWith {};

params ["_module"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

params first, before server check, for consistency


{
private _sideFromModule = _x getVariable [QGVAR(side), 0];
if (_sideFromModule == 0) then {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it planned that this could run twice for the same modules?
If so, the types are going to be out of whack due to the reassignment of the variable.

For robustness, I would resolve the side here for use only and leave the module variable intact as a number.

e.g

private _sideNumber = _x getVariable [QGVAR(side), 0];
private _side = [EAST, INDEPENDENT] select _sideNumber;


params ["_module", "_group"];

private _destinationModule = (synchronizedObjects _module) select {_x isKindOf "uksf_ailogistics_logisticsDestination"};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the macro version instead of magic strings.
QGVAR(logisticsDestination)
and
QGVAR(logisticsPicketGroup)

} else {
_module setVariable [QGVAR(side), INDEPENDENT];
};
private _side = _module getVariable [QGVAR(side), EAST];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here for the side thing as above. Once you reassign this variable, if you read it anywhere else it'll be the wrong type

@@ -0,0 +1,6 @@
class CfgFactionClasses {
class EGVAR(common,eden);
class ADDON: EGVAR(common,eden){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class ADDON: EGVAR(common,eden){
class ADDON: EGVAR(common,eden) {

@tbeswick96 tbeswick96 modified the milestones: 5.20.2, 5.20.3 Apr 14, 2021
@tbeswick96 tbeswick96 modified the milestones: 5.20.3, 5.20.4, 5.20.5 May 1, 2021
@tbeswick96 tbeswick96 removed this from the 5.20.5 milestone May 14, 2021
@tbeswick96 tbeswick96 added this to the 5.20.6 milestone May 14, 2021
@tbeswick96 tbeswick96 modified the milestones: 5.20.6, 5.21.0 Jun 3, 2021
@tbeswick96 tbeswick96 modified the milestones: 5.21.0, Backlog Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants