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: Armor values specified directly in armor JSON #3930

Merged
merged 8 commits into from
Feb 7, 2024

Conversation

Coolthulhu
Copy link
Member

@Coolthulhu Coolthulhu commented Dec 16, 2023

Purpose of change

Allow fine-tuning armor values, without having to rely on materials and material thickness.

Describe the solution

Armor item type now has an extra field: "resistance".
It looks like this:

"resistance": { "cut": 0, "bullet": 1000 }

If this field is specified, armor values from materials and thickness are ignored.

Note: if armor override is specified, armor values are not reduced when the armor is damaged.

Describe alternatives you've considered

  • Trying to salvage material thickness system by adding material percentage (10% plastic, 90% steel etc.) to allow more fiddling

Testing

  • Tests pass
  • Spawn debug item "bulletproof armor"
  • Spawn turrets
  • Get shot and take no damage
  • Spawn zombie predator
  • Confirm that all attacks deal damage, including the impale attack, which is piercing type and scratch, which is cutting

Additional context

Checklist

  • Default to material values if override isn't specified for a given type
  • Docs
  • (Optional) Reduce armor value with damage based on material thickness pre-damage and post-damage

@github-actions github-actions bot added src changes related to source code. JSON related to game datas in JSON format. tests changes related to tests mods PR changes related to mods. labels Dec 16, 2023
@scarf005 scarf005 self-requested a review December 17, 2023 22:44
@scarf005 scarf005 self-assigned this Dec 17, 2023
@scarf005
Copy link
Member

scarf005 commented Jan 6, 2024

maybe it'd be better if overrides could be defined using #2776

@Coolthulhu
Copy link
Member Author

Coolthulhu commented Jan 20, 2024

maybe it'd be better if overrides could be defined using #2776

Will do, it may be a source of conflict otherwise.

EDIT: ...Or not. It won't conflict, so I'll keep this one small for now.
It would be a big rewrite of resistance checks to change it.

@scarf005
Copy link
Member

alright. in my opinion, while manually overriding armor values could be useful in some cases, i'd like the material system to get more love, e.g computing various armor stats from material composition
we do have material thickness, but it's manually defined and doesn't get computed from coverage/armor proportion data/weight/volume.

@Coolthulhu
Copy link
Member Author

i'd like the material system to get more love, e.g computing various armor stats from material composition

That could be cool if we could manage it, but so far, the material system has been more of a hindrance than a benefit.
We don't have transmutation of materials or material variants of the same item, but we still have all the downsides that come from a material system. If we ever get material variants, we could revisit calculation from materials.

