//EDIT//
Hi, i need some help with this trigger.
[Jass=]
function Recipe takes unit hero, integer i(0), integer i(1), integer i(2), integer i(3), integer i(4), integer i(5), integer i(6), integer c(1), integer c(2), integer c(3), integer c(4), integer c(5), integer c(6), string itext, string iname returns nothing
local integer array id //get item type from item in inventory
local integer array ic //get charge from item in inventory
local integer i = 0
local integer j = 0
local integer array n = 0 //collect the charge from the items in inventory matching to item need in recipe
local player owner = GetOwningPlayer(hero)
local item ti = null
loop
exitwhen i > 5
set id = GetItemTypeId(UnitItemInSlotBJ(hero, i)
set ic = GetItemCharges(UnitItemInSlotBJ(hero, i))
set ti = UnitItemInSlotBJ(hero, i)
// here check item in inventory and remove item that are matching the recipe list
if ( id == i[1] ) and ( ti != 0 ) then
set n[1] = ( n[1] + ic )
call RemoveItem( UnitItemInSlotBJ(hero, i) )
elseif ( id == i[2] ) and ( ti != 0 ) then
set n[2] = ( n[2] + ic )
call RemoveItem( ti )
elseif ( id == i[3] ) and ( ti != 0 ) then
set n[3] = ( n[3] + ic )
call RemoveItem( ti )
elseif ( id == i[4] ) and ( ti != 0 ) then
set n[4] = ( n[4] + ic )
call RemoveItem( ti )
elseif ( id == i[5] ) and ( ti != 0 ) then
set n[5] = ( n[5] + ic )
call RemoveItem( ti )
elseif ( id == i[6] ) and ( ti != 0 ) then
set n[6] = ( n[6] + ic )
call RemoveItem( ti )
endif
set ti = null
set i = i + 1
endloop
//here check if charge collected from items are sufficient for the recipe
if ( n[1] >= c[1] ) and ( n[2] >= c[2] ) and ( n[3] >= c[3] ) and ( n[4] >= c[4] ) and ( n[5] >= c[5] ) and ( n[6] >= c[6] ) then
set n[1] = ( n[1] - c[1] )
set n[2] = ( n[2] - c[2] )
set n[3] = ( n[3] - c[3] )
set n[4] = ( n[4] - c[4] )
set n[5] = ( n[5] - c[5] )
set n[6] = ( n[6] - c[6] )
call UnitAddItemByIdSwapped( i[0], hero )
call DisplayTimedTextToPlayer(owner), 0.,0., 6.00, ( "|c0000c400Troll:|r |c00ffff64Me haz crafted " + iname ) )
else
call DisplayTimedTextToPlayer(owner), 0.,0., 6.00, ( "|c0000c400Troll:|r |c00ffff64Me haz no resourcez for " + iname ) )
call DisplayTimedTextToPlayer(owner), 0.,0., 6.00, itext )
endif
//here give back all items (1 charge) back 1 by 1. there is a stacking trigger who will run upon acquiring items.
set i = 1
loop
exitwhen i > 6
if ( n > 0 ) then
set j = 1
loop
exitwhen j > n
call UnitAddItemByIdSwapped( i, hero )
set j = j + 1
endloop
endif
set i = i + 1
endloop
set i = 0
loop
exitwhen i > 6
set i(i) = null
set i = i + 1
endloop
set owner = null
set hero = null
endfunction
function onCast takes nothing returns nothing
set unit hero = GetTriggerUnit()
call Recipe(hero, 'I024', 'I011', 'I009', 'I100', 0, 0, 0, 7, 5, 1, 0, 0, 0, "Need 7 stones, 5 woods and 1 glass", " a stone hutt")
endfunction
function onInit takes nothing returns nothing
call RegisterSpellEffectEvent('A000', function onCast)
endfunction
[/code]
It is not working it says it expect a return ??
this trigger take the caster, 7 integer for items ( the item created and the 6 possible items needed for the recipe) the 6 following integer are for the charge of the 6 items, then 2 string....
I want to use SpellEffectEvent to call this trigger
Bribe said to use it with this :
[Jass=]
private function onCast takes nothing returns nothing
// Do actions
endfunction
private function onInit takes nothing returns nothing
call RegisterSpellEffectEvent('A000', function onCast)
endfunction[/code]
i don't understand how to use Bribe SpellEffectEvent library and why the recipe function doesn't work and want to return something?
Hi, i need some help with this trigger.
[Jass=]
function Recipe takes unit hero, integer i(0), integer i(1), integer i(2), integer i(3), integer i(4), integer i(5), integer i(6), integer c(1), integer c(2), integer c(3), integer c(4), integer c(5), integer c(6), string itext, string iname returns nothing
local integer array id //get item type from item in inventory
local integer array ic //get charge from item in inventory
local integer i = 0
local integer j = 0
local integer array n = 0 //collect the charge from the items in inventory matching to item need in recipe
local player owner = GetOwningPlayer(hero)
local item ti = null
loop
exitwhen i > 5
set id = GetItemTypeId(UnitItemInSlotBJ(hero, i)
set ic = GetItemCharges(UnitItemInSlotBJ(hero, i))
set ti = UnitItemInSlotBJ(hero, i)
// here check item in inventory and remove item that are matching the recipe list
if ( id == i[1] ) and ( ti != 0 ) then
set n[1] = ( n[1] + ic )
call RemoveItem( UnitItemInSlotBJ(hero, i) )
elseif ( id == i[2] ) and ( ti != 0 ) then
set n[2] = ( n[2] + ic )
call RemoveItem( ti )
elseif ( id == i[3] ) and ( ti != 0 ) then
set n[3] = ( n[3] + ic )
call RemoveItem( ti )
elseif ( id == i[4] ) and ( ti != 0 ) then
set n[4] = ( n[4] + ic )
call RemoveItem( ti )
elseif ( id == i[5] ) and ( ti != 0 ) then
set n[5] = ( n[5] + ic )
call RemoveItem( ti )
elseif ( id == i[6] ) and ( ti != 0 ) then
set n[6] = ( n[6] + ic )
call RemoveItem( ti )
endif
set ti = null
set i = i + 1
endloop
//here check if charge collected from items are sufficient for the recipe
if ( n[1] >= c[1] ) and ( n[2] >= c[2] ) and ( n[3] >= c[3] ) and ( n[4] >= c[4] ) and ( n[5] >= c[5] ) and ( n[6] >= c[6] ) then
set n[1] = ( n[1] - c[1] )
set n[2] = ( n[2] - c[2] )
set n[3] = ( n[3] - c[3] )
set n[4] = ( n[4] - c[4] )
set n[5] = ( n[5] - c[5] )
set n[6] = ( n[6] - c[6] )
call UnitAddItemByIdSwapped( i[0], hero )
call DisplayTimedTextToPlayer(owner), 0.,0., 6.00, ( "|c0000c400Troll:|r |c00ffff64Me haz crafted " + iname ) )
else
call DisplayTimedTextToPlayer(owner), 0.,0., 6.00, ( "|c0000c400Troll:|r |c00ffff64Me haz no resourcez for " + iname ) )
call DisplayTimedTextToPlayer(owner), 0.,0., 6.00, itext )
endif
//here give back all items (1 charge) back 1 by 1. there is a stacking trigger who will run upon acquiring items.
set i = 1
loop
exitwhen i > 6
if ( n > 0 ) then
set j = 1
loop
exitwhen j > n
call UnitAddItemByIdSwapped( i, hero )
set j = j + 1
endloop
endif
set i = i + 1
endloop
set i = 0
loop
exitwhen i > 6
set i(i) = null
set i = i + 1
endloop
set owner = null
set hero = null
endfunction
function onCast takes nothing returns nothing
set unit hero = GetTriggerUnit()
call Recipe(hero, 'I024', 'I011', 'I009', 'I100', 0, 0, 0, 7, 5, 1, 0, 0, 0, "Need 7 stones, 5 woods and 1 glass", " a stone hutt")
endfunction
function onInit takes nothing returns nothing
call RegisterSpellEffectEvent('A000', function onCast)
endfunction
[/code]
It is not working it says it expect a return ??
this trigger take the caster, 7 integer for items ( the item created and the 6 possible items needed for the recipe) the 6 following integer are for the charge of the 6 items, then 2 string....
I want to use SpellEffectEvent to call this trigger
Bribe said to use it with this :
[Jass=]
private function onCast takes nothing returns nothing
// Do actions
endfunction
private function onInit takes nothing returns nothing
call RegisterSpellEffectEvent('A000', function onCast)
endfunction[/code]
i don't understand how to use Bribe SpellEffectEvent library and why the recipe function doesn't work and want to return something?
Last edited: