From c8e76795eaf02369eff1652cb80f4f65b5193584 Mon Sep 17 00:00:00 2001 From: Spookerton <918997+Spookerton@users.noreply.github.com> Date: Wed, 21 Feb 2024 20:29:54 +0300 Subject: [PATCH] [MIRROR] rsf improvement pass --- code/game/objects/items/weapons/RSF.dm | 105 +++++++++++-------------- test/check-paths.sh | 2 +- 2 files changed, 48 insertions(+), 59 deletions(-) diff --git a/code/game/objects/items/weapons/RSF.dm b/code/game/objects/items/weapons/RSF.dm index 66b94659ec02a..46564e814b373 100644 --- a/code/game/objects/items/weapons/RSF.dm +++ b/code/game/objects/items/weapons/RSF.dm @@ -4,14 +4,17 @@ icon = 'icons/obj/tools/rcd.dmi' icon_state = "rcd" - var/const/MODE_CIGARETTE = "Cigarette" - var/const/MODE_GLASS = "Drinking Glass" - var/const/MODE_PAPER = "Paper" - var/const/MODE_PEN = "Pen" - var/const/MODE_DICE = "Dice Pack" + /// The things an RSF can create as a map of {"name" = [radial icon, energy cost, path]}. + var/static/list/modes = list( + "Cigarette" = list("cigarette", 10, /obj/item/clothing/mask/smokable/cigarette), + "Drinking Glass" = list("glass", 50, /obj/item/reagent_containers/food/drinks/glass2), + "Paper" = list("paper", 10, /obj/item/paper), + "Pen" = list("pen", 50, /obj/item/pen), + "Dice Pack" = list("dicebag", 200, /obj/item/storage/pill_bottle/dice) + ) - /// The current mode of the RSF. One of the MODE_* constants. - var/mode = MODE_CIGARETTE + /// The current mode of the RSF. One of the keys in the modes list. + var/mode /// The maximum amount of matter the RSF can hold when not a robot RSF. var/max_stored_matter = 30 @@ -20,47 +23,22 @@ var/stored_matter -/obj/item/rsf/Initialize() - . = ..() - stored_matter = max_stored_matter - - /obj/item/rsf/examine(mob/user, distance) . = ..() if (distance <= 0) to_chat(user, "It currently holds [stored_matter]/[max_stored_matter] fabrication units.") -/obj/item/rsf/attackby(obj/item/item, mob/living/user) - if (istype(item, /obj/item/rcd_ammo)) - var/obj/item/rcd_ammo/ammo = item - if (stored_matter >= max_stored_matter) - to_chat(user, "The RSF can't hold any more matter.") - return TRUE - var/use_amount = min(ammo.remaining, max_stored_matter - stored_matter) - stored_matter += use_amount - ammo.remaining -= use_amount - if (ammo.remaining <= 0) - qdel(ammo) - playsound(loc, 'sound/machines/click.ogg', 10, TRUE) - to_chat(user, "The RSF now holds [stored_matter]/[max_stored_matter] fabrication units.") - return TRUE - return ..() - - /obj/item/rsf/attack_self(mob/living/user) - var/list/options = list() - options[MODE_CIGARETTE] = mutable_appearance('icons/screen/radial.dmi', "cigarette") - options[MODE_GLASS] = mutable_appearance('icons/screen/radial.dmi', "glass") - options[MODE_PAPER] = mutable_appearance('icons/screen/radial.dmi', "paper") - options[MODE_PEN] = mutable_appearance('icons/screen/radial.dmi', "pen") - options[MODE_DICE] = mutable_appearance('icons/screen/radial.dmi', "dicebag") - var/choice = show_radial_menu(user, user, options, require_near = TRUE, radius = 42, tooltips = TRUE, check_locs = list(src)) + var/radial = list() + for (var/key in modes) + radial[key] = mutable_appearance('icons/screen/radial.dmi', modes[key][1]) + var/choice = show_radial_menu(user, user, radial, require_near = TRUE, radius = 42, tooltips = TRUE, check_locs = list(src)) if (!choice || !user.use_sanity_check(src)) return mode = choice - to_chat(user, SPAN_NOTICE("Changed dispending mode to \the [choice].")) - playsound(loc, 'sound/effects/pop.ogg', 50, FALSE) + to_chat(user, SPAN_NOTICE("Changed dispensing mode to \"[choice]\".")) + playsound(src, 'sound/effects/pop.ogg', 50, FALSE) /obj/item/rsf/use_before(atom/target, mob/living/user, list/click_parameters) @@ -69,30 +47,17 @@ var/turf/into = get_turf(target) if (!into) return FALSE - var/required_energy - var/obj/product - switch (mode) - if (MODE_CIGARETTE) - product = new /obj/item/clothing/mask/smokable/cigarette - required_energy = 10 - if (MODE_GLASS) - product = new /obj/item/reagent_containers/food/drinks/glass2 - required_energy = 50 - if (MODE_PAPER) - product = new /obj/item/paper - required_energy = 10 - if (MODE_PEN) - product = new /obj/item/pen - required_energy = 50 - if (MODE_DICE) - product = new /obj/item/storage/pill_bottle/dice - required_energy = 200 + if (!(mode in modes)) + to_chat(user, SPAN_WARNING("\The [src] is not set to dispense anything.")) + return TRUE + var/details = modes[mode] if (isrobot(user)) var/mob/living/silicon/robot/robot = user if (robot.stat || !robot.cell) to_chat(user, SPAN_WARNING("You're in no condition to do that.")) return TRUE - if (!robot.cell.checked_use(required_energy)) + var/cost = details[2] + if (!robot.cell.checked_use(cost)) to_chat(user, SPAN_WARNING("You don't have enough energy to do that.")) return TRUE else if (stored_matter < 1) @@ -101,6 +66,30 @@ else stored_matter-- playsound(loc, 'sound/machines/click.ogg', 10, TRUE) - to_chat(user, "Dispensing [product ? product : "product"]...") + var/obj/product = details[3] + product = new product + to_chat(user, "Dispensing \a [product]...") product.dropInto(into) return TRUE + + +/obj/item/rsf/use_tool(obj/item/item, mob/living/user, list/click_params) + if (istype(item, /obj/item/rcd_ammo)) + var/obj/item/rcd_ammo/ammo = item + if (stored_matter >= max_stored_matter) + to_chat(user, "The RSF can't hold any more matter.") + return TRUE + var/use_amount = min(ammo.remaining, max_stored_matter - stored_matter) + stored_matter += use_amount + ammo.remaining -= use_amount + if (ammo.remaining <= 0) + qdel(ammo) + playsound(loc, 'sound/machines/click.ogg', 10, TRUE) + to_chat(user, "The RSF now holds [stored_matter]/[max_stored_matter] fabrication units.") + return TRUE + return ..() + + +/obj/item/rsf/loaded/Initialize() + . = ..() + stored_matter = max_stored_matter diff --git a/test/check-paths.sh b/test/check-paths.sh index 627911db73978..9385e8de7e760 100755 --- a/test/check-paths.sh +++ b/test/check-paths.sh @@ -57,7 +57,7 @@ exactly 0 "simulated = 0/1" 'simulated\s*=\s*\d' -P exactly 2 "var/ in proc arguments" '(^/[^/].+/.+?\(.*?)var/' -P exactly 0 "tmp/ vars" 'var.*/tmp/' -P exactly 7 "uses of .len" '\.len\b' -P -exactly 193 "attackby() override" '\/attackby\((.*)\)' -P +exactly 192 "attackby() override" '\/attackby\((.*)\)' -P exactly 15 "uses of examine()" '[.|\s]examine\(' -P # If this fails it's likely because you used '/atom/proc/examine(mob)' instead of '/proc/examinate(mob, atom)' - Exception: An examine()-proc may call other examine()-procs exactly 7 "direct modifications of overlays list" '\boverlays((\s*[|^=+&-])|(\.(Cut)|(Add)|(Copy)|(Remove)|(Remove)))' -P exactly 0 "new/list list instantiations" 'new\s*/list' -P