System SRS - Short Recipe System

Reaction score
341
Introduction : I Was just bored so i decided to make a recipe system , Using JASS.

Why Its Different : This one is really short , and 1 action away from adding new recipe combos.

How To Use : Simply add one custom script action to set a new recipe. For Example:

JASS:
Custom script:   call CreateRecipe("clsd","crys","I000")


It will create a new recipe combo using the First Raw item Id "clsd" ( the crystal ball item ) and the next item "cyrs" ( Cloak of shadows ) and the last Raw ID Is the Product . So basicly that action is saying

Crystal Ball + Cloak Of Shaows = NEW ITEM

Main Code :

JASS:
globals
    integer num1 = 0
endglobals

function Char2Id takes string c returns integer
    local integer i = 0
    local string abc = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
    local string t

    loop
        set t = SubString(abc,i,i + 1)
        exitwhen t == null or t == c
        set i = i + 1
    endloop
    if i < 10 then
        return i + 48
    elseif i < 36 then
        return i + 65 - 10
    endif
    return i + 97 - 36
endfunction

function String2Id takes string s returns integer
    return ((Char2Id(SubString(s,0,1)) * 256 + Char2Id(SubString(s,1,2))) * 256 + Char2Id(SubString(s,2,3))) * 256 + Char2Id(SubString(s,3,4))
endfunction

function CreateRecipe takes string one, string two, string product returns nothing
    set udg_RecipeNumber = udg_RecipeNumber + 1
    set udg_Item1[udg_RecipeNumber] = String2Id(one)
    set udg_Item2[udg_RecipeNumber] = String2Id(two)
    set udg_Product[udg_RecipeNumber] = String2Id(product)
    set udg_NumberOfCombos = udg_NumberOfCombos + 1
endfunction

function CC takes nothing returns boolean
    if ( not ( UnitHasItemOfTypeBJ(GetManipulatingUnit(), udg_Item1[num1]) == true ) ) then
        return false
    endif
    if ( not ( UnitHasItemOfTypeBJ(GetManipulatingUnit(), udg_Item2[num1]) == true ) ) then
        return false
    endif
    return true
endfunction

function Combine takes nothing returns nothing
    set num1 = 0
    loop
        exitwhen num1>udg_NumberOfCombos
            set num1 = num1 + 1
            if ( CC() ) then
            call CreateItemLoc( udg_Product[num1], GetRandomLocInRect(GetPlayableMapRect()) )
            call DisplayTextToForce( GetForceOfPlayer(GetOwningPlayer(GetManipulatingUnit())), ( ( ( "You Have Combined " + GetItemName(GetItemOfTypeFromUnitBJ(GetManipulatingUnit(), udg_Item1[num1])) ) + " And a " ) + ( GetItemName(GetItemOfTypeFromUnitBJ(GetManipulatingUnit(), udg_Item2[num1])) + ( " And Created A " + GetItemName(GetLastCreatedItem()) ) ) ) )
            call RemoveItem( GetLastCreatedItem() )
            call RemoveItem( GetItemOfTypeFromUnitBJ(GetManipulatingUnit(), udg_Item1[num1]) )
            call RemoveItem( GetItemOfTypeFromUnitBJ(GetManipulatingUnit(), udg_Item2[num1]) )
            call UnitAddItemByIdSwapped( udg_Product[num1], GetManipulatingUnit() )
            call AddSpecialEffectLocBJ( GetUnitLoc(GetManipulatingUnit()), "Abilities\\Spells\\Undead\\ReplenishHealth\\ReplenishHealthCaster.mdl" )
            set udg_SE[GetConvertedPlayerId(GetOwningPlayer(GetManipulatingUnit()))] = GetLastCreatedEffectBJ()
            call TriggerSleepAction( 1.00 )
            call DestroyEffectBJ( udg_SE[GetConvertedPlayerId(GetEnumPlayer())] ) 
    endif
    endloop

endfunction


Demo Triggers

