Cooldown for attacking

I would like to be able to give my wizards the ability to check the cooldown for their attack, is this possible currently? If so, how do I do it? I have an archer running around and would like to know if I can fire or not before I select my command.

Thanks

There’s the getCooldown method you can add. If you’re checking your own cooldowns from within chooseAction, though, it won’t work because chooseAction doesn’t run during a cooldown, except if your’e doing an action-specific cooldown that’s longer than the general cooldown (think a shrink or terrify spell). Thangs should be able to call getCooldown('some-action-name') on other thangs if getCooldown is part of their API in the programmable.HasAPI config.

1 Like

So, getCooldown(‘attack’) doesn’t seem to work, but chooseAction does run while I can’t attack. My bow has a cooldown of 0.6 seconds. Or is that an example of something I can’t check?

Hmm, maybe something’s not working properly. What makes you think chooseAction() runs while you can’t attack? That should only happen if you explicitly set a specificCooldown longer than the cooldown for the attack action.

I guess I just assumed that chooseAction() was running. I guess the idea is that shooting the bow takes 0.6 seconds? So once you decide to attack it will take that long before you can do anything else. If I wanted the wizard to be able to tell the archer to do something in that time, I’d need to set specificCooldown = 0.6 and cooldown = 0.4 (or something less than .6), correct?

Ah it seems the code snippet I posted in the other thread did not work correctly then. In my defence, it is hard to see how long things take if they are all smaller than a second, and I didn’t have this.now() :).

Yes, and then the archer could use if (getCooldown('attack')) === 0 to see if she’s ready to attack again.

Hmmmm.

this.say(this.getCooldown(‘jumpTo’)); with single or double quotes always equals 0 for me.

Even right after you jump? It should be zero when you are ready to use the jump.

Gold Rush with Javascript

this.jumpTo(myTarget.pos);
this.say(this.getCooldown('jumpTo'));

Before, during, and after the jump, he says “0”.

Oh, I just realized that it’s getCooldown('jump') for that one. That’s an older API; the new findCooldown would have given an error (it’s the same except it does error handling), so for the new hero levels, it would catch that.