Quantcast
Stat normalization mod - ESOUI
Thread Tools Display Modes
02/06/21, 08:59 AM   #1
Kaozak
Join Date: Feb 2021
Posts: 3
Question 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:
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?
  Reply With Quote
02/06/21, 11:47 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 3,719
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
  Reply With Quote
02/06/21, 11:51 AM   #3
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 303
https://www.esoui.com/downloads/info2124.html
__________________
Admin for TES5Edit, occasional LOOT masterlist contributor, and Wrye Bash contributor. I also maintain special Fallout 3 and Fallout NV versions of Wrye Flash.
  Reply With Quote
02/08/21, 03:34 AM   #4
Kaozak
Join Date: Feb 2021
Posts: 3
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?
  Reply With Quote
02/08/21, 04:35 AM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 3,719
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.
  Reply With Quote
02/11/21, 05:10 AM   #6
Kaozak
Join Date: Feb 2021
Posts: 3
Originally Posted by Baertram View Post
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.

Originally Posted by Baertram View Post
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.
  Reply With Quote
02/11/21, 05:51 AM   #7
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,487
Originally Posted by Kaozak View Post
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.
__________________
https://www.imperialtradingcompany.eu/ - My Addons - The Vault (Early updates and experimental projects) - My patreon - My blog
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Stat normalization mod

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off