1. The 30th edition of the Modeling Contest is finally up! The Portable Buildings need your attention, so come along and have a blast!
    Dismiss Notice
  2. The Aftermath has been revealed for the 19th Terraining Contest! Be sure to check out the Results and see what came out of it.
    Dismiss Notice
  3. Melee Mapping Contest #3 - Results are out! Congratulate the winners and check plenty of new 4v4 melee maps designed for this competition!
    Dismiss Notice
  4. The winners of our cinematic soundtrack competition have been decided! Step by the Music Contest #11 - Results to check the entries and congratulate the winners!
    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,544
    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:
      477
    Last edited: Aug 1, 2018
  2. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,032
    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,007
    Resources:
    10
    Tools:
    2
    Maps:
    2
    Spells:
    5
    Tutorials:
    1
    Resources:
    10
    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,544
    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:
    5,923
    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,032
    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,544
    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,032
    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:
    704
    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:
    136
    Resources:
    0
    Resources:
    0
    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:
    303
    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:
    74
    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,007
    Resources:
    10
    Tools:
    2
    Maps:
    2
    Spells:
    5
    Tutorials:
    1
    Resources:
    10
    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 at 4:57 PM
  14. rufreakde

    rufreakde

    Joined:
    Mar 10, 2019
    Messages:
    14
    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:
    254
    Resources:
    4
    Spells:
    3
    Tutorials:
    1
    Resources:
    4
    This is so useful! +rep

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

    rufreakde

    Joined:
    Mar 10, 2019
    Messages:
    14
    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,007
    Resources:
    10
    Tools:
    2
    Maps:
    2
    Spells:
    5
    Tutorials:
    1
    Resources:
    10
    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 at 7:04 PM
  18. rufreakde

    rufreakde

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

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,007
    Resources:
    10
    Tools:
    2
    Maps:
    2
    Spells:
    5
    Tutorials:
    1
    Resources:
    10
    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.