• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Is there a way to read what abilities a unit have?

Status
Not open for further replies.

deepstrasz

Map Reviewer
Level 75
Joined
Jun 4, 2009
Messages
20,284
Ingame? In the editor you can see the abilities of the units either by going into the Object Editor or by reading the unit descriptions in the Unit Palette. But then, you don't get the description for the abilities and you have too look them up in the Abilities Editor (submenu of Object Editor). But, I think you already know this. I'm not quite sure where exactly you want the abilities to show.
 
Yes, like for example saving 4 abilities to footman (type 'hfoo') :

JASS:
function Setup takes nothing returns nothing
    local integer parentKey = 'hfoo'

    call SaveInteger(hash, parentKey, 0, 4) // store how many abilities

    call SaveInteger(hash, parentKey, 1, 'A001') // store ability 1
    call SaveInteger(hash, parentKey, 2, 'A001') // store ability 2
    call SaveInteger(hash, parentKey, 3, 'A002') // store ability 3
    call SaveInteger(hash, parentKey, 4, 'A004') // store ability 4
endfunction

function LoopThroughAbilities takes unit u returns nothing
    local integer parentKey = GetUnitTypeId(u)
    local integer abilitiesCount = LoadInteger(hash, parentKey, 0)
    local integer abilityId

    local integer i = 1
    loop
        exitwhen i > abilitiesCount

        set abilityId = LoadInteger(hash, parentKey, i)
        call BJDebugMsg("Unit Ability #" + I2S(i) + ": " + GetObjectName(abilityId) )

        set i = i + 1
    endloop
endfunction

edit:

when really used like this one could for sure write some short API which handles then saving and getting abilities, but not sure you would even use it. ^^
 
Yes maintaing such data from hand is unpracticable, currently best one could do is letting the data save code be autogenerated.
I think one could do that by converting to lni with W3x2Lni v2.4.6, then one has the data in an easy unit <> ability connection. After that one would need to write a tool which interpretts the data and generates the data code filling the hash. lni has an easy format in which all unit data is saved inside table/unit.ini then one does not need to know how to access mpq nor we data.
Then one would place the generated hash code into your map in world Editor.

Edit: Wait slk might be better. with lni you have to consider unchanged fields (Reading parent unitType).
Edit2: Coded something together in java 8, reading such a unitabilities.slk and autogenerating such hash entries.
 

Attachments

  • GetUnitAbilities.zip
    12.8 KB · Views: 43
Last edited:
Status
Not open for further replies.
Top