1. The Melee Mapping Contest #4: 2v2 - Results are out! Step by to congratulate the winners!
    Dismiss Notice
  2. We're hosting the 15th Mini-Mapping Contest with YouTuber Abelhawk! The contestants are to create a custom map that uses the hidden content within Warcraft 3 or is inspired by any of the many secrets within the game.
    Dismiss Notice
  3. The 20th iteration of the Terraining Contest is upon us! Join and create exquisite Water Structures for it.
    Dismiss Notice
  4. Check out the Staff job openings thread.
    Dismiss Notice

Dynamically Retrieve Object Editor Fields

Discussion in 'The Lab' started by TriggerHappy, Aug 1, 2018.

  1. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,609
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    [​IMG]

    Code (vJASS):
    call BJDebugMsg("Base Defense = " + I2S(GetObjectFieldInteger('Hpal', "def")))
    call BJDebugMsg("Heal Value = " + R2S(GetObjectFieldReal('Ahea', "Rng1")))
     


    Doesn't work for all objects/fields. Many abilities fields work, some upgrades, and some units.

    Code (vJASS):
    function DebugIdInteger2IdString takes integer value returns string // taken from Cheats.j
        local string charMap = ".................................!.#$%&'()*+,-./0123456789:;<=>.@ABCDEFGHIJKLMNOPQRSTUVWXYZ[.]^_`abcdefghijklmnopqrstuvwxyz{|}~................................................................................................................................."
        local string result = ""
        local integer remainingValue = value
        local integer charValue
        local integer byteno
        set byteno = 0
        loop
            set charValue = ModuloInteger(remainingValue, 256)
            set remainingValue = remainingValue / 256
            set result = SubString(charMap, charValue, charValue + 1) + result
            set byteno = byteno + 1
            exitwhen byteno == 4
        endloop
        return result
    endfunction

    function GetObjectFieldString takes integer abilCode, string field returns string
        local string original = BlzGetAbilityExtendedTooltip('Amls', 1)
        local string output
        call BlzSetAbilityExtendedTooltip('Amls', "<" + DebugIdInteger2IdString(abilCode) + "," + field + ">", 1)
        set output = BlzGetAbilityExtendedTooltip('Amls', 1)
        call BlzSetAbilityExtendedTooltip('Amls', original, 1)
        return output
    endfunction

    function GetObjectFieldInteger takes integer abilCode, string field returns integer
        return S2I(GetObjectFieldString(abilCode, field))
    endfunction

    function GetObjectFieldReal takes integer abilCode, string field returns real
        return S2R(GetObjectFieldString(abilCode, field))
    endfunction
     
     

    Attached Files:

    • img.png
      img.png
      File size:
      7.8 KB
      Views:
      618
    Last edited: Aug 1, 2018
  2. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,260
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    I would be careful of this causing OoS errors with real fields with fractional values. In some locales the ',' character is the fractional delimiter which I do not think the locale independent implementation of S2R would like as it probably only expects a fractional delimiter of '.'.
     
  3. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,132
    Resources:
    13
    Tools:
    2
    Maps:
    2
    Spells:
    7
    Tutorials:
    1
    JASS:
    1
    Resources:
    13
    That is Amazing "reading from the object Editor", But there is a small misstake the uploaded charMap misses one "." at the start.

    In my testing 'Ahea' became "Bifb".
    After adding one "." at the beginning it produced expected values.
     
    Last edited: Aug 1, 2018
  4. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,609
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    Odd, if I copy & paste the code in the main post it works for me without having to change anything.

    EDIT: It turns out we can read more than just abilities. Main post updated.
     
    Last edited: Aug 1, 2018
  5. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,100
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Awesome trick!
     
  6. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,260
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Still needs to be tested if it is net safe for all fields in a multiplayer game containing clients of various locales. Tooltips fall into the realm of localized strings.
     
  7. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,609
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    It only works for numerical values, so there would be no string mismatch. If some floats do in fact have commas in tooltips, that would be an easy fix by replacing commas with periods.
     
  8. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,260
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Assuming every locale uses decimal numbers... Which honestly I do not know the answer to lol.
     
  9. BloodSoul

    BloodSoul

    Joined:
    May 10, 2009
    Messages:
    722
    Resources:
    2
    Spells:
    2
    Resources:
    2
    I was getting the same result as Tasyen; Ahea = Bifb. Either adding a dot or subtracting charValue by 1
    set charValue = ModuloInteger(remainingValue, 256)-1
    solved my problem.
     
  10. -Manuel-

    -Manuel-

    Joined:
    Oct 4, 2016
    Messages:
    170
    Resources:
    1
    Maps:
    1
    Resources:
    1
    wow this is awesome. No more long and tedious lists for unit datas. I will to test.
     
  11. Lord_Earthfire

    Lord_Earthfire

    Joined:
    Oct 5, 2008
    Messages:
    306
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Just a thing, this idea is sick. I known of data out of the editor for tooltips, but never really bothered with them.

    Which makes me think, shouldn't it be possible with that to have acess to gameplay constants? These are, too, connected with this type of fields in the tooltips of armor and attributes (Although i believe their synthax is different and hardcoded, like i said, never botherered with it much).
     
  12. Trokkin

    Trokkin

    Joined:
    Jan 23, 2015
    Messages:
    80
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Awesome. So with it custom interfaces become somewhat more general and lightweight.
    Just a note, you could optimize your function if you won't care for original description. And you could also implement error case handling.
     
  13. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,132
    Resources:
    13
    Tools:
    2
    Maps:
    2
    Spells:
    7
    Tutorials:
    1
    JASS:
    1
    Resources:
    13
    One can also read reals including the first 2 digits behind "." by adding ",%%" to the field beeing read, then the gained object value is 100 times bigger but the values behind "." are not skiped.
    Allowing to read for example unit regeneration which is 0.25 for melee human units resulting into 25. without that ,%% the gained value would be 0.

    Although I think one can not read values beeing placed inside a txt file for the normal game (I was for example not capable to read missilespeed which is inside such an abilitystrings.txt file)

    Example GetObjectFieldString('AEim' "Dur1,%%"). (In object Editor one would only write one "%" but in jass one has to write 2)
     
    Last edited: Mar 15, 2019
  14. rufreakde

    rufreakde

    Joined:
    Mar 10, 2019
    Messages:
    15
    Resources:
    0
    Resources:
    0
    Works realy nice if you want to get the max levels of different Skills through a GIU.ability handle! Thanks you very much! :)
     
  15. _Guhun_

    _Guhun_

    Joined:
    Jun 12, 2010
    Messages:
    321
    Resources:
    7
    Spells:
    6
    Tutorials:
    1
    Resources:
    7
    This is so useful! +rep

    Now we just need some setters for these getters... please, Blizz!
     
  16. rufreakde

    rufreakde

    Joined:
    Mar 10, 2019
    Messages:
    15
    Resources:
    0
    Resources:
    0
    Woudn't we need Instancing before that? Right now everything is static right? So the values across an ability would be changed for all heroes having this ability if you would set it. With a specific instance for the ability per hero (created maybe when you "add it") you would be able to modifiy the ability only for a specific hero.

    Don't think Blizzard will change that because the engine is so old. But it would be nice though. :)
     
  17. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,132
    Resources:
    13
    Tools:
    2
    Maps:
    2
    Spells:
    7
    Tutorials:
    1
    JASS:
    1
    Resources:
    13
    Patch v1.29 introduced: adjusting cooldowns and manacosts of spells for specific units (by triggers during the game).

    Edit:
    although still seriously buggy for some spells:
    any self morphing spell
    any variantion of single target corpse animation spells (necromancer, avatar of veng ...)​

    But that will hopefully be fixed with other patches.
     
    Last edited: Mar 17, 2019
  18. rufreakde

    rufreakde

    Joined:
    Mar 10, 2019
    Messages:
    15
    Resources:
    0
    Resources:
    0
    WoW :O Thanks didn't know that actually.
     
  19. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,132
    Resources:
    13
    Tools:
    2
    Maps:
    2
    Spells:
    7
    Tutorials:
    1
    JASS:
    1
    Resources:
    13
    One can not read much unit/item data with this technic.
    Tested all fields in unitMetadata.Slk, unitData.slk, unitbalance.slk as key most did return 0 and beeing wrong with that.

    The fields working:
    mindmg1
    maxdmg1
    RealHP

    HP
    ManaN
    def
    regenHP

    mindmg and maxdmg did return a value but it was the default melee one, therefore not useable.

    HP and RealHP returned the same value, max hp.
    def is the armor.
    manaN the max mana.
    regenHP life regeneration per second

    HP, def, manaN, regenHP return the value the unit has in Object Editor.

    for items i could only read
    uses
    beeing the default amount of charges.