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

Port over mutations granting effects (and fix) #180

Merged
merged 1 commit into from
Nov 3, 2020
Merged

Port over mutations granting effects (and fix) #180

merged 1 commit into from
Nov 3, 2020

Conversation

chaosvolt
Copy link
Member

Summary

SUMMARY: Features "Port over changes allowing enchantments to grant mutations, more flexible implementation of relic-based clairvoyance."

Purpose of change

Adds the code changes from the PRs that allow for enchantments to grant the effects of mutations. This includes the clairvoyance update that was added at the same time as the first PR, and the code changes in the followup PR so that it wasn't pretty much only applying mutation flag effects.

However, instead of tying clairvoyance to a mutation flag, I implemented it via effect flag instead. This is more versatile, not only can any source of enchantments thus provide clairvoyance via granting an effect, but likewise any source of effects (not just enchantments) can do so.

This will likely go well with future plans to JSONize more hardcoded checks to allow using effect flags.

Describe the solution

  1. Ported over changes to character.cpp, but with checks for effect flags instead of mutation flags, while also retaining the AEP checks since artifacts aren't quite gone yet.
  2. Ported over changes to item.cpp and item.h from the fix PR.
  3. Ported over changes to magic_enchantment.cpp and magic_enchantmemt.h allowing enchantments to add mutations.
  4. Ported over changes to mutation.cpp from the fix PR.
  5. Ported over changes to newcharacter.cpp also supporting this feature.
  6. Added the Debug Clairvoyance trait from the PR for testing.
  7. Added the debug testing relic from the last couple PRs, this time with a mutation effect added to it and an enchantment effect. Will alter its relic data as subsequent PRs warrant, making it a testbed for subsequent features being ported over.
  8. Added definitions for the flags to flags.json, not necessary but it's useful for reference since effect flags are not yet documented.
  9. Updated MAGIC.md to describe mutations from enchantments as well as effects from enchantments, added a demonstration of the former to the example mutation after that section.

Describe alternatives you've considered

Adding in the stranger method of checking for clairvoyance via mutation flag anyway. I was intially tempted to just add both to the code since it wouldn't really hurt, but I realized that using an effect flag for it can ALREADY do everything that the mutation flag can do, making the mutation flag method redundant.

Testing

Testing:

  1. Compile and load test.
  2. Start up game and spawn in the current edition of the Cube of Shame.
  3. Wield cube and wait a bit, confirming that effects of Psychosis start to take effect.
  4. Activate cube and check that debug clairvoyance is on the effect list, and that you can see through walls.
  5. Drop or deactivate cube, to confirm that clairvoyance effect goes away.
  6. Drop cube and confirm that Psychosis trait is gone.
  7. Debug in Psychosis trait onto the player.
  8. Pick up and drop cube again to confirm it does not remove the existing mutation.

Additional context

Relevant PRs:

  1. enchantments can have mutations, redo clairvoyance artifacts CleverRaven/Cataclysm-DDA#42199
  2. mutation enchantment item fix CleverRaven/Cataclysm-DDA#42950

Not ported over:

  1. The changes that turn the Architect's Cube from a generated-on-command artifact to a JSON-defined relic, since I added the Cube of Shame for general relic testing.
  2. Debug Clairvoyance trait, since mutations can grant enchantments, enchantments are about to be able to grant mutations, and enchantments can grant effects, etc etc.

Feel free to request any mutation checks that might be desirable to convert into an effect-flag check. Reasonably easy for me to do.

@chaosvolt
Copy link
Member Author

Running character.cpp through Astyle 3.1 shows a lot of changes the style edit proposes, but nothing in the sections this PR touched, far as I can tell?

Unless the message is saying game_inventory.cpp is where the astyle failure is, which would be odd given that wasn't touched at all.

@Coolthulhu
Copy link
Member

Unless the message is saying game_inventory.cpp is where the astyle failure is

That's my fault, thanks for reporting.

@Coolthulhu Coolthulhu merged commit 3178ea6 into cataclysmbnteam:upload Nov 3, 2020
{
"id": "debug_active_relic_test",
"type": "TOOL",
"name": { "str": "Cube of Shame", "str_pl": "Cubes of Shame" },
Copy link
Member

Choose a reason for hiding this comment

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

src/translations.cpp:530 [translation::deserialize(JsonIn&)::<lambda(const string&, int)>] 
line 203:40: Please use "str_sp" instead of "str" and "str_pl" for text with identical singular and plural forms

Copy link
Member Author

Choose a reason for hiding this comment

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

Plural string is "cubes of shame" which is not identical?

Copy link
Contributor

@olanti-p olanti-p Nov 3, 2020

Choose a reason for hiding this comment

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

"magazine_well": 1,
"relic_data": {
"passive_effects": [
{ "has": "HELD", "condition": "ALWAYS", "mutations": [ "SCHIZOPHRENIC" ] },
Copy link
Member

Choose a reason for hiding this comment

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

SCHIZOPHRENIC is a terrible mutation for testing because it's RNG-dependent.
Try something like carnivore.

Copy link
Member Author

Choose a reason for hiding this comment

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

True, was a bit of waiting. Had picked it more for thematic purposes, but can change to Carnivore next time I alter its properties.

"color": "blue",
"weight": "400 g",
"volume": "500 ml",
"charges_per_use": 1,
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't seem to be introduced here, but there is a bug with the system: charges_per_use do nothing here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Artifact from having based the item off a standard electronic item (fairly certain it was a flashlight), a lot of transforming items in the game have a charges per use but don't seem to respect it, seen in both DDA and BN.

Copy link
Member

Choose a reason for hiding this comment

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

Oh right: charge consumption occurs at the end of the function, but in transformation, this would consume charges from the transformed item, which may not work.

Copy link
Member Author

Choose a reason for hiding this comment

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

That could be it. Placing it earlier in the order would fix that, but it might be good to ensure that the check for needs_charges still happens earlier. Otherwise, presumably an item that checks for having a certain number of charges would (if it's exactly at the threshold for passing the needs_charges check) consume its charges, then fail the check.

@Coolthulhu
Copy link
Member

Crap, I accidentally merged it before testing it.
Well, the only serious error I see here is that json translation thing, trivially fixable.

@chaosvolt chaosvolt deleted the relic-mutations branch November 3, 2020 16:24
@chaosvolt
Copy link
Member Author

Ah, I just now found the translation error. It's in the name of the active version, not the inactive one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants