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. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. 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.

[Solved] Patch 1.31: 0-indexed & not-0-indexed functions ??

Discussion in 'World Editor Help Zone' started by Ricola3D, Aug 30, 2019.

  1. Ricola3D

    Ricola3D

    Joined:
    Feb 27, 2019
    Messages:
    225
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Hello,

    I read that with patch 1.31 normally all "natives" are now 0-indexed. However I have the following trigger that seems to proove it wrong.

    The trigger is done to reduce all cooldowns by 20% when a unit carries an given item (In short, everytime a spell is cast, I compare the ability CD, the unit ability CD and the presence of the item, and reduce or restore the unit ability CD if numbers don't match).

    When I test it, it seems to reduce the cooldown of the level+1 of the ability... That was unexpected!

    Translated in JASS, it seems that:
    - function GetUnitAbilityLevelSwapped: ability level is 1-indexed.
    - functions BlzGetAbilityCooldown, BlzGetUnitAbilityCooldown, BlzSetUnitAbilityCooldown: ability level is 0-indexed.

    Is it normal ?
    Does "Natives" only mean "Blz..." functions ?
    Or did I miss something in patch 1.31 update & bug logs ?


    • CooldownsReduction
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • ((Triggering unit) is A Hero) Equal to True
      • Actions
        • -------- Upon each cast, we check if cooldown should be reduced or restored --------
        • Set GlobalTempAbilityCode = (Ability being cast)
        • Set GlobalTempInteger = (Level of GlobalTempAbilityCode for (Triggering unit))
        • Set GlobalTempReal = (Cooldown of GlobalTempAbilityCode, Level: GlobalTempInteger)
        • Set GlobalTempReal1 = (Ability Cooldown of (Triggering unit) for ability GlobalTempAbilityCode, Level: GlobalTempInteger)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Item carried by (Triggering unit) of type Gloves of Spell Mastery) Not equal to No item
          • Then - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • GlobalTempReal Equal to GlobalTempReal1
              • Then - Actions
                • -------- Reduce cooldown of 20% --------
                • Game - Display to (All players) the text: Reduce
                • Unit - For Unit (Triggering unit), Set cooldown of ability GlobalTempAbilityCode, Level: GlobalTempInteger to (0.80 x GlobalTempReal)
              • Else - Actions
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • GlobalTempReal Greater than GlobalTempReal1
              • Then - Actions
                • -------- Restore normal cooldown --------
                • Game - Display to (All players) the text: Restore
                • Unit - For Unit (Triggering unit), Set cooldown of ability GlobalTempAbilityCode, Level: GlobalTempInteger to GlobalTempReal
              • Else - Actions
     
  2. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,061
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Yes.

    In any case GetUnitAbilityLevel returning 1 for level 1 isn't it being 0-indexed.... It's just the levels starting at 1. That native returns 0 if the unit doesn't have the ability.
     
  3. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,084
    Resources:
    0
    Resources:
    0
    I think that statement means "all new natives are now 0-indexed" (new means with new 1.29+ stuff), unless I am wrong.
    Not exactly, there are two (excluding AI files) main scripting files for jass, common.j and blizzard.j. The ones in common.j file are called native functions, they are just jass wrappers of underlying C functions They are not necessarily start with letters "Blz" (see my next point). In fact almost none of them does not. The functions in blizzard.j are created from native functions + custom jass functions that used for different kinds of stuff (GUI functions, some helper functions for enum stuff, melee initialization scripts etc...) You can find these two files in your game's mpq files.

    New developer team seem to using this Blz... convention. I guess since they are new working people on an old game, some function names and conventions might be different than older functions.