• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Dynamically Retrieve Object Editor Fields

Status
Not open for further replies.
img-png.303713

JASS:
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.

JASS:
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
 

Attachments

  • img.png
    img.png
    7.8 KB · Views: 1,114
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,178
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 '.'.
 
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.

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:
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.

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.
 
Level 10
Joined
Oct 5, 2008
Messages
355
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).
 
Level 8
Joined
Jan 23, 2015
Messages
121
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.
 
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:
Level 3
Joined
Mar 10, 2019
Messages
32
This is so useful! +rep

Now we just need some setters for these getters... please, Blizz!
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. :)
 
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:
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.
 
Status
Not open for further replies.
Top