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.
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.
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() :).
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.