diff --git a/code/game/machinery/autolathe_datums.dm b/code/game/machinery/autolathe_datums.dm index 01a40b3638f6..8abf2b96bc1c 100644 --- a/code/game/machinery/autolathe_datums.dm +++ b/code/game/machinery/autolathe_datums.dm @@ -331,6 +331,11 @@ path = /obj/item/ammo_magazine/flamer_tank/custom/large category = AUTOLATHE_CATEGORY_EXPLOSIVES +/datum/autolathe/recipe/armylathe/smoke_tank + name = "Custom M240A1 Smoke Tank" + path = /obj/item/ammo_magazine/flamer_tank/smoke + category = AUTOLATHE_CATEGORY_EXPLOSIVES + //Medilathe recipes /datum/autolathe/recipe/medilathe category = AUTOLATHE_CATEGORY_MEDICAL diff --git a/code/modules/projectiles/gun_attachables.dm b/code/modules/projectiles/gun_attachables.dm index a2801821349c..bc2b9a5a516f 100644 --- a/code/modules/projectiles/gun_attachables.dm +++ b/code/modules/projectiles/gun_attachables.dm @@ -3225,6 +3225,10 @@ Defined in conflicts.dm of the #defines folder. to_chat(user, SPAN_WARNING("This chemical will clog the nozzle!")) return + if(istype(gun.current_mag, /obj/item/ammo_magazine/flamer_tank/smoke)) // you can't fire smoke like a projectile! + to_chat(user, SPAN_WARNING("[src] can't be used with this fuel tank!")) + 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 64499a71bb12..0388f5be7aef 100644 --- a/code/modules/projectiles/guns/flamer/flamer.dm +++ b/code/modules/projectiles/guns/flamer/flamer.dm @@ -136,10 +136,13 @@ click_empty(user) else user.track_shot(initial(name)) - if(current_mag.reagents.has_reagent("stablefoam")) - unleash_foam(target, user) + if(istype(current_mag, /obj/item/ammo_magazine/flamer_tank/smoke)) + unleash_smoke(target, user) else - 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 @@ -229,6 +232,66 @@ 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_smoke(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/smoke_range = 5 // the max range the smoke will travel + var/distance = 0 // the distance traveled + var/use_multiplier = 3 // if you want to increase the ammount of units drained from the tank + var/units_in_smoke = 35 // the smoke overlaps a little so this much is probably already good + + var/datum/reagent/chemical = current_mag.reagents.reagent_list[1] + var/datum/reagents/to_disperse = new() // this is the chemholder that will be used by the chemsmoke + to_disperse.add_reagent(chemical.id, units_in_smoke) + to_disperse.my_atom = src + + var/turf/turfs[] = get_line(user, target, FALSE) + var/turf/first_turf = turfs[1] + var/turf/second_turf = turfs[2] + var/ammount_required = (min(turfs.len, smoke_range) * use_multiplier) // the ammount of units that this click requires + for(var/turf/turf in turfs) + + if(chemical.volume < ammount_required) + smoke_range = round(chemical.volume / use_multiplier) + + if(distance >= smoke_range) + break + + if(turf.density) + break + else + var/obj/effect/particle_effect/smoke/chem/checker = new() + var/atom/blocked = LinkBlocked(checker, source_turf, turf) + if(blocked) + break + + playsound(turf, 'sound/effects/smoke.ogg', 25, 1) + if(turf != first_turf && turf != second_turf) // we skip the first tile and make it small on the second so the smoke doesn't touch the user + var/datum/effect_system/smoke_spread/chem/smoke = new() + smoke.set_up(to_disperse, 5, loca = turf) + smoke.start() + if(turf == second_turf) + var/datum/effect_system/smoke_spread/chem/smoke = new() + smoke.set_up(to_disperse, 1, loca = turf) + smoke.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 smoke, empty the tank + current_mag.reagents.clear_reagents() + + show_percentage(user) + /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) diff --git a/code/modules/projectiles/magazines/flamer.dm b/code/modules/projectiles/magazines/flamer.dm index dfd9eda20d8a..bf5663cad069 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 && to_add.id != "stablefoam") + if(!to_add.intensityfire && to_add.id != "stablefoam" && !istype(src, /obj/item/ammo_magazine/flamer_tank/smoke)) to_chat(user, SPAN_WARNING("This chemical is not potent enough to be used in a flamethrower!")) return @@ -236,3 +236,9 @@ max_intensity = 60 max_range = 8 max_duration = 50 + +/obj/item/ammo_magazine/flamer_tank/smoke + name = "Custom incinerator smoke tank" + desc = "A tank holding powdered smoke that expands when exposed to an open flame and carries any chemicals along with it." + matter = list("metal" = 3750) + flamer_chem = null