• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Some sort of MUI conflict

Status
Not open for further replies.
Hi all the Hive members and helpers! I have a sort of the handle problem. When I run the spell under this code for two same heroes at the same time, I receive some non-MUI ending... The special effect only vanishes from the last caster. Screenshot of handle checking.

JASS:
function Trig_SandStorm_Conditions takes nothing returns boolean
     return GetSpellAbilityId() == 'A000'
endfunction

function SandStormEffectRemove takes nothing returns nothing
     local timer t = GetExpiredTimer()
     local timer t2 = LoadTimerHandle(udg_SandHeroHashtable,GetHandleId(t),3)
     local effect e = LoadEffectHandle(udg_SandHeroHashtable,GetHandleId(t),1)
     local unit caster = LoadUnitHandle(udg_SandHeroHashtable,GetHandleId(t),2)
     set udg_SandStormEnded[GetPlayerId(GetOwningPlayer(caster))] = true
     call BJDebugMsg("Unit Name: " + GetUnitName(caster))
     call BJDebugMsg("Unit Owner ID: " + I2S(GetPlayerId(GetOwningPlayer(caster))))
     call BJDebugMsg("Expired Timer Handle: " + I2S(GetHandleId(t)))
     call UnitRemoveAbility(caster,'A001')
     call UnitAddAbility(caster,'A000')
     call DestroyEffect(e)
     call PauseTimer(t2)
     call DestroyTimer(t)
     call DestroyTimer(t2)
     set e = null
     set t = null
endfunction

function SandStormGroupFilter takes nothing returns boolean
     local unit u = LoadUnitHandle(udg_SandHeroHashtable,GetHandleId(GetExpiredTimer()),2)
     local unit e = GetFilterUnit()
     if IsUnitEnemy(e,GetOwningPlayer(u)) then
         call UnitDamageTarget(u,e,50,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_  TYPE_WHOKNOWS)
     endif
     set u = null
     set e = null
     return false
endfunction

function SandStormSpellRepeat takes nothing returns nothing
     local timer t = GetExpiredTimer()
     local unit caster = LoadUnitHandle(udg_SandHeroHashtable,GetHandleId(t),2)
     local group g = CreateGroup()
     call GroupEnumUnitsInRange(g,GetUnitX(caster),GetUnitY(caster),200,Filter(function SandStormGroupFilter))
     set g = null
     set t = null
     set caster = null
endfunction

function Trig_SandStorm_Actions takes nothing returns nothing
     local unit caster = GetSpellAbilityUnit()
     local effect e = AddSpecialEffectTarget("war3mapImported\\SandTornado.mdx",caster,"origin")
     local integer id = GetPlayerId(GetOwningPlayer(caster))
     local timer array st
     local timer array et
     set st[id] = CreateTimer() // Spell Timer
     set et[id] = CreateTimer() // Effect Timer
     set udg_SandHeroHashtable = InitHashtable()
     call SaveEffectHandle(udg_SandHeroHashtable,GetHandleId(et[id]),1,e)
     call SaveUnitHandle(udg_SandHeroHashtable,GetHandleId(st[id]),2,caster)
     call SaveUnitHandle(udg_SandHeroHashtable,GetHandleId(et[id]),2,caster)
     set udg_SandStormEnded[GetPlayerId(GetOwningPlayer(caster))] = false
     call TimerStart(st[id],1,true,function SandStormSpellRepeat)
     call TimerStart(et[id],udg_SandStormDur[GetUnitAbilityLevel(caster,'A000')],false,function SandStormEffectRemove)
     call BJDebugMsg("Source Timer Handle: " + I2S(GetHandleId(et[id])))
     call BJDebugMsg("Started an Effect timer with duration: " + I2S(udg_SandStormDur[GetUnitAbilityLevel(caster,'A000')]))
     call SaveTimerHandle(udg_SandHeroHashtable,GetHandleId(et[id]),3,st[id])
     call UnitRemoveAbility(caster,'A000')
     call UnitAddAbility(caster,'A001')
     set et[id] = null
     set caster = null
     set st[id] = null
     set e = null
endfunction

//===========================================================================
function InitTrig_SandStorm takes nothing returns nothing
     set gg_trg_SandStorm = CreateTrigger()
     call TriggerRegisterAnyUnitEventBJ(gg_trg_SandStorm,EVENT_PLAYER_UNIT_SPELL_EFFECT)
     call TriggerAddCondition(gg_trg_SandStorm,Condition(function Trig_SandStorm_Conditions))
     call TriggerAddAction(gg_trg_SandStorm,function Trig_SandStorm_Actions)
endfunction
 
Status
Not open for further replies.
Top