Help finding flaw in item fusion trigger


You can change this now in User CP.
The basic premise of this trigger is to keep upgrading a gem, it has up to 21 levels and can be raised by fusing with a lvl 1, 2 or 3 gem.

The trigger:
function reggems takes nothing returns nothing
set gem[1]='I04U'
set gem[2]='I04V'
set gem[3]='I04W'
set gem[4]='I04X'
set gem[5]='I04Y'
set gem[6]='I04Z'
set gem[7]='I050'
set gem[8]='I051'
set gem[9]='I052'
set gem[10]='I053'
set gem[11]='I054'
set gem[12]='I055'
set gem[13]='I056'
set gem[14]='I057'
set gem[15]='I058'
set gem[16]='I059'
set gem[17]='I05B'
set gem[18]='I05A'
set gem[19]='I05C'
set gem[20]='I05D'
set gem[21]='I05E'
function Trig_Item_Fusion_L3_Actions takes nothing returns nothing
call DisableTrigger(GetTriggeringTrigger())
set fint2=0
if GetItemTypeId(GetManipulatedItem())==gem[3] then
set fint2=3
elseif GetItemTypeId(GetManipulatedItem())==gem[2] then
set fint2=2
elseif GetItemTypeId(GetManipulatedItem())==gem[1] then
set fint2=1
if fint2==0 then
call RemoveItem(GetManipulatedItem())
set fint1=21
set fint1=fint1-1
exitwhen UnitHasItemOfTypeBJ(GetTriggerUnit(),gem[fint1]) or fint1==0
if fint2==1 then
set fint3=fint1+1
elseif fint2==3 then
set fint3=fint1+3
elseif fint2==2 then
set fint3=fint1+2
call RemoveItem(GetItemOfTypeFromUnitBJ(GetTriggerUnit(),gem[fint1]))
call AddSpecialEffectTargetUnitBJ("origin",GetTriggerUnit(),"Abilities\\Spells\\Items\\AIlm\\AIlmTarget.mdl")
call DestroyEffectBJ(GetLastCreatedEffectBJ())
call UnitAddItemById(GetTriggerUnit(),gem[fint3])
call EnableTrigger(GetTriggeringTrigger())
function InitTrig_Item_Fusion_L3 takes nothing returns nothing
set gg_trg_Item_Fusion_L3=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Item_Fusion_L3,EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddAction(gg_trg_Item_Fusion_L3,function Trig_Item_Fusion_L3_Actions)
call reggems()
I attempted to test by trying to fuse lvl 1 and 2 gems and it did not do anything.
The build premise: identify item picked up as level 1,2 or 3 gem. remove it. then check for highest level gem in player inventory - if none assign 0.
set gem level fint1 (highest gem) + fint2 (level of manipulating gem)
remove fint1 gem and give the new gem.
What actually happens: I pick up 2 lvl 2 and a lvl 1 gem and all 3 sit in my inventory, no fusion.
Not sure what step I messed up


So many apples
First, indent code, second, rename programgenerated functions to something more... Memorizeable. Also, start your Array Index at 0. After that, I'm willing to view your code.

EDIT: Don't disable triggers while they're still running. Thats bad.
It's a good idea, if you use NEW GEN EDITOR. I can then see your global Var declaration ( since a Var has the value of null and not 0 if you don't declare it as 0 )
Also, if you're using GetWhatever() multiple times, it would be a great idea to store it in a Local Var and clean up at the end of your function.

Also, don't post converted GUI text. It's ugly and if you do it again, I'm gonna slap you.


Level 1 Crypt Lord
I've almost forgotten how to script in jass, but try this if it will work, I've checked it using jasscraft, but not in-game.

    integer array GEM_TABLE
    constant integer GEM_LVL_1  =   'I04U'
    constant integer GEM_LVL_2  =   'I04V'
    constant integer GEM_LVL_3  =   'I04W'
    constant integer MAX_LEVEL  =   20
    constant string FX_FILENAME =   "Abilities\\Spells\\Items\\AIlm\\AIlmTarget.mdl"

function Init_ItemTable takes nothing returns nothing
    set GEM_TABLE[0]   =   GEM_LVL_1
    set GEM_TABLE[1]   =   GEM_LVL_2
    set GEM_TABLE[2]   =   GEM_LVL_3
    set GEM_TABLE[3]   =   'I04X'
    set GEM_TABLE[4]   =   'I04Y'
    set GEM_TABLE[5]   =   'I04Z'
    set GEM_TABLE[6]   =   'I050'
    set GEM_TABLE[7]   =   'I051'
    set GEM_TABLE[8]   =   'I052'
    set GEM_TABLE[9]   =   'I053'
    set GEM_TABLE[10]  =   'I054'
    set GEM_TABLE[11]  =   'I055'
    set GEM_TABLE[12]  =   'I056'
    set GEM_TABLE[13]  =   'I057'
    set GEM_TABLE[14]  =   'I058'
    set GEM_TABLE[15]  =   'I059'
    set GEM_TABLE[16]  =   'I05B'
    set GEM_TABLE[17]  =   'I05A'
    set GEM_TABLE[18]  =   'I05C'
    set GEM_TABLE[19]  =   'I05D'
    set GEM_TABLE[20]  =   'I05E'

