Skip to content

Commit

Permalink
Allows you to smoke cigarettes while not wearing a space helmet (tgst…
Browse files Browse the repository at this point in the history
…ation#78202)

## About The Pull Request

Fixes tgstation#78199 
PR tgstation#78122 (ef44be8) was intended to allow you to smoke cigarettes in space if you
have an oxygenated helmet on.
What it _actually_ did was make it so you can _only_ smoke cigarettes if
you have an oxygenated helmet on, regardless of whether or not you are
in space (or if you inject them with liquid oxygen).

I moved the shared check into a proc to reduce duplicate code and fixed
the logic.

## Changelog

:cl:
fix: It is now possible to smoke cigarettes even if you aren't wearing a
safety helmet
/:cl:
  • Loading branch information
Jacquerel authored Sep 9, 2023
1 parent 0b30027 commit 9cd3bd6
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions code/game/objects/items/cigs_lighters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -213,22 +213,27 @@ CIGARETTE PACKETS ARE IN FANCY.DM
if(!lighting_text)
return ..()

var/mob/living/carbon/carbuser = user

if(!istype(carbuser))
carbuser = null

if(!reagents.has_reagent(/datum/reagent/oxygen)) //cigarettes need oxygen
var/datum/gas_mixture/air = return_air()
if(!air || !air.has_gas(/datum/gas/oxygen, 1) || !carbuser?.can_breathe_helmet()) //or oxygen on a tile to burn
to_chat(user, span_notice("Your [name] needs a source of oxygen to burn."))
return ..()
if(!check_oxygen(user)) //cigarettes need oxygen
balloon_alert(user, "no air!")
return ..()

if(smoketime > 0)
light(lighting_text)
else
to_chat(user, span_warning("There is nothing to smoke!"))

/// Checks that we have enough air to smoke
/obj/item/clothing/mask/cigarette/proc/check_oxygen(mob/user)
if (reagents.has_reagent(/datum/reagent/oxygen))
return TRUE
var/datum/gas_mixture/air = return_air()
if (!isnull(air) && air.has_gas(/datum/gas/oxygen, 1))
return TRUE
if (!iscarbon(user))
return FALSE
var/mob/living/carbon/the_smoker = user
return the_smoker.can_breathe_helmet()

/obj/item/clothing/mask/cigarette/afterattack(obj/item/reagent_containers/cup/glass, mob/user, proximity)
. = ..()
if(!proximity || lit) //can't dip if cigarette is lit (it will heat the reagents in the glass instead)
Expand Down Expand Up @@ -354,18 +359,9 @@ CIGARETTE PACKETS ARE IN FANCY.DM
var/mob/living/user = isliving(loc) ? loc : null
user?.ignite_mob()

var/mob/living/carbon/carbuser
if(user)
carbuser = user

if(carbuser && !istype(carbuser))
carbuser = null

if(!reagents.has_reagent(/datum/reagent/oxygen)) //cigarettes need oxygen
var/datum/gas_mixture/air = return_air()
if(!air || !air.has_gas(/datum/gas/oxygen, 1) || !carbuser?.can_breathe_helmet()) //or oxygen on a tile to burn
extinguish()
return
if(!check_oxygen(user))
extinguish()
return

smoketime -= seconds_per_tick * (1 SECONDS)
if(smoketime <= 0)
Expand Down

0 comments on commit 9cd3bd6

Please sign in to comment.