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

Fixes For Worn Enchanted Armor #54852

Merged
merged 2 commits into from
Jan 30, 2022

Conversation

bombasticSlacks
Copy link
Contributor

@bombasticSlacks bombasticSlacks commented Jan 28, 2022

Summary

Bugfixes "Fixes For Worn Enchanted Armor"

Purpose of change

Enchanted armor was broken when applying/removing traits. Also I have a desire to use the enchantment system for non magical armor. So to work towards more usability I've fixed some of the oddities.

The core issue is that when you trigger on_item_wear or on_item_takeoff you are still wearing the item that provides the traits so all of the recalculating that should happen gets done while you still have the traits

Easiest way to recreate this is try to put on an enchanted item that when worn gives Huge. Your Strength will keep scaling infinitely.

Describe the solution

This PR does the following

  • Adds a vector for "mutations to add" and "mutations to remove" to the character object

  • In on_item_takeoff and on_item_wear it just adds the relevant mutations to the relevant vectors doesn't do the calcs there

  • Split all the repeated post calcs into their own function enchantment_wear_change

  • In update body when the characters cached enchantments are recalced then the removed and added mutations are applied as well as the calls from enchantment_wear_change

  • In the loop it also tests if you still have the mutation and if so doesn't run all the removal stuff. This would be for the situation where you have two items giving the same trait

  • Needed to do some overloading of mutations_from_wearing so that you can specify your removing an item and further down the call stack ignore traits from items. This is because when doing the check for "hey did the player already have one of these mutations before putting on this item YOU ARE STILL WEARING THE ITEM SO IT SEES ITSELF"

  • I've also added a new flag for items called "MUNDANE" it's for items with enchantments that shouldn't glow pink in the menu because they aren't magic.

  • I've also added a rule so that if an item changes your size (makes you huge for example it doesn't push off the item that did it). This is for 2 reasons:

  1. It supports armors like Power Armor not being able to be worn if your already huge but still lets them make you huge when you wear them
  2. If this isn't in the game hard crashes on trying to do this under some circumstances.

Describe alternatives you've considered

Not spending hours going down this rabbit hole because of an off hand comment on discord.

Testing

Tested with a pair of earings jsoned to have:

"relic_data": {
  "passive_effects": [ { "has": "WORN", "condition": "ALWAYS", "mutations": [ "GLASSJAW" ] } ]
}

and a firebelt with:

"relic_data": {
  "passive_effects": [ { "has": "WORN", "condition": "ALWAYS", "mutations": [ "HUGE" ] } ]
},

glass jaw is great because its easy to test if your hp pool has updated on wearing and not wearing the item.

Additional context

@github-actions github-actions bot added astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Jan 28, 2022
@Maleclypse Maleclypse added <Bugfix> This is a fix for a bug (or closes open issue) Mechanics: Enchantments / Spells Enchantments and spells Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON labels Jan 29, 2022
@kevingranade kevingranade merged commit b8599a1 into CleverRaven:master Jan 30, 2022
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 <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions Mechanics: Enchantments / Spells Enchantments and spells Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants