HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Retrieve unit abilities

06-20-2006, 12:02 AM#1
Alevice
Is there any efficient way to retrieve them? I want to make a spell (let's assume it is called the ability swap) that randomly picks a spell from a random unit in an area, and switches spells.

Eg.

- Caster casts Ability Swap on an area with a Sea witch
- The spell picks mana shield randomly
- Caster gets mana shield
- Sea witch gets Ability Swap instead and can later steal another spell in retribution.

Getting them, probably by icon index or something like that, would be nice. So far, the native GetUnitAbilityLevel seems my best choice, by comparing if the unit has at least one level of each ability. however, that would mean I'd have to check every single ability for each unit that its examinated, and that is miles away from efficient.

Any ideas on that?

I'd really not prefer to hardcode every possible skill for every existing unit. Thanks in advance
06-20-2006, 03:10 PM#2
Naakaloh
I don't think you have any other options. Although, you could have a global array of the abilities, which might make it faster to check. Of course you would only do this for the abilities that you are certain will be somewhere on the map to save yourself time.
06-20-2006, 05:16 PM#3
Alevice
Unfortunately, since this will span between multiple places, and it is meant to work with any unit available around, setting them within globals on each region this might happen would be almost as messy.

Oh well.
06-20-2006, 05:43 PM#4
Naakaloh
Well, I suppose you could loop through all possible literals of starting with 'A000' to whatever the limit is, but even though it would be less work for you, it would be a ridiculous amount of work the computer for one ability, assuming you get it to go through all of them without killing the thread. If you really want to try that instead this might help: DebugIdInteger2IdString
06-22-2006, 07:42 PM#5
Alevice
After some thought, it seems that it will have to be hardcoded after all. JASS Vault seems to have an script that might be useful. let's see how well it turns out.
06-22-2006, 11:15 PM#6
PipeDream
You could maintain a table on each unit of the abilities it has. To avoid the hell of maintaining that database you could at map start use Pitzer's function (which I'm guessing you found?) on each hero to write down into the game cache which abilities each hero has.
06-23-2006, 11:03 PM#7
Alevice
Quote:
Originally Posted by PipeDream
You could maintain a table on each unit of the abilities it has. To avoid the hell of maintaining that database you could at map start use Pitzer's function (which I'm guessing you found?) on each hero to write down into the game cache which abilities each hero has.

That seems reasonable. Thanks for the idea.

And yeah, it is PitzerMike's function I am using.