- Joined
- Feb 22, 2013
- Messages
- 161
Now don't worry it's not the whole item recipe system thing that I'm troubled about, it's how to either lower the cost of the final item of the build in the item store when you have all of the ingredients... Or make the final item not able to be bought in the item store without all of the necessary items for it?
This is an unfinished JASS code of what I have for a Recipe System:
This is an unfinished JASS code of what I have for a Recipe System:
JASS:
globals
boolean RECIPE_CONDITION = true
integer RECIPE_NEW = 0
integer array ITEM_ID1
integer array ITEM_ID2
integer array ITEM_ID3
integer array ITEM_ID4
integer array ITEM_ID5
integer array ITEM_ID6
integer array ITEM_COUNT
integer array OUTPUT_ITEM
trigger RECIPE_TRIGGER = CreateTrigger()
endglobals
function GetItem takes unit u, integer Id returns item
local integer i = 0
local item it
loop
exitwhen i == 6
if GetItemTypeId(UnitItemInSlot(u, i)) == Id then
return UnitItemInSlot(u, i)
set i = 5
endif
set i = i + 1
endloop
return null
endfunction
function HasItem takes unit u, integer i returns boolean
local integer index = 0
local integer id = -1
local integer s1 = 0
local integer s2 = 0
local integer s3 = 0
local integer s4 = 0
local integer s5 = 0
local integer s6 = 0
loop
exitwhen index == 6
set id = GetItemTypeId(UnitItemInSlot(u, index))
if id == 0 then
set id = -1
endif
if id == ITEM_ID1[i] and s1 == 0 then
set s1 = 1
set id = -1
endif
if id == ITEM_ID2[i] and s2 == 0 then
set s2 = 1
set id = -1
endif
if id == ITEM_ID3[i] and s3 == 0 then
set s3 = 1
set id = -1
endif
if id == ITEM_ID4[i] and s4 == 0 then
set s4 = 1
set id = -1
endif
if id == ITEM_ID5[i] and s5 == 0 then
set s5 = 1
set id = -1
endif
if id == ITEM_ID6[i] and s6 == 0 then
set s6 = 1
set id = -1
endif
if s1 + s2 + s3 + s4 + s5 + s6 == ITEM_COUNT[i] then
return true
endif
set index = index + 1
endloop
return false
endfunction