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

Submissions Submit JASS resources! If approved, they will be moved to their proper section.
Please read me first.

Reply
 
LinkBack Thread Tools Display Modes
Old 07-06-2008, 02:27 PM   #1 (permalink)
 
Matrix's Avatar

User
 
Join Date: Jan 2007
Posts: 59

Matrix has little to show at this moment (2)


Thumbs up Matrix Recipe System

My first sytem I've created.
**************************************************************************************
*************************Simple Recipe System v1.01***********************************
**********************************************************************************
******************************By: Matrix****************************************
Pros:
1) Allow same item-types [like Stygian Desolator]
2) Consists of 74 lines
3) Can be used not only for Jassers/vJassers but also for GUI users
4) It is the simpliest system I've ever seen:)
Cons:
The only thing it's bad is if's. Due to them it's not very fast
*******************
**Changelog v1.02**
*******************
1) Added RecipeEx function
2) Now function returns a boolean depending on wether the recipe succeeded or not
3) More Cleaner&Leakless code
*******************
**How to implant:**
*******************
The system is very easy. The only things you'll have to do to implement the system is to
copy the custom script code
*******************
**How to use:******
*******************
To use this system u have to have a trigger with the event unit pick up item and in the actions
just write:
call Recipe(GetTriggerUnit(),'rde3','rde1','rde1',0,0,0,0)
Arguments:
GetTriggerUnit() - Unit that picked up item //I think it is clear
'rde3' - The New Item rawcode (the rawcode of the item that must be created)
'rde1' - The Rawcode of the first ingredient
'rde1' - The Rawcode of the second ingredient
0 - The Recipe hasn't more ingredients so the 3,4,5,6 ingredient are 0

************************
*****Trouble Shooter****
************************
Q: I have some troubles with this system. It doesn't work!!!
A: The reason maybe globals. If u have global integer i, i1,i2,i3,i4,i5,i6,count,j,ni... and all the arguments the system works with.
If u havent JassNewGenPack all must be Ok.

