Edit Recipe System

MrCrowley

New Member
Reaction score
17
I want to edit a recipe system that I found. Unfortunately the system is written in Jass and, even after hours of reading tutorials, I can't figure out.

The system uses an "automatic" item combination, as the items will combine the moment the hero picks them up. However, I want the item combination to be manual, as in a custom spell or something that triggers the items combination. For those who dont want to download the map, here's the scripting.

Also this is pretty much that only recipe system that was variable based. The rest were just arrays and loops which wasn't what I was looking for so I can't accept alternatives. Thank you

JASS:
constant function ItemCombineEffect takes nothing returns string
    return "Abilities\\Spells\\Items\\AIlm\\AIlmTarget.mdl"
endfunction

function UnitRemoveItemById takes unit whichUnit, integer itemId returns nothing
    local integer i = 0
    local item it
    
    loop
    exitwhen (i >= bj_MAX_INVENTORY)
        set it = UnitItemInSlot(whichUnit, i)
        if GetItemTypeId(it) == itemId then
            call RemoveItem(it)
            exitwhen (true)
        endif
        set i = i + 1
    endloop
    set it = null
endfunction

function Trig_Item_Combine_Actions takes nothing returns nothing
    local integer n = 0
    local integer array it
    local integer i = 7
    local integer h = 0
    local integer x = 0
    local unit u = GetTriggerUnit()
    local boolean b = true
    local integer y = 0
    local integer z = 0
    local integer array hero_item_type

    // Get hero items
    loop
    exitwhen (x >= bj_MAX_INVENTORY)
        set hero_item_type[x] = GetItemTypeId(UnitItemInSlot(u, x))
        set x = x + 1
    endloop

    loop
    exitwhen (n >= udg_ItemN)
        set h = i + 6
        
        set x = 0
        set it[x] = hero_item_type[x]
        set x = x + 1
        set it[x] = hero_item_type[x]
        set x = x + 1
        set it[x] = hero_item_type[x]
        set x = x + 1
        set it[x] = hero_item_type[x]
        set x = x + 1
        set it[x] = hero_item_type[x]
        set x = x + 1
        set it[x] = hero_item_type[x]
        set x = x + 1
        
        set y = 0 // N of items that hero has ()
        set z = 0 // N of items needed ()
        loop
        exitwhen (i &gt;= h or udg_CItemType<i> == 0)
            set z = z + 1
            // Does unit contain item n
            set x = 0
            loop
            exitwhen (x &gt;= bj_MAX_INVENTORY)
                if (it[x] == udg_CItemType<i>) then
                    // Kick out the item
                    set it[x] = 0
                    set y = y + 1
                    // And increase by 1
                    exitwhen (true)
                endif
                set x = x + 1
            endloop
            
            set i = i + 1
        endloop
        set i = h
        
        if (y == z) then
            set h = i
            set i = i-6
            loop
            exitwhen (i &gt; h or udg_CItemType<i> == 0)
                call UnitRemoveItemById(u, udg_CItemType<i>)
                set i = i + 1
            endloop
            call UnitAddItemById(u, udg_CType[n])
            call SetSoundPosition(udg_ItemCombineSound, GetUnitX(u), GetUnitY(u), 0.)
            call StartSound(udg_ItemCombineSound)
            call DestroyEffect(AddSpecialEffectTarget(ItemCombineEffect(), u, &quot;origin&quot;))
            set u = null
            return
        endif
        
        set n = n + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Item_Combine_Core takes nothing returns nothing
    set gg_trg_Item_Combine_Core = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Item_Combine_Core, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction( gg_trg_Item_Combine_Core, function Trig_Item_Combine_Actions )

    call Preload(ItemCombineEffect())

    set udg_ItemCombineSound = CreateSound( &quot;Abilities\\Spells\\Orc\\MirrorImage\\MirrorImage.wav&quot;, false, true, true, 10, 10, &quot;&quot; )
    call SetSoundParamsFromLabel( udg_ItemCombineSound, &quot;MirrorImage&quot; )
    call SetSoundDuration( udg_ItemCombineSound, 1756 )
    call SetSoundPitch(udg_ItemCombineSound, 1.2)
    call SetSoundVolume(udg_ItemCombineSound, 100)
endfunction

</i></i></i></i>
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
What do you want to trigger it so i can edit it and give it to you
 

MrCrowley

New Member
Reaction score
17
I want it so that a unit presses a spell like "make" or something, then it will combine the items in his inventory, instead of the way its functioning now. So like...edit something in the beginning of the trigger?
 

LordXavier

TH.net Regular
Reaction score
16
I'm pretty sure EGUI has a nice custom trigger that creates a recipe. you could try that. get EGUI in the World Editor forums->Member's Projects->EGUI
 

