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

fix: Advanced Object Deconstruction no longer hides deconstruction results #5867

Merged
merged 10 commits into from
Jan 2, 2025

Conversation

karxi
Copy link
Contributor

@karxi karxi commented Jan 2, 2025

Checklist

Required

Optional

  • This is a C++ PR that modifies JSON loading or behavior.
    • I have documented the changes in the appropriate location in the doc/ folder.
    • If applicable, add checks on game load that would validate the loaded data.

Purpose of change

The change that broadened the use of Advanced Object Deconstruction also deprived players of information on what deconstructing given objects (largely electronics) could produce. This made hunting for specific parts somewhat frustrating, most of all for new players.

Describe the solution

There are a few different factors here.

  1. Constructions now have a "deny_flags" field that specifies terrain/furniture that should be blacklisted from a given construction operation.
  2. A new flag has been added, ADV_DECONSTRUCT, which (currently) marks something that can't be deconstructed by "Deconstruct (Simple) Furniture".
  3. Deconstruction results have been added back to their terrain/furniture entries. (These are what the game checks upon examination, so there wasn't really any clean way around this.)
  4. The new standard, as a result, is to add these lines to AOD entries:
    "pre_special": "check_deconstruct",
    "post_flags": [ "keep_items" ],
    "post_special": "done_deconstruct",
  1. ...and, following that, to remove "post_terrain"/"post_furniture" from the AOD entries. Use "ter_set" in the "deconstruct" definitions instead. (Basically, define the resuls of deconstruction the old way.)
  2. If you don't do ♯6 (and thus use "done_deconstruct" in a construction entry that tries to set post terrain/furniture) the game will refuse to load. (Doing that would at best double deconstruction attempts, and at worst crash the game, so it's disallowed.)

Describe alternatives you've considered

  1. Breaking compatibility with mods by forcing normal deconstruction to require a tag. Obviously, that wasn't a good idea.
  2. Updating the examination logic in map_data_common_t::extended_description to cross-reference construction results for information. This was also a pretty terrible idea.

Testing

Load the game; examine an AOD object (I used computer terminals, amongst other things); try using Furniture Deconstruction on said object (it won't be listed as possible). Use AOD on it, it should disassemble properly.
Add "post_terrain" or "post_furniture" to an AOD entry that has "post_special": "done_deconstruct", try to load the game, get an error about why it refuses to load.

Additional context

This essentially makes each AOD entry function like constr_deconstruct (Furniture Deconstruction), but denies that from working on said objects. That means that the game can still reference deconstruction fields (which also keeps terrain information in one place instead of spread out into "byproducts"), while still imposing restrictions on how something is deconstructed. It also means the Hitchhiker's Guide will neatly display deconstruction results again.
As an additional bonus, it also means deconstruction results spawn on the tile that was deconstructed, instead of being dropped under the players' feet. That really got on my nerves.

@github-actions github-actions bot added docs PRs releated to docs page src changes related to source code. JSON related to game datas in JSON format. labels Jan 2, 2025
Copy link
Contributor

autofix-ci bot commented Jan 2, 2025

Autofix has formatted code style violation in this PR.

I edit commits locally (e.g: git, github desktop) and want to keep autofix
  1. Run git pull. this will merge the automated commit into your local copy of the PR branch.
  2. Continue working.
I do not want the automated commit
  1. Format your code locally, then commit it.
  2. Run git push --force to force push your branch. This will overwrite the automated commit on remote with your local one.
  3. Continue working.

If you don't do this, your following commits will be based on the old commit, and cause MERGE CONFLICT.

Copy link
Collaborator

@RoyalFox2140 RoyalFox2140 left a comment

Choose a reason for hiding this comment

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

image
image

Correctly denies deconstruct + simple while showing resources ill receive

Copy link
Collaborator

@RobbieNeko RobbieNeko left a comment

Choose a reason for hiding this comment

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

image
It builds, it works on my machine

@RoyalFox2140 RoyalFox2140 merged commit c75fb01 into cataclysmbnteam:main Jan 2, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs PRs releated to docs page JSON related to game datas in JSON format. src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants