From 720434df777e330ed8acb6ee5602b9863fd8d289 Mon Sep 17 00:00:00 2001 From: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Date: Thu, 25 May 2023 19:08:23 -0500 Subject: [PATCH] Fixes being unable to spraypaint (#75635) ## About The Pull Request `.atom_colours[atom_colours]` seems like a copy paste error. I assume it was either intending to check for same color, or check washable color for same color. So I put in both ## Changelog :cl: Melbert fix: Fixed being unable to spraypaint things /:cl: --- code/game/atoms.dm | 17 +++++++++++++++++ code/game/objects/items/crayons.dm | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/code/game/atoms.dm b/code/game/atoms.dm index d77f1a3b138..8f484ef43c2 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -1186,6 +1186,23 @@ atom_colours[colour_priority] = null update_atom_colour() +/** + * Checks if this atom has the passed color + * Can optionally be supplied with a range of priorities, IE only checking "washable" or above + */ +/atom/proc/is_atom_colour(looking_for_color, min_priority_index = 1, max_priority_index = COLOUR_PRIORITY_AMOUNT) + // make sure uppertext hex strings don't mess with lowertext hex strings + looking_for_color = lowertext(looking_for_color) + + if(!LAZYLEN(atom_colours)) + // no atom colors list has been set up, just check the color var + return lowertext(color) == looking_for_color + + for(var/i in min_priority_index to max_priority_index) + if(lowertext(atom_colours[i]) == looking_for_color) + return TRUE + + return FALSE ///Resets the atom's color to null, and then sets it to the highest priority colour available /atom/proc/update_atom_colour() diff --git a/code/game/objects/items/crayons.dm b/code/game/objects/items/crayons.dm index 724b35b80b5..34b60edef13 100644 --- a/code/game/objects/items/crayons.dm +++ b/code/game/objects/items/crayons.dm @@ -824,8 +824,8 @@ var/fraction = min(1, . / reagents.maximum_volume) reagents.expose(carbon_target, VAPOR, fraction * volume_multiplier) - else if(actually_paints && target.atom_colours[atom_colours] == paint_color) - balloon_alert(user, "[target.p_theyre()] already of that color.") + else if(actually_paints && target.is_atom_colour(paint_color, min_priority_index = WASHABLE_COLOUR_PRIORITY)) + balloon_alert(user, "[target.p_theyre()] already that color!") return FALSE if(ismob(target) && (HAS_TRAIT(target, TRAIT_SPRAY_PAINTABLE)))