@@ -145,6 +145,7 @@ if SERVER then
145145 local calcview_consents = {}
146146 local active_force_ids = {}
147147 local active_grabbed_ents = {}
148+ local active_dots = {}
148149
149150
150151 local friendly_NPC_preferences = {}
@@ -862,6 +863,19 @@ if SERVER then
862863 end
863864 end )
864865
866+ gameevent .Listen (" entity_killed" )
867+ hook .Add ( " entity_killed" , " entity_killed_example" , function ( data )
868+ local victim_index = data .entindex_killed // Same as Victim :EntIndex () / the entity / player victim
869+ local ent = Entity (victim_index )
870+ if ent :IsValid () then
871+ if active_dots [ent ] then
872+ for timer_entid ,_ in pairs (active_dots [ent ]) do
873+ timer .Remove (timer_entid )
874+ end
875+ end
876+ end
877+ end )
878+
865879 local function MergeTargetsByID (tbl1 , tbl2 )
866880 for i ,v in ipairs (tbl2 ) do
867881 tbl1 [v :EntIndex ()] = v
@@ -1210,18 +1224,22 @@ if SERVER then
12101224 ply_prog_count = ply_prog_count + 1
12111225 else
12121226 if tbl .DOTMode then
1227+ active_dots [ent ] = active_dots [ent ] or {}
12131228 local counts = tbl .NoInitialDOT and tbl .DOTCount or tbl .DOTCount - 1
12141229 local timer_entid = tbl .UniqueID .. " _" .. ent :GetClass () .. " _" .. ent :EntIndex ()
12151230 if counts <= 0 then -- nuh uh, timer 0 means infinite repeat
12161231 timer .Remove (timer_entid )
1232+ active_dots [ent ][timer_entid ] = nil
12171233 else
12181234 if timer .Exists (timer_entid ) then
12191235 timer .Adjust (tbl .UniqueID , tbl .DOTTime , counts )
1236+ active_dots [ent ][timer_entid ] = tbl
12201237 else
12211238 timer .Create (timer_entid , tbl .DOTTime , counts , function ()
12221239 if not IsValid (ent ) then timer .Remove (timer_entid ) return end
12231240 DoDamage (ent )
12241241 end )
1242+ active_dots [ent ][timer_entid ] = tbl
12251243 end
12261244 end
12271245
0 commit comments