3 major problems

johnnymra

New Member
Reaction score
14
Hey... i'm creating kinda of an wilderness survival map and i have 3 problems.

1)i want to make charged items, for example if you get meat from an animal and then kill another one that leaves the same meat type to charge the meat onto 1 inventory slot.

2)i really don't have any kind of idea of how to make a fire cook meat... i mean when you put the meat into the fire's inventory the meat disappears and creates as many cooked meats near the fire as the introduced meat charges.

3)one last thing... i don't know how to create my own recipe system so i found Diablo-dk's on hiveworkshop and used it in a previous map with a different gameplay... i was very useful but now i don't know how to make a recipe to be active only for players that have researched some upgrades or builded some buildings (i mean that when a player builds up a special construction some recipes become availabble only for that player and his team).

please help me :(

Thanks for answers!
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
1).

whenever an item is picked up iterate through the heroes inventory.
if you find an item of the same kind which is not the aquired one than remove the newly aquired item and increase the charge for the found item.

will only work if you havent filled every inventory spot. if you have you need some system to do this process if a unit is ordered to smart to an item and the range is below 128 (or so)

2).

when fire aquires an item:
check if item type == meat, if not drop item from inventory of fire, if yes then:
remove item, create item (either in the fires inventory, or in the inventory of the players unit, or at the ground, whatever you like)

3).

we do not know the script thus we cannot help you...

post it here and maybe somebody could help you there.
basically all you have to do is to add the right condition at the right position.

the condition shouldnt be that hard, finding the right position could be harder if the script isnt written properly.
 

johnnymra

New Member
Reaction score
14
Thanks for the suggestions, i'll try them... but i don't understand one thing. When you say to modify the charges of the item what do you mean?

As for the script of the recipe system i'm really convinced is good in it's way but i don't know how to modify it without proper indications:
JASS:

//=======================================================================================================
// Recipe System
// By Fredbrik(Diablo-dk)
//
//=======================================================================================================
//globals
//integer               RN=0 // Recipe number.
//trigger               RT=CreateTrigger() // Main recipe trigger.
//boolean               RC=true
//integer array         itemid1
//integer array         itemid2
//integer array         itemid3
//integer array         itemid4
//integer array         itemid5
//integer array         itemid6
//integer array         ic //item count
//integer array         output
//endglobals
//=======================================================================================================
// User changeable constants
//=======================================================================================================
constant function Recipe_Effect takes nothing returns string
    return "Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl" //An effect that comes whenever a recipe is made.
endfunction

constant function Recipe_AP takes nothing returns string
    return "origin" //Attachment point for Recipe_Effect()
endfunction
//=======================================================================================================
// This function will return the first item of entered Id in the unit's inventory.
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 HasItems takes unit u, integer i returns boolean
    local integer index=0
    local integer id=-1
    local integer b1=0
    local integer b2=0
    local integer b3=0
    local integer b4=0
    local integer b5=0
    local integer b6=0
    loop
        exitwhen index==6
        set id=GetItemTypeId(UnitItemInSlot(u,index))
        if id == 0 then
            set id=-1
        endif
        if id == udg_itemid1<i> and b1 == 0 then
            set b1=1
            set id=-1
        endif
        if id == udg_itemid2<i> and b2 == 0 then
            set b2=1
            set id=-1
        endif
        if id == udg_itemid3<i> and b3 == 0 then
            set b3=1
            set id=-1
        endif
        if id == udg_itemid4<i> and b4 == 0 then
            set b4=1
            set id=-1
        endif
        if id == udg_itemid5<i> and b5 == 0 then
            set b5=1
            set id=-1
        endif
        if id == udg_itemid6<i> and b6 == 0 then
            set b6=1
            set id=-1
        endif
        if b1+b2+b3+b4+b5+b6 == udg_ic<i> then
            return true
        endif
        set index=index+1
    endloop
    return false
endfunction
//=======================================================================================================
// User Functions:
// Recipe Creating:
//
//=======================================================================================================
function CreateRecipe takes integer i1,integer i2,integer i3,integer i4,integer i5,integer i6,integer output returns nothing
    set udg_RN=udg_RN+1
    set udg_itemid1[udg_RN]=i1
    set udg_itemid2[udg_RN]=i2
    set udg_ic[udg_RN]=2
    if i3 != 0 then
        set udg_itemid3[udg_RN]=i3
        set udg_ic[udg_RN]=udg_ic[udg_RN]+1
    endif
    if i4 != 0 then
        set udg_itemid4[udg_RN]=i4
        set udg_ic[udg_RN]=udg_ic[udg_RN]+1
    endif
    if i5 != 0 then
        set udg_itemid5[udg_RN]=i5
        set udg_ic[udg_RN]=udg_ic[udg_RN]+1
    endif
    if i6 != 0 then
        set udg_itemid6[udg_RN]=i6
        set udg_ic[udg_RN]=udg_ic[udg_RN]+1
    endif
    set udg_output[udg_RN]=output
