System Recipe System

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
Version 1.3, please read the READ ME:

RecipeSystem1.jpg


RecipeSystem2.jpg


Code:
====================================================================================================

Foreword:

This system was made due to the popularity that the recipe system got from "Defense of the Ancients"
(known as DotA, made by IceFrog). What I wanted to do is to bring an easy way of doing this system
without creating a trigger per recipe, but rather a line per recipe. What the recipe system does
basically is takes few items and making them into another item once they are all picked up by the
same hero.

Before, this system had to have a different trigger for each recipe, however I hope once this is out
users could do what took dozens of triggers in just one. Look at the "examples" trigger for examples
of usage of this system.

I hope you enjoy, I would love to hear comments, feedbacks, bugs found, suggestions, questions or 
anythign else of that type. You can send me a private massage, or post in the system's thread.

====================================================================================================

Using the System:

Using the system is extremely easy, it was made to be user friendly, requiring you to do minimal
work. What you need to do is in order for it to work is the following:

A. Create a trigger, and call it however you want, in my map I call it Examples, add event of "time
elapsed" about 1 second should be good.

B. After that is done you need to create an action called custom script, this action can be found 
under the section "-general".

C. Type inside the action the following: call RecipeSysSet(0,0,0,0,0,0,0,"","")

D. After that replace the first "0" with the raw code of the item that should be awarded (see later
on raw code), after that replace the next zeros with the raw codes of the items that should be
taken by a hero to get the item stored in the first 0. If you want less then 6 items to be taken, 
replace only the needed zeros. 

E. Finally replace the first "" with the attachment point of the effect, and the second "" with 
the effect's string (using \\ instead of \). If you don't want an effect to appear don't replace 
the ""s.

See the trigger "examples" for a better understanding of this.

====================================================================================================

Raw Codes:

Raw codes are the core of the system, this way it can identify the items that the hero should have 
and return the time that it should get. Raw codes of the items can be found as the following:

A. Go to the object editor.

B. Go to the item editor inside the object editor.

C. Click on ctrl + d (or apple + d), now you see the raw codes of the values.

D. Look to the left were usually you would see the items' names, the first four digits are the 
item's raw code. Copy it and put it between 2 '.

E. Click ctrl + d (or apple + d) to make the object editor look normal again.

Note: In the same way you can find the raw code of anything in the object editor.

====================================================================================================

implementing the system:

Follow the following steps to implement the system properly into your map.

A. Create a variable of type game cache called "RSCache".

B. Go to the header of the map (where you see Recipe System.w3x) and copy everything there into your
map's header.

Done, it is that simple.

====================================================================================================

Histroy:

Vesion 1.3 (25th of May 2007)

     Improved testing map dramatically.
     Screenshots posted.

Vesion 1.2 (25th of May 2007)

    Added effects feature to the system.
    Another leak cleaned.
    Updated the chapter "Using the system" in the READ ME.

Version 1.1 (24th of May 2007) 

    Added special effect to the system.
    Cleared a small leak.
    Improved testing map.

Version 1.0 (23th of May 2007)

    Original system created and posted.

====================================================================================================

Credits:

KaTTaNa for the local handle system.

====================================================================================================

I hope you enjoy this, I would appreciate credits if you use this in your map.

~ Rheias ~

JASS:

// ======================================================================================= \\
//                        Local Handle System (made by KaTTaNa)                            \\
// ======================================================================================= \\






function H2I takes handle h returns integer
    return h
    return 0
endfunction

function LocalVars takes nothing returns gamecache
    if udg_RSCache == null then
        set udg_RSCache = InitGameCache("jasslocalvars.w3v")
    endif
    return udg_RSCache
endfunction

function SetHandleInt takes handle subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleString takes handle subject, string name, string value returns nothing
    if value==null then
        call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function GetHandleInt takes handle subject, string name returns integer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction

