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. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  4. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  5. The Secrets of Warcraft 3 have revealed interesting works. The RESULTS for Abelhawk's Mini-Mapping Contest #15 have come out!
    Dismiss Notice
  6. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  8. Night Rider gained several songs for his journey. The poll for the 12th Music Contest has started. Check it out!
    Dismiss Notice
  9. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  10. 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.