From 02810f7e89c76922e44b02c79b22d304121b0b26 Mon Sep 17 00:00:00 2001 From: Loganbacca Date: Thu, 13 Feb 2014 00:15:02 +1300 Subject: [PATCH] Chem grenade fixes Fixes #3986 - Foam reagent inheritance fixed: The trans_to() proc in Chemistry-Holder.dm was calling handle_reactions() every time it would add and remove reagents with add_reagent() and remove_reagent(). I've added a safety flag to both of these procs (and copy_to()) so that trans_to will not call handle_reactions() until it has added all the reagents to the target container. This allows foam to reliably take on the properties of other leftover reagents. - Fixed a bug in effect_system.dm that wasn't applying reagents from foam to the environment. - Tweaked smoke to apply reagent effects after it has stopped moving This was causing huge reagent spam at the center of the smoke cloud as it was spawning, since they were being applied every time the cloud of smoke moved. Also changed it to apply the effects 2-3 times at longer intervals (2 seconds). - Smoke also only effects tiles in a 3x3 grid now, rather than 5x5. - Summary: Chem smoke does slightly less damage (if it contains damaging reagents) Chem smoke proc calls reduced by 60-70% (significant lag reduction) Foam works properly again Foam proc calls reduced by 70-80% --- code/game/objects/effects/effect_system.dm | 48 +++++++++++-------- .../items/weapons/grenades/chem_grenade.dm | 13 +---- code/modules/reagents/Chemistry-Holder.dm | 27 ++++++----- code/modules/reagents/Chemistry-Reagents.dm | 10 ++-- code/modules/reagents/Chemistry-Recipes.dm | 2 +- 5 files changed, 51 insertions(+), 49 deletions(-) diff --git a/code/game/objects/effects/effect_system.dm b/code/game/objects/effects/effect_system.dm index 8d2d69a654f..499bb2c22a9 100644 --- a/code/game/objects/effects/effect_system.dm +++ b/code/game/objects/effects/effect_system.dm @@ -392,16 +392,15 @@ steam.start() -- spawns the effect R.my_atom = src return -/obj/effect/effect/smoke/chem/Move() - ..() - for(var/atom/A in view(2, src)) - if(reagents.has_reagent("radium")||reagents.has_reagent("uranium")||reagents.has_reagent("carbon")||reagents.has_reagent("thermite"))//Prevents unholy radium spam by reducing the number of 'greenglows' down to something reasonable -Sieve - if(prob(5)) - reagents.reaction(A) - else - reagents.reaction(A) - - return +/obj/effect/effect/smoke/chem/proc/applyReagents() + if(reagents.reagent_list.len) + for(var/atom/A in view(1, src)) + if(!istype(A, src.type)) + if(reagents.has_reagent("radium")||reagents.has_reagent("uranium")||reagents.has_reagent("carbon")||reagents.has_reagent("thermite"))//Prevents unholy radium spam by reducing the number of 'greenglows' down to something reasonable -Sieve + if(prob(5)) + reagents.reaction(A) + else + reagents.reaction(A) /obj/effect/effect/smoke/chem/affect(mob/living/carbon/M as mob ) reagents.reaction(M) @@ -474,7 +473,7 @@ steam.start() -- spawns the effect direction = pick(alldirs) if(chemholder.reagents.total_volume != 1) // can't split 1 very well - chemholder.reagents.copy_to(smoke, chemholder.reagents.total_volume / number) // copy reagents to each smoke, divide evenly + chemholder.reagents.copy_to(smoke, chemholder.reagents.total_volume / number, safety = 1) // copy reagents to each smoke, divide evenly if(color) smoke.icon += color // give the smoke color, if it has any to begin with @@ -486,9 +485,16 @@ steam.start() -- spawns the effect for(i=0, i maximum_volume) amount = (maximum_volume - total_volume) //Doesnt fit in. Make it disappear. Shouldnt happen. Will happen. @@ -435,7 +436,8 @@ datum preserve += D R.data["viruses"] = preserve - handle_reactions() + if(!safety) + handle_reactions() return 0 var/datum/reagent/D = chemical_reagents_list[reagent] @@ -454,17 +456,18 @@ datum //debug update_total() my_atom.on_reagent_change() - handle_reactions() + if(!safety) + handle_reactions() return 0 else warning("[my_atom] attempted to add a reagent called '[reagent]' which doesn't exist. ([usr])") - handle_reactions() + if(!safety) + handle_reactions() return 1 - remove_reagent(var/reagent, var/amount, var/safety)//Added a safety check for the trans_id_to - + remove_reagent(var/reagent, var/amount, var/safety = 0)//Added a safety check for the trans_id_to if(!isnum(amount)) return 1 for(var/A in reagent_list) diff --git a/code/modules/reagents/Chemistry-Reagents.dm b/code/modules/reagents/Chemistry-Reagents.dm index baf235b3665..72a92061105 100644 --- a/code/modules/reagents/Chemistry-Reagents.dm +++ b/code/modules/reagents/Chemistry-Reagents.dm @@ -925,18 +925,20 @@ datum else if(O) O.clean_blood() + reaction_turf(var/turf/T, var/volume) if(volume >= 1) + if(istype(T, /turf/simulated)) + var/turf/simulated/S = T + S.dirt = 0 T.overlays.Cut() T.clean_blood() - for(var/obj/effect/decal/cleanable/C in src) + for(var/obj/effect/decal/cleanable/C in T.contents) + src.reaction_obj(C, volume) del(C) for(var/mob/living/carbon/slime/M in T) M.adjustToxLoss(rand(5,10)) - reaction_turf(var/turf/simulated/S, var/volume) - if(volume >= 1) - S.dirt = 0 reaction_mob(var/mob/M, var/method=TOUCH, var/volume) if(iscarbon(M)) diff --git a/code/modules/reagents/Chemistry-Recipes.dm b/code/modules/reagents/Chemistry-Recipes.dm index fe56d442e0a..5203f828910 100644 --- a/code/modules/reagents/Chemistry-Recipes.dm +++ b/code/modules/reagents/Chemistry-Recipes.dm @@ -458,7 +458,7 @@ datum var/location = get_turf(holder.my_atom) var/datum/effect/effect/system/smoke_spread/chem/S = new /datum/effect/effect/system/smoke_spread/chem S.attach(location) - S.set_up(holder, 10, 0, location) + S.set_up(holder, created_volume/7.5, 0, location) playsound(location, 'sound/effects/smoke.ogg', 50, 1, -3) spawn(0) S.start()