function GetHandleString takes handle subject, string name returns string
    return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction

function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction






// ======================================================================================= \\
//                            Recipe System (made by Rheias)                               \\
// ======================================================================================= \\






function RecipeSysCon takes nothing returns boolean
    local trigger RecipeSysExe = GetTriggeringTrigger()
    local unit triggerer = GetTriggerUnit()
    local integer r = GetHandleInt(RecipeSysExe,"r")
    local integer a = GetHandleInt(RecipeSysExe,"a")
    local integer b = GetHandleInt(RecipeSysExe,"b")
    local integer c = GetHandleInt(RecipeSysExe,"c")
    local integer d = GetHandleInt(RecipeSysExe,"d")
    local integer e = GetHandleInt(RecipeSysExe,"e")
    local integer f = GetHandleInt(RecipeSysExe,"f")
    local string p = GetHandleString(RecipeSysExe,"p")
    local string t = GetHandleString(RecipeSysExe,"t")
    local integer pickedSlot = 0
    local item pickedItem
    local integer sum = GetHandleInt(RecipeSysExe,"sum")
    local integer count = 0
    
    loop
        exitwhen pickedSlot > 6
        set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
        if GetItemTypeId(pickedItem) == a and pickedItem != null then
            set count = count + 1
            exitwhen true
        endif
        set pickedSlot= pickedSlot + 1
    endloop
    
    set pickedSlot = 0
    loop
        exitwhen pickedSlot > 6
        set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
        if GetItemTypeId(pickedItem) == b and pickedItem != null then
            set count = count + 1
            exitwhen true
        endif
        set pickedSlot= pickedSlot + 1
    endloop
    
    set pickedSlot = 0
    loop
        exitwhen pickedSlot > 6
        set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
        if GetItemTypeId(pickedItem) == c and pickedItem != null then
            set count = count + 1
            exitwhen true
        endif
        set pickedSlot= pickedSlot + 1
    endloop
    
    set pickedSlot = 0
    loop
        exitwhen pickedSlot > 6
        set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
        if GetItemTypeId(pickedItem) == d and pickedItem != null then
            set count = count + 1
            exitwhen true
        endif
        set pickedSlot= pickedSlot + 1
    endloop
    
    set pickedSlot = 0
    loop
        exitwhen pickedSlot > 6
        set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
        if GetItemTypeId(pickedItem) == e and pickedItem != null then
            set count = count + 1
            exitwhen true
        endif
        set pickedSlot= pickedSlot + 1
    endloop
    
    set pickedSlot = 0
    loop
        exitwhen pickedSlot > 6
        set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
        if GetItemTypeId(pickedItem) == f and pickedItem != null then
            set count = count + 1
            exitwhen true
        endif
        set pickedSlot= pickedSlot + 1
    endloop
    
    if count == sum then
        set pickedSlot = 0
        loop
            exitwhen pickedSlot > 6
            set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
            if GetItemTypeId(pickedItem) == a and pickedItem != null then
               call UnitRemoveItem(triggerer,pickedItem)
               call RemoveItem(pickedItem)
               exitwhen true
            endif
            set pickedSlot= pickedSlot + 1
        endloop
    
        set pickedSlot = 0
        loop
            exitwhen pickedSlot > 6
            set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
            if GetItemTypeId(pickedItem) == b and pickedItem != null then
               call UnitRemoveItem(triggerer,pickedItem)
               call RemoveItem(pickedItem)
                exitwhen true
            endif
            set pickedSlot= pickedSlot + 1
        endloop
    
        set pickedSlot = 0
        loop
            exitwhen pickedSlot > 6
            set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
            if GetItemTypeId(pickedItem) == c and pickedItem != null then
               call UnitRemoveItem(triggerer,pickedItem)
               call RemoveItem(pickedItem)
                exitwhen true
            endif
            set pickedSlot= pickedSlot + 1
        endloop
    
        set pickedSlot = 0
        loop
           exitwhen pickedSlot > 6
            set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
            if GetItemTypeId(pickedItem) == d and pickedItem != null then
               call UnitRemoveItem(triggerer,pickedItem)
               call RemoveItem(pickedItem)
                exitwhen true
            endif
            set pickedSlot= pickedSlot + 1
        endloop
    
        set pickedSlot = 0
        loop
            exitwhen pickedSlot > 6
            set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
            if GetItemTypeId(pickedItem) == e and pickedItem != null then
               call UnitRemoveItem(triggerer,pickedItem)
               call RemoveItem(pickedItem)
                exitwhen true
            endif
            set pickedSlot= pickedSlot + 1
        endloop
    
        set pickedSlot = 0
        loop
            exitwhen pickedSlot > 6
            set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
            if GetItemTypeId(pickedItem) == f and pickedItem != null then
                call UnitRemoveItem(triggerer,pickedItem)
                call RemoveItem(pickedItem)
                exitwhen true
            endif
            set pickedSlot= pickedSlot + 1
        endloop
        call UnitAddItemById(triggerer,r) 
        call DestroyEffect(AddSpecialEffectTarget(t,triggerer,p))
    endif

        set pickedItem = null
        set triggerer = null
        set RecipeSysExe = null

        return true
