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: 229

Vestras

Retired
Reaction score
249
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!
 
Reaction score
341
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
 

Vestras

Retired
Reaction score
249
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!"
 
Reaction score
341
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?
 

ReVolver

Mega Super Ultra Cool Member
Reaction score
610
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
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
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...
 
Reaction score
341
:(

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
 

Artificial

Without Intelligence
Reaction score
326
> 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:
 
Reaction score
341
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

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top