<commit_before>/obj/item/weapon/extinguisher
	name = "fire extinguisher"
	desc = "A traditional red fire extinguisher."
	icon = 'icons/obj/items.dmi'
	icon_state = "fire_extinguisher0"
	item_state = "fire_extinguisher"
	hitsound = 'sound/weapons/smash.ogg'
	flags = CONDUCT
	throwforce = 10
	w_class = 3
	throw_speed = 2
	throw_range = 7
	force = 10
	materials = list(MAT_METAL=500)
	attack_verb = list("slammed", "whacked", "bashed", "thunked", "battered", "bludgeoned", "thrashed")
	var/max_chem = 50
	var/last_use = 1
	var/safety = 1
	var/sprite_name = "fire_extinguisher"
	var/power = 5 //Maximum distance launched water will travel
	var/precision = 0 //By default, turfs picked from a spray are random, set to 1 to make it always have at least one water effect per row
	var/cooling_power = 2 //Sets the cooling_temperature of the water reagent datum inside of the extinguisher when it is refilled
	var/list/blacklist = list("clf3")

/obj/item/weapon/extinguisher/mini
	name = "pocket fire extinguisher"
	desc = "A light and compact fibreglass-framed model fire extinguisher."
	icon_state = "miniFE0"
	item_state = "miniFE"
	hitsound = null	//it is much lighter, after all.
	flags = null //doesn't CONDUCT
	throwforce = 2
	w_class = 2
	force = 3
	materials = list()
	max_chem = 30
	sprite_name = "miniFE"
	materials = list(MAT_METAL=300)

/obj/item/weapon/extinguisher/New()
	create_reagents(max_chem)
	reagents.add_reagent("water", max_chem)

/obj/item/weapon/extinguisher/attack_self(mob/user)
	safety = !safety
	src.icon_state = "[sprite_name][!safety]"
	src.desc = "The safety is [safety ? "on" : "off"]."
	user << "The safety is [safety ? "on" : "off"]."
	return

/obj/item/weapon/extinguisher/examine(mob/user)
	..()
	if(reagents.total_volume)
		user << "It contains [round(reagents.total_volume)] units."
	else
		user << "It is empty."

/obj/item/weapon/extinguisher/proc/AttemptRefill(atom/target, mob/user)
	if(istype(target, /obj/structure/reagent_dispensers) && target.Adjacent(user))
		var/safety_save = safety
		safety = 1
		if(reagents.total_volume == reagents.maximum_volume)
			user << "<span class='warning'>\The [src] is already full!</span>"
			safety = safety_save
			return 1
		var/obj/structure/reagent_dispensers/W = target
		var/list/badchem = W.reagents.reagent_list&blacklist
			if(badchem.len)
				visible_message("<span class='warning'>[W] refuses to refill [src]!</span>")
				return 1
		var/transferred = W.reagents.trans_to(src, max_chem)
		if(transferred > 0)
			user << "<span class='notice'>\The [src] has been refilled by [transferred] units.</span>"
			playsound(src.loc, 'sound/effects/refill.ogg', 50, 1, -6)
			for(var/datum/reagent/water/R in reagents.reagent_list)
				R.cooling_temperature = cooling_power
		else
			user << "<span class='warning'>\The [W] is empty!</span>"
		safety = safety_save
		return 1
	else
		return 0

