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. The 15th Mini-Mapping Contest came to an end. The Secrets of Warcraft 3 are soon to be revealed! Come and vote in the public poll for your favorite maps.
    Dismiss Notice
  3. The 12th incarnation of the Music Contest is LIVE! The theme is Synthwave. Knight Rider needs a song to listen to on his journey. You should definitely have some fun with this theme!
    Dismiss Notice
  4. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  5. 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,484
    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,484
    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.