ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Stat normalization mod (https://www.esoui.com/forums/showthread.php?t=9576)

Kaozak 02/06/21 08:59 AM

Stat normalization mod
 
Hi there,

I want to write a mod, that normalizes stats for display, as I hate the big numbers of ESO.

Basically, I want to modify any label displaying a stamina/health/magicka value to show something like:
Quote:

var displayValue = Math.floor(actualValue / normalizationBase);
I'm having a bit of trouble understanding where the numbers are coming from though.

Are there any methods like GetCurrent/Max([attributeType]) or GetCost([attributeType]), or would I need to modify every tooltip manually?

Baertram 02/06/21 11:47 AM

You'd have to check the eso source code how the tooltips are build:
https://github.com/esoui/esoui/tree/master/esoui

Most probably there are API functions used, which are defined in the API txt documentation files then:
https://wiki.esoui.com/APIVersion#live_API_version
-> Search for GetUnitPower

Sharlikran 02/06/21 11:51 AM

https://www.esoui.com/downloads/info2124.html

Kaozak 02/08/21 03:34 AM

I've tried overwriting zo_strformat, as it's called for all relevant strings I want to modify. But it seems like the tooltips get build before the mod even loads. I could only intercept strings for map tooltips, not ability tooltips.

Is there even a clean solution to modify the tooltips then? Or do I need to inject the code, when the tooltip opens?

Baertram 02/08/21 04:35 AM

Code:

I've tried overwriting zo_strformat,
Not a good idea! These functions are used everywhere in every game and addon related string handling, so if you mess with this you will most probably destroy everything that relies on this function :(


Some parts of the tooltips use a constant like SI_QUALITY_TEXT etc.
Tooltip text is build before the tooltip opens and just replaced in the tooltip into the palceholder SI_whatever as far as I know.
Chekc other addons code like Alchemy Tooltips.

Could be that the stats are not handled the sme way and cannot be altered! But there was an addon "CritPercent" or similar which altered the text to show the crit percentage instead of values I think, so it might be possible.

Kaozak 02/11/21 05:10 AM

Quote:

Originally Posted by Baertram (Post 43178)
Code:

I've tried overwriting zo_strformat,
Not a good idea! These functions are used everywhere in every game and addon related string handling, so if you mess with this you will most probably destroy everything that relies on this function :(

That wouldn't be a problem, I had a working prototype. I've selected the messages via the ID (first parameter) and only modify the other parameters accordingly in those specific cases. After that, I called the base function, that handles the actual formatting of the modified parameters.

Only problem as said: Even though the tooltip calls the zo_strformat method, it does so before I can inject my overwrite, which makes the overwrite basically useless.

Quote:

Originally Posted by Baertram (Post 43178)
Some parts of the tooltips use a constant like SI_QUALITY_TEXT etc.
Tooltip text is build before the tooltip opens and just replaced in the tooltip into the palceholder SI_whatever as far as I know.
Chekc other addons code like Alchemy Tooltips.

Could be that the stats are not handled the sme way and cannot be altered! But there was an addon "CritPercent" or similar which altered the text to show the crit percentage instead of values I think, so it might be possible.

My second idea was to modify the tooltip as it opens, as that's a point where the addon is definetively loaded. That will work, but is a really ugly solution, and is much more work than the overwrite, which is why I wanted to avoid that. :P

But thanks for the tip with other Mods, I will have a look at those. :) I really had trouble finding anything up-to-date so far, which is why I just stopped looking, but that might have been a bit prematurely.

sirinsidiator 02/11/21 05:51 AM

Quote:

Originally Posted by Kaozak (Post 43189)
That wouldn't be a problem, I had a working prototype. I've selected the messages via the ID (first parameter) and only modify the other parameters accordingly in those specific cases. After that, I called the base function, that handles the actual formatting of the modified parameters.

That's what you would think, but it makes quite a few differences (not just in this specific case).

By overwriting and running your own code before the original function, you are slowing it down compared to just leaving it alone. Most of the time not something you'd notice, but maybe some other code calls it a bazillion times in a loop and now it's twice as slow and suddenly people notice freezes with the combination of your addon and another one. Not something that most authors can easily debug.

Another huge difference is that any function touched (as in replaced) by an addon is marked as unsafe. When the game calls that function from a secure context, you suddenly get an error. Something like zo_strformat is called from literally anywhere in the game, so it's likely to fail in some situations. Really huge pain in the ass to find out why it suddenly does that, since the error can't tell you which addon is at fault. Can't tell you how many hours I wasted hunting down such bugs.

And depending on how your replacement operates, it may break in the future in case ZOS changes the signature of the function. Wouldn't be the first time that happens due to some addon naively overwriting some function.

So please don't say it wouldn't be a problem. You always gotta be careful when you change shared resources. ;)


All times are GMT -6. The time now is 05:41 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI