Jump to content

[Share][GuIdE]MaKiNg ReCipEs-ItEmS + [JASS Function] (OTRS) Recipe Items


Recommended Posts

Posted

                            ALL CREDITS FOR THIS GOES TO : ORC_TAMER

 

recipetutorialdr5pp3.png

 

Here a basic script using structs and methods to combine items into 1.

 

Changelog:

Version: 2.0 (Added New Function Arguments and Optimized Coding)

Version: 1.0 (Fixed minor bug)

 

Jass:

 

//===========================================================================
//  OTRS (Orc_Tamer's Recipe System)
//  Recipe System that allows you to make recipe items for you easier.
//  Author: Orc_Tamer
//  Date: 01.December.2007
//
//  How to implement:
//  Requires JASS NewGen World Editor
//  Just copy this trigger to your map.
//===========================================================================
library RecipeFunction

struct RecipeItems
    integer item0_id  
    integer item1_id  
    integer item2_id 
    integer item3_id  
    integer item4_id
    integer item5_id
    integer item6_id
    integer item7_id
    unit u
    item item1 = null
    item item2 = null 
    item item3 = null 
    item item4 = null
    item item5 = null
    item item6 = null
    
    method CheckItems2 takes nothing returns nothing
        local integer this_id
        local integer i = 0 
        loop
        set this_id = GetItemTypeId(UnitItemInSlot(.u, i)) 
        if this_id == .item0_id then 
            set .item1 = UnitItemInSlot(.u, i) 
        elseif this_id == .item1_id then 
            set .item2 = UnitItemInSlot(.u, i) 
        endif
        set i = i + 1
        exitwhen i >= bj_MAX_INVENTORY
        endloop
        if .item1 != null and .item2 != null then 
            call RemoveItem(.item1)
            call RemoveItem(.item2) 
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl",.u,"overhead"))
            call UnitAddItemById(.u, .item2_id)
            set .item1 = null 
            set .item2 = null
            set .u = null
        endif
    endmethod
    
    method CheckItems3 takes nothing returns nothing
        local integer this_id 
        local integer i = 0 
        loop
        set this_id = GetItemTypeId(UnitItemInSlot(.u, i)) 
        if this_id == .item0_id then 
            set .item1 = UnitItemInSlot(.u, i)
        elseif this_id == .item1_id then 
            set .item2 = UnitItemInSlot(.u, i) 
        elseif this_id == .item2_id then 
            set .item3 = UnitItemInSlot(.u, i) 
        endif
        set i = i + 1 
        exitwhen i >= bj_MAX_INVENTORY 
        endloop
        if .item1 != null and .item2 != null and .item3 != null then
            call RemoveItem(.item1) 
            call RemoveItem(.item2)
            call RemoveItem(.item3) 
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl",.u,"overhead")) //adds a special effect
            call UnitAddItemById(.u, .item3_id)
            set .item1 = null 
            set .item2 = null 
            set .item3 = null 
            set .u = null
        endif
    endmethod
    
    method CheckItems4 takes nothing returns nothing
        local integer this_id 
        local integer i = 0
        loop
        set this_id = GetItemTypeId(UnitItemInSlot(.u, i))
        if this_id == .item0_id then 
            set .item1 = UnitItemInSlot(.u, i)
        elseif this_id == .item1_id then 
            set .item2 = UnitItemInSlot(.u, i)
        elseif this_id == .item2_id then 
            set .item3 = UnitItemInSlot(.u, i)
        elseif this_id == .item3_id then
            set .item4 = UnitItemInSlot(.u, i)
        endif
        set i = i + 1 
        exitwhen i >= bj_MAX_INVENTORY 
        endloop
        if .item1 != null and .item2 != null and .item3 != null and .item4 != null then 
            call RemoveItem(.item1) 
            call RemoveItem(.item2) 
            call RemoveItem(.item3)
            call RemoveItem(.item4)
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl",.u,"overhead")) 
            call UnitAddItemById(.u, .item4_id)
            set .item1 = null 
            set .item2 = null 
            set .item3 = null 
            set .item4 = null
            set .u = null 
        endif
    endmethod
    
    method CheckItems5 takes nothing returns nothing
        local integer this_id 
        local integer i = 0
        loop
        set this_id = GetItemTypeId(UnitItemInSlot(.u, i))
        if this_id == .item0_id then 
            set .item1 = UnitItemInSlot(.u, i)
        elseif this_id == .item1_id then 
            set .item2 = UnitItemInSlot(.u, i)
        elseif this_id == .item2_id then 
            set .item3 = UnitItemInSlot(.u, i)
        elseif this_id == .item3_id then
            set .item4 = UnitItemInSlot(.u, i)
        elseif this_id == .item4_id then
            set .item5 = UnitItemInSlot(.u, i)
        endif
        set i = i + 1 
        exitwhen i >= bj_MAX_INVENTORY 
        endloop
        if .item1 != null and .item2 != null and .item3 != null and .item4 != null and .item5 != null then 
            call RemoveItem(.item1) 
            call RemoveItem(.item2) 
            call RemoveItem(.item3)
            call RemoveItem(.item4)
            call RemoveItem(.item5)
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl",.u,"overhead")) 
            call UnitAddItemById(.u, .item5_id)
            set .item1 = null 
            set .item2 = null 
            set .item3 = null 
            set .item4 = null
            set .item5 = null
            set .u = null 
        endif
    endmethod
    
    method CheckItems6 takes nothing returns nothing
        local integer this_id 
        local integer i = 0
        loop
        set this_id = GetItemTypeId(UnitItemInSlot(.u, i))
        if this_id == .item0_id then 
            set .item1 = UnitItemInSlot(.u, i)
        elseif this_id == .item1_id then 
            set .item2 = UnitItemInSlot(.u, i)
        elseif this_id == .item2_id then 
            set .item3 = UnitItemInSlot(.u, i)
        elseif this_id == .item3_id then
            set .item4 = UnitItemInSlot(.u, i)
        elseif this_id == .item4_id then
            set .item5 = UnitItemInSlot(.u, i)
        elseif this_id == .item5_id then
            set .item6 = UnitItemInSlot(.u, i)
        endif
        set i = i + 1 
        exitwhen i >= bj_MAX_INVENTORY 
        endloop
        if .item1 != null and .item2 != null and .item3 != null and .item4 != null and .item5 != null and .item6 != null then 
            call RemoveItem(.item1) 
            call RemoveItem(.item2) 
            call RemoveItem(.item3)
            call RemoveItem(.item4)
            call RemoveItem(.item5)
            call RemoveItem(.item6)
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl",.u,"overhead")) 
            call UnitAddItemById(.u, .item6_id)
            set .item1 = null 
            set .item2 = null 
            set .item3 = null 
            set .item4 = null
            set .item5 = null
            set .item6 = null
            set .u = null 
        endif
    endmethod
