• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Snippet] ItemPreloader

Level 7
Joined
Apr 27, 2011
Messages
272
ItemPreload is a map utility that will allow you to preload items in order to eliminate the lag they cause during gameplay when picked up.

JASS:
library ItemPreload initializer ItemPreload_ini

	/*
	* ItemPreload by Alain.Mark (please give credits when used)
	* 
	* -Info-
	*	-Dumps the little lag caused by picking up items at map initialization instead, to ensure a smooth gameplay.
	*
	* -API-
	*	-function PreloadItem takes itemTypeID returns nothing
	*
	*/
	
	/*
	* CONFIGURATION SECTION
	*/
	
	globals	
		private constant player  PRELOADER_UNIT_OWNER = Player(15)
		private constant integer PRELOADER_UNIT_ID    = 'n000' // Be sure that the unit has an "Unit Inventory" ability!
		private constant real    PRELOADER_UNIT_X     = 0.00
		private constant real    PRELOADER_UNIT_Y     = 0.00
	endglobals
	
	/*
	* SYSTEM CODE
	*/
	
	globals
		private unit ITEM_PRELOADER=null
	endglobals
	
	function PreloadItem takes integer itemTypeId returns nothing
		call RemoveItem(UnitAddItemById(ITEM_PRELOADER,itemTypeId)) //inline friendly
	endfunction
	
    private function ItemPreload_ini takes nothing returns nothing
        set ITEM_PRELOADER=CreateUnit(PRELOADER_UNIT_OWNER,PRELOADER_UNIT_ID,PRELOADER_UNIT_X,PRELOADER_UNIT_Y,0.00)
    endfunction
    
endlibrary
 
Last edited:
Level 7
Joined
Apr 27, 2011
Messages
272
Meh, you can do that but this one would easily box'em up. Example:

Scenario 1: Item QWER has four abilities (let's say an hp mod, mana mod, damage mod and last, but not the least, an armor mod), it would only take one function call to preload them all, when they are preloaded via preloading the item. :p

Scenario 2: If this one preloads the abilities individually it would take 4 function calls, and obviously that'd would be moar expensive. and again -> :p
 
Okay, this is short and simple, and I'll approve it on grounds that we have approved resources that only function with cohadar's JassHelper. (Calling PreloadItem from a module initializer in Vexorian's JassHelper wouldn't work)

edit
It's also useful for people who don't want to use the Widgetizer for reasons I do not know.
 
Level 7
Joined
Nov 18, 2012
Messages
312
Okay, this is short and simple, and I'll approve it on grounds that we have approved resources that only function with cohadar's JassHelper. (Calling PreloadItem from a module initializer in Vexorian's JassHelper wouldn't work)

edit
It's also useful for people who don't want to use the Widgetizer for reasons I do not know.
what's widgetizer for?
 

Submission:
[Snippet] ItemPreload

Date:
18 October 16

Status:
Graveyard
Note:

The resource was previously approved and therefore should work fine.
If you use this script already in your codes, it's okay to keep it there.
But now we have this approved [Snippet] Resource Preloader, and so it's time to graveyard these specializations.
 
Top