From 68718f527aa47db76b8cf6518caca9f68b96d4d8 Mon Sep 17 00:00:00 2001 From: Aranclanos Date: Thu, 25 Jul 2013 06:19:06 -0300 Subject: [PATCH] Standarization for the candle code and now the process() of it will remove the candle from a mob properly when the wax runs out, avoiding a runtime. --- code/game/objects/items/candle.dm | 139 +++++++++++++++--------------- 1 file changed, 70 insertions(+), 69 deletions(-) diff --git a/code/game/objects/items/candle.dm b/code/game/objects/items/candle.dm index 1802d4496b2..ca0c40fe668 100644 --- a/code/game/objects/items/candle.dm +++ b/code/game/objects/items/candle.dm @@ -13,82 +13,83 @@ light(var/flavor_text = "\red [usr] lights the [name].") +/obj/item/candle/update_icon() + var/i + if(wax>150) + i = 1 + else if(wax>80) + i = 2 + else i = 3 + icon_state = "candle[i][lit ? "_lit" : ""]" + + +/obj/item/candle/attackby(obj/item/weapon/W as obj, mob/user as mob) + ..() + if(istype(W, /obj/item/weapon/weldingtool)) + var/obj/item/weapon/weldingtool/WT = W + if(WT.isOn()) //Badasses dont get blinded by lighting their candle with a welding tool + light("\red [user] casually lights the [name] with [W], what a badass.") + else if(istype(W, /obj/item/weapon/lighter)) + var/obj/item/weapon/lighter/L = W + if(L.lit) + light() + else if(istype(W, /obj/item/weapon/match)) + var/obj/item/weapon/match/M = W + if(M.lit) + light() + else if(istype(W, /obj/item/candle)) + var/obj/item/candle/C = W + if(C.lit) + light() + else if(istype(W, /obj/item/clothing/mask/cigarette)) + var/obj/item/clothing/mask/cigarette/M = W + if(M.lit) + light() + + +/obj/item/candle/light(var/flavor_text = "\red [usr] lights the [name].") + if(!src.lit) + src.lit = 1 + //src.damtype = "fire" + for(var/mob/O in viewers(usr, null)) + O.show_message(flavor_text, 1) + SetLuminosity(CANDLE_LUMINOSITY) + processing_objects.Add(src) + + +/obj/item/candle/process() + if(!lit) + return + wax-- + if(!wax) + new/obj/item/trash/candle(src.loc) + if(istype(src.loc, /mob)) + var/mob/M = src.loc + M.before_take_item(src) + del(src) update_icon() - var/i - if(wax>150) - i = 1 - else if(wax>80) - i = 2 - else i = 3 - icon_state = "candle[i][lit ? "_lit" : ""]" + if(istype(loc, /turf)) //start a fire if possible + var/turf/T = loc + T.hotspot_expose(700, 5) - attackby(obj/item/weapon/W as obj, mob/user as mob) - ..() - if(istype(W, /obj/item/weapon/weldingtool)) - var/obj/item/weapon/weldingtool/WT = W - if(WT.isOn()) //Badasses dont get blinded by lighting their candle with a welding tool - light("\red [user] casually lights the [name] with [W], what a badass.") - else if(istype(W, /obj/item/weapon/lighter)) - var/obj/item/weapon/lighter/L = W - if(L.lit) - light() - else if(istype(W, /obj/item/weapon/match)) - var/obj/item/weapon/match/M = W - if(M.lit) - light() - else if(istype(W, /obj/item/candle)) - var/obj/item/candle/C = W - if(C.lit) - light() - else if(istype(W, /obj/item/clothing/mask/cigarette)) - var/obj/item/clothing/mask/cigarette/M = W - if(M.lit) - light() - - - light(var/flavor_text = "\red [usr] lights the [name].") - if(!src.lit) - src.lit = 1 - //src.damtype = "fire" - for(var/mob/O in viewers(usr, null)) - O.show_message(flavor_text, 1) - SetLuminosity(CANDLE_LUMINOSITY) - processing_objects.Add(src) - - - process() - if(!lit) - return - wax-- - if(!wax) - new/obj/item/trash/candle(src.loc) - if(istype(src.loc, /mob)) - src.dropped() - del(src) +/obj/item/candle/attack_self(mob/user as mob) + if(lit) + lit = 0 update_icon() - if(istype(loc, /turf)) //start a fire if possible - var/turf/T = loc - T.hotspot_expose(700, 5) + SetLuminosity(0) + user.SetLuminosity(user.luminosity - CANDLE_LUMINOSITY) - attack_self(mob/user as mob) - if(lit) - lit = 0 - update_icon() - SetLuminosity(0) - user.SetLuminosity(user.luminosity - CANDLE_LUMINOSITY) +/obj/item/candle/pickup(mob/user) + if(lit) + SetLuminosity(0) + user.SetLuminosity(user.luminosity + CANDLE_LUMINOSITY) - pickup(mob/user) - if(lit) - SetLuminosity(0) - user.SetLuminosity(user.luminosity + CANDLE_LUMINOSITY) - - - dropped(mob/user) - if(lit) - user.SetLuminosity(user.luminosity - CANDLE_LUMINOSITY) - SetLuminosity(CANDLE_LUMINOSITY) +/obj/item/candle/dropped(mob/user) + if(lit) + user.SetLuminosity(user.luminosity - CANDLE_LUMINOSITY) + SetLuminosity(CANDLE_LUMINOSITY) #undef CANDLE_LUMINOSITY \ No newline at end of file