endfunction
function CreateRecipe2 takes integer i1,integer i2,integer i3 returns nothing
    set udg_RN=udg_RN+1
    set udg_itemid1[udg_RN]=i1
    set udg_itemid2[udg_RN]=i2
    set udg_output[udg_RN]=i3
    set udg_ic[udg_RN]=2
endfunction

// Creates a recipe that requires 2 items to combine into a new item. i3 is the combined item.
// Example: call CreateRecipe2(&#039;I000&#039;,&#039;I001&#039;,&#039;I002&#039;)
function CreateRecipe3 takes integer i1,integer i2,integer i3,integer i4 returns nothing
    set udg_RN=udg_RN+1
    set udg_itemid1[udg_RN]=i1
    set udg_itemid2[udg_RN]=i2
    set udg_itemid3[udg_RN]=i3
    set udg_output[udg_RN]=i4
    set udg_ic[udg_RN]=3
endfunction

// The same as CreateRecipe2 except this requires 3 items to combine. i4 is the combined item.
function CreateRecipe4 takes integer i1,integer i2,integer i3,integer i4,integer i5 returns nothing
    set udg_RN=udg_RN+1
    set udg_itemid1[udg_RN]=i1
    set udg_itemid2[udg_RN]=i2
    set udg_itemid3[udg_RN]=i3
    set udg_itemid4[udg_RN]=i4
    set udg_output[udg_RN]=i5
    set udg_ic[udg_RN]=4
endfunction

// The same as CreateRecipe2 except this requires 4 items to combine. i5 is the combined item.
function CreateRecipe5 takes integer i1,integer i2,integer i3,integer i4,integer i5,integer i6 returns nothing
    set udg_RN=udg_RN+1
    set udg_itemid1[udg_RN]=i1
    set udg_itemid2[udg_RN]=i2
    set udg_itemid3[udg_RN]=i3
    set udg_itemid4[udg_RN]=i4
    set udg_itemid5[udg_RN]=i5
    set udg_output[udg_RN]=i6
    set udg_ic[udg_RN]=5
endfunction

// The same as CreateRecipe2 except this requires 5 items to combine. i6 is the combined item.
function CreateRecipe6 takes integer i1,integer i2,integer i3,integer i4,integer i5,integer i6,integer i7 returns nothing
    set udg_RN=udg_RN+1
    set udg_itemid1[udg_RN]=i1
    set udg_itemid2[udg_RN]=i2
    set udg_itemid3[udg_RN]=i3
    set udg_itemid4[udg_RN]=i4
    set udg_itemid5[udg_RN]=i5
    set udg_itemid6[udg_RN]=i6
    set udg_output[udg_RN]=i7
    set udg_ic[udg_RN]=6
endfunction

// The same as CreateRecipe2 except this requires 6 items to combine. i7 is the combined item.
//===================================================================================================
// This function disassembles a recipe item to its original components.

function DisItem takes unit u,item it returns boolean
    local integer c=GetItemUserData(it)
    local item array newitem
    local integer i=udg_ic[c]
    if it != null then
        if i &lt;= 6-UnitInventoryCount(u)+1 and i &gt; 0 then
            set udg_RC=false
            if udg_itemid2[c] != null then
                set newitem[1]=CreateItem(udg_itemid1[c],GetUnitX(u),GetUnitY(u))
                set newitem[2]=CreateItem(udg_itemid2[c],GetUnitX(u),GetUnitY(u))
                endif
            if udg_itemid3[c] != null then
                set newitem[3]=CreateItem(udg_itemid3[c],GetUnitX(u),GetUnitY(u))
                call UnitAddItem(u,newitem[3])
            endif
            if udg_itemid4[c] != null then
                set newitem[4]=CreateItem(udg_itemid4[c],GetUnitX(u),GetUnitY(u))
                call UnitAddItem(u,newitem[4])
            endif
            if udg_itemid5[c] != null then
                set newitem[5]=CreateItem(udg_itemid5[c],GetUnitX(u),GetUnitY(u))
                call UnitAddItem(u,newitem[5])
            endif
            if udg_itemid6[c] != null then
                set newitem[6]=CreateItem(udg_itemid6[c],GetUnitX(u),GetUnitY(u))
                call UnitAddItem(u,newitem[6])
            endif
            call RemoveItem(it)
            call UnitAddItem(u,newitem[1])
            call UnitAddItem(u,newitem[2])

        set newitem[1]=null
        set newitem[2]=null
        set newitem[3]=null
        set newitem[4]=null
        set newitem[5]=null
        set newitem[6]=null
        set udg_RC=true
        else
            return false
        endif
    endif
    return true
