• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[JASS] Item Combination

Status
Not open for further replies.
Level 4
Joined
Dec 31, 2007
Messages
26
:grin::grin:
Hey, I just have a quick JASS question...for experienced JASS'ers plz?

Ok...I need help to write the JASS for combining two or three items. I've tried it but it doesn't work.

For Ex. Cheese - Slot 1 + Orb Of Frost - Slot 2 = Frosty Cheese or
something...lol.

:infl_thumbs_up:

Thank you!
 
Last edited:
I have just what you need. Just give me some time to search for my codes.

Ahhh, i found it, this is just what you need. This code was made by PurplePoot, one of the best Jassers in THW.

JASS:
function Comb_conds takes nothing returns boolean  
    return GetItemTypeId(GetManipulatedItem()) == 'I01F'//The Item that simulats the recipe 
endfunction
//======================================================================= 
function CountItemsInInventory takes unit who, integer itemType returns integer  
    local integer i = 0 //Item slots available  
    local integer num = 0 //Item Amount  
    loop  
        exitwhen i > 5 
        if GetItemTypeId(UnitItemInSlot(who,i)) == itemType then //don't replace this! It's a parameter  
            set num = num + 1                                   //for this function so that it can  
        endif                                                  //be used in any situation!  
        set i = i + 1 
    endloop  
    return num 
endfunction
//======================================================================= 
function I_dunno_what_i_am_doing takes nothing returns nothing  
    local unit who = GetTriggerUnit()  
    local integer i = 0 
    local effect ef
    local integer IR= 'I01F' //Item that simulates the recipe  
    local integer IB= 'I012' // rawcode of the item i buyed 3 times  
    local integer IG= 'I00D' //rawcode of the item that will replace the recipe and the 3 items (the comboniation)  
    local integer cnt = 0 
    if CountItemsInInventory(who,IB) > 2 then  
        call RemoveItem(GetManipulatedItem())  
        loop  
            exitwhen i > 5 or cnt > 2 
            if GetItemTypeId(UnitItemInSlot(who,i)) == IB then  
                call RemoveItem(UnitItemInSlot(who,i))  
                set cnt = cnt + 1 
            endif  
            set i = i + 1 
        endloop  
        set ef = AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIsm\\AIsmTarget.mdl", who, "origin")  
        call UnitAddItemById(who,IG)  
    endif  
    set who = null 
    call DestroyEffect(ef)
    set ef = null
endfunction 
//=============================================================================== 
function InitTrig_Combination1 takes nothing returns nothing  
    local integer index = 0 
    set gg_trg_Combination1 = CreateTrigger()  
    loop 
        exitwhen index == 16 
        call TriggerRegisterPlayerUnitEvent(gg_trg_Combination1, Player(index), EVENT_PLAYER_UNIT_PICKUP_ITEM, null)  
        set index = index + 1 
    endloop  
    call TriggerAddCondition( gg_trg_Combination1, Condition( function Comb_conds) )  
    call TriggerAddAction( gg_trg_Combination1, function I_dunno_what_i_am_doing) 
endfunction

To make this work you need 3 items:
1 - One item to SIMULATE the recipe. This will not be the combination. It is the item you buy in the shop.
2 - The item you want to collect. In this case I collect an item 3 times and I activate this trigger
3 - The real combination item. It will replace your items by only one.

If you have any questions about the code you can ask.

Oh, Btw, Give reputation points+ to those you help you =)

Also, don't just copy paste the code, try to understand it how it works, as its concepts will really help you in the future =)
 
Last edited:
Status
Not open for further replies.
Top