Thread Tools Display Modes
04-30-16, 04:00 PM   #1
Ishayu
A Defias Bandit
Join Date: Feb 2016
Posts: 2
Overwriting a default addon

Hi everybody,

I'm a little new to addon development, but I have identified a need in Legion for a personal stat squish of sorts by basically going through the UI and reducing the size of health, damage, healing, and mana (not other resources) displayed in the game. Why? Cause we're gonna have 2 million health and do 400k DPS and a lot of people don't like such big numbers, myself included.

While addons are easy to deal with (I can hook their scripts based on what events they are registered and their execution path is already tainted, so me redirecting their calls and then returning them, somewhat like an interceptor, does no real harm) the default UI is quite different.

The default UI often calls protected functions, and so if I change any underlying function it gets tainted! And the default UI does a lot of nasty things it couldn't do if it was tainted, such as showing or hiding unit frames in combat.

This causes problems for example, if I do this and place the addon first in the load order (by calling it !aSquishMe for instance):

local _UnitHealth = UnitHealth

function UnitHealth( unit )
-- Get original function value
local ret = _UnitHealth(unit)
if (isTimewalking) then return ret end
-- Test if returns nil
if (ret == nil) then return ret end
-- Check level range
local level = _UnitLevel("player")
if (level and (level < 1 or level > _maxLevel)) then return ret end
--Apply squish
return floor(ret*dsn[level])
end

and this works fine for every single unit frame I can think of, but the minute TargetFrameToT:Show() fires in TargetFrame.lua in the default UI, for instance, I get problems.

Is there anything I can realistically do about this? Should I pick an entirely different approach and, if yes, what would you recommend? I'd really like to not have to literally hook into every addon on the planet, to be honest, but if that's the only way then so be it.
  Reply With Quote
04-30-16, 04:35 PM   #2
Folji
A Flamescale Wyrmkin
 
Folji's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 136
My first guess for a decent way to do it would probably be to use hooksecurefunc() to grab the text objects immediately after update and overwrite them with new data, though that might lead to some brief flicks in which the original text shows before it changes.

A common strategy for such things is to get rid of the original element by either going ClearAllPoints() or SetParent(SomeHiddenDummyFrame). And then write your own text update functions.
  Reply With Quote
04-30-16, 04:56 PM   #3
Ishayu
A Defias Bandit
Join Date: Feb 2016
Posts: 2
Originally Posted by Folji View Post
My first guess for a decent way to do it would probably be to use hooksecurefunc() to grab the text objects immediately after update and overwrite them with new data, though that might lead to some brief flicks in which the original text shows before it changes.

A common strategy for such things is to get rid of the original element by either going ClearAllPoints() or SetParent(SomeHiddenDummyFrame). And then write your own text update functions.
So the hooking strategy is the one that I originally tried using, and it sounds like a decent idea at first, but in practice it very quickly gets ridiculous.

For example, attempting to apply this in a consistent manner to PitBull4 or Shadowed Unit Frames, which have complicated tagging features. I end up having to redefine every single tag! And I have to do it for a big chunk of unit frame addons.

This approach allows me to simply tamper with the data before it enters.

I can of course sidestep the problem by simply telling people not to use the standard frames together with the addon, which is probably what I'll do for the time being. Either that, or I'll offer two different versions depending on people's needs.

Also, I'm not quite sure I understand why this is even happening. It didn't happen in 6.2.3. I'm not saying what I'm doing is pretty by any stretch, but why would changing that function taint the entire "UNIT_HEALTH" event and every function called because of it? The problem does not appear for UnitHealthMax, UnitPower, UnitPowerMax, GetManaRegen, etc.

Last edited by Ishayu : 04-30-16 at 04:59 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Overwriting a default addon


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