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

How to save Ability Code as a variable in a hashtable using GUI?

Level 3
Joined
Sep 9, 2022
Messages
13
I'm trying to save an Ability Code variable for a specific unit key. "Let's call it AddAbility" into a hashtable so I can add the ability back to a unit later. I already have the unit's handle as Unitkey

My issue is that I can't find a way to save ability code variables into a hashtable. All I can save is integers but to use Add Ability to Unit actions I need ability code. How do I work around this?

I have AddAbility[0] as a first ability and I want each integer as seperate ones for each unit.

This is a simple example of how i'm trying to add the ability.
  • For each (Integer A) from 0 to Unitkey, do (Actions)
    • Loop - Actions
      • Unit - Add AddAbility[(Integer A)] to (Last replaced unit)
 
Level 5
Joined
Apr 15, 2019
Messages
35
My issue is that I can't find a way to save ability code variables into a hashtable. All I can save is integers but to use Add Ability to Unit actions I need ability code. How do I work around this?
Yeah, ability codes are just an integers. But GUI being GUI and doesn't allow certain things. You will have to use custom scripts.
 
Level 3
Joined
Sep 9, 2022
Messages
13
Yeah, ability codes are just an integers. But GUI being GUI and doesn't allow certain things. You will have to use custom scripts.
Ahhh okay, I did try that but I kept getting syntax errors. Do you know a working script to save them?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,932
Ahhh okay, I did try that but I kept getting syntax errors. Do you know a working script to save them?
  • Set Variable MyAbilityCode = Avatar
  • Custom script: set udg_MyInteger = udg_MyAbilityCode
  • Hashtable - Save 1000 as 0 of MyInteger in Hashtable
Variables:
MyInteger = Integer
MyAbilityCode = Ability Code

You can get the Integer ID of an Ability being cast like this:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Avatar
  • Actions
    • Custom script: set udg_MyInteger = GetSpellAbilityId()
    • Set Variable LoadedInteger = (Load 0 of MyInteger from Hashtable)
^ LoadedInteger will be equal to 1000.
 
Last edited:
Top