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 assign reader for damage instances, deprecate legacy damage code #37329

Merged
merged 2 commits into from Apr 9, 2020

Conversation

anothersimulacrum
Copy link
Member

@anothersimulacrum anothersimulacrum commented Jan 23, 2020

Summary

SUMMARY: Infrastructure "Add damage instance assign reader, unify item damage loading code"

Purpose of change

This makes it easier to modify the damage type of ranged weapons (instead of all of them dealing DT_STAB, as well as enabling obsoleting legacy members for armor penetration and proportional damage in favor of having one damage object that defines that.

In the future, this will make it easier to allow using damage objects everywhere we have damage, instead of raw integers for various types (in places like item melee damage).

Describe the solution

Add an assign reader for damage_instances and three static functions to validate the assigned damage, and to assign damage using relative and proportional.

Add unconditional_ res_mult and damage_mult to replace proportional damage and add proportional piercing capability, for arrows.

Describe alternatives you've considered

Not doing the JSON changes in the same PR. I probably will back them out and do them in a separate PR later.

Testing

Tests run correctly.

TODO:

  • Ensure that damage for things are unchanged with and without this applied
  • Make sure this displays correctly
  • Make sure that the obsoleted members/new members of damage units all work properly and are slotted in where they should be.

Additional context

Working towards obsoleting use of raw floats over multiple members to assign damage.
Originally started as a look into making a DT_BULLET, and then looking into using damage objects for bullet/gun damage.

src/damage.cpp Outdated Show resolved Hide resolved
@ZhilkinSerg ZhilkinSerg added 0.E Feature Freeze [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Items / Item Actions / Item Qualities Items and how they work and interact labels Jan 30, 2020
@ZhilkinSerg
Copy link
Contributor

I suggest we jsonize damage types too. I actually started this in https://github.com/ZhilkinSerg/Cataclysm-DDA/tree/jsonize-damage-type.

@anothersimulacrum
Copy link
Member Author

Okay, after fixing two issues regarding copy-from, I think everything's working right and this is ready for merge. I've decided to pull out the JSON changes (barring one to prevent load error) to make extra sure that this works with no data migration.

I'll open another PR with those.

@anothersimulacrum anothersimulacrum marked this pull request as ready for review March 18, 2020 22:40
@anothersimulacrum anothersimulacrum changed the title [WIP][CR] Add assign reader for damage instances, deprecate legacy damage code [CR] Add assign reader for damage instances, deprecate legacy damage code Mar 18, 2020
@anothersimulacrum anothersimulacrum changed the title [CR] Add assign reader for damage instances, deprecate legacy damage code Add assign reader for damage instances, deprecate legacy damage code Mar 19, 2020
@ZhilkinSerg
Copy link
Contributor

Can you resolve conflicts please?

@anothersimulacrum
Copy link
Member Author

Hhm, rebased, but found a bug. Looking into it.

This assign reader allows consistent and clear reading of damage
instances for all items.

Make the necessary changes to item factory and damage units to preserve
existing functionality.
These names weren't very clear, hopefully this is an improvement.

The JSON changes are to fix errors this exposes.
@anothersimulacrum
Copy link
Member Author

Should be good now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Items / Item Actions / Item Qualities Items and how they work and interact [JSON] Changes (can be) made in JSON
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants