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. Let your favorite entries duke it out in the 15th Techtree Contest Poll.
    Dismiss Notice
  4. Weave light to take you to your highest hopes - the 6th Special Effect Contest is here!
    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.

[Snippet] Resource Preloader

Discussion in 'JASS Resources' started by AGD, Aug 12, 2016.

  1. AGD

    AGD

    Joined:
    Mar 29, 2016
    Messages:
    538
    Resources:
    13
    Spells:
    7
    Tutorials:
    1
    JASS:
    5
    Resources:
    13
    Updated to version 1.3
    - You can now preload at any time during the game instead of only during the map initialization
    - Significantly optimized the code
    - Removed the unnecessary custom function for checking preload duplicates
    - Added Table to the library requirements
    - Other changes
     
  2. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,515
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Submission: ResourcePreloader v1.3
    Date: 16 October 16
    Status: Approved
    Note:

    A good preload snippet which includes everything one can need.


    I forgot to say to add the item to the dummy-unit at DoAbilityPreload to load it's abilities. And also remove the ability at DoAbilityPreload.
     
    Last edited: Oct 16, 2016
  3. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,515
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Can you do the changes?
     
  4. AGD

    AGD

    Joined:
    Mar 29, 2016
    Messages:
    538
    Resources:
    13
    Spells:
    7
    Tutorials:
    1
    JASS:
    5
    Resources:
    13
    Yes, wait for some minutes.
     
  5. AGD

    AGD

    Joined:
    Mar 29, 2016
    Messages:
    538
    Resources:
    13
    Spells:
    7
    Tutorials:
    1
    JASS:
    5
    Resources:
    13
    UPDATED:
    Done
     
  6. AGD

    AGD

    Joined:
    Mar 29, 2016
    Messages:
    538
    Resources:
    13
    Spells:
    7
    Tutorials:
    1
    JASS:
    5
    Resources:
    13
    UPDATED to v1.4
    - Made Table optional
    - Added UnitRecycler as an optional requirement
    - Upon calling PreloadUnit(), if the unit is not a hero and UnitRecycler is found, the unit will be added to the unit stock instead. Otherwise, it goes with normal preloading.
    - dummy unit's movement is disabled to prevent possible game crash.
    - Other changes
     
    Last edited: Oct 25, 2016
  7. AGD

    AGD

    Joined:
    Mar 29, 2016
    Messages:
    538
    Resources:
    13
    Spells:
    7
    Tutorials:
    1
    JASS:
    5
    Resources:
    13
    UPDATED to v1.4b

    - Fixed a bug in the Ranged preloading in which the condition start == end won't be met and therefore the loop will not exit thus resulting to hitting the op limit (Important update)
    - Reduced function DoAbilityPreload into 1 line
    - Uses GetWorldBounds() instead of bj_mapInitialPlayableArea as the distance basis of the dummy unit's placement
    - Improved function DoUnitPreload
     
    Last edited: Nov 4, 2016
  8. AGD

    AGD

    Joined:
    Mar 29, 2016
    Messages:
    538
    Resources:
    13
    Spells:
    7
    Tutorials:
    1
    JASS:
    5
    Resources:
    13
    UPDATED to v1.4c

    - Made BJObjectId an optional requirement
    - Removed the debug messages
     
  9. AGD

    AGD

    Joined:
    Mar 29, 2016
    Messages:
    538
    Resources:
    13
    Spells:
    7
    Tutorials:
    1
    JASS:
    5
    Resources:
    13
    Small Update
    v1.4d
    - Changed
    Player(15)
    to
    Player(PLAYER_NEUTRAL_PASSIVE)
    in order to be compatible with newer patches
     
  10. AGD

    AGD

    Joined:
    Mar 29, 2016
    Messages:
    538
    Resources:
    13
    Spells:
    7
    Tutorials:
    1
    JASS:
    5
    Resources:
    13
    Small but important update
    v1.4e
    - Fixed a bug regarding the preload dummy not being hidden beyond map boundaries
     
  11. SinisterLuffy

    SinisterLuffy

    Joined:
    Apr 8, 2020
    Messages:
    35
    Resources:
    0
    Resources:
    0
    This resource is crashing the game during loading time on patch 1.31.1.

    The following line is the culprit:
    call SetUnitY(dummy, GetRectMaxY(world) + 1000)
    .
    Removing the + 1000 fixed the issue.

    And I am not sure this resource is working for me. I still get a lag spike whenever I drop any item for the first time.
    I added the item via UnitAddItemById in a module initializer, if this information has any bearing on my issue.

    For preloading, I use this rather simple code:
    Code (vJASS):
    scope Test initializer onInit

        private function onInit takes nothing returns nothing
            call PreloadItem('I049')
            call PreloadAbility('A041')
        endfunction
    endscope
     
    Last edited: Jul 8, 2020
  12. JAKEZINC

    JAKEZINC

    Joined:
    Aug 13, 2013
    Messages:
    1,596
    Resources:
    9
    Spells:
    9
    Resources:
    9
    ^ This resource works. The crash is depending on a map for sure.
    Although, the lag spike you're having is hard to determine if you're using that last legacy patch
    (as it's notorious for having a very poor performance compared to other legacy patches)
     
  13. AGD

    AGD

    Joined:
    Mar 29, 2016
    Messages:
    538
    Resources:
    13
    Spells:
    7
    Tutorials:
    1
    JASS:
    5
    Resources:
    13
    Sorry for the late response. Yes it indeed crashes the game (in 1.31.1). I've put it in a constant at the top in the new update (see first post). Also, I recommend to use 'uloc' as the preload dummy type (now also configurable).

    I'm not sure that that way of adding item to unit has any bearing on the problem since you mentioned that the lag occurs for any items dropped.

    Your way of preloading should also be fine.