- Joined
- May 16, 2012
- Messages
- 644
I think i found a bug with the events EVENT_PLAYER_UNIT_PICKUP_ITEM and EVENT_PLAYER_UNIT_DROP_ITEM. Recently i created an immolation like item for my map and i'm using these 2 events to check when to active or deactive the immolation effect. In the first trigger, when a unit acquire a specific item, i check if the value of a boolean array variable in the index of the unit custom value (Unit Index value) is false (by default on creation of the boolean vector) and then, in the actions, i set the same variable to true, so if the unit acquire the same item again it will not have duplicated immo effect, and for that i'm using the event PICKUP_ITEM. To deactivate the effect when this unit drop that item i'm using the DROP_ITEM event and check if this unit has more items of that type before calling the actions to set the value of the boolean variable to false again. Note that the value of this variable is used to destroy the immo effect when its false, so its imperative for it to be set properly, but for some weird reason the PICKUP_ITEM event is also triggering the DROP_ITEM event (i've add some custom debug msgs).
Activation
Deactivation
Am i doing something wrong, or this is actually a new bug?
Activation
JASS:
scope GuardingFlames initializer Init
private function Immolation takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = LoadUnitHandle(udg_HeroHash, GetHandleId(t), 1)
local effect e = LoadEffectHandle(udg_HeroHash, GetHandleId(t), 2)
local group g
local unit v
if udg_GuardingFlamesCheck[GetUnitUserData(u)] then
set g = CreateGroup()
call GroupEnumUnitsInRange(g, GetUnitX(u), GetUnitY(u), 400.00, null)
loop
set v = FirstOfGroup(g)
exitwhen v == null
if(IsUnitEnemy(v, GetOwningPlayer(u)) and UnitAlive(v) and not IsUnitType(v, UNIT_TYPE_STRUCTURE)) then
call DestroyEffect(AddSpecialEffectTarget("ImmolationRedDamage.mdx", v, "chest"))
call UnitDamageTarget(u, v, 250.0, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
endif
call GroupRemoveUnit(g, v)
endloop
call DestroyGroup(g)
else
call DestroyEffect(e)
call FlushChildHashtable(udg_HeroHash, GetHandleId(t))
call PauseTimer(t)
call DestroyTimer(t)
endif
set t = null
set u = null
set e = null
set g = null
endfunction
private function Actions takes nothing returns nothing
local item i = GetManipulatedItem()
local unit u = GetManipulatingUnit()
local timer t = CreateTimer()
local effect e = AddSpecialEffectTarget("ImmolationRed.mdx", u, "chest")
set udg_GuardingFlamesCheck[GetUnitUserData(u)] = true
call SaveUnitHandle(udg_HeroHash, GetHandleId(t), 1, u)
call SaveEffectHandle(udg_HeroHash, GetHandleId(t), 2, e)
call TimerStart(t, 1.00, true, function Immolation)
set i = null
set u = null
set t = null
set e = null
endfunction
private function Conditions takes nothing returns boolean
local unit u = GetManipulatingUnit()
local item i = GetManipulatedItem()
if not udg_GuardingFlamesCheck[GetUnitUserData(u)] and GetItemTypeId(i) == 'I05T' then
call Actions()
endif
set u = null
set i = null
return false
endfunction
//===========================================================================
private function Init takes nothing returns nothing
set gg_trg_GuardingFlames = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_GuardingFlames, EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(gg_trg_GuardingFlames, Condition(function Conditions))
endfunction
endscope
Deactivation
JASS:
scope GuardingFlamesDeac initializer Init
private function Actions takes nothing returns nothing
local unit u = GetManipulatingUnit()
set udg_GuardingFlamesCheck[GetUnitUserData(u)] = false
set u = null
endfunction
private function Conditions takes nothing returns boolean
local unit u = GetManipulatingUnit()
local item i = GetManipulatedItem()
call ArcingTextTag.create(("|cff32cd32" + I2S(UnitHasItemOfType(u, 'I05T'))), u)
if (GetItemTypeId(i) == 'I05T') and (UnitHasItemOfType(u, 'I05T') == 0) then
call Actions()
endif
set u = null
set i = null
return false
endfunction
//===========================================================================
private function Init takes nothing returns nothing
set gg_trg_GuardingFlamesDeac = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_GuardingFlamesDeac, EVENT_PLAYER_UNIT_DROP_ITEM)
call TriggerAddCondition(gg_trg_GuardingFlamesDeac, Condition(function Conditions))
endfunction
endscope
Am i doing something wrong, or this is actually a new bug?