Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smoke Flamer #6146

Merged
merged 11 commits into from
May 10, 2024
5 changes: 5 additions & 0 deletions code/game/machinery/autolathe_datums.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions code/modules/projectiles/gun_attachables.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
69 changes: 66 additions & 3 deletions code/modules/projectiles/guns/flamer/flamer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion code/modules/projectiles/magazines/flamer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Loading