/obj/item/weapon/extinguisher/afterattack(atom/target, mob/user , flag)
	//TODO; Add support for reagents in water.
	if(target.loc == user || !check_allowed_items(target)) //No more spraying yourself when putting your extinguisher away
		return
	var/Refill = AttemptRefill(target, user)
	if(Refill)
		return
	if (!safety)
		if (src.reagents.total_volume < 1)
			usr << "<span class='warning'>\The [src] is empty!</span>"
			return

		if (world.time < src.last_use + 20)
			return

		src.last_use = world.time

		playsound(src.loc, 'sound/effects/extinguish.ogg', 75, 1, -3)

		var/direction = get_dir(src,target)

		if(usr.buckled && isobj(usr.buckled) && !usr.buckled.anchored)
			spawn(0)
				var/obj/B = usr.buckled
				var/movementdirection = turn(direction,180)
				step(B, movementdirection)
				sleep(1)
				step(B, movementdirection)
				sleep(1)
				step(B, movementdirection)
				sleep(1)
				step(B, movementdirection)
				sleep(2)
				step(B, movementdirection)
				sleep(2)
				step(B, movementdirection)
				sleep(3)
				step(B, movementdirection)
				sleep(3)
				step(B, movementdirection)
				sleep(3)
				step(B, movementdirection)

		else user.newtonian_move(turn(direction, 180))

		var/turf/T = get_turf(target)
		var/turf/T1 = get_step(T,turn(direction, 90))
		var/turf/T2 = get_step(T,turn(direction, -90))
		var/list/the_targets = list(T,T1,T2)
		if(precision)
			var/turf/T3 = get_step(T1, turn(direction, 90))
			var/turf/T4 = get_step(T2,turn(direction, -90))
			the_targets = list(T,T1,T2,T3,T4)

		for(var/a=0, a<5, a++)
			spawn(0)
				var/obj/effect/effect/water/W = new /obj/effect/effect/water(get_turf(src))
				var/turf/my_target = pick(the_targets)
				if(precision)
					the_targets -= my_target
				var/datum/reagents/R = new/datum/reagents(5)
				if(!W) return
				W.reagents = R
				R.my_atom = W
				if(!W || !src) return
				src.reagents.trans_to(W,1)
				for(var/b=0, b<power, b++)
					step_towards(W,my_target)
					if(!W || !W.reagents) return
					W.reagents.reaction(get_turf(W))
					for(var/atom/atm in get_turf(W))
						if(!W) return
						W.reagents.reaction(atm, TOUCH) // so it actually puts peeps out with water etc
					if(W.loc == my_target) break
					if(!W.reagents.total_volume) break
					sleep(2)

	else
		return ..()

/obj/item/weapon/extinguisher/AltClick(mob/user)
	EmptyExtinguisher(user)

/obj/item/weapon/extinguisher/proc/EmptyExtinguisher(var/mob/user)
	if(loc == user && reagents.total_volume)
		reagents.clear_reagents()
		user.visible_message("[user] empties out \the [src] onto the floor using the release valve.", "<span class='info'>You quietly empty out \the [src] using its release valve.</span>")
	return

/obj/item/weapon/extinguisher/autolathe_crafted(obj/machinery/autolathe/A)
	reagents.clear_reagents()
	return
<commit_msg>little typo<commit_after>/obj/item/weapon/extinguisher
	name = "fire extinguisher"
	desc = "A traditional red fire extinguisher."
	icon = 'icons/obj/items.dmi'
	icon_state = "fire_extinguisher0"
	item_state = "fire_extinguisher"
	hitsound = 'sound/weapons/smash.ogg'
	flags = CONDUCT
	throwforce = 10
	w_class = 3
	throw_speed = 2
	throw_range = 7
	force = 10
	materials = list(MAT_METAL=500)
	attack_verb = list("slammed", "whacked", "bashed", "thunked", "battered", "bludgeoned", "thrashed")
	var/max_chem = 50
	var/last_use = 1
	var/safety = 1
	var/sprite_name = "fire_extinguisher"
	var/power = 5 //Maximum distance launched water will travel
	var/precision = 0 //By default, turfs picked from a spray are random, set to 1 to make it always have at least one water effect per row
	var/cooling_power = 2 //Sets the cooling_temperature of the water reagent datum inside of the extinguisher when it is refilled
	var/list/blacklist = list("clf3")

/obj/item/weapon/extinguisher/mini
	name = "pocket fire extinguisher"
	desc = "A light and compact fibreglass-framed model fire extinguisher."
	icon_state = "miniFE0"
	item_state = "miniFE"
	hitsound = null	//it is much lighter, after all.
	flags = null //doesn't CONDUCT
	throwforce = 2
	w_class = 2
	force = 3
	materials = list()
	max_chem = 30
	sprite_name = "miniFE"
	materials = list(MAT_METAL=300)

/obj/item/weapon/extinguisher/New()
	create_reagents(max_chem)
	reagents.add_reagent("water", max_chem)

/obj/item/weapon/extinguisher/attack_self(mob/user)
	safety = !safety
	src.icon_state = "[sprite_name][!safety]"
	src.desc = "The safety is [safety ? "on" : "off"]."
	user << "The safety is [safety ? "on" : "off"]."
	return

/obj/item/weapon/extinguisher/examine(mob/user)
	..()
	if(reagents.total_volume)
		user << "It contains [round(reagents.total_volume)] units."
	else
		user << "It is empty."

