• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[Solved] Is there a way to prevent the leaks generated by deleting & rebuilding a trigger by creating a trigger and adding events?

Status
Not open for further replies.
JASS:
//麣鼶爨矲韠龖龘纛灪麤麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠灪麤麣鼶爨矲韠
//麣鼶爨矲韠龖龘纛灪麤 REBUILD 韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠灪麤麣鼶爨矲韠
//麣鼶爨矲韠龖龘纛灪麤         麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖
function U_DD_on_damage takes nothing returns nothing
  local unit dsrc
  local unit dmged
  local location dmgedp
  local integer dsrctid
  local real dmg
  set dsrc = GetEventDamageSource()
  set dmged = GetTriggerUnit()
  set dmgedp = GetUnitLoc(dmged)
  set dsrctid = GetUnitTypeId(dsrc)
  set dmg = GetEventDamage()
  if GetUnitAbilityLevelSwapped('A04E', dsrc) > 0 and dmg > 100 then
    call U_DD_GS(dsrc, dmged,"frostnova")
  endif
  if dmg > 50 and U_DD_RE_conds(1,dsrc,dmged,true) then
    if udg_Cam_Shakiness + 4 < 8.5 then
      set udg_Cam_Shakiness = udg_Cam_Shakiness + 4
    else 
      set udg_Cam_Shakiness = 8.5
    endif
    call CameraSetEQNoiseForPlayer( Player(0), udg_Cam_Shakiness )
    //call U_DD_OPD(dsrc, dmged, "stomp")
    call U_DD_se(dmgedp, 2, "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl")
    call U_DD_dmgar (dsrc, dmged, 250, 50, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
  endif
  set dsrc = null
  set dmged = null
  call RemoveLocation(dmgedp)
  set dmgedp = null
endfunction
//  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖 
//龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  
//  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖 
function U_DD_R_grpxtion takes nothing returns nothing
  local unit atkd
  local unit atkr
  local integer ord
  set atkd = GetEnumUnit()
  set atkr = LoadUnitHandleBJ(1, GetHandleIdBJ(atkd), udg_U_DD_Temp)
  set ord = GetUnitCurrentOrder(atkr)
  if CountUnitsInGroup(U_DD_getatkrs(atkd)) == 0 or IsUnitDeadBJ(atkd)then
    //call U_DD_pr("no related attackers left - " +GetUnitName(atkd))
    call GroupRemoveUnitSimple( atkd, udg_U_DD_Registered )
  else
    //call U_DD_pr("\"" +I2S(CountUnitsInGroup(U_DD_getatkrs(atkd)))+ "\"" + "followed up - " +GetUnitName(atkd))
    call TriggerRegisterUnitEvent( gg_trg_Damage_Detection_Detect, atkd, EVENT_UNIT_DAMAGED )
  endif
  set atkd = null
  set atkr = null
endfunction
//  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖 
//龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  
//  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖 
function U_DD_on_iteration takes nothing returns nothing
  set udg_U_DD_I = udg_U_DD_I + 1
  call DestroyTrigger(gg_trg_Damage_Detection_Detect)
  set gg_trg_Damage_Detection_Detect = CreateTrigger(  )
  call ForGroup(udg_U_DD_Registered, function U_DD_R_grpxtion)
  call TriggerAddAction( gg_trg_Damage_Detection_Detect, function U_DD_on_damage )
endfunction
//麣鼶爨矲韠龖龘纛灪麤         麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠
//麣鼶爨矲韠龖龘纛灪麤 REBUILD 韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠灪麤麣鼶爨矲韠
//麣鼶爨矲韠龖龘纛灪麤麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠灪麤麣鼶爨矲韠
 
Why do you need/want to do this?
It's part of my Damage Detection system.
 
Because On Damage event is only detected through specific units, and I need to build a trigger which registers / self-destructs dynamically.
What version are we talking about here?
Because 1.31.1 has EVENT_PLAYER_UNIT_DAMAGING and EVENT_PLAYER_UNIT_DAMAGED that you can register to a native TriggerRegisterPlayerUnitEvent takes trigger whichTrigger, player whichPlayer, playerunitevent whichPlayerUnitEvent, boolexpr filter returns event
 
Right. I don't think that you can clean up any events on any game version without some major modifications.
Edit: I clicked send before it was ready, so edited it a few times :p
Edit2: There are a few ways of dodging the problem, but they all come with some draw-backs...
 
What version are we talking about here?
Because 1.31.1 has EVENT_PLAYER_UNIT_DAMAGING and EVENT_PLAYER_UNIT_DAMAGED that you can register to a native TriggerRegisterPlayerUnitEvent takes trigger whichTrigger, player whichPlayer, playerunitevent whichPlayerUnitEvent, boolexpr filter returns event
Thanks for the help. Just updated. This worked perfectly.
 
Status
Not open for further replies.
Top