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

feat(port): start work on porting relic generation #4171

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

chaosvolt
Copy link
Member

Purpose of change

This finally starts work on porting relic generation.

Very WIP as right now it doesn't compile due to an issue in relic.cpp I'm not sure the issue of, plus other things to be done.

Describe the solution

C++ changes:

  1. Calls to artifact spawns in debug_menu.cpp, map_extra.cpp, mapgen.cpp, and mondeath.cpp updated to use the new version of the function below.
  2. Added relicgen loading to init.cpp.
  3. Added item::overwrite_relic function to item.cpp and item.h.
  4. Port the PR's add/set functions to magic_enchantment.cpp and magic_enchantment.h.
  5. Port the PR's conversion of spawn_artifact into a thing that creates a relic instead of an old-style artifact.
  6. Ported relic.cpp and relic.h stuff meant to defined relic generation code. Some apparent overlap with relic recharge so I'm not 100% if things are all in the right places.

JSON changes:

  1. Ported Korg's relic gen JSON from that source PR. Will likely be overhauled and improved once I get it working, depending on whether we simplify the way it picks effects.

Doc changes:

  1. Ported relicgen code documentation.

TODO:

  1. Make sure it works and test the fuck out of it. It's spell and relic code, it always needs that.
  2. Possibly simplify the whole type_weights and strength stuff into a less convoluted "pick X good values and Y bad ones" system.
  3. Search for any other things related to relic gen in follow up PRs that should be put in this PR to start.
  4. Write better relicgen effects.
  5. Port support for spawning relics in itemgroups.
  6. Port Korg's "convert old artifacts into a randomly-generated relic" migration but maybe actually try to see if it can convert AEPs into direct relic equivalents, instead of the lazy workaround DDA uses that just converts it into a new relic with rerolled properties.

Describe alternatives you've considered

Putting this off until Olanti or Kheir suffer through trying to port this and test it for bugs instead.

Testing

Testing to continue as implementation ensues.

Of note, current issue:

relic.cpp(165,12): error C2065: 'relic_procgen_data_factory': undeclared identifier
relic.cpp(171,12): error C2065: 'relic_procgen_data_factory': undeclared identifier
relic.cpp(176,5): error C2065: 'relic_procgen_data_factory': undeclared identifier

I'm assuming this means I placed the needed file contents in the wrong spots within namespaces/classes/whatever, due to the fact that #2284 already defined some of the same spaces the relicgen PR defined, I just can't spot the problem at a glance here.

Additional context

Source PR: relic generation, by @KorGgenT: CleverRaven/Cataclysm-DDA#41589

Checklist

chaosvolt and others added 4 commits January 24, 2024 10:50
Co-Authored-By: Curtis Merrill <30208401+KorGgenT@users.noreply.github.com>
Co-Authored-By: Curtis Merrill <30208401+KorGgenT@users.noreply.github.com>
@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 28, 2024
Copy link
Contributor

autofix-ci bot commented Jan 28, 2024

The Autofix app has found code style violation and automatically formatted this Pull Request.

I locally edit my commits (e.g: git, github desktop)

Please choose following options:

I'd like to accept the automated commit
  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.

This PR is complete and I don't want to edit it anymore

It's safe to ignore this message.

I edit this PR through web UI

You can ignore this message and continue working.

I have no idea what this message is talking about

You can ignore this message and continue working. If you find any problem, please ask for help and ping @scarf005.

@Cactoideae
Copy link
Contributor

Please, for the love of all that's holy, improve on the overhaul instead of porting it as-is. Half the artifact effects have been broken or incomplete ever since DDA switched them over to relics, and nobody ever cared to fix any of it.

@chaosvolt
Copy link
Member Author

I plan to, yeah. Adding more and better relic effects for them to generate with for one, possibly overhauling how the generation tables work.

Right now I've kinda left it on the backburner because I need to convert some functions here to use item identity stuff.

src/map.cpp Outdated
{
add_item_or_charges( p, item::spawn( new_natural_artifact( prop ),
calendar::start_of_cataclysm ) );
add_item_or_charges( p, item::spawn( id->create_item( rules ) ) );
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need the item::spawn call here, you can just use id->create_item raw. It won't cause any real problems but it's spawning a new copy of the item and deleting the original.

Other than that it looks good though.

Copy link
Member Author

Choose a reason for hiding this comment

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

You sure that's the only problem? Because as it is now it doesn't compile because I haven't finished converting all functions to use item identity stuff, if I recall.

src/relic.cpp Outdated

it->overwrite_relic( generate( rules, *it_id ) );

return detached_ptr<item>( it );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, this needs to be just return it as well. I'm not sure about the empty error, it's suggesting is_empty. Might be right?

@chaosvolt
Copy link
Member Author

Closing for now as this has been in the "it's not working because I don't fully understand item identity yet" limbo for a while and I've not really made any progress since then.

More importantly, an idea struck me last night about a possible way to accomplish this general idea. The good news is it won't involve glomming onto any of Korg's code, trying to untangle the differences in code between the forks, and hunt for any untested jank hidden in it. The bad news is I'm going to it's going to be absolutely fucking tedious for me to work on instead of actually difficult.

Will muse upon the idea when I get home.

@chaosvolt chaosvolt closed this May 16, 2024
@chaosvolt
Copy link
Member Author

So I may be stupid, I'm compile-testing this now and it seems to be working? I'll play with it a bit more and reopen if everything goes well.

@chaosvolt chaosvolt reopened this May 17, 2024
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