/obj/item/weapon/extinguisher/proc/AttemptRefill(atom/target, mob/user)
	if(istype(target, /obj/structure/reagent_dispensers) && target.Adjacent(user))
		var/safety_save = safety
		safety = 1
		if(reagents.total_volume == reagents.maximum_volume)
			user << "<span class='warning'>\The [src] is already full!</span>"
			safety = safety_save
			return 1
		var/obj/structure/reagent_dispensers/W = target
		var/list/badchem = W.reagents.reagent_list&blacklist
		if(badchem.len)
			visible_message("<span class='warning'>[W] refuses to refill [src]!</span>")
			return 1
		var/transferred = W.reagents.trans_to(src, max_chem)
		if(transferred > 0)
			user << "<span class='notice'>\The [src] has been refilled by [transferred] units.</span>"
			playsound(src.loc, 'sound/effects/refill.ogg', 50, 1, -6)
			for(var/datum/reagent/water/R in reagents.reagent_list)
				R.cooling_temperature = cooling_power
		else
			user << "<span class='warning'>\The [W] is empty!</span>"
		safety = safety_save
		return 1
	else
		return 0

/obj/item/weapon/extinguisher/afterattack(atom/target, mob/user , flag)
	//TODO; Add support for reagents in water.
	if(target.loc == user || !check_allowed_items(target)) //No more spraying yourself when putting your extinguisher away
		return
	var/Refill = AttemptRefill(target, user)
	if(Refill)
		return
	if (!safety)
		if (src.reagents.total_volume < 1)
			usr << "<span class='warning'>\The [src] is empty!</span>"
			return

		if (world.time < src.last_use + 20)
			return

		src.last_use = world.time

		playsound(src.loc, 'sound/effects/extinguish.ogg', 75, 1, -3)

		var/direction = get_dir(src,target)

		if(usr.buckled && isobj(usr.buckled) && !usr.buckled.anchored)
			spawn(0)
				var/obj/B = usr.buckled
				var/movementdirection = turn(direction,180)
				step(B, movementdirection)
				sleep(1)
				step(B, movementdirection)
				sleep(1)
				step(B, movementdirection)
				sleep(1)
				step(B, movementdirection)
				sleep(2)
				step(B, movementdirection)
				sleep(2)
				step(B, movementdirection)
				sleep(3)
				step(B, movementdirection)
				sleep(3)
				step(B, movementdirection)
				sleep(3)
				step(B, movementdirection)

		else user.newtonian_move(turn(direction, 180))

		var/turf/T = get_turf(target)
		var/turf/T1 = get_step(T,turn(direction, 90))
		var/turf/T2 = get_step(T,turn(direction, -90))
		var/list/the_targets = list(T,T1,T2)
		if(precision)
			var/turf/T3 = get_step(T1, turn(direction, 90))
			var/turf/T4 = get_step(T2,turn(direction, -90))
			the_targets = list(T,T1,T2,T3,T4)

		for(var/a=0, a<5, a++)
			spawn(0)
				var/obj/effect/effect/water/W = new /obj/effect/effect/water(get_turf(src))
				var/turf/my_target = pick(the_targets)
				if(precision)
					the_targets -= my_target
				var/datum/reagents/R = new/datum/reagents(5)
				if(!W) return
				W.reagents = R
				R.my_atom = W
				if(!W || !src) return
				src.reagents.trans_to(W,1)
				for(var/b=0, b<power, b++)
					step_towards(W,my_target)
					if(!W || !W.reagents) return
					W.reagents.reaction(get_turf(W))
					for(var/atom/atm in get_turf(W))
						if(!W) return
						W.reagents.reaction(atm, TOUCH) // so it actually puts peeps out with water etc
					if(W.loc == my_target) break
					if(!W.reagents.total_volume) break
					sleep(2)

	else
		return ..()

/obj/item/weapon/extinguisher/AltClick(mob/user)
	EmptyExtinguisher(user)

/obj/item/weapon/extinguisher/proc/EmptyExtinguisher(var/mob/user)
	if(loc == user && reagents.total_volume)
		reagents.clear_reagents()
		user.visible_message("[user] empties out \the [src] onto the floor using the release valve.", "<span class='info'>You quietly empty out \the [src] using its release valve.</span>")
	return

/obj/item/weapon/extinguisher/autolathe_crafted(obj/machinery/autolathe/A)
	reagents.clear_reagents()
	return

{'fraction_non_alphanumeric': 0.13720827829150153, 'fraction_numerical': 0.015499779832672832, 'mean_word_length': 3.948148148148148, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4815702', 'n_tokens_mistral': 4953, 'n_tokens_neox': 4232, 'n_words': 915}