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 haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Weave light to take you to your highest hopes - the 6th Special Effect Contest is here!
    Dismiss Notice
  4. Lead your forces to battle in the 15th Techtree Contest. The call is yours, commander!
    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.

[JASS] Calling BlzSetUnitAbilityCooldown crashes the game on cast

Discussion in 'Triggers & Scripts' started by Boar, Jul 28, 2018.

  1. Boar

    Boar

    Joined:
    Oct 10, 2009
    Messages:
    401
    Resources:
    0
    Resources:
    0
    Hey guys!

    So, I'm using a spell based off of 'Chemical Rage' - I'm using Jass to reduce the cooldown of this ability forever by 1 second. The problem is that it crashes the game when I cast it next. Got any ideas?

    Code (vJASS):

                // Reduce the cooldown of the ultimate ability
                set levelOfAbility = GetUnitAbilityLevel(this.target, SPELL_E_ID)
                set cooldown = BlzGetUnitAbilityCooldown(this.target, SPELL_E_ID, levelOfAbility)
             
                if cooldown - this.getCooldownReduction() > 1 then
                    call BlzSetUnitAbilityCooldown(this.target, SPELL_E_ID, levelOfAbility, cooldown - this.getCooldownReduction())
                else
                    call BlzSetUnitAbilityCooldown(this.target, SPELL_E_ID, levelOfAbility, 1)
                endif
     
     
    Last edited by a moderator: Jul 29, 2018
  2. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,828
    Resources:
    17
    Maps:
    1
    Spells:
    10
    Tutorials:
    6
    Resources:
    17
    Maybe the variables are somehow wrong.

    For example, let's say the cooldown is trying to be set to -1, maybe that would cause a crash?

    So I'd remove the cd calls and do a few debugs messages to make sure the calculations are correct and whatnot.
     
  3. Boar

    Boar

    Joined:
    Oct 10, 2009
    Messages:
    401
    Resources:
    0
    Resources:
    0
    So it should only be crashing if it is a negative value?

    Tinkering with it now...
     
  4. Boar

    Boar

    Joined:
    Oct 10, 2009
    Messages:
    401
    Resources:
    0
    Resources:
    0
    The cooldown is definitely being set correctly. I'm seeing it being reduced (By logging the cooldown via BlzGetCooldownRemaining) go from 200.00 -> 199.00 -> 198.00 etc.

    But the moment the ability is cast and the cooldown has been altered at all, the map crashes.

    hmm...
     
  5. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,427
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    which event are you using for that trigger? If you are using spell cast event, try using the starts-effect equivalent instead--maybe setting the cooldown at that time is bugging out the engine.

    You can also try doing a 0 second timer before setting the cooldown and see if that fixes the crash.
     
  6. Boar

    Boar

    Joined:
    Oct 10, 2009
    Messages:
    401
    Resources:
    0
    Resources:
    0
    It's called from a periodic timer, when <this> custom missile enters within 50 units of the target.

    There's no crash on other abilities, maybe its *just* Chemical Rage that's broken
     
    Last edited: Jul 29, 2018
  7. Lord_Earthfire

    Lord_Earthfire

    Joined:
    Oct 5, 2008
    Messages:
    339
    Resources:
    1
    Spells:
    1
    Resources:
    1
    I may be wrong here, but isn't chemical rage a morphing skill like metamorphosis? I know morphing abilities in conjunction with triggets can cause quire wonky behaviour. Could this be the reason for the problem?