endfunction



function RecipeSysSet takes integer r,integer a,integer b,integer c,integer d,integer e,integer f, string p, string t returns nothing
    local trigger RecipeSysExe = CreateTrigger()
    local boolexpr RecipeSysCondition = Condition(function RecipeSysCon)
    local integer sum = 0

    call TriggerRegisterAnyUnitEventBJ(RecipeSysExe,EVENT_PLAYER_UNIT_PICKUP_ITEM)
    
    if r != 0 then 
        call SetHandleInt(RecipeSysExe,"r",r)
        if a != 0 then
            call SetHandleInt(RecipeSysExe,"a",a)
            set sum = sum + 1
        endif
        if b != 0 then
            call SetHandleInt(RecipeSysExe,"b",b)
            set sum = sum + 1
        endif
        if c != 0 then
            call SetHandleInt(RecipeSysExe,"c",c)
            set sum = sum + 1
        endif
        if d != 0 then
            call SetHandleInt(RecipeSysExe,"d",d)
            set sum = sum + 1
        endif
        if e != 0 then
            call SetHandleInt(RecipeSysExe,"e",e)
            set sum = sum + 1
        endif
        if f != 0 then
            call SetHandleInt(RecipeSysExe,"f",f)
            set sum = sum + 1
        endif
        call SetHandleInt(RecipeSysExe,"sum",sum)
        call SetHandleString(RecipeSysExe,"p",p)
        call SetHandleString(RecipeSysExe,"t",t)
        call TriggerAddCondition(RecipeSysExe,RecipeSysCondition)
    else
        call DisableTrigger(RecipeSysExe)
        call DestroyTrigger(RecipeSysExe)
    endif
    set RecipeSysExe = null
    set RecipeSysCondition = null
endfunction
 

Attachments

  • Recipe System 1.3.w3x
    23.6 KB · Views: 851

Demi666

New Member
Reaction score
127
Thanks :D!

you will get credit in cRR Arena:) this is exactly what i needed:)
but excpect a pm or two:p since i might need help:) anyways +rep:)
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
> you will get credit in cRR Arena

Thanks.

> this is exactly what i needed

Good to hear that, this is what the system is for. ;)

> but excpect a pm or two since i might need help

I'll be happy to help if you need it.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Please post the code because some people would rather comment on the code than the system itself. *cough* me *cough* *cough* *wheeeezzz* ;)
 

elmstfreddie

The Finglonger
Reaction score
203
How can you wink well you're coughing???

lol

ANYWAYS... Well, you said please read the READ ME, so of course I skipped over it... Then I saw nothing! >_<
As purge said post the code, and details on it please o_O
 

