From db361176cf4143d819442c2214be75d79db49d74 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 31 Aug 2023 03:43:10 +0200 Subject: [PATCH] [MIRROR] Cursed Slot Machine Fixes [MDB IGNORE] (#23420) * Cursed Slot Machine Fixes (#77989) ## About The Pull Request A lot of these were stuff I did in response to reviews but apparently didn't test extremely thoroughly. My bad. * The proc for checking if the machine is in use is split out into its own thing for clarity, and for potential reuse. * The signal is no longer fucked up so you can actually get more than one curse out of the slot machine as intended. * Admin heals (and admin heals only) can remove the status effect. This is just in case someone fucks up a variable when running an event and wants to quickly heal some people while they varedit it to actually be a proper event. * Some nice code stuff while I was there, we don't need to be typecasting to human anymore so it's nice to fix that. ## Why It's Good For The Game Fixes are good. ## Changelog :cl: fix: The Cursed Slot Machine should now actually give you more than one pull. /:cl: * Cursed Slot Machine Fixes --------- Co-authored-by: san7890 --- code/datums/status_effects/debuffs/cursed.dm | 4 +- .../objects_and_mobs/cursed_slot_machine.dm | 47 ++++++++++--------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/code/datums/status_effects/debuffs/cursed.dm b/code/datums/status_effects/debuffs/cursed.dm index 2ee7266f7b9..20afa8a7ea6 100644 --- a/code/datums/status_effects/debuffs/cursed.dm +++ b/code/datums/status_effects/debuffs/cursed.dm @@ -5,6 +5,8 @@ /datum/status_effect/grouped/cursed id = "cursed" alert_type = /atom/movable/screen/alert/status_effect/cursed + remove_on_fullheal = TRUE + heal_flag_necessary = HEAL_ADMIN /// The max number of curses a target can incur with this status effect. var/max_curse_count = DEFAULT_MAX_CURSE_COUNT /// The amount of times we have been "applied" to the target. @@ -32,7 +34,7 @@ return ..() /// Checks the number of curses we have and returns information back to the slot machine. `max_curse_amount` is set by the slot machine itself. -/datum/status_effect/grouped/cursed/proc/check_curses(max_curse_amount) +/datum/status_effect/grouped/cursed/proc/check_curses(mob/user, max_curse_amount) SIGNAL_HANDLER if(curse_count >= max_curse_amount) return SLOT_MACHINE_USE_CANCEL diff --git a/code/modules/mapfluff/ruins/objects_and_mobs/cursed_slot_machine.dm b/code/modules/mapfluff/ruins/objects_and_mobs/cursed_slot_machine.dm index e85a90b783c..ab6b2bb1825 100644 --- a/code/modules/mapfluff/ruins/objects_and_mobs/cursed_slot_machine.dm +++ b/code/modules/mapfluff/ruins/objects_and_mobs/cursed_slot_machine.dm @@ -34,36 +34,18 @@ if(!ishuman(user)) return - var/mob/living/carbon/human/human_user = user - - if(in_use) - balloon_alert(human_user, "already spinning!") - return - - if(!COOLDOWN_FINISHED(src, spin_cooldown)) - to_chat(human_user, span_danger("The machine doesn't engage. You get the compulsion to try again in a few seconds.")) - return - - in_use = TRUE - - var/signal_value = SEND_SIGNAL(human_user, COMSIG_CURSED_SLOT_MACHINE_USE, max_curse_amount) - - if(signal_value & SLOT_MACHINE_USE_POSTPONE) - return - - if(signal_value & SLOT_MACHINE_USE_CANCEL) // failsafe in case we don't want to let the machine be used for some reason (like if we're maxed out on curses but not getting gibbed) - say("We're sorry, but we can no longer serve you at this establishment.") + if(!check_and_set_usage(user)) return user.visible_message( - span_warning("[human_user] pulls [src]'s lever with a glint in [user.p_their()] eyes!"), + span_warning("[user] pulls [src]'s lever with a glint in [user.p_their()] eyes!"), span_warning("You feel a draining as you pull the lever, but you know it'll be worth it."), ) icon_screen = "slots_screen_working" update_appearance() playsound(src, 'sound/lavaland/cursed_slot_machine.ogg', 50, FALSE) - addtimer(CALLBACK(src, PROC_REF(determine_victor), human_user), 5 SECONDS) + addtimer(CALLBACK(src, PROC_REF(determine_victor), user), 5 SECONDS) /obj/structure/cursed_slot_machine/update_overlays() . = ..() @@ -71,11 +53,32 @@ . += mutable_appearance(icon, overlay_state) . += emissive_appearance(icon, overlay_state, src) -/obj/structure/cursed_slot_machine/proc/determine_victor(mob/living/user) +/// Validates that the user can use the cursed slot machine. User is the person using the slot machine. Returns TRUE if we can, FALSE otherwise. +/obj/structure/cursed_slot_machine/proc/check_and_set_usage(mob/living/carbon/human/user) + if(in_use) + balloon_alert_to_viewers("already spinning!") + return FALSE + + var/signal_value = SEND_SIGNAL(user, COMSIG_CURSED_SLOT_MACHINE_USE, max_curse_amount) + + if(!COOLDOWN_FINISHED(src, spin_cooldown) || (signal_value & SLOT_MACHINE_USE_POSTPONE)) + to_chat(user, span_danger("The machine doesn't engage. You get the compulsion to try again in a few seconds.")) + return FALSE + + if(signal_value & SLOT_MACHINE_USE_CANCEL) // failsafe in case we don't want to let the machine be used for some reason (like if we're maxed out on curses but not getting gibbed) + say("We're sorry, but we can no longer serve you at this establishment.") + return FALSE + + in_use = TRUE + return TRUE + +/obj/structure/cursed_slot_machine/proc/determine_victor(mob/living/carbon/human/user) icon_screen = initial(icon_screen) update_appearance() + in_use = FALSE COOLDOWN_START(src, spin_cooldown, cooldown_length) + if(!prob(win_prob)) if(status_effect_on_roll && isnull(user.has_status_effect(/datum/status_effect/grouped/cursed))) user.apply_status_effect(/datum/status_effect/grouped/cursed)