• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Need help for System

Status
Not open for further replies.

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
//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?
 
Last edited:
Level 19
Joined
Aug 8, 2007
Messages
2,765
JASS:
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)

....

you cant do that...
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
It is too much for an arguement,reduce it please.
Also i think the arguements has a limits.

no, i believe i had ~50 arguments in one trigger.

it would still be more efficient to either use a number stack or a integer array
 

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
the problem is i need all thos integer for the recipe to work....

i(1) is for item 1 and c(1) is for charge of item 1
these correspond to the recipe description.
i(0) is the item created when all the needed items and charge are validated
hero is the unit
the string are linked to message display if the recipe was successfully crafted or not

how can i remove argument? since they are all needed
and what is the limit of arguments?

the trigger when try to save only say that it expect a return
but i don't understand what i should return and why? a boolean but what for....
Jass is so complicated :(
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
the problem is i need all thos integer for the recipe to work....

i(1) is for item 1 and c(1) is for charge of item 1
these correspond to the recipe description.
i(0) is the item created when all the needed items and charge are validated
hero is the unit
the string are linked to message display if the recipe was successfully crafted or not

how can i remove argument? since they are all needed
and what is the limit of arguments?

the trigger when try to save only say that it expect a return
but i don't understand what i should return and why? a boolean but what for....
Jass is so complicated :(

didnt u hear me? you cant do this. -_-

you cant make an argument with either () or [] it has to all be ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
 
Status
Not open for further replies.
Top