From 8c98e4769c1c430eaa9cd919da171228811b7e72 Mon Sep 17 00:00:00 2001
From: kevinz000 <2003111+kevinz000@users.noreply.github.com>
Date: Tue, 27 Mar 2018 10:53:06 -0700
Subject: [PATCH] Fixes hot potato coloration (#36655)
* Fixes hot potato coloration
* wupps
---
code/game/objects/items/hot_potato.dm | 47 +++++++++++++++++++--------
1 file changed, 33 insertions(+), 14 deletions(-)
diff --git a/code/game/objects/items/hot_potato.dm b/code/game/objects/items/hot_potato.dm
index 65bfd09f9c..9777deaf6d 100644
--- a/code/game/objects/items/hot_potato.dm
+++ b/code/game/objects/items/hot_potato.dm
@@ -23,8 +23,31 @@
var/detonate_flash_range = 5
var/detonate_fire_range = 5
+ var/active = FALSE
+
var/color_val = FALSE
+ var/datum/weakref/current
+
+/obj/item/hot_potato/Destroy()
+ if(active)
+ deactivate()
+ return ..()
+
+/obj/item/hot_potato/proc/colorize(mob/target)
+ //Clear color from old target
+ if(current)
+ var/mob/M = current.resolve()
+ if(istype(M))
+ M.remove_atom_colour(FIXED_COLOUR_PRIORITY)
+ //Give to new target
+ current = null
+ //Swap colors
+ color_val = !color_val
+ if(istype(target))
+ current = WEAKREF(target)
+ target.add_atom_colour(color_val? "#ffff00" : "#00ffff", FIXED_COLOUR_PRIORITY)
+
/obj/item/hot_potato/proc/detonate()
var/atom/location = loc
location.visible_message("[src] [detonate_explosion? "explodes" : "activates"]!", "[src] activates! You've ran out of time!")
@@ -37,9 +60,6 @@
M.dropItemToGround(src, TRUE)
qdel(src)
-/obj/item/hot_potato/proc/is_active()
- return isnull(detonation_timerid)? FALSE : TRUE
-
/obj/item/hot_potato/attack_self(mob/user)
if(activate(timer, user))
user.visible_message("[user] squeezes [src], which promptly starts to flash red-hot colors!", "You squeeze [src], activating its countdown and attachment mechanism!",
@@ -56,19 +76,18 @@
L.SetSleeping(0)
L.SetUnconscious(0)
L.reagents.add_reagent("muscle_stimulant", CLAMP(5 - L.reagents.get_reagent_amount("muscle_stimulant"), 0, 5)) //If you don't have legs or get bola'd, tough luck!
- color_val = !color_val
- L.add_atom_colour(color_val? "#ffff00" : "#00ffff", FIXED_COLOUR_PRIORITY)
+ colorize(L)
/obj/item/hot_potato/examine(mob/user)
. = ..()
- if(is_active())
+ if(active)
to_chat(user, "[src] is flashing red-hot! You should probably get rid of it!")
if(show_timer)
to_chat(user, "[src]'s timer looks to be at [DisplayTimeText(activation_time - world.time)]!")
/obj/item/hot_potato/equipped(mob/user)
. = ..()
- if(is_active())
+ if(active)
to_chat(user, "You have a really bad feeling about [src]!")
/obj/item/hot_potato/afterattack(atom/target, mob/user, adjacent, params)
@@ -99,7 +118,7 @@
if(.)
add_logs(user, victim, "forced a hot potato with explosive variables ([detonate_explosion]-[detonate_dev_range]/[detonate_heavy_range]/[detonate_light_range]/[detonate_flash_range]/[detonate_fire_range]) onto")
user.visible_message("[user] forces [src] onto [victim]!", "You force [src] onto [victim]!", "You hear a mechanical click and a beep.")
- user.remove_atom_colour(TEMPORARY_COLOUR_PRIORITY)
+ colorize(null)
else
add_logs(user, victim, "tried to force a hot potato with explosive variables ([detonate_explosion]-[detonate_dev_range]/[detonate_heavy_range]/[detonate_light_range]/[detonate_flash_range]/[detonate_fire_range]) onto")
user.visible_message("[user] tried to force [src] onto [victim], but it could not attach!", "You try to force [src] onto [victim], but it is unable to attach!", "You hear a mechanical click and two buzzes.")
@@ -107,10 +126,10 @@
/obj/item/hot_potato/dropped(mob/user)
. = ..()
- user.remove_atom_colour(TEMPORARY_COLOUR_PRIORITY)
+ colorize(null)
/obj/item/hot_potato/proc/activate(delay, mob/user)
- if(is_active())
+ if(active)
return
update_icon()
if(sticky)
@@ -122,6 +141,7 @@
var/turf/T = get_turf(src)
message_admins("[user? "[ADMIN_LOOKUPFLW(user)] has primed [src]" : "A [src] has been primed"] (Timer:[delay],Explosive:[detonate_explosion],Range:[detonate_dev_range]/[detonate_heavy_range]/[detonate_light_range]/[detonate_fire_range]) for detonation at [COORD(T)]([T.loc])")
log_game("[user? "[user] has primed [src]" : "A [src] has been primed"] ([detonate_dev_range]/[detonate_heavy_range]/[detonate_light_range]/[detonate_fire_range]) for detonation at [COORD(T)]([T.loc])")
+ active = TRUE
/obj/item/hot_potato/proc/deactivate()
update_icon()
@@ -130,12 +150,11 @@
deltimer(detonation_timerid)
STOP_PROCESSING(SSfastprocess, src)
detonation_timerid = null
- if(ismob(loc))
- var/mob/user = loc
- user.remove_atom_colour(TEMPORARY_COLOUR_PRIORITY)
+ colorize(null)
+ active = FALSE
/obj/item/hot_potato/update_icon()
- icon_state = is_active()? icon_on : icon_off
+ icon_state = active? icon_on : icon_off
/obj/item/hot_potato/syndicate
detonate_light_range = 4