Chuckleberry-Finn / Skill-Recovery-Journal

Mod for Project Zomboid which allows users to craft journals, record gained skills, and recover lost skill progression.
https://steamcommunity.com/sharedfiles/filedetails/?id=2503622437
GNU Affero General Public License v3.0
29 stars 32 forks source link

Fixed incorrect skill amounts being written to journal #67

Closed CyberSavvy531 closed 10 months ago

CyberSavvy531 commented 10 months ago

The issue appears to stem from copying over the similar if-block from the unBlock function. Instead of multiplying like in unBlock, the code in catchJavaAddXP uses division, and the numbers were not modified to account for that. The variable xpBoostNumerator was also being used as the divisor, so I renamed it appropriately to 'denominator'. Left some robust comments to help potential readers understand the math as well.

Testing: I did some very rudimentary testing with an unemployed, trait-less character. Did a couple tasks to give some quick exp to the sneak, lightfood, and cooking skills as they seemed to be the most common skills affected. Spawned a journal, transcribed it, and the values in the journal matched exactly what I would expect. The attached console log also corroborates this.

17-12-23_13-33-24_DebugLog.txt

CyberSavvy531 commented 10 months ago

After further testing and tweaking, it looks to me like at least traits and possibly professions are not being accounted for correctly regardless of this XP multipler bugfix. I tested with a fresh unemployed character, with the fast learning trait (and fast reader, but that's irrelevant to this test), and sandbox option "Recover Profession And Traits Bonus XP" set to false. When transcribing to the journal, the XP shown in the journal tooltip showed the full XP amount.

For example, I mostly used the cooking skill to test. When adding canned potatoes to a stew pot, the base XP amount given is 0.75. With the fast learner trait, that value become 0.975 (rounded down to 0.97 on the in-game skills menu). When I then transcribe that to a journal, the journal will show the full 0.97 was transcribed. I would expect it to only transcribe the base 0.75.

Unless I'm misunderstanding how you account for bonus XP.

CyberSavvy531 commented 10 months ago

Also, this fix does not seem to revert the XP already "recorded" by the mod. So, even with this change, transcribing to a new journal with my existing character still applies the incorrectly multiplied experience points. So, a way to reset that for both I and other users without creating entirely new characters would be great, but I haven't figured out how that's stored yet.

I'm admittedly not a Lua dev, but a seasoned C++ dev and modder. I don't know much about Project Zomboid's libraries and functions either. Your mod is the only context I have for PZ modding so far, so any and all knowledge you share is appreciated.

Chuckleberry-Finn commented 10 months ago

Sorry, meant to check on this. Will be reading through it now.

Chuckleberry-Finn commented 10 months ago

Also, this fix does not seem to revert the XP already "recorded" by the mod. So, even with this change, transcribing to a new journal with my existing character still applies the incorrectly multiplied experience points. So, a way to reset that for both I and other users without creating entirely new characters would be great, but I haven't figured out how that's stored yet.

I'm admittedly not a Lua dev, but a seasoned C++ dev and modder. I don't know much about Project Zomboid's libraries and functions either. Your mod is the only context I have for PZ modding so far, so any and all knowledge you share is appreciated.

This is one of the current issues with how I rewrote the mod, and I plan to revert it, but borrow something related to TV XP from this version.

CyberSavvy531 commented 10 months ago

If Discord would be easier for more long term discussion, I'm open to that as well. Probably best to DM on Steam for those details, though, so just send a friend request on Steam if you're interested.

edit: Just saw your comment on the Steam workshop.

Chuckleberry-Finn commented 10 months ago

This is no longer needed as that half of the mod has been rewritten. Thank you, and enjoy. :)

CyberSavvy531 commented 10 months ago

Awesome! Looking forward to giving it a go!