Q: Why did u do this shit?
A: I'm cr8ing an AoS map and I was searching for a simple recipe sytem but I didn't find=(
That's why I decided to cr8 my own =)


Hopefully you like the system!
~Matrix 3.08.08

P.S. I think I found my new home...
It's thehelper.net - really helper
Thx a lot to Earth-Fury for his suggestion
Code

function Recipe takes unit hero, integer ni, integer i1, integer i2, integer i3, integer i4, integer i5, integer i6, string Effect, string where returns boolean
local integer id
local integer i = 0
local integer j = 1
local integer count = 0
local item array Items
local item it = null
if i1!=0 then
   set count = count+1
endif
if i2!=0 then
   set count = count+1
endif
if i3!=0 then
   set count = count+1
endif
if i4!=0 then
   set count = count+1
endif
if i5!=0 then
   set count = count+1
endif
if i6!=0 then
   set count = count+1
endif
loop
    exitwhen i>5
    set it = UnitItemInSlot(hero, i)
    set id = GetItemTypeId(it)
    if id == i1 and i1!=0 then
           set Items[j] = it
           set j = j+1
           set i1=0
    elseif id == i2 and i2!=0 then
           set Items[j] = it
           set j = j+1
           set i2=0
    elseif id == i3 and i3!=0 then
           set Items[j] = it
           set j = j+1
           set i3=0
    elseif id == i4 and i4!=0 then
           set Items[j]= it
           set j=j+1
           set i4=0
    elseif id == i5 and i5!=0 then
           set Items[j] = UnitItemInSlot(hero, i)
           set j=j+1
           set i5=0
    elseif id == i6 and i6!=0 then
           set Items[j] = it
           set j=j+1
           set i6=0
    endif
    set i = i+1
endloop
set i = 1
if j-1!=count then
   return false
endif
loop
    exitwhen i>count
    call RemoveItem(Items[i])
    set Items[i]=null
    set i = i+1
endloop
set it = null
set bj_lastCreatedItem = UnitAddItemById(hero, ni)
call DestroyEffect(AddSpecialEffectTarget(Effect,hero,where))
return true
endfunction
function RecipeEx takes unit hero, integer ni, integer i1, integer i2, integer i3, integer i4, integer i5, integer i6 returns boolean
    return Recipe(hero,ni,i1,i2,i3,i4,i5,i6,null,null)
endfunction


Download Matrix Recipe System v1.02
__________________

Download Roshan Wars v0.4b
Download Simple Recipe System v1.02 New**
Download DamageUnitOverTime
Download Simple Filter System v1.0
I stand for the Light..
The Light is my strength!

Last edited by Matrix; 08-06-2008 at 09:10 AM..
Matrix is offline   Reply With Quote
Old 07-14-2008, 09:23 AM   #2 (permalink)
 
Matrix's Avatar

User
 
Join Date: Jan 2007
Posts: 59

Matrix has little to show at this moment (2)


fixed bug!
__________________

Download Roshan Wars v0.4b
Download Simple Recipe System v1.02 New**
Download DamageUnitOverTime
Download Simple Filter System v1.0
I stand for the Light..
The Light is my strength!
Matrix is offline   Reply With Quote
Old 07-22-2008, 03:59 PM   #3 (permalink)
 
Earth-Fury's Avatar

Inside You <3
 
Join Date: Feb 2004
Posts: 545

Earth-Fury is a glorious beacon of light (532)Earth-Fury is a glorious beacon of light (532)Earth-Fury is a glorious beacon of light (532)Earth-Fury is a glorious beacon of light (532)Earth-Fury is a glorious beacon of light (532)

PayPal Donor: This user has donated to The Hive. 

  1. Functions are indented. Period.
    Code

    function Recipe takes unit hero, integer ni, integer i1, integer i2, integer i3, integer i4, integer i5, integer i6, string Effect, string where returns nothing
        local integer id
        local integer i = 0
        local integer j = 1
        local integer count = 0
        local integer array ItemId
        local item array Item

        if i1!=0 then
           set count = count+1
           set ItemId[count]=i1
        endif
        if i2!=0 then
           set count = count+1
           set ItemId[count]=i2
        endif
        if i3!=0 then
           set count = count+1
           set ItemId[count]=i3
        endif
        if i4!=0 then
           set count = count+1
           set ItemId[count]=i4
        endif
        if i5!=0 then
           set count = count+1
           set ItemId[count]=i5
        endif
        if i6!=0 then
           set count = count+1
           set ItemId[count]=i6
        endif

        loop
            exitwhen i>5
            set id = GetItemTypeId(UnitItemInSlot(hero, i))
            if id == ItemId[1] and ItemId[1]!=0 then
                   set Item[j] = UnitItemInSlot(hero, i)
                   set j = j+1
                   set ItemId[1]=0
            elseif id == ItemId[2] and ItemId[2]!=0 then
                   set Item[j] = UnitItemInSlot(hero, i)
                   set j = j+1
                   set ItemId[2]=0
            elseif id == ItemId[3] and ItemId[3]!=0 then
                   set Item[j] = UnitItemInSlot(hero, i)
                   set j = j+1
                   set ItemId[3]=0
            elseif id == ItemId[4] and ItemId[4]!=0 then
                   set Item[j]= UnitItemInSlot(hero, i)
                   set j=j+1
                   set ItemId[4]=0
            elseif id == ItemId[5] and ItemId[5]!=0 then
                   set Item[j] = UnitItemInSlot(hero, i)
                   set j=j+1
                   set ItemId[5]=0
            elseif id == ItemId[6] and ItemId[6]!=0 then
                   set Item[j] = UnitItemInSlot(hero, i)
                   set j=j+1
                   set ItemId[6]=0
            endif
            set i = i+1
        endloop

        set i = 1
        loop
            exitwhen i>count
            if Item[i]==null then
                return
            endif
            set i = i+1
        endloop

        set i =1
        loop
            exitwhen i>count
            call RemoveItem(Item[i])
            set Item[i]=null
            set i = i+1
        endloop

        call DestroyEffect(AddSpecialEffectTarget(Effect,hero,where))

        call UnitAddItemById(hero, ni)
    endfunction

  2. The function's API is actually not half bad. A good enough example of procedural programming. However, the function should return a boolean indicating the recipes success or failure.

  3. 1-based arrays are failures:
            if i1!=0 then
           set count = count+1
           set ItemId[count]=i1
        endif

  4. Failing to use nested loops, while theoretically more efficient on an immeasurably small scale, is a failure:
            if id == ItemId[1] and ItemId[1]!=0 then
                   set Item[j] = UnitItemInSlot(hero, i)
                   set j = j+1
                   set ItemId[1]=0
            elseif id == ItemId[2] and ItemId[2]!=0 then
                   set Item[j] = UnitItemInSlot(hero, i)
                   set j = j+1
                   set ItemId[2]=0
            elseif id == ItemId[3] and ItemId[3]!=0 then
                   set Item[j] = UnitItemInSlot(hero, i)
                   set j = j+1
                   set ItemId[3]=0
            elseif id == ItemId[4] and ItemId[4]!=0 then
                   set Item[j]= UnitItemInSlot(hero, i)
                   set j=j+1
                   set ItemId[4]=0
            elseif id == ItemId[5] and ItemId[5]!=0 then
                   set Item[j] = UnitItemInSlot(hero, i)
                   set j=j+1
                   set ItemId[5]=0
            elseif id == ItemId[6] and ItemId[6]!=0 then
                   set Item[j] = UnitItemInSlot(hero, i)
                   set j=j+1
                   set ItemId[6]=0
            endif

  5. Singular instead of plural names on array variables is a failure:
        local integer array ItemId
        local item array Item

  6. Using UnitInventorySize to reduce iteration count in the event of a unit with less than 6 inventory slots would be nice.

  7.     set i = 1
        loop
            exitwhen i>count
            if Item[i]==null then
                return
            endif
            set i = i+1
        endloop
    .. Isn't this what j is for?
    if j != count then
        return
    endif

  8. The repeated calls to UnitItemInSlot(hero, i) should be optimized out with an item type local.

  9. As I have mentioned, this function should return a boolean depending on weather the recipe succeeded or not. That would allow removal of special effect code from the function, without removing the possibility of the functionality.
__________________
Giving reputation is a nice way to say thank you to someone that helps you!
Earth-Fury is offline   Reply With Quote
Old 08-03-2008, 12:42 PM   #4 (permalink)
 
Matrix's Avatar

User
 
Join Date: Jan 2007
Posts: 59

Matrix has little to show at this moment (2)


so using loop is a wrong decisin if the array number is =< 6?? and i needn't use it or what?

Im going editing..

thx for pointing it out! +rep

sry for so long being out of there (f***ing job)
__________________

Download Roshan Wars v0.4b
Download Simple Recipe System v1.02 New**
Download DamageUnitOverTime
Download Simple Filter System v1.0
I stand for the Light..
The Light is my strength!
Matrix is offline   Reply With Quote
Old 08-06-2008, 09:09 AM   #5 (permalink)
 
Matrix's Avatar

User
 
Join Date: Jan 2007
Posts: 59

Matrix has little to show at this moment (2)


Updated!!!
__________________

Download Roshan Wars v0.4b
Download Simple Recipe System v1.02 New**
Download DamageUnitOverTime
Download Simple Filter System v1.0
I stand for the Light..
The Light is my strength!
Matrix is offline   Reply With Quote
Reply

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[vjass] ORTS - Orc_Tamer's Recipe System 2.0 Orc_Tamer "Graveyard" 7 08-01-2008 07:09 AM
Recipe System need serius help Tan World Editor Help Zone 9 10-02-2007 06:11 PM
Need skins from the Matrix Ravager3000 Requests 6 02-21-2007 10:17 PM
[JASS] Recipe System Help August Triggers & Scripts 1 01-20-2006 01:52 AM
Need Matrix Models!!! CursedOne Requests 0 08-05-2005 08:08 PM

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






Your link here 
Loans | Bad Credit Loans | Credit Cards | Bankruptcy | Libros de historia
Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Copyright©Ralle