modifier descriptions with updating values

i often see modifiers that have updating descriptions, like slarks essence shift for example. the description of the modifier says something like "stealing X agility", with the X value changing depending on the number of stacks. how can i do the same thing in my modifiers?

ive tried to look at other customs for examples, but what ive found confuses me and i cant copy what they do. ive seen things like %value%, %value%%%, and %value%d. but i dont understand what the differences between these are, or how to use them.

can someone explain how to do this? it would be greatly appreciated!

Comments

  • Posts: 213

    I remember poking at this with one ability. localization, modifier definition

  • edited November 2016 Posts: 51

    @DankBud modifier description can include actual values of its property, there valve uses something like percent encoding or escape sequence, so:

    • %MODIFIER_PROPERTY_SOME_NAME% means actual value of some_name property
    • %% means just % (here you escape a percent sign itself)
    • also you can specify a value format of property, it's following first %, so:
      • d means decimal (i.e. no point in the number)
      • f means floating point (i.e. with mandatory point)

    Examples:

    "DOTA_Tooltip_modifier_alchemist_chemical_rage_Description"         "Reducing attack time to %fMODIFIER_PROPERTY_BASE_ATTACK_TIME_CONSTANT%, increasing health regeneration by %dMODIFIER_PROPERTY_HEALTH_REGEN_CONSTANT%, increasing mana regen to %fMODIFIER_PROPERTY_BASE_MANA_REGEN%, increasing movespeed by %dMODIFIER_PROPERTY_MOVESPEED_BONUS_CONSTANT%."
    
    "DOTA_Tooltip_modifier_ogre_magi_ignite_description"    "You are on fire! Taking periodic damage and slowed by %dMODIFIER_PROPERTY_MOVESPEED_BONUS_PERCENTAGE%%%."
    

    so format is

    %[d|f]property_name%[%%] 
    
  • Posts: 183

    @Salax thank you so much! this is very clear and helps alot. ill be sure to save this for future reference.

    one question tho, does this only work with modifier properties? or could i use something from say, the ability special block in descriptions as well?

  • Posts: 51

    @DankBud

    As I know, you cant use specials in modifier description. But there is a way to display any custom value, for this you need to use lua modifiers and MODIFIER_PROPERTY_TOOLTIP. (example from Noya). Can also add that you can use as many MODIFIER_PROPERTY_TOOLTIP as you want in one single description.

  • Posts: 51

    BTW, there is original modifier description format from Valve, probably should post it

    // substitution for modifier tooltips
    // %MODIFIER_PROPERTY_MAGICAL_RESISTANCE_BONUS% - 'd' prints the value returned by the function as an integer
    // 'd' for integer
    // 'f' for float
    // optional '-' to not abs() the values
    // optional number to specify the number of decimals to print after a float
    // eg: %-2fMODIFIER_PROPERTY_BASEDAMAGEOUTGOING_PERCENTAGE% 
    // use %% to draw a percentage sign