MrCrowley

New Member
Reaction score
17
pretty much

btw Lord Xaivier i checked out EGUI and it does have a recipe system, and they provided a link to see the scripting...but it was broken D':
I will download it later though, thanks.
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
Well in any case here is the trigger

JASS:
constant function ItemCombineEffect takes nothing returns string
    return &quot;Abilities\\Spells\\Items\\AIlm\\AIlmTarget.mdl&quot;
endfunction

function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == &#039;A000&#039; //Your Spell RawCode

function UnitRemoveItemById takes unit whichUnit, integer itemId returns nothing
    local integer i = 0
    local item it
    
    loop
    exitwhen (i &gt;= bj_MAX_INVENTORY)
        set it = UnitItemInSlot(whichUnit, i)
        if GetItemTypeId(it) == itemId then
            call RemoveItem(it)
            exitwhen (true)
        endif
        set i = i + 1
    endloop
    set it = null
endfunction

function Trig_Item_Combine_Actions takes nothing returns nothing
    local integer n = 0
    local integer array it
    local integer i = 7
    local integer h = 0
    local integer x = 0
    local unit u = GetTriggerUnit()
    local boolean b = true
    local integer y = 0
    local integer z = 0
    local integer array hero_item_type

    // Get hero items
    loop
    exitwhen (x &gt;= bj_MAX_INVENTORY)
        set hero_item_type[x] = GetItemTypeId(UnitItemInSlot(u, x))
        set x = x + 1
    endloop

    loop
    exitwhen (n &gt;= udg_ItemN)
        set h = i + 6
        
        set x = 0
        set it[x] = hero_item_type[x]
        set x = x + 1
        set it[x] = hero_item_type[x]
        set x = x + 1
        set it[x] = hero_item_type[x]
        set x = x + 1
        set it[x] = hero_item_type[x]
        set x = x + 1
        set it[x] = hero_item_type[x]
        set x = x + 1
        set it[x] = hero_item_type[x]
        set x = x + 1
        
        set y = 0 // N of items that hero has ()
        set z = 0 // N of items needed ()
        loop
        exitwhen (i &gt;= h or udg_CItemType<i> == 0)
            set z = z + 1
            // Does unit contain item n
            set x = 0
            loop
            exitwhen (x &gt;= bj_MAX_INVENTORY)
                if (it[x] == udg_CItemType<i>) then
                    // Kick out the item
                    set it[x] = 0
                    set y = y + 1
                    // And increase by 1
                    exitwhen (true)
                endif
                set x = x + 1
            endloop
            
            set i = i + 1
        endloop
        set i = h
        
        if (y == z) then
            set h = i
            set i = i-6
            loop
            exitwhen (i &gt; h or udg_CItemType<i> == 0)
                call UnitRemoveItemById(u, udg_CItemType<i>)
                set i = i + 1
            endloop
            call UnitAddItemById(u, udg_CType[n])
            call SetSoundPosition(udg_ItemCombineSound, GetUnitX(u), GetUnitY(u), 0.)
            call StartSound(udg_ItemCombineSound)
            call DestroyEffect(AddSpecialEffectTarget(ItemCombineEffect(), u, &quot;origin&quot;))
            set u = null
            return
        endif
        
        set n = n + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Item_Combine_Core takes nothing returns nothing
    set gg_trg_Item_Combine_Core = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Item_Combine_Core, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Item_Combine_Core, function Conditions)
    call TriggerAddAction( gg_trg_Item_Combine_Core, function Trig_Item_Combine_Actions )

    call Preload(ItemCombineEffect())

    set udg_ItemCombineSound = CreateSound( &quot;Abilities\\Spells\\Orc\\MirrorImage\\MirrorImage.wav&quot;, false, true, true, 10, 10, &quot;&quot; )
    call SetSoundParamsFromLabel( udg_ItemCombineSound, &quot;MirrorImage&quot; )
    call SetSoundDuration( udg_ItemCombineSound, 1756 )
    call SetSoundPitch(udg_ItemCombineSound, 1.2)
    call SetSoundVolume(udg_ItemCombineSound, 100)
endfunction</i></i></i></i>
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
That raw code i made it like that but you can change it to what you like that why i put the comment in for you and not sure what you mean with the last part
 

MrCrowley

New Member
Reaction score
17
I was asking if it looked like i did it right -_- I understood that i had to change it, i just wasn't sure if i changed it in the right way.

As for the second problem, dont worry i already solved it, but i have another problem. Whenever i try to test the map I get 88 compile errors. An error for every single line starting at the top with local integer i = 0...
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
Oh sory but after that rawcode thing 'A002' press enter and type endfunction
 
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