//TESH.scrollpos=60
//TESH.alwaysfold=0
function Recipe takes unit hero, integer ni, integer i1, integer i2, integer i3, integer i4, integer i5, integer i6, string Effect, string where returns boolean
local integer id
local integer i = 0
local integer j = 1
local integer count = 0
local item array Items
local item it = null
if i1!=0 then
set count = count+1
endif
if i2!=0 then
set count = count+1
endif
if i3!=0 then
set count = count+1
endif
if i4!=0 then
set count = count+1
endif
if i5!=0 then
set count = count+1
endif
if i6!=0 then
set count = count+1
endif
loop
exitwhen i>5
set it = UnitItemInSlot(hero, i)
set id = GetItemTypeId(it)
if id == i1 and i1!=0 then
set Items[j] = it
set j = j+1
set i1=0
elseif id == i2 and i2!=0 then
set Items[j] = it
set j = j+1
set i2=0
elseif id == i3 and i3!=0 then
set Items[j] = it
set j = j+1
set i3=0
elseif id == i4 and i4!=0 then
set Items[j]= it
set j=j+1
set i4=0
elseif id == i5 and i5!=0 then
set Items[j] = UnitItemInSlot(hero, i)
set j=j+1
set i5=0
elseif id == i6 and i6!=0 then
set Items[j] = it
set j=j+1
set i6=0
endif
set i = i+1
endloop
set i = 1
if j-1!=count then
return false
endif
loop
exitwhen i>count
call RemoveItem(Items[i])
set Items[i]=null
set i = i+1
endloop
set it = null
set bj_lastCreatedItem = UnitAddItemById(hero, ni)
call DestroyEffect(AddSpecialEffectTarget(Effect,hero,where))
return true
endfunction
function RecipeEx takes unit hero, integer ni, integer i1, integer i2, integer i3, integer i4, integer i5, integer i6 returns boolean
return Recipe(hero,ni,i1,i2,i3,i4,i5,i6,null,null)
endfunction
Name | Type | is_array | initial_value |
y | integer | Yes |
//TESH.scrollpos=0
//TESH.alwaysfold=0
Special thanks to the following...
Sebra for finding bug!
Thx a lot to Earth-Fury for his suggestion
I'm still angry on myself coz I didn't find it!
WC3C for being awesome.
And anyone who actually takes the time to read through this.
Thanks!
Matrix
__________________________________________________________________________________________
P.S. If there is anything utilized in this map of yours that I forgot to credit you for, |
PLEASE let me know and I'll fix it ASAP. |
__________________________________________________________________________________________|
Do give credits if you use this in your map(s)!
Thanks in advance!
//TESH.scrollpos=3
//TESH.alwaysfold=0
**************************************************************************************
*************************Simple Recipe System v1.01***********************************
**********************************************************************************
******************************By: Matrix****************************************
Pros:
1) Allow same item-types [like Stygian Desolator]
2) Consists of 74 lines
3) Can be used not only for Jassers/vJassers but also for GUI users
4) It is the simpliest system I've ever seen:)
Cons:
The only thing it's bad is if's. Due to them it's not very fast
*******************
**Changelog v1.02**
*******************
1) Added RecipeEx function
2) Now function returns a boolean depending on wether the recipe succeeded or not
3) More Cleaner&Leakless code
*******************
**How to implant:**
*******************
The system is very easy. The only things you'll have to do to implement the system is to
copy the custom script code
*******************
**How to use:******
*******************
To use this system u have to have a trigger with the event unit pick up item and in the actions
just write:
call Recipe(GetTriggerUnit(),'rde3','rde1','rde1',0,0,0,0)
Arguments:
GetTriggerUnit() - Unit that picked up item //I think it is clear
'rde3' - The New Item rawcode (the rawcode of the item that must be created)
'rde1' - The Rawcode of the first ingredient
'rde1' - The Rawcode of the second ingredient
0 - The Recipe hasn't more ingredients so the 3,4,5,6 ingredient are 0
************************
*****Trouble Shooter****
************************
Q: I have some troubles with this system. It doesn't work!!!
A: The reason maybe globals. If u have global integer i, i1,i2,i3,i4,i5,i6,count,j,ni... and all the arguments the system works with.
If u havent JassNewGenPack all must be Ok.
Q: Why did u do this shit?
A: I'm cr8ing an AoS map and I was searching for a simple recipe sytem but I didn't find=(
That's why I decided to cr8 my own =)
Hopefully you like the system!
~Matrix 3.08.08
P.S. I think I found my new home...
It's thehelper.net - really helper
Thx a lot to Earth-Fury for his suggestion
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Trig_Demo_Actions takes nothing returns nothing
if Recipe(GetTriggerUnit(),'rde3','rde1','rde1',0,0,0,0,"Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl","origin") then
call QuestMessageBJ( GetForceOfPlayer(GetOwningPlayer(GetTriggerUnit())), bj_QUESTMESSAGE_ALWAYSHINT, "U have just completed "+GetItemName(bj_lastCreatedItem)+" recipe!" )
return
elseif Recipe(GetTriggerUnit(),'ratc','rat6','rat6',0,0,0,0,"Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl","origin") then
call QuestMessageBJ( GetForceOfPlayer(GetOwningPlayer(GetTriggerUnit())), bj_QUESTMESSAGE_ALWAYSHINT, "U have just completed "+GetItemName(bj_lastCreatedItem)+" recipe!" )
return
elseif Recipe(GetTriggerUnit(),'pmna','penr','penr',0,0,0,0,"Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl","origin") then
call QuestMessageBJ( GetForceOfPlayer(GetOwningPlayer(GetTriggerUnit())), bj_QUESTMESSAGE_ALWAYSHINT, "U have just completed "+GetItemName(bj_lastCreatedItem)+" recipe!" )
return
elseif Recipe(GetTriggerUnit(),'rhth','prvt','prvt',0,0,0,0,"Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl","origin") then
call QuestMessageBJ( GetForceOfPlayer(GetOwningPlayer(GetTriggerUnit())), bj_QUESTMESSAGE_ALWAYSHINT, "U have just completed "+GetItemName(bj_lastCreatedItem)+" recipe!" )
return
elseif Recipe(GetTriggerUnit(),'cnob','rst1','rag1','rin1',0,0,0,"Abilities\\Spells\\Items\\AIam\\AIamTarget.mdl","origin") then
call QuestMessageBJ( GetForceOfPlayer(GetOwningPlayer(GetTriggerUnit())), bj_QUESTMESSAGE_ALWAYSHINT, "U have just completed "+GetItemName(bj_lastCreatedItem)+" recipe!" )
return
endif
endfunction
function InitTrig_Demo takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i==16
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_PICKUP_ITEM, null)
set i = i+1
endloop
call TriggerAddAction( t, function Trig_Demo_Actions )
set t = null
endfunction
function Trig_RecipeGUI_Actions takes nothing returns nothing
call Recipe(GetTriggerUnit(),'rde3','rde1','rde1',0,0,0,0,"Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl","origin")
call Recipe(GetTriggerUnit(),'ratc','rat6','rat6',0,0,0,0,"Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl","origin")
call Recipe(GetTriggerUnit(),'pmna','penr','penr',0,0,0,0,"Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl","origin")
call Recipe(GetTriggerUnit(),'rhth','prvt','prvt',0,0,0,0,"Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl","origin")
call Recipe(GetTriggerUnit(),'cnob','rst1','rag1','rin1',0,0,0,"Abilities\\Spells\\Items\\AIam\\AIamTarget.mdl","origin")
endfunction
//===========================================================================
function InitTrig_RecipeGUI takes nothing returns nothing
set gg_trg_RecipeGUI = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_RecipeGUI, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction( gg_trg_RecipeGUI, function Trig_RecipeGUI_Actions )
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Initial_Stuffz_Actions takes nothing returns nothing
call DisplayTimedTextToPlayer(Player(0), 0, 0, 99999, " |c00999900#################################|r")
call DisplayTimedTextToPlayer(Player(0), 0, 0, 99999, "|cffffcc00Simple Recipe System:|r v1.02")
call DisplayTimedTextToPlayer(Player(0), 0, 0, 99999, "From |c003333ffthehelper.net|r")
call DisplayTimedTextToPlayer(Player(0), 0, 0, 99999, "Made by |c00ffffccMatrix|r 3.08.08")
call DisplayTimedTextToPlayer(Player(0), 0, 0, 99999, " |c00999900#################################|r")
call DisplayTimedTextToPlayer(Player(0), 0, 0, 99, "Thx Sebra for finding bug!")
call DisplayTimedTextToPlayer(Player(0), 0, 0, 99, "Thx Earth-Fury for suggestions!")
call FogMaskEnable(false)
call FogEnable(false)
endfunction
function InitTrig_Initial_Stuffz takes nothing returns nothing
set gg_trg_Initial_Stuffz = CreateTrigger()
call TriggerAddAction(gg_trg_Initial_Stuffz, function Initial_Stuffz_Actions)
endfunction