HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Getting Ability Data from the trigger editor

11-05-2010, 09:57 PM#1
Switch33
There used to be a test map somewhere where you could basically code with the object editor. I'm not trying to do something as ridiculous as that. But is there any way to get information from a spell? I only need to get a 4 letter unit code(string) or an integer so I can check the unit's food cost to prevent a build tiny farm type spell. I don't think setting a variable per all the spells i make would be a viable solution.

GetSummonedUnit() and GetSpellAbilityUnit() are too slow so they cannot be used.

I'm thinking somehow I can use GetAbilityEffectById() to get an string or unit id? I think that was how Vexorian did it somewhat before.

Any help would be great thanks. Or if the alternative method; attaching a way to get a unit id from an ability id is possible maybe provide that instead if its better.
11-05-2010, 10:45 PM#2
Anitarf
The only object data that I know for sure can be read by the trigger editor are some of the ability art fields. The function to read those is GetAbilityEffectById, I have used it in my Demon Huntress spellpack if you want to see an example. You could for example use the missile art of your abilities to pass a string to your trigger which would then convert it to integer.

The alternative solution of using a database to link abilities and units is fairly simple as well, all you need is Table. The code would then look something like this:
Collapse JASS:
library AbilityDatabaseExample initializer Init requires Table
    globals
        private Table t
    endglobals

    private function Init takes nothing returns nothing
        set t=Table.create()
        set t['A000']=1
        set t['A001']=1
        set t['A002']=3
        set t['A003']=5
        //...
    endfunction

    function GetAbilityData takes integer abilityID returns integer
        return t[abilityID]
    endfunction
endlibrary
11-05-2010, 11:11 PM#3
Switch33
Thanks, i think i'm gonna go with the Table method as it's probably easiest.