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:
(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.
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.
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.
What am I doing wrong?
Thanks.
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
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.
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.
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.
What am I doing wrong?
Thanks.