• 🏆 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!

Get abilities of a unit type

Status
Not open for further replies.
I this map of mine hero units are randomly spawned based on a hero array variable.
Their levels are set accordingly to some parameters in game.

The AI controlled heroes will not use their skill points per default so is there a way to either, force the AI to use skill points, or get what abilities the spawned hero has and set them manually?

There is the "Set Level Of Ability For Unit" but that requires that I know exactly what unit type it is.
Since I have like 30 hero types that will be an enourmous if/else check trigger I have to write, not to mention that I need a way to store ALL abilities (that would be 90 abilities in total).
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
I don't think you can get the abilities of a unit / unit type. After all there are multiple abilities per unit, so you would have to return a collection of abilities which is not supported by JASS.
You probably have to go with checking every ability by its own. Instead of a huge if/else sequence, I recommend using a hashtable to map the ability ids to the unit type using 4 child keys, as every hero has 4 abilities. Then you can only check these 4 abilities.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
I am not a big fan of hashtables in GUI, they have a lot of problems.
Actually an ability is just an integer. You can "convert" it like this:
you have an integer variable named Integer and an ability variable named Ability
use a custom script and type: set udg_Integer = udg_Ability.
Now you can use save integer in your hashtable.

  • Test
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set Ability = Acid Bomb
      • Custom script: set udg_Integer = udg_Ability
      • Hashtable - Save Integer as 0 of 0 in (Last created hashtable)
This works, because the variable type in GUI is the same as an integer in jass, so actually both variables have type integer. However in the GUI interface, if you set the value of a variable of type ability, it shows a list of all abilities, which cannot be seen, if the type is integer. So you first need type abiltiy, to select your abiltiy from that list, but after that you need integer, because otherwise it crashes the editor.

There are some other hashtable actions that crash the editor, probably because their types just don't exist in JASS (ability, unitpool, itempool for example)
 
Status
Not open for further replies.
Top