• 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.

[JASS] Function Recipe Item is Slow?

Status
Not open for further replies.
Level 5
Joined
Jan 4, 2009
Messages
118
JASS:
function RecipeItem takes unit itemOwner, integer item1, integer quantity, integer item2, integer item3, integer last_item returns nothing

local u = itemOwner
local integer i
local integer j
local integer last_item
local integer quantity = quantity
local array intger item
local effect sfx
set item[1] = item1
set item[2] = item2
set item[3] = item3
set last_item  = last_item

//Loop check Item
set i = 1
loop
	if(item[i] != null)then
		local integer itemChk = itemChk + 1
	endif
	set i = i + 1
	exitwhen i == 3
endloop

// Begin Loop for CreateNewItem
if(itemChk == 1)then // Case A : Has 1 Item Type
	// For 1 Item Type but requires 2 or 3 piece
	if(quantity == 2)then
		set i = 1
		loop
			call RemoveItem(u, item[1])
			set i = i +1
			exitwhen i == 2
		endloop
	call CreateItem(u, last_item) // I don't rememeber this function sorry... xD
	else if(quantity == 3)then
		set i = 1
		loop
			call RemoveItem(u, item[1])
			set i = i +1
			exitwhen i == 3
		endloop
	call CreateItem(u, last_item) // I don't rememeber this function sorry... xD
	set sfx = AddSpecialEffect("Any Effect", GetUnitX(u), GetUnitY(u))
	call DestroyEffect(sfx)
	set sfx = null
	endif
else if(itemChk == 2)then // Case B : Has 2 Item Type
	set i = 1
	loop
		if(i < quantity)then
			set j = 1
			loop
				call RemoveItem(u, item[i])
				set j = j + 1
				exitwhen j == 2
			endloop
		else
			call RemoveItem(u, item[i])
		endif
		set i = i + 1
		exitwhen i == itemChk
	endloop
	call CreateItem(u, last_item) // I don't rememeber this function sorry... xD
	set sfx = AddSpecialEffect("Any Effect", GetUnitX(u), GetUnitY(u))
	call DestroyEffect(sfx)
	set sfx = null
endif
else if(itemChk == 3)then // Case C : Has 3 Item Type
	set i = 1
	loop
		call RemoveItem(u, item[i])
		set i = i + 1
		exitwhen i == itemChk
	endloop
	call CreateItem(u, last_item) // I don't rememeber this function sorry... xD
	set sfx = AddSpecialEffect("Any Effect", GetUnitX(u), GetUnitY(u))
	call DestroyEffect(sfx)
	set sfx = null
endif

set u = null
set sfx = null
set i = 0
set j = 0
endfunction

Hello All Guys ... I wonder If I use this function to recipe single item or double item ....This function is slows or leak?

help me to check this plz...

If nothing leak ... Thanks you very much :ogre_haosis:
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,243
Don't use arrays, you're using only to indexes.

The first line should propably look like this:
JASS:
function Recipe2item takes unit item_owner, item item1, integer quantity1, item item2, integer quantity2, integer last_item returns nothing

removeItem -> RemoveItem

You need to null local unit and item variables. However in this function, you don't need to even create them. Use the input parameters.

You have a loop using j with exitwhen j == 6, but you're not modifying j anywhere.

What is the loop thingy supposed to do?
 
Level 5
Joined
Jan 4, 2009
Messages
118
Update function Now!! and plz to look ... leak thanks

This function is calling from another trigger .... and I will try use for doing same trigger item 1, item 2, item 3
Plz .. and thanks for find leak and bug thanks

If this function no has and ready for use I will bring to use for my map

thanks ..... a lot

removeItem -> RemoveItem
Thanks a lot .. I'll do it.

You need to null local unit and item variables. However in this function, you don't need to even create them. Use the input parameters.
I forgot sorry.

You have a loop using j with exitwhen j == 6, but you're not modifying j anywhere.
arrr ... I forgot again... xD

What is the loop thingy supposed to do?
I forgot agian ..... -*-a
I will try function to paste on map header and call from anothor trigger ..... and I will try create function to use for all case

Example.
- Orchid Malevolance - 3x Oblivion Staff
- Diffusal Blade - 2x Blade of Alacrity, Robe of Magi, Recipe
etc.

thanks Mr. Maker
I have been saw many your suggestion. I think you have good suggestion... for me.

sorry for problem to use english language ... I not skill ... -*-a
 
Status
Not open for further replies.
Top