endstruct

function Recipe2 takes unit hero, integer i1, integer i2, integer ni returns nothing
    local RecipeItems IS=RecipeItems.create() 
    set IS.item0_id = i1 
    set IS.item1_id = i2 
    set IS.item2_id = ni 
    set IS.u = hero 
    call IS.CheckItems2() 
    call IS.destroy() 
endfunction

function Recipe3 takes unit hero, integer i1, integer i2, integer i3, integer ni returns nothing
    local RecipeItems IS=RecipeItems.create()
    set IS.item0_id = i1 
    set IS.item1_id = i2 
    set IS.item2_id = i3 
    set IS.item3_id = ni 
    set IS.u = hero 
    call IS.CheckItems3() 
    call IS.destroy()
endfunction

function Recipe4 takes unit hero, integer i1, integer i2, integer i3, integer i4, integer ni returns nothing
    local RecipeItems IS=RecipeItems.create()
    set IS.item0_id = i1 
    set IS.item1_id = i2 
    set IS.item2_id = i3 
    set IS.item3_id = i4 
    set IS.item4_id = ni
    set IS.u = hero 
    call IS.CheckItems4() 
    call IS.destroy()
endfunction

function Recipe5 takes unit hero, integer i1, integer i2, integer i3, integer i4, integer i5, integer ni returns nothing
    local RecipeItems IS=RecipeItems.create()
    set IS.item0_id = i1 
    set IS.item1_id = i2 
    set IS.item2_id = i3 
    set IS.item3_id = i4
    set IS.item4_id = i5
    set IS.item5_id = ni
    set IS.u = hero 
    call IS.CheckItems5() 
    call IS.destroy()
endfunction

function Recipe6 takes unit hero, integer i1, integer i2, integer i3, integer i4, integer i5, integer i6, integer ni returns nothing
    local RecipeItems IS=RecipeItems.create()
    set IS.item0_id = i1 
    set IS.item1_id = i2 
    set IS.item2_id = i3 
    set IS.item3_id = i4
    set IS.item4_id = i5
    set IS.item5_id = i6
    set IS.item6_id = ni
    set IS.u = hero 
    call IS.CheckItems6() 
    call IS.destroy()
endfunction

endlibrary

 

 

This is an example you can use:

GUI:

 

RecipeGUI
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        Custom script:   call Recipe2(GetTriggerUnit(),'rde1','rde2','rde3')
        Custom script:   call Recipe3(GetTriggerUnit(),'afac','spsh','ajen','bgst')
        Custom script:   call Recipe4(GetTriggerUnit(),'ratc','rat6','rat9','bspd','modt')
        Custom script:   call Recipe5(GetTriggerUnit(),'ofro','olig','oven','ocor','oslo','sor9')
        Custom script:   call Recipe6(GetTriggerUnit(),'pghe','pgma','pdiv','pomn','pres','pnvu','infs')

 

JASS:

function Trig_RecipeChecking_Actions takes nothing returns nothing
    call Recipe2(GetTriggerUnit(),'rde1','rde2','rde3')
    call Recipe3(GetTriggerUnit(),'afac','spsh','ajen','bgst')
    call Recipe4(GetTriggerUnit(),'ratc','rat6','rat9','bspd','modt')
    call Recipe5(GetTriggerUnit(),'ofro','olig','oven','ocor','oslo','sor9')
    call Recipe6(GetTriggerUnit(),'pghe','pgma','pdiv','pomn','pres','pnvu','infs')
endfunction

function InitTrig_RecipeJASS takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddAction( t, function Trig_RecipeChecking_Actions )
endfunction

 

 

EnJoY. cOmMeNtT pLLeAzEe :-)

Some DeMo MapS :)

Recipe System.w3x + Recipe System2.w3x

  • 3 weeks later...
  • 1 year later...
Guest
This topic is now closed to further replies.


×
×
  • Create New...