@Coolthulhu Coolthulhu marked this pull request as ready for review January 21, 2024 04:41
@github-actions github-actions bot added the docs PRs releated to docs page label Jan 21, 2024
@chaosvolt chaosvolt merged commit 9f3d069 into cataclysmbnteam:main Feb 7, 2024
12 of 14 checks passed
@chaosvolt
Copy link
Member

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\optional(69,17): warning C4244: 'initializing': conversion from '_Ty' to 'float', possible loss of data
1>        with
1>        [
1>            _Ty=double
1>        ] (compiling source file ..\src\damage.cpp)
1>C:\Users\Vincent\Documents\GitHub\Cataclysm-BN\src\damage.cpp(528): message : see reference to function template instantiation 'std::_Optional_destruct_base<_Ty,true>::_Optional_destruct_base<double>(std::in_place_t,double &&)' being compiled
1>        with
1>        [
1>            _Ty=float
1>        ]
1>C:\Users\Vincent\Documents\GitHub\Cataclysm-BN\src\damage.cpp(528): message : see reference to function template instantiation 'std::_Optional_destruct_base<_Ty,true>::_Optional_destruct_base<double>(std::in_place_t,double &&)' being compiled
1>        with
1>        [
1>            _Ty=float
1>        ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\optional(185): message : see reference to function template instantiation 'std::_Optional_construct_base<_Ty>::_Optional_construct_base<double>(std::in_place_t,double &&)' being compiled
1>        with
1>        [
1>            _Ty=float
1>        ] (compiling source file ..\src\damage.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\optional(185): message : see reference to function template instantiation 'std::_Optional_construct_base<_Ty>::_Optional_construct_base<double>(std::in_place_t,double &&)' being compiled
1>        with
1>        [
1>            _Ty=float
1>        ] (compiling source file ..\src\damage.cpp)
1>C:\Users\Vincent\Documents\GitHub\Cataclysm-BN\src\damage.cpp(437): message : see reference to function template instantiation 'std::optional<float>::optional<double,0>(_Ty2 &&)' being compiled
1>        with
1>        [
1>            _Ty2=double
1>        ]
1>C:\Users\Vincent\Documents\GitHub\Cataclysm-BN\src\damage.cpp(435): message : see reference to function template instantiation 'std::optional<float>::optional<double,0>(_Ty2 &&)' being compiled
1>        with
1>        [
1>            _Ty2=double
1>        ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\functional(660,27): warning C4244: 'return': conversion from 'float' to '_Rx', possible loss of data
1>        with
1>        [
1>            _Rx=int
1>        ] (compiling source file ..\src\item_factory.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\functional(821): message : see reference to function template instantiation '_Rx std::_Invoker_ret<_Rx,false>::_Call<_Callable&,const material_type&>(_Fx,const material_type &) noexcept(false)' being compiled
1>        with
1>        [
1>            _Rx=int,
1>            _Callable=Item_factory::finalize_pre::<lambda_4b9ec9ab2f0215014811fd4b67454d7c>,
1>            _Fx=Item_factory::finalize_pre::<lambda_4b9ec9ab2f0215014811fd4b67454d7c> &
1>        ] (compiling source file ..\src\item_factory.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\functional(822): message : see reference to function template instantiation '_Rx std::_Invoker_ret<_Rx,false>::_Call<_Callable&,const material_type&>(_Fx,const material_type &) noexcept(false)' being compiled
1>        with
1>        [
1>            _Rx=int,
1>            _Callable=Item_factory::finalize_pre::<lambda_4b9ec9ab2f0215014811fd4b67454d7c>,
1>            _Fx=Item_factory::finalize_pre::<lambda_4b9ec9ab2f0215014811fd4b67454d7c> &
1>        ] (compiling source file ..\src\item_factory.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\functional(821): message : while compiling class template member function '_Rx std::_Func_impl_no_alloc<Item_factory::finalize_pre::<lambda_4b9ec9ab2f0215014811fd4b67454d7c>,_Rx,const material_type &>::_Do_call(const material_type &)'
1>        with
1>        [
1>            _Rx=int
1>        ] (compiling source file ..\src\item_factory.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\functional(717): message : see reference to class template instantiation 'std::_Func_impl_no_alloc<Item_factory::finalize_pre::<lambda_4b9ec9ab2f0215014811fd4b67454d7c>,_Ret,const material_type &>' being compiled
1>        with
1>        [
1>            _Ret=int
1>        ] (compiling source file ..\src\item_factory.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\functional(911): message : see reference to variable template 'const bool _Is_large<std::_Func_impl_no_alloc<<lambda_4b9ec9ab2f0215014811fd4b67454d7c>,int,material_type const &> >' being compiled (compiling source file ..\src\item_factory.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\functional(1042): message : see reference to function template instantiation 'void std::_Func_class<_Ret,const material_type &>::_Reset<Item_factory::finalize_pre::<lambda_4b9ec9ab2f0215014811fd4b67454d7c>>(_Fx &&)' being compiled
1>        with
1>        [
1>            _Ret=int,
1>            _Fx=Item_factory::finalize_pre::<lambda_4b9ec9ab2f0215014811fd4b67454d7c>
1>        ] (compiling source file ..\src\item_factory.cpp)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\functional(1042): message : see reference to function template instantiation 'void std::_Func_class<_Ret,const material_type &>::_Reset<Item_factory::finalize_pre::<lambda_4b9ec9ab2f0215014811fd4b67454d7c>>(_Fx &&)' being compiled
1>        with
1>        [
1>            _Ret=int,
1>            _Fx=Item_factory::finalize_pre::<lambda_4b9ec9ab2f0215014811fd4b67454d7c>
1>        ] (compiling source file ..\src\item_factory.cpp)
1>C:\Users\Vincent\Documents\GitHub\Cataclysm-BN\src\item_factory.cpp(605): message : see reference to function template instantiation 'std::function<int (const material_type &)>::function<Item_factory::finalize_pre::<lambda_4b9ec9ab2f0215014811fd4b67454d7c>,0>(_Fx)' being compiled
1>        with
1>        [
1>            _Fx=Item_factory::finalize_pre::<lambda_4b9ec9ab2f0215014811fd4b67454d7c>
1>        ]
1>C:\Users\Vincent\Documents\GitHub\Cataclysm-BN\src\item_factory.cpp(603): message : see reference to function template instantiation 'std::function<int (const material_type &)>::function<Item_factory::finalize_pre::<lambda_4b9ec9ab2f0215014811fd4b67454d7c>,0>(_Fx)' being compiled
1>        with
1>        [
1>            _Fx=Item_factory::finalize_pre::<lambda_4b9ec9ab2f0215014811fd4b67454d7c>
1>        ]

Still compiles but pretty error spammy, both seem to be caused by this PR?

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. mods PR changes related to mods. src changes related to source code. tests changes related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants