- Joined
- Mar 31, 2012
- Messages
- 13
Hey guys. Simple question: Does this leak?
My map was lag-free until i added this. Doesn't seem like it leaks to me, but who knows, bj_lastCreatedItem & the like are a very shady lot... Maybe it causes lag in some other way? The trigger itself works perfectly but as soon as you activate the spell even once, warcraft starts lagging continuously.
There are other ways to achieve this, i know, but this way fits my purposes best & if possible want to avoid having to rewrite the trigger completely.
JASS:
function Inventory_Switch_Condition takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function Inventory_Switch takes nothing returns nothing
local integer i = 0
loop
exitwhen i > 5
set bj_lastCreatedItem = null
if udg_The_Sack[i] != null then
set bj_lastCreatedItem = CreateItem(udg_The_Sack[i], GetUnitX(GetSpellAbilityUnit()), GetUnitY(GetSpellAbilityUnit()))
call SetItemCharges(bj_lastCreatedItem, udg_The_Sack[i + 6])
endif
set udg_The_Sack[i] = GetItemTypeId(UnitItemInSlot(GetSpellAbilityUnit(), i))
set udg_The_Sack[i + 6] = GetItemCharges(UnitItemInSlot(GetSpellAbilityUnit(), i))
call RemoveItem(UnitItemInSlot(GetSpellAbilityUnit(), i))
if bj_lastCreatedItem != null then
call UnitAddItem(GetSpellAbilityUnit(), bj_lastCreatedItem)
endif
set i = i + 1
endloop
endfunction
function Learn_Inventory_Switch_Condition takes nothing returns boolean
return GetLearnedSkill() == 'A000'
endfunction
function Learn_Inventory_Switch takes nothing returns nothing
//Trigger doesn't have to be MUI because only one Hero at a time will have it, but variables need reset when
//given to a different Hero.
local integer i = 0
loop
exitwhen i > 5
set udg_The_Sack[i] = 0
set udg_The_Sack[i + 6] = 0
set i = i + 1
endloop
endfunction
//===========================================================================
function InitTrig_The_Sack takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Inventory_Switch_Condition))
call TriggerAddAction(t, function Inventory_Switch)
set t = null
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_HERO_SKILL)
call TriggerAddCondition(t, Condition(function Learn_Inventory_Switch_Condition))
call TriggerAddAction(t, function Learn_Inventory_Switch)
set t = null
endfunction
My map was lag-free until i added this. Doesn't seem like it leaks to me, but who knows, bj_lastCreatedItem & the like are a very shady lot... Maybe it causes lag in some other way? The trigger itself works perfectly but as soon as you activate the spell even once, warcraft starts lagging continuously.
There are other ways to achieve this, i know, but this way fits my purposes best & if possible want to avoid having to rewrite the trigger completely.
Last edited: