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

When does IncUnitAbilityLevel reset cooldown?

Status
Not open for further replies.
Hey Guys,

In my spell pack for Orianna I have 4 abilities based on channel. I use the IncUnitAbilityLevel native to hide the command card without resetting cooldown.

I have an issue though. The resetting process indeed does reset the cooldown, but only for 1 of the abilities.

If I comment out this one line:

JASS:
// Method used to passify (disable) Orianna's abilities - occurs
        // when the ball already has some action.
        private method passifyAbilities takes nothing returns nothing
            set this.attackRevertLevel=GetUnitAbilityLevel(ori,COMMAND_ATTACK_ID)
            set this.dissonanceRevertLevel=GetUnitAbilityLevel(ori,COMMAND_DISONNANCE_ID)
            set this.protectRevertLevel=GetUnitAbilityLevel(ori,COMMAND_PROTECT_ID)
            set this.shockwaveRevertLevel=GetUnitAbilityLevel(ori,COMMAND_SHOCKWAVE_ID)
            if GetUnitAbilityLevel(this.ori,COMMAND_ATTACK_DIS_ID)>0 then
                call SetUnitAbilityLevel(this.ori,COMMAND_ATTACK_ID,5)
                call IncUnitAbilityLevel(this.ori,COMMAND_ATTACK_ID)
                call UnitAddAbility(this.ori,COMMAND_ATTACK_DIS_ID)
            endif
            if GetUnitAbilityLevel(this.ori,COMMAND_DISONNANCE_ID)>0 then
                call SetUnitAbilityLevel(this.ori,COMMAND_DISONNANCE_ID,5)
                call IncUnitAbilityLevel(this.ori,COMMAND_DISONNANCE_ID)
                call UnitAddAbility(this.ori,COMMAND_DISSONANCE_DIS_ID)
            endif
            if GetUnitAbilityLevel(this.ori,COMMAND_PROTECT_ID)>0 then
                call SetUnitAbilityLevel(this.ori,COMMAND_PROTECT_ID,5)
                //call IncUnitAbilityLevel(this.ori,COMMAND_PROTECT_ID)
                call UnitAddAbility(this.ori,COMMAND_PROTECT_DIS_ID)
            endif
            if GetUnitAbilityLevel(this.ori,COMMAND_SHOCKWAVE_ID)>0 then
                call SetUnitAbilityLevel(this.ori,COMMAND_SHOCKWAVE_ID,3)
                call IncUnitAbilityLevel(this.ori,COMMAND_SHOCKWAVE_ID)
                call UnitAddAbility(this.ori,COMMAND_SHOCKWAVE_DIS_ID)
            endif
        endmethod

The problem is fixed - the ability no longer resets its cooldown and all behaves normally. (But now Orianna will have two command cards for protect sometimes - not what I want)

Anyone know why this problem might occur?
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
Doesn't solve the problem, but
If COMMAND_ATTACK_DIS_ID is > 0 you add it?
JASS:
            if GetUnitAbilityLevel(this.ori,COMMAND_ATTACK_DIS_ID)>0 then
                call SetUnitAbilityLevel(this.ori,COMMAND_ATTACK_ID,5)
                call IncUnitAbilityLevel(this.ori,COMMAND_ATTACK_ID)
                call UnitAddAbility(this.ori,COMMAND_ATTACK_DIS_ID)

I even changed the settings in the object editor to have them 100% equal to the other abilities (didn't change anything) ...
wc3 is stupid.
 
I just changed that one line.. not sure what happened but it seems to be working now.

I don't really have time to do a lot of testing but if you don't spot any problems now I'll update the official post.

Edit: Forget it

Edit2: There's another problem by the way, the spell actually has no mana cost with this bug. Looking into it more.

Edit3: I tried changing unit cast point, cast backswing point, casting time, art follow through time, etc - nothing seems to fix it.

I also updated the code to not call GetUnitAbilityLevel() twice each (calling another native twice causes a similar problem IIRC) - no good.
 

Attachments

  • (4)Orianna102a.w3x
    160.1 KB · Views: 48
Last edited:
Level 7
Joined
Mar 6, 2006
Messages
282
I find it odd that the other 2 skills are using the same method and they don't suffer from this problem. I even made a test map and recreated your method and the cooldown worked fine.

Have you considered using call SetPlayerAbilityAvailable(Player(0), COMMAND_PROTECT_ID, false) to hide the command card? The only downside is that you can't have more than one Orianna per player.

Another idea would be to add another level to each ability, so they go to 6. Then use the FIRST level as your "hiding" level, by not setting "Data - Options - Visible" so you're hiding the command card at level 1. Make a trigger that catches when your hero first learns Protect, and immediately set it to level 2 (which is actually level 1 to them). So when disabling the ability, just set it to level 1. The problem with doing this on lvl 6 is that they would be able to learn that skill up to level 6, which isn't intended.
 
Have you considered using call SetPlayerAbilityAvailable(Player(0), COMMAND_PROTECT_ID, false) to hide the command card? The only downside is that you can't have more than one Orianna per player.

Yes I'm aware of this option, but as you said already, it totally defeats the purpose of having the abilities MUI.

Another idea would be to add another level to each ability, so they go to 6. Then use the FIRST level as your "hiding" level, by not setting "Data - Options - Visible" so you're hiding the command card at level 1. Make a trigger that catches when your hero first learns Protect, and immediately set it to level 2 (which is actually level 1 to them). So when disabling the ability, just set it to level 1. The problem with doing this on lvl 6 is that they would be able to learn that skill up to level 6, which isn't intended.

The problem with this is that if a player levels up while an ability is passified, they can upgrade it. The problem persists even at level 18 so there's no simple workaround.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
I didn't check your code, but I've had similar problems occur when swapping abilities with engineering upgrade.
To fix it, you need a timer. If you change an ability exactly when it is cast, then it will use the new stats. Since channel has 0 cooldown and mana cost by default, then that's what probably happens to your abilities too.

This bug can be abused to make an ability use different stats for one cast, so it should be highly useful somewhere else too.

EDIT: Now that I think of it. You can quite easily abuse this to make the cooldown reduction stat.
 
You could also try basing the Protect skill off of something else. I might test both of these in a sec.

No can do, only Channel can be used to retain cooldowns.

Wait a second; you can reset a single ability cooldown when using set ability level? How?

On the contrary, IncUnitAbilityLevel hides a command card without resetting the cooldown. If you want to reset the cooldown all you have to do is remove/add the ability.
 
Level 7
Joined
Mar 6, 2006
Messages
282
How about this?

4 Dummy abilities, only used for LEARNING the skills.
4 Main abilities, that are added to the hero, once the corresponding dummy skill is learned.

This way, you have the 4 Main abilities with an extra level on them, like 6, to do the "Data - Not Visible", and so when you want to passify the skills, then set them to level 6, and you're good to go. They can't be leveled because the Dummy Learning skill is never changed.

You would also have to trigger the Tome of Retraining's effect.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Have you tested that? Did it fix it? I can make flags that wait one clock period before the passify/actify (which is analogous to a separate timer)

I've previously run into an issue for a very similar reason, so my guess is that it applies here too.

Basically what it seems to be is that "Starts the effect of an ability" runs before ability data is read. This means that when you increase the ability level from this event, then you make the ability use a different cooldown (0 in this case). I've tested it with engineering upgrade and it seems likely that it also applies to simply changing the ability level.
With non-triggered abilities you would also find additional issues, such as wrong mana cost being used, damage, range, etc.
 
Status
Not open for further replies.
Top