Rheias
New Helper (I got over 2000 posts)
- Reaction score
- 232
Version 1.3, please read the READ ME:
Code:
====================================================================================================
Foreword:
This system was made due to the popularity that the recipe system got from "Defense of the Ancients"
(known as DotA, made by IceFrog). What I wanted to do is to bring an easy way of doing this system
without creating a trigger per recipe, but rather a line per recipe. What the recipe system does
basically is takes few items and making them into another item once they are all picked up by the
same hero.
Before, this system had to have a different trigger for each recipe, however I hope once this is out
users could do what took dozens of triggers in just one. Look at the "examples" trigger for examples
of usage of this system.
I hope you enjoy, I would love to hear comments, feedbacks, bugs found, suggestions, questions or
anythign else of that type. You can send me a private massage, or post in the system's thread.
====================================================================================================
Using the System:
Using the system is extremely easy, it was made to be user friendly, requiring you to do minimal
work. What you need to do is in order for it to work is the following:
A. Create a trigger, and call it however you want, in my map I call it Examples, add event of "time
elapsed" about 1 second should be good.
B. After that is done you need to create an action called custom script, this action can be found
under the section "-general".
C. Type inside the action the following: call RecipeSysSet(0,0,0,0,0,0,0,"","")
D. After that replace the first "0" with the raw code of the item that should be awarded (see later
on raw code), after that replace the next zeros with the raw codes of the items that should be
taken by a hero to get the item stored in the first 0. If you want less then 6 items to be taken,
replace only the needed zeros.
E. Finally replace the first "" with the attachment point of the effect, and the second "" with
the effect's string (using \\ instead of \). If you don't want an effect to appear don't replace
the ""s.
See the trigger "examples" for a better understanding of this.
====================================================================================================
Raw Codes:
Raw codes are the core of the system, this way it can identify the items that the hero should have
and return the time that it should get. Raw codes of the items can be found as the following:
A. Go to the object editor.
B. Go to the item editor inside the object editor.
C. Click on ctrl + d (or apple + d), now you see the raw codes of the values.
D. Look to the left were usually you would see the items' names, the first four digits are the
item's raw code. Copy it and put it between 2 '.
E. Click ctrl + d (or apple + d) to make the object editor look normal again.
Note: In the same way you can find the raw code of anything in the object editor.
====================================================================================================
implementing the system:
Follow the following steps to implement the system properly into your map.
A. Create a variable of type game cache called "RSCache".
B. Go to the header of the map (where you see Recipe System.w3x) and copy everything there into your
map's header.
Done, it is that simple.
====================================================================================================
Histroy:
Vesion 1.3 (25th of May 2007)
Improved testing map dramatically.
Screenshots posted.
Vesion 1.2 (25th of May 2007)
Added effects feature to the system.
Another leak cleaned.
Updated the chapter "Using the system" in the READ ME.
Version 1.1 (24th of May 2007)
Added special effect to the system.
Cleared a small leak.
Improved testing map.
Version 1.0 (23th of May 2007)
Original system created and posted.
====================================================================================================
Credits:
KaTTaNa for the local handle system.
====================================================================================================
I hope you enjoy this, I would appreciate credits if you use this in your map.
~ Rheias ~
JASS:
// ======================================================================================= \\
// Local Handle System (made by KaTTaNa) \\
// ======================================================================================= \\
function H2I takes handle h returns integer
return h
return 0
endfunction
function LocalVars takes nothing returns gamecache
if udg_RSCache == null then
set udg_RSCache = InitGameCache("jasslocalvars.w3v")
endif
return udg_RSCache
endfunction
function SetHandleInt takes handle subject, string name, integer value returns nothing
if value==0 then
call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
else
call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function SetHandleString takes handle subject, string name, string value returns nothing
if value==null then
call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
else
call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function GetHandleInt takes handle subject, string name returns integer
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleString takes handle subject, string name returns string
return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction
function FlushHandleLocals takes handle subject returns nothing
call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction
// ======================================================================================= \\
// Recipe System (made by Rheias) \\
// ======================================================================================= \\
function RecipeSysCon takes nothing returns boolean
local trigger RecipeSysExe = GetTriggeringTrigger()
local unit triggerer = GetTriggerUnit()
local integer r = GetHandleInt(RecipeSysExe,"r")
local integer a = GetHandleInt(RecipeSysExe,"a")
local integer b = GetHandleInt(RecipeSysExe,"b")
local integer c = GetHandleInt(RecipeSysExe,"c")
local integer d = GetHandleInt(RecipeSysExe,"d")
local integer e = GetHandleInt(RecipeSysExe,"e")
local integer f = GetHandleInt(RecipeSysExe,"f")
local string p = GetHandleString(RecipeSysExe,"p")
local string t = GetHandleString(RecipeSysExe,"t")
local integer pickedSlot = 0
local item pickedItem
local integer sum = GetHandleInt(RecipeSysExe,"sum")
local integer count = 0
loop
exitwhen pickedSlot > 6
set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
if GetItemTypeId(pickedItem) == a and pickedItem != null then
set count = count + 1
exitwhen true
endif
set pickedSlot= pickedSlot + 1
endloop
set pickedSlot = 0
loop
exitwhen pickedSlot > 6
set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
if GetItemTypeId(pickedItem) == b and pickedItem != null then
set count = count + 1
exitwhen true
endif
set pickedSlot= pickedSlot + 1
endloop
set pickedSlot = 0
loop
exitwhen pickedSlot > 6
set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
if GetItemTypeId(pickedItem) == c and pickedItem != null then
set count = count + 1
exitwhen true
endif
set pickedSlot= pickedSlot + 1
endloop
set pickedSlot = 0
loop
exitwhen pickedSlot > 6
set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
if GetItemTypeId(pickedItem) == d and pickedItem != null then
set count = count + 1
exitwhen true
endif
set pickedSlot= pickedSlot + 1
endloop
set pickedSlot = 0
loop
exitwhen pickedSlot > 6
set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
if GetItemTypeId(pickedItem) == e and pickedItem != null then
set count = count + 1
exitwhen true
endif
set pickedSlot= pickedSlot + 1
endloop
set pickedSlot = 0
loop
exitwhen pickedSlot > 6
set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
if GetItemTypeId(pickedItem) == f and pickedItem != null then
set count = count + 1
exitwhen true
endif
set pickedSlot= pickedSlot + 1
endloop
if count == sum then
set pickedSlot = 0
loop
exitwhen pickedSlot > 6
set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
if GetItemTypeId(pickedItem) == a and pickedItem != null then
call UnitRemoveItem(triggerer,pickedItem)
call RemoveItem(pickedItem)
exitwhen true
endif
set pickedSlot= pickedSlot + 1
endloop
set pickedSlot = 0
loop
exitwhen pickedSlot > 6
set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
if GetItemTypeId(pickedItem) == b and pickedItem != null then
call UnitRemoveItem(triggerer,pickedItem)
call RemoveItem(pickedItem)
exitwhen true
endif
set pickedSlot= pickedSlot + 1
endloop
set pickedSlot = 0
loop
exitwhen pickedSlot > 6
set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
if GetItemTypeId(pickedItem) == c and pickedItem != null then
call UnitRemoveItem(triggerer,pickedItem)
call RemoveItem(pickedItem)
exitwhen true
endif
set pickedSlot= pickedSlot + 1
endloop
set pickedSlot = 0
loop
exitwhen pickedSlot > 6
set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
if GetItemTypeId(pickedItem) == d and pickedItem != null then
call UnitRemoveItem(triggerer,pickedItem)
call RemoveItem(pickedItem)
exitwhen true
endif
set pickedSlot= pickedSlot + 1
endloop
set pickedSlot = 0
loop
exitwhen pickedSlot > 6
set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
if GetItemTypeId(pickedItem) == e and pickedItem != null then
call UnitRemoveItem(triggerer,pickedItem)
call RemoveItem(pickedItem)
exitwhen true
endif
set pickedSlot= pickedSlot + 1
endloop
set pickedSlot = 0
loop
exitwhen pickedSlot > 6
set pickedItem = UnitItemInSlot(triggerer,pickedSlot)
if GetItemTypeId(pickedItem) == f and pickedItem != null then
call UnitRemoveItem(triggerer,pickedItem)
call RemoveItem(pickedItem)
exitwhen true
endif
set pickedSlot= pickedSlot + 1
endloop
call UnitAddItemById(triggerer,r)
call DestroyEffect(AddSpecialEffectTarget(t,triggerer,p))
endif
set pickedItem = null
set triggerer = null
set RecipeSysExe = null
return true
endfunction
function RecipeSysSet takes integer r,integer a,integer b,integer c,integer d,integer e,integer f, string p, string t returns nothing
local trigger RecipeSysExe = CreateTrigger()
local boolexpr RecipeSysCondition = Condition(function RecipeSysCon)
local integer sum = 0
call TriggerRegisterAnyUnitEventBJ(RecipeSysExe,EVENT_PLAYER_UNIT_PICKUP_ITEM)
if r != 0 then
call SetHandleInt(RecipeSysExe,"r",r)
if a != 0 then
call SetHandleInt(RecipeSysExe,"a",a)
set sum = sum + 1
endif
if b != 0 then
call SetHandleInt(RecipeSysExe,"b",b)
set sum = sum + 1
endif
if c != 0 then
call SetHandleInt(RecipeSysExe,"c",c)
set sum = sum + 1
endif
if d != 0 then
call SetHandleInt(RecipeSysExe,"d",d)
set sum = sum + 1
endif
if e != 0 then
call SetHandleInt(RecipeSysExe,"e",e)
set sum = sum + 1
endif
if f != 0 then
call SetHandleInt(RecipeSysExe,"f",f)
set sum = sum + 1
endif
call SetHandleInt(RecipeSysExe,"sum",sum)
call SetHandleString(RecipeSysExe,"p",p)
call SetHandleString(RecipeSysExe,"t",t)
call TriggerAddCondition(RecipeSysExe,RecipeSysCondition)
else
call DisableTrigger(RecipeSysExe)
call DestroyTrigger(RecipeSysExe)
endif
set RecipeSysExe = null
set RecipeSysCondition = null
endfunction