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

Reset Swing Timer?

Status
Not open for further replies.
Level 4
Joined
Mar 8, 2006
Messages
27
Is it possible to reset a units swing timer (auto attack cooldown) during runtime?

I've tried:

- `UnitResetCooldown` (probably resets ability CDs :shrug:)
- `BlzSetUnitAttackCooldown` set attack speed to like 0.01 and then reset back after a swing. Doesn't work because the swing timer uses the countdown from the previous swing, so it won't reduce the cooldown until the next swing, which is too late.
- `UnitRemoveAbility(unit, 'Aatk')` and then add it back, but it doesn't seem to be able to be added back after.
- `BlzEndUnitAbilityCooldown(unit, 'Aatk')`
- `BlzUnitInterruptAttack(unit)`
- `BlzUnitDisableAbility(unit, 'Aatk', true, true)` and re-enable after

My last resort will be to literally delete the unit and make a new one, but it doesn't play well with other systems so it's a bit of a pain to do, hence being a last resort.

Any ideas?
 
Level 7
Joined
Jul 4, 2007
Messages
249
Don't think it's possible. Maybe a future patch will add this functionality. Add it to the list of things we want implemented.
Isn't it all about the animation? I did something like this before and just changed something with the animation. Or am I gravely misunderstanding the question?
Yea found it, it's the other way though but should work the same way?
  • Unit - Interrupt target's Attack
  • Animation - Change target's animation speed to 25.00% of its original speed
And for the next swing the animation speed is automatically reset
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,557
Does interrupt attack work like that? I was going to recommend trying that but he said he tested it and it didn't work.

Edit: Tested it and it doesn't work. What he wants to do is reset the cooldown of a unit's attack. As in, if a unit has a 2.00 second Attack cooldown and it attacks a unit, he wants to to end the 2.00 second cooldown timer early so that the unit can attack again. You'll see this in games like League of Legends, where some abilities will reset the attack cooldown and allow you to attack twice in quick succession.
 
Last edited:
Level 4
Joined
Mar 8, 2006
Messages
27
Edit: Tested it and it doesn't work. What he wants to do is reset the cooldown of a unit's attack. As in, if a unit has a 2.00 second Attack cooldown, and it attacks a unit, he wants to be able to finish that 2.00 second timer early so the unit can attack again earlier than it normally could. You'll see this in games like League of Legends, where some abilities will reset the attack cooldown and allow you to attack twice in quick succession.

Yeah exactly that. I guess right now the only way will be to use a duplicate unit and swap them out during the reset. Bit of a pain but I might do it anyway...
 
Level 7
Joined
Jul 4, 2007
Messages
249
I see, so what you need is to change the attack speed instead. If you have damage detection it's possible if you just give the unit gloves of haste ability and remove it on next hit.
  • start
    • Events
      • Player - Player 1 (Red) types a chat message containing a as An exact match
    • Conditions
    • Actions
      • Unit - Add aa (Gloves of Haste) to Mountain Giant 0013 <gen>
      • Trigger - Turn on end <gen>
  • end
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • GDD_DamageSource Equal to Mountain Giant 0013 <gen>
    • Actions
      • Unit - Remove aa (Gloves of Haste) from GDD_DamageSource
      • Trigger - Turn off (This trigger)
And it seems to be working as you described? Pretty cool actually, I'll probably use this myself :D
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,557
Ah, that works alright. I don't think it's perfect though as it's still limited by the minimum attack cooldown so there's a very short delay between the two attacks. Also, it will make your next attack extremely fast animation-wise which is an unwanted side effect. It also conflicts with attack speed reductions like from a slowing effect.

I think maybe a combination of your trigger above with this might get even better results. Note that it bugs out if I set the Attack Cooldown to 0.
vJASS:
Custom script:   call BlzSetUnitAttackCooldown( udg_YourUnit, 0.01, 0 )

With that being said, it's still not really what we want. I hope Blizzard implements a legit cooldown reset so we don't have to rely on weird workarounds that have other issues. However, I did come up with some neat ideas from this. You can make a pretty cool double-attack effect like this.
 
Last edited:
Level 7
Joined
Jul 4, 2007
Messages
249
it's still limited by the minimum attack cooldown so there's a very short delay between the two attacks.
Yes there's gonna be that, but it looks more realistic tbh, not instantly interrupting the attack but actually making a faster movement.
Also, it will make your next attack extremely fast animation-wise which is an unwanted side effect.
It doesn't affect the next attack when I do it, sometimes it does though I saw because it fails to remove it in time for some reason, but it's mostly working well.
It also conflicts with attack speed reductions like from a slowing effect.
I think you get to a maximum attack speed anyways, so it's still gonna be at max no matter how much slow a unit is under. (unless you use insane amounts on slow aswell :D)
I think maybe a combination of your trigger above with this might get even better results. Note that it bugs out if I set the Attack Cooldown to 0.
vJASS:
Custom script:   call BlzSetUnitAttackCooldown( udg_YourUnit, 0.01, 0 )
I will check this later, did you try it?
You can make a pretty cool double-attack effect like this.
Oh yea that's what I thought was the intention, I keep misunderstanding haha

There's another flaw with this system btw, it only works for melee units. Unless you have a system that somehow determines if a projectile has been created or something.
 
Last edited:
Level 4
Joined
Mar 8, 2006
Messages
27
I'm really surprised, but that works! I wonder what the difference is between that and setting the cooldown via `BlzSetUnitAttackCooldown`. I guess the item version has the code set up properly to reset the swing timer to the new value if you picked up an item for example, but they didn't include that in the `BlzSetUnitAttackCooldown` version.

Thanks for the help!
 
Level 7
Joined
Jul 4, 2007
Messages
249
I'm really surprised, but that works! I wonder what the difference is between that and setting the cooldown via `BlzSetUnitAttackCooldown`. I guess the item version has the code set up properly to reset the swing timer to the new value if you picked up an item for example, but they didn't include that in the `BlzSetUnitAttackCooldown` version.

Thanks for the help!
Thanks for the idea :D
 
Status
Not open for further replies.
Top