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

Make enchantment mutations work again #78659

Merged
merged 7 commits into from
Dec 22, 2024

Conversation

osuphobia
Copy link
Contributor

@osuphobia osuphobia commented Dec 19, 2024

Summary

Infrastructure "Make enchantment mutations work again"

Purpose of change

Fix #74994
Fix #77971

Describe the solution

Removed dead codes about enchantment mutations.
Made new infrastructure, that save mutations to cached_mutations, allow functioning mutations to be properly read in enchantment_cache.
New enchantment mutations will override old enchantments and conflicting my_mutations, following the mutating rules. Overridden mutations are disabled untill said enchantments are removed.
Removed redundants caused by #74994 .

Describe alternatives you've considered

Testing

Worked fine and passed test cases locally.
Picking up The Architect's Cub and you can immediately see through walls.
Wear the Ixythyug the Destroyer's soul, and see that the bonus stats actually have effect, and the conflicting no longer works.
Transform to a bear, you got the traits, buffs, flags, integrated armors etc correctly, and can't transform into a cougar unless first back to human.
Change to cougar and see that you can pounce.
The mutation UI and @ menu also work as expected, character creating and debug mutating works as usual.
2024-12-20 013903

2024-12-20 013913

2024-12-19 211352

2024-12-20 013350

2024-12-20 013805

2024-12-20 013745

Additional context

Wearing the Ixythyug the Destroyer's soul immediately makes you emaciated, while druid transforming does not have this side effect. Is this intended behavior?

@github-actions github-actions bot added NPC / Factions NPCs, AI, Speech, Factions, Ownership Info / User Interface Game - player communication, menus, etc. [JSON] Changes (can be) made in JSON Bionics CBM (Compact Bionic Modules) Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies Code: Tests Measurement, self-control, statistics, balancing. [C++] Changes (can be) made in C++. Previously named `Code` Monsters Monsters both friendly and unfriendly. Melee Melee weapons, tactics, techniques, reach attack Character / World Generation Issues and enhancements concerning stages of creating a character or a world Mods: Magiclysm Anything to do with the Magiclysm mod Mechanics: Enchantments / Spells Enchantments and spells Items: Armor / Clothing Armor and clothing labels Dec 19, 2024
@github-actions github-actions bot requested a review from KorGgenT December 19, 2024 17:51
@github-actions github-actions bot added the Mods: Xedra Evolved Anything to do with Xedra Evolved label Dec 19, 2024
@github-actions github-actions bot requested a review from Maleclypse December 19, 2024 17:51
@github-actions github-actions bot added <Bugfix> This is a fix for a bug (or closes open issue) Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style json-styled JSON lint passed, label assigned by github actions labels Dec 19, 2024
astyle

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Dec 19, 2024
@Standing-Storm
Copy link
Contributor

Standing-Storm commented Dec 19, 2024

Wearing the Ixythyug the Destroyer's soul immediately makes you emaciated, while druid transforming does not have this side effect. Is this intended behavior?

This is because your calories remain constant but your new size expects appropriate caloric values for that size. In the druid form transformation EoCs, I have effects to directly modify your calories to account for the size changes (and return you to where they were before when you change back), whereas the Blood Mage spell just applies the mutations and has no such special handling. Becoming emaciated is an undesirable side effect of growing bigger so suddenly.

I did include flags to handle shapeshifted size (TEMPORARY_SHAPESHIFT etc) so that you are actually as big as you're supposed to be, but actually making a shapeshift size change automatically account for calories was (and probably still is) beyond my skill level.

@SariusSkelrets
Copy link
Contributor

It have special handling, but only if you gain the destroyer's soul through its spell. Spawing the item directly bypasses the handling EOC.

I know, I'm the one who added the demonic possession handling.

src/newcharacter.cpp Outdated Show resolved Hide resolved
src/newcharacter.cpp Outdated Show resolved Hide resolved
src/magic_enchantment.h Outdated Show resolved Hide resolved
src/magic_enchantment.cpp Outdated Show resolved Hide resolved
src/character.cpp Outdated Show resolved Hide resolved
@osuphobia
Copy link
Contributor Author

osuphobia commented Dec 20, 2024

I did include flags to handle shapeshifted size (TEMPORARY_SHAPESHIFT etc) so that you are actually as big as you're supposed to be, but actually making a shapeshift size change automatically account for calories was (and probably still is) beyond my skill level.

I've seen this, and maybe we can use this flag to recalculate your body fat percentage:

 void Character::recalculate_size()
 {
     if( has_flag( json_flag_TEMPORARY_SHAPESHIFT ) ) {
-        if( has_flag( json_flag_SHAPESHIFT_SIZE_TINY ) ) {
-            size_class = creature_size::tiny;
-        } else if( has_flag( json_flag_SHAPESHIFT_SIZE_SMALL ) ) {
-            size_class = creature_size::small;
-        } else if( has_flag( json_flag_SHAPESHIFT_SIZE_LARGE ) ) {
-            size_class = creature_size::large;
-        } else if( has_flag( json_flag_SHAPESHIFT_SIZE_HUGE ) ) {
-            size_class = creature_size::huge;
-        } else {
-            size_class = creature_size::medium;
-        }
+        magical_resize();
     } else {
         if( has_flag( json_flag_TINY ) ) {
             size_class = creature_size::tiny;
@@ -545,6 +535,28 @@ void Character::recalculate_size()
     path_settings->size = size_class;
 }

+void Character::magical_resize()
+{
+    const float bmi_before = get_bmi_fat();
+    creature_size old_size_class = size_class;
+    if( has_flag( json_flag_SHAPESHIFT_SIZE_TINY ) ) {
+        size_class = creature_size::tiny;
+    } else if( has_flag( json_flag_SHAPESHIFT_SIZE_SMALL ) ) {
+        size_class = creature_size::small;
+    } else if( has_flag( json_flag_SHAPESHIFT_SIZE_LARGE ) ) {
+        size_class = creature_size::large;
+    } else if( has_flag( json_flag_SHAPESHIFT_SIZE_HUGE ) ) {
+        size_class = creature_size::huge;
+    } else {
+        size_class = creature_size::medium;
+    }
+    if( old_size_class != size_class ) {
+        const float bmi_after = get_bmi_fat();
+        int nkcal = get_stored_kcal() * bmi_before / bmi_after;
+        set_stored_kcal( nkcal );
+    }
+}

Nah, this does not work when back to human, need to reconsider it.

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Dec 20, 2024
@Night-Pryanik Night-Pryanik merged commit 53cbd1e into CleverRaven:master Dec 22, 2024
22 of 26 checks passed
@osuphobia osuphobia deleted the refactor_enchantment_2 branch December 22, 2024 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions Bionics CBM (Compact Bionic Modules) <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Character / World Generation Issues and enhancements concerning stages of creating a character or a world Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Code: Tests Measurement, self-control, statistics, balancing. Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Info / User Interface Game - player communication, menus, etc. Items: Armor / Clothing Armor and clothing [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions Mechanics: Enchantments / Spells Enchantments and spells Melee Melee weapons, tactics, techniques, reach attack Mods: Magiclysm Anything to do with the Magiclysm mod Mods: Xedra Evolved Anything to do with Xedra Evolved Monsters Monsters both friendly and unfriendly. Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies NPC / Factions NPCs, AI, Speech, Factions, Ownership
Projects
None yet
4 participants