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
609
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
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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