1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  4. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  5. Units have been turned into heroes in our latest Icon Contest! Vote for the best icon set at the Icon Contest #18 Poll!
    Dismiss Notice
  6. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  7. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  8. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Spell] How to check if an ability is ready to cast?

Discussion in 'World Editor Help Zone' started by pred1980, Mar 6, 2016.

  1. pred1980

    pred1980

    Joined:
    Mar 19, 2010
    Messages:
    844
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Hi hivers,

    how can i check if an ability is rdy to cast. I'm working on an hero AI and i need to know when the ability is rdy (cooldown is over!) again.

    Reg.
     
  2. A Void

    A Void

    Joined:
    Mar 29, 2011
    Messages:
    2,486
    Resources:
    10
    Models:
    2
    Spells:
    1
    Tutorials:
    7
    Resources:
    10
    Basically store the cooldown number into a variable (real). When the ability is cast for the first time, run a timer using the variable you created. After that timer expires (cooldown) the ability is ready to be used again and it will keep doing this everytime you cast that ability.
     
  3. pred1980

    pred1980

    Joined:
    Mar 19, 2010
    Messages:
    844
    Resources:
    1
    Maps:
    1
    Resources:
    1
    ok, that is an workaround but is it possible without it?

    For example:

    if i call this here:
    Code (vJASS):
    call IssueTargetOrder(.hero, DO_ORDER, .target)
    , it gives true or false back. but as i suspect if it gives "true" back it will also cast the ability, right?
     
  4. A Void

    A Void

    Joined:
    Mar 29, 2011
    Messages:
    2,486
    Resources:
    10
    Models:
    2
    Spells:
    1
    Tutorials:
    7
    Resources:
    10
    I have no idea, I don't use jass. Anyway I created a test map for you. Use water elemental ability and wait until the cooldown is over.
     

    Attached Files:

  5. DD_legionTN

    DD_legionTN

    Joined:
    Dec 19, 2012
    Messages:
    410
    Resources:
    0
    Resources:
    0
    If I remember correctly, if returns "true" = cast successfully, if returns "false" = fail to cast
     
  6. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,653
    Resources:
    3
    Spells:
    3
    Resources:
    3
    If that function returns true, you are able to cast it.
    Units that can cast those abilities instantly (0 cast time, 0 cast point, 0 rotation delay, etc) will have cast it before you can order them to stop casting it.
    Then you also have abilities like berserk, defend, etc.

    But that is not the only thing...
    When it returns false, the reason may be from many different things.
    It could be the ability is on cooldown, but it could also be that the unit hasnt got enough mana, the target that is used is untargetable, the caster is stunned/silenced/whatever, etc.

    So keeping track of the cooldowns and stuff is the best thing to do.