Help finding flaw in item fusion trigger

afisakov

You can change this now in User CP.
Reaction score
37
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:
Code:
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'
endfunction
 
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
endif
if fint2==0 then
return
else
call RemoveItem(GetManipulatedItem())
endif
set fint1=21
loop
set fint1=fint1-1
exitwhen UnitHasItemOfTypeBJ(GetTriggerUnit(),gem[fint1]) or fint1==0
endloop
if fint2==1 then
set fint3=fint1+1
elseif fint2==3 then
set fint3=fint1+3
elseif fint2==2 then
set fint3=fint1+2
endif
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())
endfunction
 
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()
endfunction

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
 

Hatebreeder

So many apples
Reaction score
380
OH GOD MY EYES !
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.
 

chobibo

Level 1 Crypt Lord
Reaction score
48
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.

JASS:
globals
    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"
endglobals

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'
endfunction

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

// 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)
endfunction
 
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
    else
        // Nothing to do so exit
        // the function.
        return
    endif
    
    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
    
endfunction

 
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()
endfunction
 
</i>
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top