function GetGemIndex takes integer iItemId returns integer
    local integer i=0
        if (iItemId==GEM_TABLE<i>) then
            return i
        exitwhen (i==MAX_LEVEL)
    return -1

// trigger functions

function OnPickUpgradeGem takes nothing returns boolean
    local integer iItemId=GetItemTypeId(GetManipulatedItem())
    return (iItemId==GEM_LVL_1) or (iItemId==GEM_LVL_2) or (iItemId==GEM_LVL_3)
function OnPickUp takes nothing returns nothing
    local integer iItemId=0
    local integer inc=0
    // Set to null after use.
    local item hItem=null   
    local effect hFx=null
    local unit hUnit=null
    set hItem=GetManipulatedItem()
    set iItemId=GetItemTypeId(hItem)
    if (iItemId==GEM_LVL_1) then
        set inc=1
    elseif (iItemId==GEM_LVL_2) then
        set inc=2
    elseif (iItemId==GEM_LVL_3) then
        set inc=3
        // Nothing to do so exit
        // the function.
    set hUnit=GetTriggerUnit()
    call UnitRemoveItem(hUnit,hItem)
    call UnitAddItemById(hUnit,GEM_TABLE[GetGemIndex(iItemId)+inc])
    // Apply Special Effect
    set hFx=AddSpecialEffectTarget(&quot;origin&quot;,hUnit,FX_FILENAME)
    call DestroyEffect(hFx)
    set hFx=null
    set hUnit=null
    set hItem=null

function InitTrig_Item_Fusion_L3 takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_PICKUP_ITEM)
    call TriggerAddCondition(t,Condition(function OnPickUpgradeGem))
    call TriggerAddAction(t,function OnPickUp)
    call Init_ItemTable()
General chit-chat
Help Users
  • No one is chatting at the moment.
  • tom_mai78101 tom_mai78101:
    Make sure you keep checking out my news..
  • Jesus4Lyf Jesus4Lyf:
    Man, I made this account 15 years ago? Wild. :)
  • Ghan Ghan:
    Seeing J4L is definitely a blast from the past.
  • Jesus4Lyf Jesus4Lyf:
    Oh hey Ghan! Long time. :)
  • jonas jonas:
    J4L! What has happened in your life
  • Jesus4Lyf Jesus4Lyf:
    Hmm, how to summarize... Moved to the USA and got married. Became a professional software engineer and solution lead. Learning Godot for game dev. :)
  • jonas jonas:
    So you are pursuing game dev as a hobby? What industry is your dayjob in?
  • jonas jonas:
  • Jesus4Lyf Jesus4Lyf:
    Not quite FAANG, less pay for a less hours/stress. Yeah, game dev as a hobby.
  • jonas jonas:
    makes sense. Do we have a hobby game dev subforum to showcase some work?
  • Blackveiled Blackveiled:
    Happy Thursday
  • The Helper The Helper:
    Happy Thursday!
  • The Helper The Helper:
  • The Helper The Helper:
    hey tom_mai please do not archive anymore news
  • Ghan Ghan:
    AMD Ryzen 7000 next week :D
  • The Helper The Helper:
  • tom_mai78101 tom_mai78101:
    "hey tom_mai please do not archive anymore news" ----> Got it. What should we do with the "News Archive" subforum?
  • The Helper The Helper:
    I think leave it for real old news that cannot be sorted the reason we had it in the first place was a server issue that we do not have anymore. I don't want to get rid of the archive just not put anything in it for now until we figure it out more
  • The Helper The Helper:
    The side chat has nothing on the discord. it is not possible but the biggest thing on my wish list right now is a sidechat channel on the disord that hooks up to this...
  • Ghan Ghan:
    I've been selected for the Diablo IV beta.
  • Ghan Ghan:
  • The Helper The Helper:
    that is so cool
    Eh just noticed the new discord section on the side. Looks great!
  • Blackveiled Blackveiled:
    :( feels bad I can't ever get selected for any beta I sign up for. It's annoying as heck.

    The Helper Discord

    Members online

    No members online now.


    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.