Create Recipe Demo
Code:
Create Recipes
    Events
        Time - Elapsed game time is 0.00 seconds
    Conditions
    Actions
        Set RecipeNumber = 0
        Set NumberOfCombos = 0
        Set Item1[0] = (Item-type of No item)
        Set Item2[0] = (Item-type of No item)
        Set Product[0] = (Item-type of No item)
        --------   --------
        -------- Crystal Cloak Of Shadows --------
        Custom script:   call CreateRecipe("clsd","crys","I000")
        --------   --------

CombineItem
Code:
Cmbine
    Events
        Unit - A unit Acquires an item
    Conditions
    Actions
        Custom script:   call Combine()


Thanks to Acehart for the String2Id function
 

Attachments

  • SRS - Simple Recipe System v1.01.w3x
    15.4 KB · Views: 230
This has nothing to do with a recipe system.
Actually, it's only one function, because everything else than the CreateRecipe function could be cut off;

JASS:
function CreateRecipe takes integer one, integer two, integer product returns nothing
    set udg_RecipeNumber = udg_RecipeNumber + 1
    set udg_Item1[udg_RecipeNumber] = one
    set udg_Item2[udg_RecipeNumber] = two
    set udg_Product[udg_RecipeNumber] = product
    set udg_NumberOfCombos = udg_NumberOfCombos + 1
endfunction


I suggest you to learn more JASS and vJASS before submitting "systems", since most systems is nicely coded and longer than 7 lines!

Sorry if that sounded aggressive, but really, this isn't a recipe system, this is just setting some globals.
A real recipe system should combine the items to the specified items automaticly, so the user didn't have to do it manually!
 
Well i didnt want to do it in vJASS , because i didnt want to make it require NewGen.


I guess ill make a vJASS Version also


Also if you check the demo it has the trigger that combines the items , in one way
 
Didn't you read what I said at all?
You'll probably need to make a new system before this gets approved, because this ain't a system.

"A real recipe system should combine the items to the specified items automaticly, so the user didn't have to do it manually!"
 
Ok , lol.

But doing it automaticly is even worse , not as customisable.

What if a player that knows no JASS want to make it when a unit casts an ability items combine?
 
My system was EGUI implemented so you can add it using the default gui features. With your system it wouldn't be possible.


try something like

JASS:
function Recipe takes integer item1,integer item2,integer item3,integer item4,integer item5,integer item6,integer itemcombine returns nothing
endfunction
 
And that's what you needed String2Id for??? :banghead:
Given you already have to find out the IDs, just use those directly, as simple integers...


As for "system"... this is a single function that adds two values to an array...
 
:(

Im working more on the system right now , trying to work on the suggestions you guys gave me.


EDIT : I updated it , its still not auto but you dont have to make a long trigger just to combine items , it will do it auto for you once you call this function

JASS:
call Combine()



Allowing you to combine it with any event
 
> also im talking about my system not artificals.
He was just giving my system as an example of a system that combines the items automatically, but still has the flexibility of combining the items whenever you want instead of the automatic combining. So it's possible to have both.

And this doesn't support having the same item type twice in a recipe. :p

You say it's different from the others because it's short. Well, Matrix's one was short, and now it's graveyarded. Mine one is bloody long, but is approved at WC3C. Shortness is superior?

JASS:
function Combine takes item one, item two returns nothing

endfunction
What a funny function. :D I'd suggest you finishing this function and making a function that checks if a unit has all of the items that belong to a recipe (possibly making it possible to have the same item-type several times in a recipe). So you could just do
Code:
Set TempUnit = (Triggering unit)
Set Recipe = <The recipe being checked>
Custom Script:   if CheckRecipe(udg_TempUnit, udg_Recipe) then
Custom Script:   call Combine(udg_TempUnit, udg_Recipe)
Custom Script:   endif
Also adding a possibility to have more than 2 items wouldn't hurt at all.

> Im working more on the system right now
:thup:
 
Oh hey artificial , i updated map so look at it now and combine function does something.

OFFTOPIC : U dissapeared artificial.



EDIT : I am now working on allowing up to 6 combos for 1 recipe
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top