• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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