This was giving me a lot of aggravation, but I figured it out! I wanted to share in case anyone else ever needs to have an iron grip on their ability charges.
First, I couldn't figure out HOW to edit the charges directly. So I did a hackjob to make it happen. It seems the display number is done by MaxCount, and you can use this to give the illusion of showing the number of charges.
The whole REASON i wanted to do this is that regeneration of charges seems to be additive, e.g. if you have 0 charges on a 10 max capacity charge, with a 2 sec recharge rate, it will take 20 seconds to regenerate 1 charge (wtf?), and if you have 9 charges on a 10 max, it'll take 2 seconds to regenerate 1 charge...
Well, and also charge use is a bit mucked up when you use multiple levels too. So! Here's my trigger-based charge system.
Key action is this:
Catalog - Set value of Abilities "TossGrenade" "Cost[0].Charge.CountMax" for player x to (String(GrenCount))
Here's some snippets from my code I wrote, some variables to note for my example:
the ability is called Nova - Toss Grenade (ID: TossGrenade). This ability has 5 trainable levels, each level the maximum charge amount increses by 5.
This skill can only be learned on one Unit, who is tracked by a xHero[0] variable.
x is my default index counter, usually looping through Player numbers.
GrenadeRegen is a global variable integer that I use to track if it's been the duration I want to regenerate a charge (in my case, 10 seconds)
GrenCount is my global variable integer for tracking how many charges the hero has of the skill.
I set the ability to not cost any charges to use. Also when the ability is learned, I use a catalog set to accurately report the number of charges (all charge information is 0 on this skill's ability data info). Then, I manually track the usage of charges like so:
TossGrenade
Events
Unit - Any Unit uses Nova - Nova - Toss Grenade at Effect3 - Cast stage (Ignore shared abilities)
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
GrenCount > 0
Then
Variable - Modify GrenCount: - 1
Catalog - Set value of Abilities "TossGrenade" "Cost[0].Charge.CountMax" for player (Triggering player) to (String((GrenCount + 0)))
General - If (Conditions) then do (Actions) else do (Actions)
If
GrenCount < 1
Then
Unit - Disable the Nova - Toss Grenade ability for (Triggering unit)
Else
Else
I then have a global timer system that goes off every 1 second (for other reasons, but added this into it). and runs this check: - Increase Grenade Counters
General - If (Conditions) then do (Actions) else do (Actions)
If
(Unit type of xHero[x]) == Nova - Nova (Hero)
GrenCount < (((Current level for ability Nova - Toss Grenade on xHero[x]) + 1) * 2)
Then
Variable - Modify GrenadeRegen: + 1
General - If (Conditions) then do (Actions) else do (Actions)
If
GrenadeRegen > 5
GrenCount < (((Current level for ability Nova - Toss Grenade on xHero[x]) + 1) * 2)
(xHero[x] has Nova - Toss Grenade) == true
Then
Unit - Enable the Nova - Toss Grenade ability for xHero[x]
Variable - Set GrenadeRegen = 0
Variable - Modify GrenCount: + 1
Catalog - Set value of Abilities "TossGrenade" "Cost[0].Charge.CountMax" for player x to (String(GrenCount))
Else
Else
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
This was giving me a lot of aggravation, but I figured it out! I wanted to share in case anyone else ever needs to have an iron grip on their ability charges.
First, I couldn't figure out HOW to edit the charges directly. So I did a hackjob to make it happen. It seems the display number is done by MaxCount, and you can use this to give the illusion of showing the number of charges.
The whole REASON i wanted to do this is that regeneration of charges seems to be additive, e.g. if you have 0 charges on a 10 max capacity charge, with a 2 sec recharge rate, it will take 20 seconds to regenerate 1 charge (wtf?), and if you have 9 charges on a 10 max, it'll take 2 seconds to regenerate 1 charge...
Well, and also charge use is a bit mucked up when you use multiple levels too. So! Here's my trigger-based charge system.
Key action is this:
Catalog - Set value of Abilities "TossGrenade" "Cost[0].Charge.CountMax" for player x to (String(GrenCount))
Here's some snippets from my code I wrote, some variables to note for my example:
the ability is called Nova - Toss Grenade (ID: TossGrenade). This ability has 5 trainable levels, each level the maximum charge amount increses by 5.
This skill can only be learned on one Unit, who is tracked by a xHero[0] variable.
x is my default index counter, usually looping through Player numbers.
GrenadeRegen is a global variable integer that I use to track if it's been the duration I want to regenerate a charge (in my case, 10 seconds)
GrenCount is my global variable integer for tracking how many charges the hero has of the skill.
I set the ability to not cost any charges to use. Also when the ability is learned, I use a catalog set to accurately report the number of charges (all charge information is 0 on this skill's ability data info). Then, I manually track the usage of charges like so:
TossGrenade
Events
Unit - Any Unit uses Nova - Nova - Toss Grenade at Effect3 - Cast stage (Ignore shared abilities)
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
GrenCount > 0
Then
Variable - Modify GrenCount: - 1
Catalog - Set value of Abilities "TossGrenade" "Cost[0].Charge.CountMax" for player (Triggering player) to (String((GrenCount + 0)))
General - If (Conditions) then do (Actions) else do (Actions)
If
GrenCount < 1
Then
Unit - Disable the Nova - Toss Grenade ability for (Triggering unit)
Else
Else
I then have a global timer system that goes off every 1 second (for other reasons, but added this into it). and runs this check:
-Increase Grenade Counters
General - If (Conditions) then do (Actions) else do (Actions)
If
(Unit type of xHero[x]) == Nova - Nova (Hero)
GrenCount < (((Current level for ability Nova - Toss Grenade on xHero[x]) + 1) * 2)
Then
Variable - Modify GrenadeRegen: + 1
General - If (Conditions) then do (Actions) else do (Actions)
If
GrenadeRegen > 5
GrenCount < (((Current level for ability Nova - Toss Grenade on xHero[x]) + 1) * 2)
(xHero[x] has Nova - Toss Grenade) == true
Then
Unit - Enable the Nova - Toss Grenade ability for xHero[x]
Variable - Set GrenadeRegen = 0
Variable - Modify GrenCount: + 1
Catalog - Set value of Abilities "TossGrenade" "Cost[0].Charge.CountMax" for player x to (String(GrenCount))
Else
Else