(Keeps Hive Alive)
Go Back   The Hive Workshop - A Warcraft III Modding Site > Warcraft III Resources > Submissions > "Graveyard"

"Graveyard" Resources which were not approved are moved to this section.

 
 
LinkBack Thread Tools Display Modes
Old 05-01-2008, 11:49 AM   #1 (permalink)

Anozer jasser
 
Join Date: Apr 2008
Posts: 237

Troll-Brain has little to show at this moment (13)Troll-Brain has little to show at this moment (13)


Reciepe

function Reciepe takes unit u, integer item1, integer item2, integer item3, integer item4, integer item5, integer item6, integer itemResult returns boolean
    local integer array uItem
    local integer array rItem
    local integer array slot
    local boolean array b
    local boolean array slotFull
    local integer inc = 0
    local integer inc2 = 0
    local integer count = 0
    local boolean check = true

    set rItem[1] = item1
    set rItem[2] = item2
    set rItem[3] = item3
    set rItem[4] = item4
    set rItem[5] = item5
    set rItem[6] = item6

    loop
    exitwhen inc == 7
        set inc = inc + 1
        if rItem[inc] == 0 then
            set b[inc] = true
        else
            set b[inc] = false
        endif
    endloop

    set inc = 0

    loop
    set inc = inc + 1
    exitwhen inc == 7
        set uItem[inc] = GetItemTypeId(UnitItemInSlot(u,inc-1))
    endloop

    set inc = 0

    loop
    exitwhen inc == 7
    set inc = inc + 1
        loop
        set inc2 = inc2 + 1
        exitwhen inc2 == 7 or b[inc] == true
            if rItem[inc] == uItem[inc2] and not slotFull[inc2] then
                set b[inc] = true
                set slot[count] = inc2 - 1
                set slotFull[inc2] = true
                set count = count + 1
            endif
        endloop
        set inc2 = 0
    endloop

    set inc = 0

    loop
    set inc = inc + 1
    exitwhen inc == 7
        if b[inc] == false then
            set check = false
        endif
    endloop

    set inc = 0

    if check then
        loop
        exitwhen count == 0
            set count = count - 1
            call RemoveItem( UnitItemInSlot(u,slot[count]) )
        endloop
            set bj_lastCreatedItem = CreateItem(itemResult, GetUnitX(u), GetUnitY(u) )
            call UnitAddItem(u, bj_lastCreatedItem)
    endif
    return check
endfunction

Description : it's for combine objects in one of your choice
How to use ? :
u is your unit whith an inventory
item1 ... item 6 are integers (item type in gui), you can use rawcode 'xxxx', just use the shortcut Ctrl+d in the object editot for see it in the object editor.
Even if you don't want 6 items to combine you must use 6 integers, but use 0 if you don't want to use an other one.
the order with 0 and rawcodes doesn't matter
finally itemResult is the combine item

PS : i use bj_lastCreatedItem for the result item so you can use the last created item in gui, but if you don't want this juste replace these lines :
            set bj_lastCreatedItem = CreateItem(itemResult, GetUnitX(u), GetUnitY(u) )
            call UnitAddItem(u, bj_lastCreatedItem)
with this :


            call UnitAddItem(u, CreateItem(itemResult, GetUnitX(u), GetUnitY(u)))

and maybe UnitAddItem is useless because i think that create an item to an unit position give to it, but i can't test now, my cd is broken and i must reinstall war3

Last edited by Troll-Brain; 05-01-2008 at 12:10 PM..
Troll-Brain is offline  
Old 05-22-2008, 09:22 PM   #2 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

  • Arrays start at 0
  • You can replace CreateItem then UnitAddItem with UnitAddItemById
  • ==false can be replaced with not
  • This isn't particularly useful, seeing as it doesn't even manage the recipes; it just checks if you have one that you have to pass right then and there, and if you have it it combines the items.
  • There are lots of wasted variables, such as the integer array 'slot'
  • Unoptimized in general (I'm not going to bother continuing, as it would cause large parts of the code to be rewritten)

Sorry, but this is rather poorly optimized and not particularly useful. Additionally, there are many that are optimized better, as well as more useful (because they handle the recipes completely, as opposed to simply combinations) out there.

~Graveyarded.
PurplePoot is offline  
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

All times are GMT. The time now is 09:22 AM.






Your link here 
Xbox Mod Chips | Credit Counseling | Home Loan | Cell Phones | Problem Mortgage
Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Copyright©Ralle