diff --git a/code/game/objects/effects/effect_system/foam.dm b/code/game/objects/effects/effect_system/foam.dm index 525cb8c731a9..7a06fa50619c 100644 --- a/code/game/objects/effects/effect_system/foam.dm +++ b/code/game/objects/effects/effect_system/foam.dm @@ -20,6 +20,7 @@ var/expand = 1 animate_movement = 0 var/metal = FOAM_NOT_METAL + var/time_to_solidify = 4 SECONDS /obj/effect/particle_effect/foam/Initialize(mapload, ismetal=0) @@ -28,7 +29,7 @@ metal = ismetal playsound(src, 'sound/effects/bubbles2.ogg', 25, 1, 5) addtimer(CALLBACK(src, PROC_REF(foam_react)), 3 + metal*3) - addtimer(CALLBACK(src, PROC_REF(foam_metal_final_react)), 40) + addtimer(CALLBACK(src, PROC_REF(foam_metal_final_react)), time_to_solidify) /obj/effect/particle_effect/foam/proc/foam_react() process() diff --git a/code/modules/projectiles/gun_attachables.dm b/code/modules/projectiles/gun_attachables.dm index 943cddd27ff5..a2801821349c 100644 --- a/code/modules/projectiles/gun_attachables.dm +++ b/code/modules/projectiles/gun_attachables.dm @@ -3221,6 +3221,10 @@ Defined in conflicts.dm of the #defines folder. to_chat(user, SPAN_WARNING("\The [gun] doesn't have enough fuel to launch a projectile!")) return + if(istype(flamer_reagent, /datum/reagent/foaming_agent/stabilized)) + to_chat(user, SPAN_WARNING("This chemical will clog the nozzle!")) + return + gun.last_fired = world.time gun.current_mag.reagents.remove_reagent(flamer_reagent.id, FLAME_REAGENT_USE_AMOUNT * fuel_per_projectile) diff --git a/code/modules/projectiles/guns/flamer/flamer.dm b/code/modules/projectiles/guns/flamer/flamer.dm index 5daef0bdff74..64499a71bb12 100644 --- a/code/modules/projectiles/guns/flamer/flamer.dm +++ b/code/modules/projectiles/guns/flamer/flamer.dm @@ -136,7 +136,10 @@ click_empty(user) else user.track_shot(initial(name)) - unleash_flame(target, user) + if(current_mag.reagents.has_reagent("stablefoam")) + unleash_foam(target, user) + else + unleash_flame(target, user) return AUTOFIRE_CONTINUE return NONE @@ -226,6 +229,59 @@ new /obj/flamer_fire(to_fire, create_cause_data(initial(name), user), R, max_range, current_mag.reagents, flameshape, target, CALLBACK(src, PROC_REF(show_percentage), user), fuel_pressure, fire_type) +/obj/item/weapon/gun/flamer/proc/unleash_foam(atom/target, mob/living/user) + last_fired = world.time + if(!current_mag || !current_mag.reagents || !current_mag.reagents.reagent_list.len) + return + + var/source_turf = get_turf(user) + var/foam_range = 6 // the max range the foam will travel + var/distance = 0 // the distance traveled + var/use_multiplier = 3 // if you want to increase the ammount of foam drained from the tank + var/datum/reagent/chemical = current_mag.reagents.reagent_list[1] + + var/turf/turfs[] = get_line(user, target, FALSE) + var/turf/first_turf = turfs[1] + var/ammount_required = (min(turfs.len, foam_range) * use_multiplier) // the ammount of units that this click requires + for(var/turf/turf in turfs) + + if(chemical.volume < ammount_required) + foam_range = round(chemical.volume / use_multiplier) + + if(distance >= foam_range) + break + + if(turf.density) + break + else + var/obj/effect/particle_effect/foam/checker = new() + var/atom/blocked = LinkBlocked(checker, source_turf, turf) + if(blocked) + break + + if(turf == first_turf) // this is so the first foam tile doesn't expand and touch the user + var/datum/effect_system/foam_spread/foam = new() + foam.set_up(0.5, turf, metal_foam = FOAM_METAL_TYPE_IRON) + foam.start() + else + var/datum/effect_system/foam_spread/foam = new() + foam.set_up(1, turf, metal_foam = FOAM_METAL_TYPE_IRON) + foam.start() + sleep(2) + + distance++ + + var/ammount_used = distance * use_multiplier // the actual ammount of units that we used + + chemical.volume = max(chemical.volume - ammount_used, 0) + + current_mag.reagents.total_volume = chemical.volume // this is needed for show_percentage to work + + if(chemical.volume < use_multiplier) // there aren't enough units left for a single tile of foam, empty the tank + current_mag.reagents.clear_reagents() + + show_percentage(user) + /obj/item/weapon/gun/flamer/proc/show_percentage(mob/living/user) if(current_mag) to_chat(user, SPAN_WARNING("The gauge reads: [round(current_mag.get_ammo_percent())]% fuel remains!")) diff --git a/code/modules/projectiles/magazines/flamer.dm b/code/modules/projectiles/magazines/flamer.dm index 7fba325177c6..dfd9eda20d8a 100644 --- a/code/modules/projectiles/magazines/flamer.dm +++ b/code/modules/projectiles/magazines/flamer.dm @@ -90,7 +90,7 @@ to_chat(user, SPAN_WARNING("You can't mix fuel mixtures!")) return - if(!to_add.intensityfire) + if(!to_add.intensityfire && to_add.id != "stablefoam") to_chat(user, SPAN_WARNING("This chemical is not potent enough to be used in a flamethrower!")) return diff --git a/code/modules/reagents/chemistry_reactions/other.dm b/code/modules/reagents/chemistry_reactions/other.dm index 24a8563e0848..28250aa38803 100644 --- a/code/modules/reagents/chemistry_reactions/other.dm +++ b/code/modules/reagents/chemistry_reactions/other.dm @@ -360,6 +360,12 @@ required_reagents = list("fluorine" = 2, "carbon" = 2, "sulphuric acid" = 1) result_amount = 5 +/datum/chemical_reaction/stablefoam + name = "Stabilized metallic foam" + id = "stablefoam" + result = "stablefoam" + required_reagents = list("fluorosurfactant" = 1, "iron" = 1, "sulphuric acid" = 1) + result_amount = 1 /datum/chemical_reaction/foam name = "Foam" diff --git a/code/modules/reagents/chemistry_reagents/other.dm b/code/modules/reagents/chemistry_reagents/other.dm index 786a58857830..2c441fb7059c 100644 --- a/code/modules/reagents/chemistry_reagents/other.dm +++ b/code/modules/reagents/chemistry_reagents/other.dm @@ -613,6 +613,15 @@ color = "#664B63" // rgb: 102, 75, 99 chemclass = CHEM_CLASS_UNCOMMON +/datum/reagent/foaming_agent/stabilized + name = "Stabilized metallic foam" + id = "stablefoam" + description = "Stabilized metallic foam that solidifies when exposed to an open flame" + reagent_state = LIQUID + color = "#d4b8d1" + chemclass = CHEM_CLASS_UNCOMMON + properties = list(PROPERTY_TOXIC = 8) + /datum/reagent/nicotine name = "Nicotine" id = "nicotine"