Name | Type | is_array | initial_value |
Arrow_Angle | real | No | |
Arrow_Caster | unit | Yes | |
Arrow_CasterLoc | location | No | |
Arrow_CountMaxSize | integer | No | |
Arrow_Counts | integer | No | |
Arrow_CusValue | integer | No | |
Arrow_Distance | real | Yes | |
Arrow_DistanceCount | real | Yes | |
Arrow_DistanceTravel | real | Yes | |
Arrow_DummyLoc | location | No | |
Arrow_Movement | location | No | |
Arrow_RandomUnit | group | No | |
Arrow_StartGroup | group | No | |
Arrow_StunDuration | integer | Yes | |
Arrow_TargetPoint | location | No | |
Arrow_UnitGroup | group | No | |
Caster_Pnt | location | No | |
CL_AbilityLevel | integer | Yes | |
CL_AOE | real | Yes | |
CL_Caster | unit | Yes | |
CL_Count | integer | Yes | |
CL_Damage | integer | Yes | |
CL_FirstTarget | boolean | Yes | |
CL_Group | group | Yes | |
CL_Loc | location | Yes | |
CL_Player | player | Yes | |
CL_Slashes | integer | Yes | |
CL_Special | effect | Yes | |
CL_Target | unit | Yes | |
CL_Victim | unit | Yes | |
Damage | real | Yes | |
Delay | real | Yes | |
DuelGroup | group | No | |
Duration | real | Yes | |
ic | integer | Yes | |
itemid1 | integer | Yes | |
itemid2 | integer | Yes | |
itemid3 | integer | Yes | |
itemid4 | integer | Yes | |
itemid5 | integer | Yes | |
itemid6 | integer | Yes | |
JD_Angle | real | Yes | |
JD_Counter | real | Yes | |
JD_Distances | real | Yes | |
JD_Effect | string | Yes | |
JD_Group | group | No | |
JD_Integers | integer | Yes | |
JD_LevelOfAbility | integer | Yes | |
JD_PickGroup | group | No | |
JD_ReachedDistance | real | Yes | |
JD_SpeedUnits | real | Yes | |
JD_TempPoint | location | Yes | |
JD_TreesDestroy | boolean | Yes | |
JD_Unit | unit | Yes | |
JDA_DestroyTrees_Dash | boolean | No | |
JDA_LevelOfAbility | integer | No | |
JDA_SpecialEffect | string | No | |
JDA_Speed | real | No | |
JDA_TargetPoint | location | No | |
JDA_Unit | unit | No | |
KB_Angle | real | Yes | |
KB_Casters | unit | Yes | |
KB_CountBuffs | integer | No | |
KB_DestroyTrees | boolean | Yes | |
KB_EffectCounter | integer | Yes | |
KB_EffectCounter2 | integer | Yes | |
KB_Effects_1 | string | Yes | |
KB_Effects_2 | string | Yes | |
KB_GeneralIntegers | integervar | Yes | |
KB_KnockbackedUnits | group | No | |
KB_Levels | integer | Yes | |
KB_MaxDistance | real | Yes | |
KB_ReachedDistance | real | Yes | |
KB_ReducedReal | real | No | |
KB_ReduceSpeedReal | real | Yes | |
KB_SpecificSpeed | real | Yes | |
KB_StartPositions | location | Yes | |
KB_TempPoint | location | Yes | |
KB_TempReal | real | No | |
KB_TotalKnockUnits | integer | No | |
KB_Units | unit | Yes | |
KBA_Caster | unit | No | |
KBA_DestroyTrees | boolean | No | |
KBA_DistancePerLevel | real | No | |
KBA_Level | integer | No | |
KBA_SpecialEffects | string | Yes | |
KBA_Speed | real | No | |
KBA_StartingPosition | location | No | |
KBA_TargetUnit | unit | No | |
Kills | integer | Yes | |
Max_Index | integer | No | |
MH_Angle | real | Yes | |
MH_Attack | boolean | Yes | |
MH_Caster | unit | Yes | |
MH_Damage | real | Yes | |
MH_Distance | real | Yes | |
MH_Group | group | Yes | |
MH_Hook | unit | Yes | |
MH_Hooks | group | Yes | |
MH_Index | integer | Yes | |
MH_Life | real | Yes | |
MH_Move | real | Yes | |
MH_NearHook | group | Yes | |
MH_Point | location | Yes | |
MH_Shmat | unit | Yes | |
MH_Spell | abilcode | Yes | |
MH_Target | unit | Yes | |
MH_Time | real | Yes | |
MUI_1 | integer | No | |
MUI_2 | integer | Yes | |
MUI_3 | integervar | No | |
output | integer | Yes | |
PlaySound | soundtype | Yes | SoundTypeEffect |
Pounce_ABILID | abilcode | No | |
Pounce_AT | abilcode | No | |
Pounce_DT | attacktype | No | |
Pounce_Dummy | attacktype | No | |
Pounce_DummyABILID | abilcode | No | |
Pounce_DummyType | abilcode | No | |
Pounce_XMax | abilcode | No | |
Pounce_XMin | abilcode | No | |
Pounce_YMax | abilcode | No | |
Pounce_YMin | abilcode | No | |
PounceHash | abilcode | No | |
PounceLoc | abilcode | No | |
RC | boolean | No | |
RN | integer | No | |
RT | trigger | No | |
Rupture_Apagado | boolean | Yes | |
Rupture_Integer | integer | No | |
Rupture_Loop | integervar | No | |
RuptureCaster_1 | unit | Yes | |
RuptureCaster_2 | unit | Yes | |
RupturePunto_1 | location | Yes | |
RupturePunto_2 | location | No | |
RuptureTiempo | integer | Yes | |
RuptureTurnoApagado | integer | No | |
Shockwave_Angle | real | No | |
Shockwave_Group | group | Yes | |
Shockwave_Point | location | Yes | |
SSCaster | unit | Yes | |
SSCount | integer | No | |
SSDamage | real | Yes | |
SSDelay | real | Yes | |
SSDummyGroup | group | Yes | |
SSDuration | real | Yes | |
SSHas | boolean | Yes | |
SSIndex | integer | No | |
SSInteger | integervar | No | |
SSLastRecycled | integer | No | |
SSMax | integer | No | |
SSRecycledList | integer | Yes | |
SSTarget | unit | Yes | |
Temp | integer | No | |
TempInt | abilcode | No | |
TempPoint | location | No | |
TempPoint2 | location | No | |
TempPoint3 | location | No | |
Time | timer | No | |
TimerN | abilcode | No |
version 1.22:
Minor bug fixes.
version 1.21:
Shortened some functions, and indented text. (thx blu_da_noob)
version 1.2:
Changed code to fix a bug that caused recipes with more than one of the
same type of item to not work correctly.
Example:
CreateRecipe2('I000','I000','I001') would cause bug in earlier versions.
version 1.1:
Optimized code a bit.
version 1.0:
First release.
====================================================================
Recipe System. /
By Diablo-dk. /
====================================================================
Introduction:
This is a simple JASS recipe system that i made, using global arrays.
i made it as userfriendly as possible.
NOTE: this system uses ItemUserData.
Usage:
It is Very Simple how to use it. (check the Demo trigger for an example)
You create a new recipe this way:
call CreateRecipe2(itemid1,itemid2,itemid3.
Add this line to map initialization, and the system will do the rest.
itemid1 and itemid2 is the items required to make the recipe.
itemid3 is the combined item.
i also made some other functions for handling bigger recipes
CreateRecipe3
CreateRecipe4
CreateRecipe5
CreateRecipe6
they all do the same expect that they require x amount of items to combine.
the last itemid is always the combined item.
Another way to do it is just calling CreateRecipe(id,id,id,id,id,id,output)
this function can sometimes be handy if you don't like writing the number,
but keep in mind that you will have to enter 7 arguments no matter what, an example
would be this:
call CreateRecipe(id1,id2,id3,id4,0,0,output)
NOTE: this function is slightly slower than the others as it uses ifs.
and keep in mind that you should not make a recipe with it like this:
call CreateRecipe(id1,0,id2,id3,0,0,output)
all zeros MUST be after the ids or else it will bug.
I added a DisItem function too.
call DisItem(somerecipeitem)
It disassembles the recipe item entered to its original components.
It also returns a boolean. if there's not enough space for the items, or if it's not a
recipe item, it will return false.
in any other case it will return true
Implemention:
To implement this system into your map you just have to copy the Recipe trigger script
to your map header(custom script section)
and the GlobalVars trigger(make sure to remove it again and have automatically
create unknown variables)
Also, add this line to map initialization: Custom script: call InitRecipe()
And 1 more important thing. Remember to give credits if you use in your map!
//=======================================================================================================
// Recipe System
// By Fredbrik(Diablo-dk)
//
//=======================================================================================================
//globals
//integer RN=0 // Recipe number.
//trigger RT=CreateTrigger() // Main recipe trigger.
//boolean RC=true
//integer array itemid1
//integer array itemid2
//integer array itemid3
//integer array itemid4
//integer array itemid5
//integer array itemid6
//integer array ic //item count
//integer array output
//endglobals
//=======================================================================================================
// User changeable constants
//=======================================================================================================
constant function Recipe_Effect takes nothing returns string
return "Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl" //An effect that comes whenever a recipe is made.
endfunction
constant function Recipe_AP takes nothing returns string
return "origin" //Attachment point for Recipe_Effect()
endfunction
//=======================================================================================================
// This function will return the first item of entered Id in the unit's inventory.
function GetItem takes unit u, integer Id returns item
local integer i=0
local item it
loop
exitwhen i==6
if GetItemTypeId(UnitItemInSlot(u,i)) == Id then
return UnitItemInSlot(u,i)
set i=5
endif
set i=i+1
endloop
return null
endfunction
//==============================
function HasItems takes unit u, integer i returns boolean
local integer index=0
local integer id=-1
local integer b1=0
local integer b2=0
local integer b3=0
local integer b4=0
local integer b5=0
local integer b6=0
loop
exitwhen index==6
set id=GetItemTypeId(UnitItemInSlot(u,index))
if id == 0 then
set id=-1
endif
if id == udg_itemid1[i] and b1 == 0 then
set b1=1
set id=-1
endif
if id == udg_itemid2[i] and b2 == 0 then
set b2=1
set id=-1
endif
if id == udg_itemid3[i] and b3 == 0 then
set b3=1
set id=-1
endif
if id == udg_itemid4[i] and b4 == 0 then
set b4=1
set id=-1
endif
if id == udg_itemid5[i] and b5 == 0 then
set b5=1
set id=-1
endif
if id == udg_itemid6[i] and b6 == 0 then
set b6=1
set id=-1
endif
if b1+b2+b3+b4+b5+b6 == udg_ic[i] then
return true
endif
set index=index+1
endloop
return false
endfunction
//=======================================================================================================
// User Functions:
// Recipe Creating:
//
//=======================================================================================================
function CreateRecipe takes integer i1,integer i2,integer i3,integer i4,integer i5,integer i6,integer output returns nothing
set udg_RN=udg_RN+1
set udg_itemid1[udg_RN]=i1
set udg_itemid2[udg_RN]=i2
set udg_ic[udg_RN]=2
if i3 != 0 then
set udg_itemid3[udg_RN]=i3
set udg_ic[udg_RN]=udg_ic[udg_RN]+1
endif
if i4 != 0 then
set udg_itemid4[udg_RN]=i4
set udg_ic[udg_RN]=udg_ic[udg_RN]+1
endif
if i5 != 0 then
set udg_itemid5[udg_RN]=i5
set udg_ic[udg_RN]=udg_ic[udg_RN]+1
endif
if i6 != 0 then
set udg_itemid6[udg_RN]=i6
set udg_ic[udg_RN]=udg_ic[udg_RN]+1
endif
set udg_output[udg_RN]=output
endfunction
function CreateRecipe2 takes integer i1,integer i2,integer i3 returns nothing
set udg_RN=udg_RN+1
set udg_itemid1[udg_RN]=i1
set udg_itemid2[udg_RN]=i2
set udg_output[udg_RN]=i3
set udg_ic[udg_RN]=2
endfunction
// Creates a recipe that requires 2 items to combine into a new item. i3 is the combined item.
// Example: call CreateRecipe2('I000','I001','I002')
function CreateRecipe3 takes integer i1,integer i2,integer i3,integer i4 returns nothing
set udg_RN=udg_RN+1
set udg_itemid1[udg_RN]=i1
set udg_itemid2[udg_RN]=i2
set udg_itemid3[udg_RN]=i3
set udg_output[udg_RN]=i4
set udg_ic[udg_RN]=3
endfunction
// The same as CreateRecipe2 except this requires 3 items to combine. i4 is the combined item.
function CreateRecipe4 takes integer i1,integer i2,integer i3,integer i4,integer i5 returns nothing
set udg_RN=udg_RN+1
set udg_itemid1[udg_RN]=i1
set udg_itemid2[udg_RN]=i2
set udg_itemid3[udg_RN]=i3
set udg_itemid4[udg_RN]=i4
set udg_output[udg_RN]=i5
set udg_ic[udg_RN]=4
endfunction
// The same as CreateRecipe2 except this requires 4 items to combine. i5 is the combined item.
function CreateRecipe5 takes integer i1,integer i2,integer i3,integer i4,integer i5,integer i6 returns nothing
set udg_RN=udg_RN+1
set udg_itemid1[udg_RN]=i1
set udg_itemid2[udg_RN]=i2
set udg_itemid3[udg_RN]=i3
set udg_itemid4[udg_RN]=i4
set udg_itemid5[udg_RN]=i5
set udg_output[udg_RN]=i6
set udg_ic[udg_RN]=5
endfunction
// The same as CreateRecipe2 except this requires 5 items to combine. i6 is the combined item.
function CreateRecipe6 takes integer i1,integer i2,integer i3,integer i4,integer i5,integer i6,integer i7 returns nothing
set udg_RN=udg_RN+1
set udg_itemid1[udg_RN]=i1
set udg_itemid2[udg_RN]=i2
set udg_itemid3[udg_RN]=i3
set udg_itemid4[udg_RN]=i4
set udg_itemid5[udg_RN]=i5
set udg_itemid6[udg_RN]=i6
set udg_output[udg_RN]=i7
set udg_ic[udg_RN]=6
endfunction
// The same as CreateRecipe2 except this requires 6 items to combine. i7 is the combined item.
//===================================================================================================
// This function disassembles a recipe item to its original components.
function DisItem takes unit u,item it returns boolean
local integer c=GetItemUserData(it)
local item array newitem
local integer i=udg_ic[c]
if it != null then
if i <= 6-UnitInventoryCount(u)+1 and i > 0 then
set udg_RC=false
if udg_itemid2[c] != null then
set newitem[1]=CreateItem(udg_itemid1[c],GetUnitX(u),GetUnitY(u))
set newitem[2]=CreateItem(udg_itemid2[c],GetUnitX(u),GetUnitY(u))
endif
if udg_itemid3[c] != null then
set newitem[3]=CreateItem(udg_itemid3[c],GetUnitX(u),GetUnitY(u))
call UnitAddItem(u,newitem[3])
endif
if udg_itemid4[c] != null then
set newitem[4]=CreateItem(udg_itemid4[c],GetUnitX(u),GetUnitY(u))
call UnitAddItem(u,newitem[4])
endif
if udg_itemid5[c] != null then
set newitem[5]=CreateItem(udg_itemid5[c],GetUnitX(u),GetUnitY(u))
call UnitAddItem(u,newitem[5])
endif
if udg_itemid6[c] != null then
set newitem[6]=CreateItem(udg_itemid6[c],GetUnitX(u),GetUnitY(u))
call UnitAddItem(u,newitem[6])
endif
call RemoveItem(it)
call UnitAddItem(u,newitem[1])
call UnitAddItem(u,newitem[2])
set newitem[1]=null
set newitem[2]=null
set newitem[3]=null
set newitem[4]=null
set newitem[5]=null
set newitem[6]=null
set udg_RC=true
else
return false
endif
endif
return true
endfunction
//=======================================================================================================
//
//Main Recipe Function: Do not change unless you know what you are doing
//
//=======================================================================================================
function Recipe_Main takes nothing returns nothing
local item it
local integer i=0
local unit u=GetManipulatingUnit()
loop
exitwhen i==udg_RN
set i=i+1
if udg_RC == true then
if udg_ic[i] == 6 then
if HasItems(u,i) then
call RemoveItem(GetItem(u,udg_itemid1[i]))
call RemoveItem(GetItem(u,udg_itemid2[i]))
call RemoveItem(GetItem(u,udg_itemid3[i]))
call RemoveItem(GetItem(u,udg_itemid4[i]))
call RemoveItem(GetItem(u,udg_itemid5[i]))
call RemoveItem(GetItem(u,udg_itemid6[i]))
call DestroyEffect(AddSpecialEffectTarget(Recipe_Effect(),u,Recipe_AP()))
set it=CreateItem(udg_output[i],GetUnitX(u),GetUnitY(u))
call SetItemUserData(it,i) //Used for disassembling.
call UnitAddItem(u,it)
set i=udg_RN
endif
elseif udg_ic[i] == 5 then
if HasItems(u,i) then
call RemoveItem(GetItem(u,udg_itemid1[i]))
call RemoveItem(GetItem(u,udg_itemid2[i]))
call RemoveItem(GetItem(u,udg_itemid3[i]))
call RemoveItem(GetItem(u,udg_itemid4[i]))
call RemoveItem(GetItem(u,udg_itemid5[i]))
call DestroyEffect(AddSpecialEffectTarget(Recipe_Effect(),u,Recipe_AP()))
set it=CreateItem(udg_output[i],GetUnitX(u),GetUnitY(u))
call SetItemUserData(it,i) //Used for disassembling.
call UnitAddItem(u,it)
set i=udg_RN
endif
elseif udg_ic[i] == 4 then
if HasItems(u,i) then
call RemoveItem(GetItem(u,udg_itemid1[i]))
call RemoveItem(GetItem(u,udg_itemid2[i]))
call RemoveItem(GetItem(u,udg_itemid3[i]))
call RemoveItem(GetItem(u,udg_itemid4[i]))
call DestroyEffect(AddSpecialEffectTarget(Recipe_Effect(),u,Recipe_AP()))
set it=CreateItem(udg_output[i],GetUnitX(u),GetUnitY(u))
call SetItemUserData(it,i) //Used for disassembling.
call UnitAddItem(u,it)
set i=udg_RN
endif
elseif udg_ic[i] == 3 then
if HasItems(u,i) then
call RemoveItem(GetItem(u,udg_itemid1[i]))
call RemoveItem(GetItem(u,udg_itemid2[i]))
call RemoveItem(GetItem(u,udg_itemid3[i]))
call DestroyEffect(AddSpecialEffectTarget(Recipe_Effect(),u,Recipe_AP()))
set it=CreateItem(udg_output[i],GetUnitX(u),GetUnitY(u))
call SetItemUserData(it,i) //Used for disassembling.
call UnitAddItem(u,it)
set i=udg_RN
endif
elseif udg_ic[i] == 2 then
if HasItems(u,i) then
call RemoveItem(GetItem(u,udg_itemid1[i]))
call RemoveItem(GetItem(u,udg_itemid2[i]))
call DestroyEffect(AddSpecialEffectTarget(Recipe_Effect(),u,Recipe_AP()))
set it=CreateItem(udg_output[i],GetUnitX(u),GetUnitY(u))
call SetItemUserData(it,i) //Used for disassembling.
call UnitAddItem(u,it)
set i=udg_RN
endif
endif
endif
endloop
set it=null
set u=null
endfunction
function InitRecipe takes nothing returns nothing
set udg_RT=CreateTrigger()
set udg_RC=true
call TriggerRegisterAnyUnitEventBJ( udg_RT, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction(udg_RT,function Recipe_Main)
endfunction
//call this at map init.
//forced by WE
function InitTrig_Recipe takes nothing returns nothing
endfunction
// End Recipe