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

Add cargo eden attributes #4780

Merged
merged 14 commits into from
May 31, 2017
Merged

Add cargo eden attributes #4780

merged 14 commits into from
May 31, 2017

Conversation

kymckay
Copy link
Member

@kymckay kymckay commented Dec 20, 2016

Inspired by #4283

  • Add an ace_cargo_space attribute to vehicles to alter how much cargo they can carry
  • Add an ace_cargo_size attribute to objects to alter how much cargo space they consume
  • Add a ace_cargo_setSize public function
  • Add a ace_cargo_setSpace public function
  • Deprecate ace_cargo_makeLoadable public function and associated module

Known issues in current WIP implementation:

  • Public functions do not provide menus for future JIP players
    • This is no different from current behaviour of existing public function, probably because it's a PITA to handle. Could be fixed using a CBA_fnc_globalEventJIP, would need to track the ID of which on the object for future function calls to overwrite the event.
  • Public functions used more than once on the same object (which doesn't usually have a menu) will add two action menu entries
  • Vehicles may have 2 cargo actions in their interaction menu (XEH initPost runs twice when added retroactively via function CBATeam/CBA_A3#567)

- Add a ace_cargo_space attribute to vehicles to alter how much cargo they can carry
- Add an ace_cargo-size attribute to objects to alter how much cargo space they consume
@kymckay kymckay added kind/enhancement Release Notes: **IMPROVED:** status/WIP labels Dec 20, 2016
control = "Edit";

// Expression only runs on the server, must handle actions for all machines and future JIPs (Why BI?!)
expression = QUOTE(_this setVariable [ARR_3('%s',_value,true)]; [QQGVAR(EdenObjectInit),_this] call CBA_fnc_globalEventJIP;);
Copy link
Member Author

Choose a reason for hiding this comment

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

Just realised there's a missing ARR_2 here that I must have added on my local version after committing. Rest assured, that's not what was making the initObject call fail to work.

Not perfect, but prevents the attribute from being added to static objects where the postInit XEH won't run for the time being
- Adds two functions `fnc_setSize.sqf` and `fnc_setSpace.sqf` to update
  the cargo size/space respectively of any given object.
- Functions provide means to change these values either locally or
  globally.
- Will delay execution until after settings have initalized so that
  functions work correctly no matter when they're called.
- Functions are now used by eden attributes to correctly apply values to
  any object without issue.
- Currently will not update size/space for JIP players, unsure how best to
  handle.
- Currently will create duplicate action menu entries for objects on which
  the functions are used more than once.
- Adds additional condition to the cargo menu for vehicles (requires
  `hasCargo`)
- Change the `canLoad` object variable to a boolean for simplicity
This module and associated public function are entriely replaced by the
new eden settings and associated functions.
@kymckay
Copy link
Member Author

kymckay commented Dec 21, 2016

Good call, it actually looks like this is being handled already in fnc_canLoadItemIn so it can be removed from the action conditions 😄

Already handled in `fnc_canLoadItemIn`.

This reverts commit 6169af9.
Prevents multiple calls to the cargo API on the same object from adding
multiple menu entries to the object.
Adds relevant cargo menus on JIP machines to any objects globally provided with
size/space via the public API.
@kymckay
Copy link
Member Author

kymckay commented Dec 21, 2016

Fixed and tested JIP compatiblity 👍 Working as expected

@kymckay
Copy link
Member Author

kymckay commented Dec 21, 2016

Think this is now ready to go if anyone wants to review it. Assigned commy as he's a listed maintainer and pabst because he showed some interest in this.

@kymckay kymckay added this to the 3.10.0 milestone Dec 21, 2016
- Now no menu is added if the new space/size is not applicable.
- No need to add the cargo actions if already done globally in a previous
  function call.
- The init functions use an object variable instead of a GVAR for marking objects as already initalized. Saving some resources in cases where objects are later deleted/cleaned up.
- Added some macros to get the space/size of a config, making code more readable in places.
@commy2
Copy link
Contributor

commy2 commented Apr 10, 2017

I like it, could be merged.

@kymckay
Copy link
Member Author

kymckay commented May 10, 2017

Mentioned in private slack, but looking at this now I'm not sure I like the way I've handled the locality in the public functions. I believe my intent was to allow the size/space to be set independently on each machine if desired (for example maybe only a specific player should be able to load the object in question). However it introduces a layer of complexity I'm not sure we want to have.

@PabstMirror
Copy link
Contributor

I think size vars should to be the same on all machines

@kymckay
Copy link
Member Author

kymckay commented May 31, 2017

Yeah I think it keeps things simpler to have values synced. I'll modify the public functions in this.

kymckay and others added 4 commits May 31, 2017 14:36
- Keeps the size/space value set publically synced. Use cases for individual
  values on each machine are minimal.
- If a user wanted to restrict who can load what, we should provide other
  methods of achieving that which don't complicate the code here.
 Conflicts:
	addons/cargo/functions/fnc_initObject.sqf
	addons/cargo/script_component.hpp
Copy link
Contributor

@PabstMirror PabstMirror left a comment

Choose a reason for hiding this comment

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

Looks good,
got it working with #4871

 Conflicts:
	addons/cargo/functions/fnc_initVehicle.sqf
@kymckay kymckay merged commit fea2326 into master May 31, 2017
@kymckay kymckay deleted the edenCargo branch May 31, 2017 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Release Notes: **IMPROVED:**
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants