TriggerHappy
...
- 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:
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 :
Demo Triggers
Create Recipe Demo
CombineItem
Thanks to Acehart for the String2Id function
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