Trigger executes with no errors, but nothing happens

Grothdmal

New Member
Reaction score
1
Hey, I made an item stacking trigger (that worked fine a while ago, mind you). Now, whenever a hero picks up multiple charged items, they simply refuse to stack. Here's the code itself:

Code:
function Trig_Item_Stacking_Conditions takes nothing returns boolean
    if ( not ( GetTriggerUnit() == udg_Hero ) ) then
        return false
    endif
    return true
endfunction

function Trig_Item_Stacking_Func002Func003Func001C takes nothing returns boolean
    if ( not ( GetItemTypeId(UnitItemInSlotBJ(udg_Hero, GetForLoopIndexA())) == udg_Item_type ) ) then
        return false
    endif
    return true
endfunction

function Trig_Item_Stacking_Func002Func010C takes nothing returns boolean
    if ( ( GetItemTypeId(GetManipulatedItem()) == 'I00H' ) ) then
        return true
    endif
    if ( ( GetItemTypeId(GetManipulatedItem()) == 'I006' ) ) then
        return true
    endif
    if ( ( GetItemTypeId(GetManipulatedItem()) == 'I00G' ) ) then
        return true
    endif
    if ( ( GetItemTypeId(GetManipulatedItem()) == 'I00E' ) ) then
        return true
    endif
    if ( ( GetItemTypeId(GetManipulatedItem()) == 'I001' ) ) then
        return true
    endif
    if ( ( GetItemTypeId(GetManipulatedItem()) == 'I00F' ) ) then
        return true
    endif
    return false
endfunction

function Trig_Item_Stacking_Func002C takes nothing returns boolean
    if ( not Trig_Item_Stacking_Func002Func010C() ) then
        return false
    endif
    return true
endfunction

function Trig_Item_Stacking_Actions takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_682" )
    if ( Trig_Item_Stacking_Func002C() ) then
        call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_683" )
        set udg_Item_type = GetItemTypeId(GetManipulatedItem())
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = 6
        loop
            exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
            if ( Trig_Item_Stacking_Func002Func003Func001C() ) then
                call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_685" )
                set udg_Charges = ( udg_Charges + GetItemCharges(UnitItemInSlotBJ(udg_Hero, GetForLoopIndexA())) )
                call RemoveItem( UnitItemInSlotBJ(udg_Hero, GetForLoopIndexA()) )
            else
            endif
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
        call DisableTrigger( GetTriggeringTrigger() )
        call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_684" )
        call UnitAddItemByIdSwapped( udg_Item_type, udg_Hero )
        call SetItemCharges( GetLastCreatedItem(), udg_Charges )
        set udg_Charges = 0
        call EnableTrigger( GetTriggeringTrigger() )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Item_Stacking takes nothing returns nothing
    set gg_trg_Item_Stacking = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Item_Stacking, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddCondition( gg_trg_Item_Stacking, Condition( function Trig_Item_Stacking_Conditions ) )
    call TriggerAddAction( gg_trg_Item_Stacking, function Trig_Item_Stacking_Actions )
endfunction
(Note: The above code is converted to custom text from GUI, but it runs the same. udg_Hero is the player, and the ID's (I00H, I00F, etc) are some of the stackable items)

I put "call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_684" )"'s at certain points to see if the entire trigger is running, and every string is displayed… every part of the trigger runs. :D

What's even weirder is that when I remove "call DisableTrigger( GetTriggeringTrigger() )" and pick up an item, WC3 crashes (like I would expect it to). :banghead:

So apparently the trigger is running fine, executes everytime I pick up an item, and whenever I pick up a stackable item it runs the code as if they were stacking, displaying the appropriate DisplayTextToForce, but the items just sit there, with a charge of 1, taking up valuable inventory space. :eek:

This is annoying because there's this one quest that requires 10 of a certain item, which was fine when stacking worked. Now it doesn't at all, and I haven't changed the code at all. :confused:

What am I doing wrong?
Thanks.
 
Reaction score
341
There was no point in converting this to jass, as you modified nothing.

Post the GUI trigger. It's obvious.
 

Grothdmal

New Member
Reaction score
1
Trigger:
  • Item Stacking
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Triggering unit) Equal to Hero
    • Actions
      • Game - Display to (All players) the text: Acquire Item Trigge...
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Item-type of (Item being manipulated)) Equal to Bear Meat
              • (Item-type of (Item being manipulated)) Equal to Chicken Meat
              • (Item-type of (Item being manipulated)) Equal to Dire Wolf Meat
              • (Item-type of (Item being manipulated)) Equal to Wheat
              • (Item-type of (Item being manipulated)) Equal to Wolf Meat
              • (Item-type of (Item being manipulated)) Equal to Barrel of Grain
        • Then - Actions
          • Game - Display to (All players) the text: Item Identified
          • Set Item_type = (Item-type of (Item being manipulated))
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-type of (Item carried by Hero in slot (Integer A))) Equal to Item_type
                • Then - Actions
                  • Game - Display to (All players) the text: Removing item
                  • Set Charges = (Charges + (Charges remaining in (Item carried by Hero in slot (Integer A))))
                  • Item - Remove (Item carried by Hero in slot (Integer A))
                • Else - Actions
          • Trigger - Turn off (This trigger)
          • Game - Display to (All players) the text: Creating and Chargi...
          • Hero - Create Item_type and give it to Hero
          • Item - Set charges remaining in (Last created item) to Charges
          • Set Charges = 0
          • Trigger - Turn on (This trigger)
        • Else - Actions


There ya' go.
 

Grothdmal

New Member
Reaction score
1
It is initially on, I have to turn it off because the trigger activates whenever the Hero receives an item.
In the trigger, the Hero is given an item, turning the trigger off allows the rest of the trigger to run without firing off another instance of it.
Without the two Trigger Turn off/on the, the trigger would set it self off infinitely (give item to hero, hero acquires item, activates trigger, which gives item to hero, hero acquires item, activates trigger, etc).
So it is initially on, as I said it works fine, all the lines seem to work… it's just that the items don't stack and nothing seems to happen other than the Game text being displayed.
 

_whelp

New Member
Reaction score
54
So what's with the
Trigger:
  • Trigger - Turn on (This trigger)
?

Post your map too.
 

Grothdmal

New Member
Reaction score
1
Right, 'cause I turned off the trigger before.

look:
Trigger:
  • Else - Actions
    • Trigger - Turn off (This trigger)
    • Game - Display to (All players) the text: Creating and Chargi...
    • Hero - Create Item_type and give it to Hero
    • Item - Set charges remaining in (Last created item) to Charges
    • Set Charges = 0
    • Trigger - Turn on (This trigger)
    • Else - Actions

I turn the trigger off to prevent the crash… but I want items to keep stacking in the future so after it's done running I turn it back on again.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top