Files
Bubberstation/code/game/objects/items/storage/fancy.dm
SkyratBot 232ac4b6ee [MIRROR] Making the fuck you coupon trigger only once, take two (#26866)
* Making the fuck you coupon trigger only once, take two (#81953)

## About The Pull Request

So a previous pr attempted to fix the fuck you coupon, by adding 1 to
the arguments.
```dm
(tgstation/code/modules/cargo/coupon.dm, line 87)
cursed.AddComponent(/datum/component/omen, 1)
```
But this was setting the `vessel` rather than the `incidents_left`
argument to 1.
```dm
(tgstation/code/datums/components/omen.dm, line 20)
/datum/component/omen/Initialize(obj/vessel, incidents_left, luck_mod, damage_mod)
```
Moving this argument over one fixes the issue.
```dm
cursed.AddComponent(/datum/component/omen, null, 1)
```

However! We're now skipping over the `vessel` value, which is used to
burn up a curse's vessel once the curse is expended.
Setting this to `src` rather than `null` means the fuck you coupon
actually gets 'expended', which I think it better than just using `null`
or `incidents_left = 1`. The coupon's useless once it's done, and this
way it's cooler anyway.
For consistency, we then also add this behaviour to when the coupon
gives you a heart attack instead.

Then! I noticed there was a _second_ bug with fuck you coupons, where it
would stop prematurely if the location wasn't a mob.
```dm
(tgstation/code/modules/cargo/coupon.dm, line 80-81)
if(!ismob(loc))
	return FALSE
```
However, this also happens when you don't have a free hand for it to put
the coupon in, and thus entirely negating the curse and just giving you
a useless fuck you coupon.
We fix this by just adding a `user` argument to `generate`, which it
prefers to use when available, and is set to the user ripping off the
coupon in the first place.
## Why It's Good For The Game

Fixes #81946.
As fuck you coupons are pretty much useless after expending their curse,
and we have to add the vessel value anyway, I thought it'd be more
fitting to add the coupon as the vessel rather than just putting in
null. Then, for consistency, I felt it'd be best to make them *also*
burn when giving you a heart attack when you already have a curse.
Y'know, it's expending the coupon for it's one-time fuck you!

Also fixes fuck you coupons not actually applying their curse if you
didn't have any free hands for it to put the coupon in when ripping it
off.
## Changelog
🆑
fix: Fuck you coupons ACTUALLY trigger only once again. As a
consequence, they also burn up when expended for their one-time fuck
you.
fix: Fuck you coupons work regardless of whether you had a free hand or
not.
/🆑

* Making the fuck you coupon trigger only once, take two

---------

Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com>
2024-03-13 19:42:55 -04:00

601 lines
18 KiB
Plaintext

/*
* The 'fancy' path is for objects like donut boxes that show how many items are in the storage item on the sprite itself
* .. Sorry for the shitty path name, I couldnt think of a better one.
*
* Contains:
* Donut Box
* Egg Box
* Candle Box
* Cigarette Box
* Rolling Paper Pack
* Cigar Case
* Heart Shaped Box w/ Chocolates
* Coffee condiments display
*/
/obj/item/storage/fancy
icon = 'icons/obj/food/containers.dmi'
resistance_flags = FLAMMABLE
custom_materials = list(/datum/material/cardboard = SHEET_MATERIAL_AMOUNT)
/// Used by examine to report what this thing is holding.
var/contents_tag = "errors"
/// What type of thing to fill this storage with.
var/spawn_type
/// How many of the things to fill this storage with.
var/spawn_count = 0
/// Whether the container is open, always open, or closed
var/open_status = FANCY_CONTAINER_CLOSED
/// What material do we get when we fold this box?
var/foldable_result = /obj/item/stack/sheet/cardboard
/// Whether it supports open and closed state icons.
var/has_open_closed_states = TRUE
/obj/item/storage/fancy/Initialize(mapload)
. = ..()
atom_storage.max_slots = spawn_count
/obj/item/storage/fancy/PopulateContents()
if(!spawn_type)
return
for(var/i = 1 to spawn_count)
var/thing_in_box = pick(spawn_type)
new thing_in_box(src)
/obj/item/storage/fancy/update_icon_state()
icon_state = "[base_icon_state][has_open_closed_states && open_status ? contents.len : null]"
return ..()
/obj/item/storage/fancy/examine(mob/user)
. = ..()
if(!open_status)
return
if(length(contents) == 1)
. += "There is one [contents_tag] left."
else
. += "There are [contents.len <= 0 ? "no" : "[contents.len]"] [contents_tag]s left."
/obj/item/storage/fancy/attack_self(mob/user)
if(open_status == FANCY_CONTAINER_CLOSED)
open_status = FANCY_CONTAINER_OPEN
else if(open_status == FANCY_CONTAINER_OPEN)
open_status = FANCY_CONTAINER_CLOSED
update_appearance()
. = ..()
if(contents.len)
return
if(!foldable_result || (flags_1 & HOLOGRAM_1))
return
var/obj/item/result = new foldable_result(user.drop_location())
balloon_alert(user, "folded")
// Gotta delete first, so then the cardboard appears in the same hand
qdel(src)
user.put_in_hands(result)
/obj/item/storage/fancy/Exited(atom/movable/gone, direction)
. = ..()
if(open_status == FANCY_CONTAINER_CLOSED)
open_status = FANCY_CONTAINER_OPEN
update_appearance()
/obj/item/storage/fancy/Entered(atom/movable/arrived, atom/old_loc, list/atom/old_locs)
. = ..()
if(open_status == FANCY_CONTAINER_CLOSED)
open_status = FANCY_CONTAINER_OPEN
update_appearance()
#define DONUT_INBOX_SPRITE_WIDTH 4
/*
* Donut Box
*/
/obj/item/storage/fancy/donut_box
name = "donut box"
desc = "Mmm. Donuts."
icon = 'icons/obj/food/donuts.dmi'
icon_state = "donutbox_open" //composite image used for mapping
base_icon_state = "donutbox"
spawn_type = /obj/item/food/donut/plain
spawn_count = 6
open_status = TRUE
appearance_flags = KEEP_TOGETHER|LONG_GLIDE
custom_premium_price = PAYCHECK_COMMAND * 1.75
contents_tag = "donut"
/obj/item/storage/fancy/donut_box/Initialize(mapload)
. = ..()
atom_storage.set_holdable(/obj/item/food/donut)
/obj/item/storage/fancy/donut_box/PopulateContents()
. = ..()
update_appearance()
/obj/item/storage/fancy/donut_box/update_icon_state()
. = ..()
icon_state = "[base_icon_state][open_status ? "_inner" : null]"
/obj/item/storage/fancy/donut_box/update_overlays()
. = ..()
if(!open_status)
return
var/donuts = 0
for(var/_donut in contents)
var/obj/item/food/donut/donut = _donut
if (!istype(donut))
continue
. += image(icon = initial(icon), icon_state = donut.in_box_sprite(), pixel_x = donuts * DONUT_INBOX_SPRITE_WIDTH)
donuts += 1
. += image(icon = initial(icon), icon_state = "[base_icon_state]_top")
#undef DONUT_INBOX_SPRITE_WIDTH
/*
* Egg Box
*/
/obj/item/storage/fancy/egg_box
icon = 'icons/obj/food/containers.dmi'
inhand_icon_state = "eggbox"
icon_state = "eggbox"
base_icon_state = "eggbox"
lefthand_file = 'icons/mob/inhands/items/food_lefthand.dmi'
righthand_file = 'icons/mob/inhands/items/food_righthand.dmi'
name = "egg box"
desc = "A carton for containing eggs."
spawn_type = /obj/item/food/egg
spawn_count = 12
contents_tag = "egg"
/obj/item/storage/fancy/egg_box/Initialize(mapload)
. = ..()
atom_storage.set_holdable(/obj/item/food/egg)
/*
* Fertile Egg Box
*/
/obj/item/storage/fancy/egg_box/fertile
name = "fertile egg box"
desc = "Only one thing here is fertile, and it's not the eggs."
spawn_type = /obj/item/food/egg/fertile
spawn_count = 6
/*
* Candle Box
*/
/obj/item/storage/fancy/candle_box
name = "candle pack"
desc = "A pack of red candles."
icon = 'icons/obj/candle.dmi'
icon_state = "candlebox5"
base_icon_state = "candlebox"
inhand_icon_state = null
worn_icon_state = "cigpack"
throwforce = 2
slot_flags = ITEM_SLOT_BELT
spawn_type = /obj/item/flashlight/flare/candle
spawn_count = 5
open_status = FANCY_CONTAINER_ALWAYS_OPEN
contents_tag = "candle"
/obj/item/storage/fancy/candle_box/Initialize(mapload)
. = ..()
atom_storage.set_holdable(/obj/item/flashlight/flare/candle)
////////////
//CIG PACK//
////////////
/obj/item/storage/fancy/cigarettes
name = "\improper Space Cigarettes packet"
desc = "The most popular brand of cigarettes, sponsors of the Space Olympics. On the back it advertises to be the only brand that can be smoked in the vaccum of space."
icon = 'icons/obj/cigarettes.dmi'
icon_state = "cig"
inhand_icon_state = "cigpacket"
worn_icon_state = "cigpack"
base_icon_state = "cig"
w_class = WEIGHT_CLASS_TINY
throwforce = 0
slot_flags = ITEM_SLOT_BELT
spawn_type = /obj/item/clothing/mask/cigarette/space_cigarette
spawn_count = 6
custom_price = PAYCHECK_CREW
age_restricted = TRUE
contents_tag = "cigarette"
///for cigarette overlay
var/candy = FALSE
/// Does this cigarette packet come with a coupon attached?
var/spawn_coupon = TRUE
/// For VV'ing, set this to true if you want to force the coupon to give an omen
var/rigged_omen = FALSE
///Do we not have our own handling for cig overlays?
var/display_cigs = TRUE
/obj/item/storage/fancy/cigarettes/attack_self(mob/user)
if(contents.len != 0 || !spawn_coupon)
return ..()
balloon_alert(user, "ooh, free coupon")
var/obj/item/coupon/attached_coupon = new
user.put_in_hands(attached_coupon)
attached_coupon.generate(rigged_omen ? COUPON_OMEN : null, null, user)
attached_coupon = null
spawn_coupon = FALSE
name = "discarded cigarette packet"
desc = "An old cigarette packet with the back torn off, worth less than nothing now."
atom_storage.max_slots = 0
/obj/item/storage/fancy/cigarettes/Initialize(mapload)
. = ..()
atom_storage.display_contents = FALSE
atom_storage.set_holdable(list(/obj/item/clothing/mask/cigarette, /obj/item/lighter))
register_context()
/obj/item/storage/fancy/cigarettes/attack_hand_secondary(mob/user, list/modifiers)
. = ..()
quick_remove_item(/obj/item/clothing/mask/cigarette, user)
/obj/item/storage/fancy/cigarettes/AltClick(mob/user)
. = ..()
var/obj/item/lighter = locate(/obj/item/lighter) in contents
if(lighter)
quick_remove_item(lighter, user)
else
quick_remove_item(/obj/item/clothing/mask/cigarette, user)
/// Removes an item from the packet if there is one
/obj/item/storage/fancy/cigarettes/proc/quick_remove_item(obj/item/grabbies, mob/user)
var/obj/item/finger = locate(grabbies) in contents
if(finger)
atom_storage.remove_single(user, finger, drop_location())
user.put_in_hands(finger)
/obj/item/storage/fancy/cigarettes/add_context(atom/source, list/context, obj/item/held_item, mob/user)
. = ..()
if(locate(/obj/item/lighter) in contents)
context[SCREENTIP_CONTEXT_ALT_LMB] = "Remove lighter"
context[SCREENTIP_CONTEXT_RMB] = "Remove [contents_tag]"
return CONTEXTUAL_SCREENTIP_SET
/obj/item/storage/fancy/cigarettes/examine(mob/user)
. = ..()
if(spawn_coupon)
. += span_notice("There's a coupon on the back of the pack! You can tear it off once it's empty.")
/obj/item/storage/fancy/cigarettes/update_icon_state()
. = ..()
icon_state = "[base_icon_state][contents.len ? null : "_empty"]"
/obj/item/storage/fancy/cigarettes/update_overlays()
. = ..()
if(!open_status || !contents.len)
return
. += "[icon_state]_open"
if(!display_cigs)
return
var/cig_position = 1
for(var/C in contents)
var/use_icon_state = ""
if(istype(C, /obj/item/lighter/greyscale))
use_icon_state = "lighter_in"
else if(istype(C, /obj/item/lighter))
use_icon_state = "zippo_in"
else if(candy)
use_icon_state = "candy"
else
use_icon_state = "cigarette"
. += "[use_icon_state]_[cig_position]"
cig_position++
/obj/item/storage/fancy/cigarettes/dromedaryco
name = "\improper DromedaryCo packet"
desc = "A packet of six imported DromedaryCo cancer sticks. A label on the packaging reads, \"Wouldn't a slow death make a change?\""
icon_state = "dromedary"
base_icon_state = "dromedary"
spawn_type = /obj/item/clothing/mask/cigarette/dromedary
/obj/item/storage/fancy/cigarettes/cigpack_uplift
name = "\improper Uplift Smooth packet"
desc = "Your favorite brand, now menthol flavored."
icon_state = "uplift"
base_icon_state = "uplift"
spawn_type = /obj/item/clothing/mask/cigarette/uplift
/obj/item/storage/fancy/cigarettes/cigpack_robust
name = "\improper Robust packet"
desc = "Smoked by the robust."
icon_state = "robust"
base_icon_state = "robust"
spawn_type = /obj/item/clothing/mask/cigarette/robust
/obj/item/storage/fancy/cigarettes/cigpack_robustgold
name = "\improper Robust Gold packet"
desc = "Smoked by the truly robust."
icon_state = "robustg"
base_icon_state = "robustg"
spawn_type = /obj/item/clothing/mask/cigarette/robustgold
/obj/item/storage/fancy/cigarettes/cigpack_carp
name = "\improper Carp Classic packet"
desc = "Since 2313."
icon_state = "carp"
base_icon_state = "carp"
spawn_type = /obj/item/clothing/mask/cigarette/carp
/obj/item/storage/fancy/cigarettes/cigpack_syndicate
name = "cigarette packet"
desc = "An obscure brand of cigarettes."
icon_state = "syndie"
base_icon_state = "syndie"
spawn_type = /obj/item/clothing/mask/cigarette/syndicate
/obj/item/storage/fancy/cigarettes/cigpack_midori
name = "\improper Midori Tabako packet"
desc = "You can't understand the runes, but the packet smells funny."
icon_state = "midori"
base_icon_state = "midori"
spawn_type = /obj/item/clothing/mask/cigarette/rollie/nicotine
/obj/item/storage/fancy/cigarettes/cigpack_candy
name = "\improper Timmy's First Candy Smokes packet"
desc = "Unsure about smoking? Want to bring your children safely into the family tradition? Look no more with this special packet! Includes 100%* Nicotine-Free candy cigarettes."
icon_state = "candy"
base_icon_state = "candy"
contents_tag = "candy cigarette"
spawn_type = /obj/item/clothing/mask/cigarette/candy
candy = TRUE
age_restricted = FALSE
/obj/item/storage/fancy/cigarettes/cigpack_candy/Initialize(mapload)
. = ..()
if(prob(7))
spawn_type = /obj/item/clothing/mask/cigarette/candy/nicotine //uh oh!
/obj/item/storage/fancy/cigarettes/cigpack_shadyjims
name = "\improper Shady Jim's Super Slims packet"
desc = "Is your weight slowing you down? Having trouble running away from gravitational singularities? Can't stop stuffing your mouth? Smoke Shady Jim's Super Slims and watch all that fat burn away. Guaranteed results!"
icon_state = "shadyjim"
base_icon_state = "shadyjim"
spawn_type = /obj/item/clothing/mask/cigarette/shadyjims
/obj/item/storage/fancy/cigarettes/cigpack_xeno
name = "\improper Xeno Filtered packet"
desc = "Loaded with 100% pure slime. And also nicotine."
icon_state = "slime"
base_icon_state = "slime"
spawn_type = /obj/item/clothing/mask/cigarette/xeno
/obj/item/storage/fancy/cigarettes/cigpack_cannabis
name = "\improper Freak Brothers' Special packet"
desc = "A label on the packaging reads, \"Endorsed by Phineas, Freddy and Franklin.\""
icon_state = "midori"
base_icon_state = "midori"
spawn_type = /obj/item/clothing/mask/cigarette/rollie/cannabis
/obj/item/storage/fancy/cigarettes/cigpack_mindbreaker
name = "\improper Leary's Delight packet"
desc = "Banned in over 36 galaxies."
icon_state = "shadyjim"
base_icon_state = "shadyjim"
spawn_type = /obj/item/clothing/mask/cigarette/rollie/mindbreaker
/obj/item/storage/fancy/rollingpapers
name = "rolling paper pack"
desc = "A pack of Nanotrasen brand rolling papers."
w_class = WEIGHT_CLASS_TINY
icon = 'icons/obj/cigarettes.dmi'
icon_state = "cig_paper_pack"
base_icon_state = "cig_paper_pack"
contents_tag = "rolling paper"
spawn_type = /obj/item/rollingpaper
spawn_count = 10
custom_price = PAYCHECK_LOWER
has_open_closed_states = FALSE
/obj/item/storage/fancy/rollingpapers/Initialize(mapload)
. = ..()
atom_storage.set_holdable(/obj/item/rollingpaper)
/obj/item/storage/fancy/rollingpapers/update_overlays()
. = ..()
if(!contents.len)
. += "[base_icon_state]_empty"
/////////////
//CIGAR BOX//
/////////////
/obj/item/storage/fancy/cigarettes/cigars
name = "\improper premium cigar case"
desc = "A case of premium cigars. Very expensive."
icon = 'icons/obj/cigarettes.dmi'
icon_state = "cigarcase"
base_icon_state = "cigarcase"
w_class = WEIGHT_CLASS_NORMAL
contents_tag = "premium cigar"
spawn_type = /obj/item/clothing/mask/cigarette/cigar
spawn_count = 5
spawn_coupon = FALSE
display_cigs = FALSE
/obj/item/storage/fancy/cigarettes/cigars/Initialize(mapload)
. = ..()
atom_storage.set_holdable(/obj/item/clothing/mask/cigarette/cigar)
/obj/item/storage/fancy/cigarettes/cigars/update_icon_state()
. = ..()
//reset any changes the parent call may have made
icon_state = base_icon_state
/obj/item/storage/fancy/cigarettes/cigars/update_overlays()
. = ..()
if(!open_status)
return
var/cigar_position = 1 //generate sprites for cigars in the box
for(var/obj/item/clothing/mask/cigarette/cigar/smokes in contents)
. += "[smokes.icon_off]_[cigar_position]"
cigar_position++
/obj/item/storage/fancy/cigarettes/cigars/cohiba
name = "\improper Cohiba Robusto cigar case"
desc = "A case of imported Cohiba cigars, renowned for their strong flavor."
icon_state = "cohibacase"
base_icon_state = "cohibacase"
spawn_type = /obj/item/clothing/mask/cigarette/cigar/cohiba
/obj/item/storage/fancy/cigarettes/cigars/havana
name = "\improper premium Havanian cigar case"
desc = "A case of classy Havanian cigars."
icon_state = "cohibacase"
base_icon_state = "cohibacase"
spawn_type = /obj/item/clothing/mask/cigarette/cigar/havana
/*
* Heart Shaped Box w/ Chocolates
*/
/obj/item/storage/fancy/heart_box
name = "heart-shaped box"
desc = "A heart-shaped box for holding tiny chocolates."
icon = 'icons/obj/food/containers.dmi'
inhand_icon_state = "chocolatebox"
icon_state = "chocolatebox"
base_icon_state = "chocolatebox"
lefthand_file = 'icons/mob/inhands/items/food_lefthand.dmi'
righthand_file = 'icons/mob/inhands/items/food_righthand.dmi'
contents_tag = "chocolate"
spawn_type = list(
/obj/item/food/bonbon,
/obj/item/food/bonbon/chocolate_truffle,
/obj/item/food/bonbon/caramel_truffle,
/obj/item/food/bonbon/peanut_truffle,
/obj/item/food/bonbon/peanut_butter_cup,
)
spawn_count = 8
/obj/item/storage/fancy/heart_box/Initialize(mapload)
. = ..()
atom_storage.set_holdable(/obj/item/food/bonbon)
/obj/item/storage/fancy/nugget_box
name = "nugget box"
desc = "A cardboard box used for holding chicken nuggies."
icon = 'icons/obj/food/containers.dmi'
icon_state = "nuggetbox"
base_icon_state = "nuggetbox"
contents_tag = "nugget"
spawn_type = /obj/item/food/nugget
spawn_count = 6
/obj/item/storage/fancy/nugget_box/Initialize(mapload)
. = ..()
atom_storage.set_holdable(/obj/item/food/nugget)
/*
* Jar of pickles
*/
/obj/item/storage/fancy/pickles_jar
icon = 'icons/obj/food/containers.dmi'
icon_state = "pickles"
base_icon_state = "pickles"
name = "pickles"
desc = "A jar for containing pickles."
spawn_type = /obj/item/food/pickle
spawn_count = 10
contents_tag = "pickle"
foldable_result = /obj/item/reagent_containers/cup/beaker/large
custom_materials = list(/datum/material/glass = SHEET_MATERIAL_AMOUNT)
open_status = FANCY_CONTAINER_ALWAYS_OPEN
has_open_closed_states = FALSE
/obj/item/storage/fancy/pickles_jar/Initialize(mapload)
. = ..()
atom_storage.set_holdable(/obj/item/food/pickle)
/obj/item/storage/fancy/pickles_jar/update_icon_state()
. = ..()
if(!contents.len)
icon_state = "[base_icon_state]_empty"
else
if(contents.len < 5)
icon_state = "[base_icon_state]_[contents.len]"
else
icon_state = base_icon_state
/*
* Coffee condiments display
*/
/obj/item/storage/fancy/coffee_condi_display
icon = 'icons/obj/food/containers.dmi'
icon_state = "coffee_condi_display"
base_icon_state = "coffee_condi_display"
name = "coffee condiments display"
desc = "A neat small wooden box, holding all your favorite coffee condiments."
contents_tag = "coffee condiment"
custom_materials = list(/datum/material/wood = SHEET_MATERIAL_AMOUNT/2)
resistance_flags = FLAMMABLE
foldable_result = /obj/item/stack/sheet/mineral/wood
open_status = FANCY_CONTAINER_ALWAYS_OPEN
has_open_closed_states = FALSE
/obj/item/storage/fancy/coffee_condi_display/Initialize(mapload)
. = ..()
atom_storage.max_slots = 14
atom_storage.set_holdable(list(
/obj/item/reagent_containers/condiment/pack/sugar,
/obj/item/reagent_containers/condiment/creamer,
/obj/item/reagent_containers/condiment/pack/astrotame,
/obj/item/reagent_containers/condiment/chocolate,
))
/obj/item/storage/fancy/coffee_condi_display/update_overlays()
. = ..()
var/has_sugar = FALSE
var/has_sweetener = FALSE
var/has_creamer = FALSE
var/has_chocolate = FALSE
for(var/thing in contents)
if(istype(thing, /obj/item/reagent_containers/condiment/pack/sugar))
has_sugar = TRUE
else if(istype(thing, /obj/item/reagent_containers/condiment/pack/astrotame))
has_sweetener = TRUE
else if(istype(thing, /obj/item/reagent_containers/condiment/creamer))
has_creamer = TRUE
else if(istype(thing, /obj/item/reagent_containers/condiment/chocolate))
has_chocolate = TRUE
if (has_sugar)
. += "condi_display_sugar"
if (has_sweetener)
. += "condi_display_sweetener"
if (has_creamer)
. += "condi_display_creamer"
if (has_chocolate)
. += "condi_display_chocolate"
/obj/item/storage/fancy/coffee_condi_display/PopulateContents()
for(var/i in 1 to 4)
new /obj/item/reagent_containers/condiment/pack/sugar(src)
for(var/i in 1 to 3)
new /obj/item/reagent_containers/condiment/pack/astrotame(src)
for(var/i in 1 to 4)
new /obj/item/reagent_containers/condiment/creamer(src)
for(var/i in 1 to 3)
new /obj/item/reagent_containers/condiment/chocolate(src)
update_appearance()