MrCrowley
New Member
- Reaction score
- 17
I want to edit a recipe system that I found. Unfortunately the system is written in Jass and, even after hours of reading tutorials, I can't figure out.
The system uses an "automatic" item combination, as the items will combine the moment the hero picks them up. However, I want the item combination to be manual, as in a custom spell or something that triggers the items combination. For those who dont want to download the map, here's the scripting.
Also this is pretty much that only recipe system that was variable based. The rest were just arrays and loops which wasn't what I was looking for so I can't accept alternatives. Thank you
The system uses an "automatic" item combination, as the items will combine the moment the hero picks them up. However, I want the item combination to be manual, as in a custom spell or something that triggers the items combination. For those who dont want to download the map, here's the scripting.
Also this is pretty much that only recipe system that was variable based. The rest were just arrays and loops which wasn't what I was looking for so I can't accept alternatives. Thank you
JASS:
constant function ItemCombineEffect takes nothing returns string
return "Abilities\\Spells\\Items\\AIlm\\AIlmTarget.mdl"
endfunction
function UnitRemoveItemById takes unit whichUnit, integer itemId returns nothing
local integer i = 0
local item it
loop
exitwhen (i >= bj_MAX_INVENTORY)
set it = UnitItemInSlot(whichUnit, i)
if GetItemTypeId(it) == itemId then
call RemoveItem(it)
exitwhen (true)
endif
set i = i + 1
endloop
set it = null
endfunction
function Trig_Item_Combine_Actions takes nothing returns nothing
local integer n = 0
local integer array it
local integer i = 7
local integer h = 0
local integer x = 0
local unit u = GetTriggerUnit()
local boolean b = true
local integer y = 0
local integer z = 0
local integer array hero_item_type
// Get hero items
loop
exitwhen (x >= bj_MAX_INVENTORY)
set hero_item_type[x] = GetItemTypeId(UnitItemInSlot(u, x))
set x = x + 1
endloop
loop
exitwhen (n >= udg_ItemN)
set h = i + 6
set x = 0
set it[x] = hero_item_type[x]
set x = x + 1
set it[x] = hero_item_type[x]
set x = x + 1
set it[x] = hero_item_type[x]
set x = x + 1
set it[x] = hero_item_type[x]
set x = x + 1
set it[x] = hero_item_type[x]
set x = x + 1
set it[x] = hero_item_type[x]
set x = x + 1
set y = 0 // N of items that hero has ()
set z = 0 // N of items needed ()
loop
exitwhen (i >= h or udg_CItemType<i> == 0)
set z = z + 1
// Does unit contain item n
set x = 0
loop
exitwhen (x >= bj_MAX_INVENTORY)
if (it[x] == udg_CItemType<i>) then
// Kick out the item
set it[x] = 0
set y = y + 1
// And increase by 1
exitwhen (true)
endif
set x = x + 1
endloop
set i = i + 1
endloop
set i = h
if (y == z) then
set h = i
set i = i-6
loop
exitwhen (i > h or udg_CItemType<i> == 0)
call UnitRemoveItemById(u, udg_CItemType<i>)
set i = i + 1
endloop
call UnitAddItemById(u, udg_CType[n])
call SetSoundPosition(udg_ItemCombineSound, GetUnitX(u), GetUnitY(u), 0.)
call StartSound(udg_ItemCombineSound)
call DestroyEffect(AddSpecialEffectTarget(ItemCombineEffect(), u, "origin"))
set u = null
return
endif
set n = n + 1
endloop
endfunction
//===========================================================================
function InitTrig_Item_Combine_Core takes nothing returns nothing
set gg_trg_Item_Combine_Core = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Item_Combine_Core, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction( gg_trg_Item_Combine_Core, function Trig_Item_Combine_Actions )
call Preload(ItemCombineEffect())
set udg_ItemCombineSound = CreateSound( "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImage.wav", false, true, true, 10, 10, "" )
call SetSoundParamsFromLabel( udg_ItemCombineSound, "MirrorImage" )
call SetSoundDuration( udg_ItemCombineSound, 1756 )
call SetSoundPitch(udg_ItemCombineSound, 1.2)
call SetSoundVolume(udg_ItemCombineSound, 100)
endfunction
</i></i></i></i>