elmstfreddie

The Finglonger
Reaction score
203
I was gonna say they were completely different, but they are both widgets =(

Anyways, point is yeah, a completely different method would be used for combining units.
 
I

IKilledKEnny

Guest
Extremely useful, thanks for making this. You should know that many people are too lazy to read the read me, so keeping a description outside of it might increase interes in the system.
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
Thanks for kind comment IKilledKEnny.

Version 1.1 is posted, quoted from the READ ME:

Histroy:

Version 1.1 (24th of May 2007)

Cleared a small leak.
Improved testing map.

Version 1.0 (23th of May 2007)

Original system created and posted.
 

Sooda

Diversity enchants
Reaction score
318
It' s very good idea to use that custom script line for adding new recipes for people who want easy and simple solution.
Your way of doing it Rheias is very good.
Though when you are after speed it should use global arrays. I would point out that in JASS item slots start from 0 and end at 5.

EDIT: I checked out that test map. "Just Another Warcraft III map" with nondescript isn' t very appropriate for system like yours. When it' s famous combining like DotA then should' t here be one Recipe shop and another Level 1 shop. Would demonstrate it much more in use. You could do some show-off items and their recipes also. So you could buy them and combine. In DotA there is special effect what shows you have combined item. Maybe function what would show effect.
The download counter is bugged I (I guess others too) have downloaded it and it still shows 0 downloads.
 

martix

There is no spoon
Reaction score
49
Now thats just too nice... :)
And yeah, in JASS things usually start at 0's (Players, slots, etc...) it still seem odd to me, I keep forgeting about it. :)
 

Rheias

New Helper (I got over 2000 posts)
Reaction score
232
> It' s very good idea to use that custom script line for adding new recipes for people who want easy and simple solution.
Your way of doing it Rheias is very good.

Thanks, that was the intention, I just thought it was a huge waste of memory and time to make a trigger per recipe.

> Though when you are after speed it should use global arrays.

I wasn't looking for speed but for user friendly system which is simple to import and use.

> I would point out that in JASS item slots start from 0 and end at 5.

I know, I do start from 0 I should probably end in 5, however I saw that most Blizzard functions (BJs) end at 6, I'll update it in v1.2.

> I checked out that test map. "Just Another Warcraft III map" with nondescript isn' t very appropriate for system like yours.

I never worry about those things, the file's name should be enough. ;)

> When it' s famous combining like DotA then should' t here be one Recipe shop and another Level 1 shop. Would demonstrate it much more in use. You could do some show-off items and their recipes also. So you could buy them and combine.

I do give few items by the hero at the start, but I'll add shops too at v1.2, thanks for the idea.

> In DotA there is special effect what shows you have combined item. Maybe function what would show effect.

I tryed adding effects but the system was wierd when I did that, I hope to put it as well in v1.2.

> The download counter is bugged I (I guess others too) have downloaded it and it still shows 0 downloads.

No idea why is that.

> Anyways, thanks for posting the code. I will check it out.

Thanks, enjoy. ;)

----------------------------------------------------------

Thanks for the feedbacks.
 

Sooda

Diversity enchants
Reaction score
318
> I never worry about those things, the file's name should be enough.

You aren' t the only one who thinks so. I got 5 maps with same fields "Just Another... & nondescript", want to start guessing which one is yours ?
 

DuckieKing

Elitist Through and Through
Reaction score
51
Oh man... I made a recipe system but kept it in my clan board. Ironically, I just left that clan in WC3 and got kicked off the boards. >_o
My system is manipulated a little more simply...
recipe.jpg

It saves looking for the raw code of the items.
I think I'll hoard it a little longer though.
>_>
<_<
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,494
> No idea why is that.

Don't worry. The counter is fine.
They simply aren't updated instantly, but, instead, only once every... hm... well, so it isn't instant. But it's still counting.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top