Snippet ResetTooltips

Azlier

Old World Ghost
Reaction score
461
Some abilities don't reset tooltips properly when leveled up via triggers. Charge Gold and Lumber is known to do this.

I should be updating this soon.

JASS:
// ResetTooltips - by Azlier
//  Requires NewGen

// How to import:
//  1. Create a new trigger called ResetTooltips.
//  2. Convert the trigger to custom script, and replace all the code inside with this.
//  3. Save the map.
//  4. Close the map.
//  5. Open the map and delete all code above "library ResetTooltips".
//  6. Save the map again.
//! external ObjectMerger w3a Amls arst anam "ResetTooltips"

library ResetTooltips

globals
    private constant integer RESET = 'arst'
endglobals

function ResetTooltips takes unit u returns nothing
    call UnitAddAbility(u, RESET)
    call UnitRemoveAbility(u, RESET)
endfunction

endlibrary
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Why did you store b, why not just do this:

[lJASS]if GetUnitAbilityLevel(u, 'Arav') == 0 then[/lJASS]

Edit: And, what is the point of the condition. Wouldn't it always return 1 since you added it? Must be missing something.
 

Azlier

Old World Ghost
Reaction score
461
And how would I do that? Show me what you mean.
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
I'm not getting the point of the conditionblock, it doesn't really serve a purpose? It will return 1 since you added it yes, but why put the if there... As I said, must be missing something.
 

Azlier

Old World Ghost
Reaction score
461
Some units have [lJASS]'Arav'[/lJASS] before this is called on them.
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Hmm, I suppose, I thought of optimizing it, but I'm too sleepy to see anything obvious to optimize. Sure you can add the if, but then you get an extra function call. D:
 

Azlier

Old World Ghost
Reaction score
461
That doesn't give the lovely side effect of flying working, if that works.
 

Romek

Super Moderator
Reaction score
963
Wouldn't something like this work instead?
JASS:
function ResetTooltips takes unit u returns nothing
    if UnitAddAbility(u, 'Arav') then // I'm assuming the returned boolean is false if the unit already has the ability.
        call UnitRemoveAbility(u, &#039;Arav&#039;) // Don&#039;t quote me on that though. <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
    endif
endfunction



I've never come across this tooltip resetting bug.
 

Azlier

Old World Ghost
Reaction score
461
It happens. And yes, that would work. I had it originally. I don't remember why I switched it. :nuts:

I'll switch it back, since I can't remember why...

I must at last be going truly insane.
 

Romek

Super Moderator
Reaction score
963
Anyway, I don't really see a point in this. Possibly because I've never experienced the bug.

When should someone call this function? There's no way of detecting this bug I assume, so this function would presumably need to be called for every unit periodically?
Or perhaps when a hero learns a skill; though I'm sure you could extend this to do that automatically.

Are there any other ways of fixing this bug? Perhaps learning another skill?
Until then, I'm sure the player can manage with this silly little bug, and not have the performance of the map crippled because of something so insignificant.

Hmm.. So many questions about the bug in this post. Maybe you could describe the bug you're fixing in detail in the first post?
 

Azlier

Old World Ghost
Reaction score
461
The bug happens with certain abilities when you level them up. Charge Gold and Lumber does that.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Perhaps there should be a demo map demonstrating both the bug, and this fix. :p

Will this still reset tooltips for a unit that already has Raven Form (attempting and failing to add the ability)?
 

Azlier

Old World Ghost
Reaction score
461
Ah! That was why I switched it (and failed to fix it). At least I'm not totally crazy.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Ah! That was why I switched it (and failed to fix it). At least I'm not totally crazy.
What, was it originally [ljass]if UnitRemoveAbility()[/ljass]? That'll affect any units that are in crow form (specifically with Arav, so, Druids of the Talon by default), instantly landing them, not to mention forgetting their level of the ability (which would only come into play if someone had modified the default ability.)
 

Azlier

Old World Ghost
Reaction score
461
What Romek has is what it was originally. Then I changed it to something with a local boolean to fix what you mentioned, and forgot to add one line. Then I forgot why I made it like that at awl. :p
 

Romek

Super Moderator
Reaction score
963
What it previously was wouldn't have fixed anything.
If removing and adding the ability is what fixes things:
JASS:
function ResetTooltips takes unit u returns nothing
    if UnitAddAbility(u, &#039;Arav&#039;) then
        call UnitRemoveAbility(u, &#039;Arav&#039;)
    else
        call UnitRemoveAbility(u, &#039;Arav&#039;)
        call UnitAddAbility(u, &#039;Arav&#039;)
    endif
endfunction
 

Azlier

Old World Ghost
Reaction score
461
Ah, but that instantly turns crow form Medivh back to human form. This will need some rethinking.
 

Romek

Super Moderator
Reaction score
963
Add a different ability then. :p
(If the unit already has 'Arav')
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Ah, but that instantly turns crow form Medivh back to human form. This will need some rethinking.
Wouldn't that be Druids of the Talon? Medivh's is Amrf.

Also, what Romek said.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top