endfunction
//=======================================================================================================
//
//Main Recipe Function: Do not change unless you know what you are doing
//
//=======================================================================================================
function Recipe_Main takes nothing returns nothing
    local item it
    local integer i=0
    local unit u=GetManipulatingUnit()
    loop
        exitwhen i==udg_RN
        set i=i+1
        if udg_RC == true then
            if udg_ic<i> == 6 then
                if HasItems(u,i) then
                    call RemoveItem(GetItem(u,udg_itemid1<i>))
                    call RemoveItem(GetItem(u,udg_itemid2<i>))
                    call RemoveItem(GetItem(u,udg_itemid3<i>))
                    call RemoveItem(GetItem(u,udg_itemid4<i>))
                    call RemoveItem(GetItem(u,udg_itemid5<i>))
                    call RemoveItem(GetItem(u,udg_itemid6<i>))
                    call DestroyEffect(AddSpecialEffectTarget(Recipe_Effect(),u,Recipe_AP()))
                    set it=CreateItem(udg_output<i>,GetUnitX(u),GetUnitY(u))
                    call SetItemUserData(it,i) //Used for disassembling.
                    call UnitAddItem(u,it)
                    set i=udg_RN
                endif
            elseif udg_ic<i> == 5 then
                if HasItems(u,i) then
                    call RemoveItem(GetItem(u,udg_itemid1<i>))
                    call RemoveItem(GetItem(u,udg_itemid2<i>))
                    call RemoveItem(GetItem(u,udg_itemid3<i>))
                    call RemoveItem(GetItem(u,udg_itemid4<i>))
                    call RemoveItem(GetItem(u,udg_itemid5<i>))
                    call DestroyEffect(AddSpecialEffectTarget(Recipe_Effect(),u,Recipe_AP()))
                    set it=CreateItem(udg_output<i>,GetUnitX(u),GetUnitY(u))
                    call SetItemUserData(it,i) //Used for disassembling.
                    call UnitAddItem(u,it)
                    set i=udg_RN
                endif
            elseif udg_ic<i> == 4 then
                if HasItems(u,i) then
                    call RemoveItem(GetItem(u,udg_itemid1<i>))
                    call RemoveItem(GetItem(u,udg_itemid2<i>))
                    call RemoveItem(GetItem(u,udg_itemid3<i>))
                    call RemoveItem(GetItem(u,udg_itemid4<i>))
                    call DestroyEffect(AddSpecialEffectTarget(Recipe_Effect(),u,Recipe_AP()))
                    set it=CreateItem(udg_output<i>,GetUnitX(u),GetUnitY(u))
                    call SetItemUserData(it,i) //Used for disassembling.
                    call UnitAddItem(u,it)
                    set i=udg_RN
                endif
            elseif udg_ic<i> == 3 then
                if HasItems(u,i) then
                    call RemoveItem(GetItem(u,udg_itemid1<i>))
                    call RemoveItem(GetItem(u,udg_itemid2<i>))
                    call RemoveItem(GetItem(u,udg_itemid3<i>))
                    call DestroyEffect(AddSpecialEffectTarget(Recipe_Effect(),u,Recipe_AP()))
                    set it=CreateItem(udg_output<i>,GetUnitX(u),GetUnitY(u))
                    call SetItemUserData(it,i) //Used for disassembling.
                    call UnitAddItem(u,it)
                    set i=udg_RN
                endif
            elseif udg_ic<i> == 2 then
                if HasItems(u,i) then
                    call RemoveItem(GetItem(u,udg_itemid1<i>))
                    call RemoveItem(GetItem(u,udg_itemid2<i>))
                    call DestroyEffect(AddSpecialEffectTarget(Recipe_Effect(),u,Recipe_AP()))
                    set it=CreateItem(udg_output<i>,GetUnitX(u),GetUnitY(u))
                    call SetItemUserData(it,i) //Used for disassembling.
                    call UnitAddItem(u,it)
                    set i=udg_RN
                endif
            endif
        endif
    endloop
    set it=null
    set u=null
endfunction
function InitRecipe takes nothing returns nothing
    set udg_RT=CreateTrigger()
    set udg_RC=true
    call TriggerRegisterAnyUnitEventBJ( udg_RT, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction(udg_RT,function Recipe_Main)
endfunction
//call this at map init.


//forced by WE
function InitTrig_Recipe takes nothing returns nothing
endfunction
// End Recipe
</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
i mean this GUI action or its jass equivalent:
Trigger:
  • Item - Set charges remaining in ITEM to NUMBER
 

johnnymra

New Member
Reaction score
14
i mean this GUI action or its jass equivalent:
Trigger:
Item - Set charges remaining in ITEM to NUMBER

Thanks now i got it :)

And about the artificial recipe system i don't know i'll try it to see how it works but from what i just read it seems that it does exactly what mine does except the charging system ( and Diablo-dk's also has disassemble function)
 

Laiev

Hey Listen!!
Reaction score
188
Artificial has too :p

if you have some problem, you can see the system :D
 

johnnymra

New Member
Reaction score
14
For the moment everything is fine... but i still have a problem... how do i make some recipes be enabled only to some players until all the players have the requirements (i specified above an example)
 

Laiev

Hey Listen!!
Reaction score
188
check if that player has all the ingredients and do the recipe, if that players != to the player which you want to enable, don't do anything
 

johnnymra

New Member
Reaction score
14
Maybe you didn't understand my problem.
I want when the game starts i want only some recipes to be enabled to all players so that you cant create some items even if you have the ingredients and after a player builds up a special building some new recipes become available only for him and his team.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      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