Merge pull request #7672 from Fox-McCloud/syndicate-bomb-refactor

Refactors Syndicate Bombs and Adds Chemical Bombs
This commit is contained in:
tigercat2000
2017-07-04 11:53:55 -07:00
committed by GitHub
14 changed files with 627 additions and 220 deletions
+78
View File
@@ -0,0 +1,78 @@
// Replaces chemgrenade stuff, allowing reagent explosions to be called from anywhere.
// It should be called using a location, the range, and a list of reagents involved.
// Threatscale is a multiplier for the 'threat' of the grenade. If you're increasing the affected range drastically, you might want to improve this.
// Extra heat affects the temperature of the mixture, and may cause it to react in different ways.
/proc/chem_splash(turf/epicenter, affected_range = 3, list/datum/reagents/reactants = list(), extra_heat = 0, threatscale = 1, adminlog = 1)
if(!isturf(epicenter) || !reactants.len || threatscale <= 0)
return
var/has_reagents
var/total_reagents
for(var/datum/reagents/R in reactants)
if(R.total_volume)
has_reagents = 1
total_reagents += R.total_volume
if(!has_reagents)
return
var/datum/reagents/splash_holder = new/datum/reagents(total_reagents*threatscale)
splash_holder.my_atom = epicenter // For some reason this is setting my_atom to null, and causing runtime errors.
var/total_temp = 0
for(var/datum/reagents/R in reactants)
R.trans_to(splash_holder, R.total_volume, threatscale, 1, 1)
total_temp += R.chem_temp
splash_holder.chem_temp = (total_temp/reactants.len) + extra_heat // Average temperature of reagents + extra heat.
splash_holder.handle_reactions() // React them now.
if(splash_holder.total_volume && affected_range >= 0) //The possible reactions didnt use up all reagents, so we spread it around.
var/datum/effect/system/steam_spread/steam = new /datum/effect/system/steam_spread()
steam.set_up(10, 0, epicenter)
steam.attach(epicenter)
steam.start()
var/list/viewable = view(affected_range, epicenter)
var/list/accessible = list(epicenter)
for(var/i=1; i<=affected_range; i++)
var/list/turflist = list()
for(var/turf/T in (orange(i, epicenter) - orange(i-1, epicenter)))
turflist |= T
for(var/turf/T in turflist)
if( !(get_dir(T,epicenter) in cardinal) && (abs(T.x - epicenter.x) == abs(T.y - epicenter.y) ))
turflist.Remove(T)
turflist.Add(T) // we move the purely diagonal turfs to the end of the list.
for(var/turf/T in turflist)
if(accessible[T])
continue
for(var/thing in T.GetAtmosAdjacentTurfs(alldir = TRUE))
var/turf/NT = thing
if(!(NT in accessible))
continue
if(!(get_dir(T,NT) in cardinal))
continue
accessible[T] = 1
break
var/list/reactable = accessible
for(var/turf/T in accessible)
for(var/atom/A in T.GetAllContents())
if(!(A in viewable))
continue
reactable |= A
if(extra_heat >= 300)
T.hotspot_expose(extra_heat*2, 5)
if(!reactable.len) //Nothing to react with. Probably means we're in nullspace.
return
for(var/thing in reactable)
var/atom/A = thing
var/distance = max(1,get_dist(A, epicenter))
var/fraction = 0.5/(2 ** distance) //50/25/12/6... for a 200u splash, 25/12/6/3... for a 100u, 12/6/3/1 for a 50u
splash_holder.reaction(A, TOUCH, fraction)
qdel(splash_holder)
return 1
+10 -7
View File
@@ -108,7 +108,7 @@ var/const/INGEST = 2
return the_id
/datum/reagents/proc/trans_to(target, amount=1, multiplier=1, preserve_data=1)//if preserve_data=0, the reagents data will be lost. Usefull if you use data for some strange stuff and don't want it to be transferred.
/datum/reagents/proc/trans_to(target, amount=1, multiplier=1, preserve_data=1, no_react = 0)//if preserve_data=0, the reagents data will be lost. Usefull if you use data for some strange stuff and don't want it to be transferred.
if(!target)
return
if(total_volume <= 0)
@@ -143,13 +143,14 @@ var/const/INGEST = 2
if(preserve_data)
trans_data = copy_data(current_reagent)
R.add_reagent(current_reagent.id, (current_reagent_transfer * multiplier), trans_data, chem_temp)
R.add_reagent(current_reagent.id, (current_reagent_transfer * multiplier), trans_data, chem_temp, no_react = 1)
remove_reagent(current_reagent.id, current_reagent_transfer)
update_total()
R.update_total()
R.handle_reactions()
handle_reactions()
if(!no_react)
R.handle_reactions()
handle_reactions()
return amount
/datum/reagents/proc/copy_to(obj/target, amount=1, multiplier=1, preserve_data=1, safety = 0)
@@ -537,7 +538,7 @@ var/const/INGEST = 2
var/amt = list_reagents[r_id]
add_reagent(r_id, amt, data)
/datum/reagents/proc/add_reagent(reagent, amount, list/data=null, reagtemp = 300)
/datum/reagents/proc/add_reagent(reagent, amount, list/data=null, reagtemp = 300, no_react = 0)
if(!isnum(amount))
return 1
update_total()
@@ -554,7 +555,8 @@ var/const/INGEST = 2
update_total()
my_atom.on_reagent_change()
R.on_merge(data)
handle_reactions()
if(!no_react)
handle_reactions()
return 0
var/datum/reagent/D = chemical_reagents_list[reagent]
@@ -570,7 +572,8 @@ var/const/INGEST = 2
update_total()
my_atom.on_reagent_change()
handle_reactions()
if(!no_react)
handle_reactions()
return 0
else
warning("[my_atom] attempted to add a reagent called '[reagent]' which doesn't exist. ([usr])")
@@ -40,7 +40,8 @@
/obj/machinery/biogenerator,
/obj/machinery/hydroponics,
/obj/machinery/constructable_frame,
/obj/machinery/icemachine)
/obj/machinery/icemachine,
/obj/item/weapon/bombcore/chemical)
/obj/item/weapon/reagent_containers/glass/New()
..()
+1 -9
View File
@@ -29,6 +29,7 @@
/obj/structure/reagent_dispensers/proc/boom()
visible_message("<span class='danger'>[src] ruptures!</span>")
chem_splash(loc, 5, list(reagents))
qdel(src)
/obj/structure/reagent_dispensers/ex_act(severity)
@@ -53,15 +54,6 @@
desc = "A water tank."
icon_state = "water"
/obj/structure/reagent_dispensers/watertank/boom()
playsound(loc, 'sound/effects/spray2.ogg', 50, 1, -6)
new /obj/effect/effect/water(loc)
for(var/turf/simulated/T in view(5, loc))
T.MakeSlippery()
for(var/mob/living/L in T)
L.adjust_fire_stacks(-20)
..()
/obj/structure/reagent_dispensers/watertank/high
name = "high-capacity water tank"
desc = "A highly-pressurized water tank made to hold gargantuan amounts of water.."