A very simple recipe system. Doesn't require any other system or global variable.
Based on this, by emjlr3.
What it does:
It replaces certain items in the inventory of a hero, with another item (think of DotA Allstars recipes).
It can handle double item requirements (like Desolator from DotA, who uses two Hammers and the Recipe).
It can create a custom special effect when the recipe is created (like using dull effects on weak recipes, and flashy effects on powerful recipes).
Step-by-step installation:
1. Create a trigger named whatever you like
2. Add the Generic Unit Event "A unit acquires an item"
3. Convert to custom text (Edit / Convert to Custom Text)
4. Add the following code BEFORE anything in the trigger.
5. In the actions function (below the line that should look like "function Trig_Name_Of_Your_Trigger_Actions takes nothing returns nothing" and above the line "endfunction") put the following code for each recipe you want (each on a different line):
What you should replace:
GetTriggerUnit(): leave it unchanged.
result: replace it for the rawcode of the item you want to create, between two 's.
item1-6: replace them for the rawcode of the required items (remember the 's). If you want less than 6 items, START FOR ITEM 1, and go increasing order! Replace the unused slots with 0 (zeros), with no 's.
Note: in order to get the rawcode of an item, open the object editor, go to the Items tab, press Control+D, the first four letters are the rawcode. Remember that they are CaSe SeNsItIvE.
fxpath: replace it for the path of the desired special effect, between two "s. Don't forget to replace any backslash ( \ ), for double backslashes ( \\ ).
Note: In order to get the path for an special effect, open the Object Editor, go to the Abilities tab, select any ability, double-click on "Art - Effect", click on "Add Model", select the effect you want (remember that you can see it while browsing in the gray square at the left of the WE's main window), click Ok, double-click on the model you just added, select all the text in the "Custom" box, and then you have your Special Effect's path. Then just click Cancel and Cancel and you're done.
fxpoint: replace it for the place where the Special Effect should be created (like head, overhead, origin, etc.), between two "s.
Note: if you don't want any Special Effect, replace fxpath and fxpoint with "".
6. Done!
Gotham, based on emjlr3's work.
Based on this, by emjlr3.
What it does:
It replaces certain items in the inventory of a hero, with another item (think of DotA Allstars recipes).
It can handle double item requirements (like Desolator from DotA, who uses two Hammers and the Recipe).
It can create a custom special effect when the recipe is created (like using dull effects on weak recipes, and flashy effects on powerful recipes).
Step-by-step installation:
1. Create a trigger named whatever you like
2. Add the Generic Unit Event "A unit acquires an item"
3. Convert to custom text (Edit / Convert to Custom Text)
4. Add the following code BEFORE anything in the trigger.
JASS:
function CreateRecipe takes unit u, integer result, integer it1, integer it2, integer it3, integer it4, integer it5, integer it6, string fxpath, string fxattpoint returns nothing
//=== Made by Gotham (based on emjlr3's work) for TheHelper.net ===
local integer i = 1
local integer j = 0
local integer array it
local integer total = 0
local item current
local boolean array used
local boolean recipe = true
set it[1] = it1
set it[2] = it2
set it[3] = it3
set it[4] = it4
set it[5] = it5
set it[6] = it6
set it[7] = 0
loop
set total = total + 1
exitwhen it[total]==0
endloop
set i = 1
loop
exitwhen i==total
loop
exitwhen j>5
set current = UnitItemInSlot(u,j)
if GetItemTypeId(current)==it<i> and used[j]==false then
set used[j] = true
set j = 5
elseif j==5 then
set recipe = false
endif
set j = j + 1
endloop
set j = 0
set i = i + 1
endloop
if recipe==true then
loop
exitwhen j>5
if used[j]==true then
set current = UnitItemInSlot(u,j)
call RemoveItem(current)
endif
set j=j+1
endloop
call UnitAddItemById(u,result)
call DestroyEffect(AddSpecialEffectTarget(fxpath,u,fxattpoint))
endif
set current = null
//=== Made by Gotham (based on emjlr3's work) for TheHelper.net ===
endfunction</i>
5. In the actions function (below the line that should look like "function Trig_Name_Of_Your_Trigger_Actions takes nothing returns nothing" and above the line "endfunction") put the following code for each recipe you want (each on a different line):
JASS:
call CreateRecipe(GetTriggerUnit(),result,item1,item2,item3,item4,item5,item6,fxpath,fxpoint)
What you should replace:
GetTriggerUnit(): leave it unchanged.
result: replace it for the rawcode of the item you want to create, between two 's.
item1-6: replace them for the rawcode of the required items (remember the 's). If you want less than 6 items, START FOR ITEM 1, and go increasing order! Replace the unused slots with 0 (zeros), with no 's.
Note: in order to get the rawcode of an item, open the object editor, go to the Items tab, press Control+D, the first four letters are the rawcode. Remember that they are CaSe SeNsItIvE.
fxpath: replace it for the path of the desired special effect, between two "s. Don't forget to replace any backslash ( \ ), for double backslashes ( \\ ).
Note: In order to get the path for an special effect, open the Object Editor, go to the Abilities tab, select any ability, double-click on "Art - Effect", click on "Add Model", select the effect you want (remember that you can see it while browsing in the gray square at the left of the WE's main window), click Ok, double-click on the model you just added, select all the text in the "Custom" box, and then you have your Special Effect's path. Then just click Cancel and Cancel and you're done.
fxpoint: replace it for the place where the Special Effect should be created (like head, overhead, origin, etc.), between two "s.
Note: if you don't want any Special Effect, replace fxpath and fxpoint with "".
6. Done!
Gotham, based on emjlr3's work.