phi-fell / carefree_leveling

Optimal vanilla leveling for OpenMW 0.48
The Unlicense
9 stars 2 forks source link

TES3MP - stats recorded on login get restored on skill tick #3

Closed vikdotdev closed 1 year ago

vikdotdev commented 1 year ago

When player logs in to the server that player is going to have X of magicka and Y of fatigue. On each successful spellcast those stats get reverted to their initial values of X and Y respectively. Attaching the video demonstration below. This is probably true for any skill tick, but it's easier to reproduce with spells.

I suspect this LOC is the cause, but I don't know the lua APIs at all.

Players[pid]:LoadAttributes()

Mind that this is with client side mods, but the bug is reproducible on vanilla Morrowind too. Toggling the script on the server is the only thing that causes this.

https://user-images.githubusercontent.com/33513522/210175322-edd29e1e-d6e8-49cd-bc53-4bf4c98bc4ba.mp4

I'm using latest v0.8.1 version of TES3MP.

vikdotdev commented 1 year ago

I was wrong but I was moving into a right direction 😄

This line with Players[pid]:LoadStatsDynamic() causes this issue to appear. Disabling retroactive health fixed that for me for the moment.

Removing the call to recalculate_health from here will probably fix that problem for good, albeit for the price of having to wait till next level for the recalculation to happen.

What do you think?

phi-fell commented 1 year ago

You're indeed correct on the issue and that line was the cause. I changed it to specifically send the base health value instead of all dynamic stats, this seems to fix the issue, but please double check me on that.

I think the other loads I do (of attributes) should be fine, since base attributes shouldn't be changing client side except on events I listen for? I'm still not 100% certain I understand tes3mp's network model, though, so I could be wrong.

vikdotdev commented 1 year ago

Looking at the latest change I'd expect to see HP increase in case when skill tick happens and increases owed Endurance by +1, but it does not seem to trigger in real time. I increased Endurance by 10 that way (to be able to see any numbers since we divide Endurance by 10), but it only updated when I re-connected, although I didn't count if the value was correct. It updated and increased again on the next level-up, even though I selected x5 Willpower, x1 Luck and x1 Intelligence.

Looks a bit fishy, but I can't see anything wrong in the code.

Absence of immediate update not a huge problem for me personally though.

I think the other loads I do (of attributes) should be fine, since base attributes shouldn't be changing client side except on events I listen for? I'm still not 100% certain I understand tes3mp's network model, though, so I could be wrong.

Not familiar with it at all, but events look reasonable.

phi-fell commented 1 year ago

I just pushed a commit, that adds a call to SendStatsDynamic, which might fix that. I think the issue is that the health isn't being updated client side, and it seemed to work after a quick test on my end.

vikdotdev commented 1 year ago

That does it. Thanks a lot.

phi-fell commented 1 year ago

Yay! I'm glad it's working now, I'll close this issue for now then.