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%
This commit is contained in:
Loganbacca
2014-02-13 00:15:02 +13:00
parent 47083c63ef
commit 02810f7e89
5 changed files with 51 additions and 49 deletions
+27 -21
View File
@@ -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<pick(0,1,1,1,2,2,2,3), i++)
sleep(10)
step(smoke,direction)
spawn(150+rand(10,30))
smoke.delete()
src.total_smoke--
//apply the reagents to the environment after the smoke has stopped moving - to reduce reagent spam
for(i=0, i<2 + pick(0,1,), i++)
smoke.applyReagents()
sleep(20)
sleep(60)
smoke.delete()
src.total_smoke--
/////////////////////////////////////////////
//////// Attach an Ion trail to any object, that spawns when it moves (like for the jetpack)
@@ -615,6 +621,7 @@ steam.start() -- spawns the effect
playsound(src, 'sound/effects/bubbles2.ogg', 80, 1, -3)
spawn(3 + metal*3)
process()
checkReagents()
spawn(120)
processing_objects.Remove(src)
sleep(30)
@@ -629,14 +636,13 @@ steam.start() -- spawns the effect
delete()
return
// on delete, transfer any reagents to the floor
/obj/effect/effect/foam/Del()
// transfer any reagents to the floor
/obj/effect/effect/foam/proc/checkReagents()
if(!metal && reagents)
for(var/atom/A in oview(0,src))
for(var/atom/A in src.loc.contents)
if(A == src)
continue
reagents.reaction(A, 1, 1)
..()
/obj/effect/effect/foam/process()
if(--amount < 0)
@@ -663,7 +669,7 @@ steam.start() -- spawns the effect
F.create_reagents(10)
if (reagents)
for(var/datum/reagent/R in reagents.reagent_list)
F.reagents.add_reagent(R.id,1)
F.reagents.add_reagent(R.id, 1, safety = 1) //added safety check since reagents in the foam have already had a chance to react
// foam disolves when heated
// except metal foams
@@ -734,9 +740,9 @@ steam.start() -- spawns the effect
if(carried_reagents)
for(var/id in carried_reagents)
F.reagents.add_reagent(id,1)
F.reagents.add_reagent(id, 1, null, 1) //makes a safety call because all reagents should have already reacted anyway
else
F.reagents.add_reagent("water", 1)
F.reagents.add_reagent("water", 1, safety = 1)
// wall formed by metal foams
// dense and opaque, but easy to break
@@ -151,12 +151,6 @@
for(var/obj/item/weapon/reagent_containers/glass/G in beakers)
G.reagents.trans_to(src, G.reagents.total_volume)
if(src.reagents.total_volume) //The possible reactions didnt use up all reagents.
var/datum/effect/effect/system/steam_spread/steam = new /datum/effect/effect/system/steam_spread()
steam.set_up(10, 0, get_turf(src))
steam.attach(src)
steam.start()
for(var/atom/A in view(affected_area, src.loc))
if( A == src ) continue
src.reagents.reaction(A, 1, 10)
@@ -165,11 +159,6 @@
invisibility = INVISIBILITY_MAXIMUM //Why am i doing this?
spawn(50) //To make sure all reagents can work
del(src) //correctly before deleting the grenade.
/*else
icon_state = initial(icon_state) + "_locked"
crit_fail = 1
for(var/obj/item/weapon/reagent_containers/glass/G in beakers)
G.loc = get_turf(src.loc)*/
/obj/item/weapon/grenade/chem_grenade/large
@@ -240,6 +229,8 @@
B2.reagents.add_reagent("phosphorus", 25)
B2.reagents.add_reagent("sugar", 25)
detonator = new/obj/item/device/assembly_holder/timer_igniter(src)
beakers += B1
beakers += B2
icon_state = "grenade"