/
githubmirror
/
vgstation13
Обзор
Документация
Войти
/
githubmirror
/
vgstation13
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
Bleeding-Edge
code/modules/power/lighting/lighting.dm
926 строк
28 KB
SECBATON GRIFFON
Cleaning lights removes pulse demon yellow (#39450)
18 июл 2026, 16:17
Не верифицирован
18 июл 2026, 16:17
3ff5680
Код
Авторство
О чём код?
// The lighting system // // consists of light fixtures (/obj/machinery/light) and light tube/bulb items (/obj/item/weapon/light) var/global/list/light_colors = list( "default" = LIGHT_COLOR_TUNGSTEN, \ "default (HE)" = LIGHT_COLOR_HALOGEN, \ "red" = LIGHT_COLOR_RED, \ "green" = LIGHT_COLOR_GREEN, \ "blue" = LIGHT_COLOR_BLUE, \ "cyan" = LIGHT_COLOR_CYAN, \ "pink" = LIGHT_COLOR_PINK, \ "yellow" = LIGHT_COLOR_YELLOW, \ "brown" = LIGHT_COLOR_BROWN, \ "orange" = LIGHT_COLOR_ORANGE, \ "purple" = LIGHT_COLOR_PURPLE, \ "fire" = LIGHT_COLOR_FIRE, \ "flare" = LIGHT_COLOR_FLARE, \ "slime" = LIGHT_COLOR_SLIME_LAMP, \ ) /obj/machinery/light_construct name = "light fixture frame" desc = "A light fixture under construction." icon = 'icons/obj/lighting.dmi' icon_state = "tube-construct-stage1" anchored = 1 plane = ABOVE_HUMAN_PLANE layer = LIGHT_FIXTURE_LAYER var/stage = 1 var/fixture_type = /obj/machinery/light/built var/sheets_refunded = 2 /obj/machinery/light_construct/examine(mob/user) ..() var/mode switch(src.stage) if(1) mode = "It's empty and lacks wiring." if(2) mode = "It's wired." to_chat(user, "<span class='info'>[mode]</span>") /obj/machinery/light_construct/attackby(obj/item/weapon/W as obj, mob/user as mob) src.add_fingerprint(user) if (W.is_wrench(user)) if (src.stage == 1) W.playtoolsound(src, 75) to_chat(usr, "You begin deconstructing [src].") if (!do_after(usr, src, 30)) return var/obj/item/stack/sheet/metal/M = new /obj/item/stack/sheet/metal(get_turf(src)) M.amount = sheets_refunded user.visible_message("[user.name] deconstructs [src].", \ "You deconstruct [src].", "You hear a noise.") playsound(src, 'sound/items/Deconstruct.ogg', 75, 1) qdel(src) return if (src.stage == 2) to_chat(usr, "You have to remove the wires first.") return if(istype(W, /obj/item/stack/cable_coil)) if (src.stage == 1) var/obj/item/stack/cable_coil/coil = W coil.use(1) switch(fixture_type) if (/obj/machinery/light/built) src.icon_state = "tube-empty" if(/obj/machinery/light/small/built) src.icon_state = "bulb-empty" if(/obj/machinery/light/floor/built) src.icon_state = "floor-empty" src.stage = 2 user.visible_message("[user.name] adds wires to \the [src].", \ "You add wires to \the [src]") var/obj/machinery/light/newlight = new fixture_type(src.loc) newlight.dir = src.dir src.transfer_fingerprints_to(newlight) qdel(src) return ..() /obj/machinery/light_construct/kick_act(mob/living/carbon/human/H) H.visible_message("<span class='danger'>[H] attempts to kick \the [src].</span>", "<span class='danger'>You attempt to kick \the [src].</span>") to_chat(H, "<span class='danger'>Dumb move! You strain a muscle.</span>") H.apply_damage(rand(1,2), BRUTE, pick(LIMB_RIGHT_LEG, LIMB_LEFT_LEG, LIMB_RIGHT_FOOT, LIMB_LEFT_FOOT)) H.do_attack_animation(src, H) return SPECIAL_ATTACK_FAILED /obj/machinery/light_construct/can_overload() return 0 /obj/machinery/light_construct/small name = "small light fixture frame" desc = "A small light fixture under construction." icon_state = "bulb-construct-stage1" fixture_type = /obj/machinery/light/small/built sheets_refunded = 1 /obj/machinery/light_construct/floor name = "floor light frame" desc = "A floor light fixture under construction." icon_state = "floor-empty" plane = ABOVE_TURF_PLANE layer = ABOVE_TILE_LAYER fixture_type = /obj/machinery/light/floor/built sheets_refunded = 2 var/global/list/obj/machinery/light/alllights = list() // the standard tube light fixture /obj/machinery/light name = "light fixture" icon = 'icons/obj/lighting.dmi' icon_state = "ltube1" desc = "A lighting fixture." anchored = 1 plane = ABOVE_HUMAN_PLANE layer = LIGHT_FIXTURE_LAYER use_power = MACHINE_POWER_USE_ACTIVE idle_power_usage = 2 active_power_usage = 20 power_channel = LIGHT //Lights are calc'd via area so they dont need to be in the machine list var/on = 1 // 1 if on, 0 if off var/on_gs = 0 var/static_power_used = 0 var/flickering = 0 var/obj/item/weapon/light/current_bulb = null var/area/lights_area var/spawn_with_bulb = /obj/item/weapon/light/tube var/fitting = "tube" var/break_chance = 2 var/rgb_upgrade = FALSE //add plastic to enable RGB mode // No ghost interaction. ghost_read=0 ghost_write=0 var/idle = 0 // For process(). // create a new lighting fixture /obj/machinery/light/New() ..() if(spawn_with_bulb) current_bulb = new spawn_with_bulb() else update(0) alllights += src lights_area = get_area(src) if(lights_area) lights_area.lights += src if(map.broken_lights && break_chance) if(ticker && ticker.current_state == GAME_STATE_PREGAME) // only change the chance before roundstart break_chance = clamp(break_chance-(last_crewscore/(10000/break_chance)),0,break_chance*2) // 10% at highest, 0% at lowest if(prob(break_chance)) broken(1) /obj/machinery/light/supports_holomap() return TRUE /obj/machinery/light/spook(mob/dead/observer/ghost) if(..(ghost, TRUE)) flicker() // the smaller bulb light fixture /obj/machinery/light/cultify() new /obj/structure/cult/pylon(loc) qdel(src) /obj/machinery/light/bullet_act(var/obj/item/projectile/Proj) if(istype(Proj ,/obj/item/projectile/beam)||istype(Proj,/obj/item/projectile/bullet)||istype(Proj,/obj/item/projectile/ricochet)) if(!istype(Proj ,/obj/item/projectile/beam/lasertag) && !istype(Proj ,/obj/item/projectile/beam/practice) ) broken() return ..() /obj/machinery/light/kick_act(mob/living/carbon/human/H) H.visible_message("<span class='danger'>[H] attempts to kick \the [src].</span>", "<span class='danger'>You attempt to kick \the [src].</span>") if(H.foot_impact(src,rand(1,2))) to_chat(H, "<span class='danger'>Dumb move! You strain a muscle.</span>") return SPECIAL_ATTACK_FAILED /obj/machinery/light/can_overload() return 0 /obj/machinery/light/broken icon_state = "ltube-broken" //for the mapper spawn_with_bulb = /obj/item/weapon/light/tube/broken /obj/machinery/light/he icon_state = "lhetube1" spawn_with_bulb = /obj/item/weapon/light/tube/he /obj/machinery/light/he/broken icon_state = "lhetube-broken" //for the mapper spawn_with_bulb = /obj/item/weapon/light/tube/he/broken /obj/machinery/light/he/burned icon_state = "lhetube-burned" //for the mapper spawn_with_bulb = /obj/item/weapon/light/tube/he/burned /obj/machinery/light/small icon_state = "lbulb1" desc = "A small lighting fixture." fitting = "bulb" break_chance = 5 spawn_with_bulb = /obj/item/weapon/light/bulb /obj/machinery/light/small/broken icon_state = "lbulb-broken" //for the mapper spawn_with_bulb = /obj/item/weapon/light/bulb/broken /obj/machinery/light/spot name = "spotlight" fitting = "large tube" break_chance = 0 spawn_with_bulb = /obj/item/weapon/light/tube/large /obj/machinery/light/built icon_state = "ltube-empty" //for the mapper spawn_with_bulb = null /obj/machinery/light/small/built icon_state = "lbulb-empty" //for the mapper spawn_with_bulb = null /obj/machinery/light/floor name = "floor light" desc = "A floor-mounted lighting fixture." icon_state = "floor1" fitting = "bulb" plane = ABOVE_TURF_PLANE layer = ABOVE_TILE_LAYER spawn_with_bulb = /obj/item/weapon/light/bulb /obj/machinery/light/floor/update_icon() if(current_bulb) switch(current_bulb.status) if(LIGHT_OK) icon_state = "floor[on]" if(on) color = current_bulb.brightness_color if(LIGHT_BURNED) icon_state = "floor-broken" on = 0 if(LIGHT_BROKEN) icon_state = "floor-broken" on = 0 else icon_state = "floor-empty" on = 0 /obj/machinery/light/floor/broken icon_state = "floor-broken" spawn_with_bulb = /obj/item/weapon/light/bulb/broken /obj/machinery/light/floor/built icon_state = "floor-empty" spawn_with_bulb = null /obj/machinery/light/initialize() ..() add_self_to_holomap() /obj/machinery/light/Destroy() seton(0) ..() alllights -= src if(lights_area) lights_area.lights -= src /obj/machinery/light/update_icon() if(current_bulb) switch(current_bulb.status) // set icon_states if(LIGHT_OK) icon_state = "l[current_bulb.base_state][on]" if(on) color = current_bulb.brightness_color if(LIGHT_BURNED) icon_state = "l[current_bulb.base_state]-burned" on = 0 if(LIGHT_BROKEN) icon_state = "l[current_bulb.base_state]-broken" on = 0 else icon_state = "l[fitting]-empty" on = 0 // update the icon_state and luminosity of the light depending on its state /obj/machinery/light/proc/update(var/trigger = 1) update_icon() if(on) if(light_range != current_bulb.brightness_range || light_power != current_bulb.brightness_power || light_color != current_bulb.brightness_color) current_bulb.switchcount++ if(current_bulb.rigged) if(current_bulb.status == LIGHT_OK && trigger) log_admin("LOG: Rigged light explosion, last touched by [fingerprintslast]") message_admins("LOG: Rigged light explosion, last touched by [fingerprintslast]") explode(get_mob_by_key(fingerprintslast)) else if( prob( min(60, current_bulb.switchcount*current_bulb.switchcount*0.01) ) ) if(current_bulb.status == LIGHT_OK && trigger) current_bulb.status = LIGHT_BURNED icon_state = "l[current_bulb.base_state]-burned" on = 0 set_light(0) else use_power = MACHINE_POWER_USE_ACTIVE set_light(current_bulb.brightness_range, current_bulb.brightness_power, current_bulb.brightness_color) else use_power = MACHINE_POWER_USE_IDLE set_light(0) if(current_bulb) active_power_usage = (current_bulb.cost * 10) if(on != on_gs) on_gs = on if(on) static_power_used = current_bulb.cost * 20 //20W per unit luminosity addStaticPower(static_power_used, STATIC_LIGHT) else removeStaticPower(static_power_used, STATIC_LIGHT) /* * Attempt to set the light's on/off status. * Will not switch on if broken/burned/empty. */ /obj/machinery/light/proc/seton(const/s) on = (s && current_bulb && current_bulb.status == LIGHT_OK) update() // examine verb /obj/machinery/light/examine(mob/user) ..() if(rgb_upgrade) to_chat(user, "<span class='info'>it is NT-35322 RGB compliant!</span>") if(current_bulb) switch(current_bulb.status) if(LIGHT_OK) to_chat(user, "<span class='info'>It is turned [on? "on" : "off"].</span>") if(LIGHT_BURNED) to_chat(user, "<span class='info'>The [fitting] is burnt out.</span>") if(LIGHT_BROKEN) to_chat(user, "<span class='info'>The [fitting] has been smashed.</span>") else to_chat(user, "<span class='info'>The [fitting] has been removed.</span>") // attack with item - insert light (if right type), otherwise try to break the light /obj/machinery/light/attackby(obj/item/W, mob/living/user) if(ismultitool(W)) //RGB gamer lights if(!rgb_upgrade) to_chat(user, "There's nothing to connect \the [W] to on \the [src].") return var/which = alert(user, "What would you like to change?", "Programmable Lights", "Color", "Power", "Range") var/list/choice_color_list = list("custom") + light_colors switch(which) if("Color") var/colorchoice = input(user,"Select a color to set [src] to.","[src]") in choice_color_list if(!Adjacent(user)) return if(colorchoice == "custom") current_bulb.brightness_color = input("Please select a color for the tile.", "[src]") as color else current_bulb.brightness_color = choice_color_list[colorchoice] if("Power") var/new_power = input("Desired power (must be below [initial(current_bulb.brightness_power)]): ", "Light bulb power", "") as num current_bulb.brightness_power = clamp(new_power, 0, initial(current_bulb.brightness_power)) if("Range") var/new_range = input("Desired range (must be below [initial(current_bulb.brightness_range)]): ", "Light bulb range", "") as num current_bulb.brightness_range = clamp(new_range, 0, initial(current_bulb.brightness_range)) update() return if (istype(W,/obj/item/stack/light_w)) if(rgb_upgrade) to_chat(user, "This light is already customizable.") return var/obj/item/stack/light_w/lightstack = W lightstack.use(1) rgb_upgrade = TRUE to_chat(user, "You insert \the [W] into \the [src], allowing multitool customization.") return if(rgb_upgrade && iscrowbar(W)) W.playtoolsound(src, 75) user.visible_message("[user.name] removes some plastic from \the [src].", \ "You remove some plastic from \the [src].", "You hear a noise.") rgb_upgrade = FALSE current_bulb.brightness_color = initial(current_bulb.brightness_color) drop_stack(/obj/item/stack/light_w, get_turf(src), 1, user) return user.delayNextAttack(8) // attempt to insert light if(istype(W, /obj/item/weapon/light)) if(current_bulb) to_chat(user, "There is a [fitting] already inserted.") return else src.add_fingerprint(user) var/obj/item/weapon/light/L = W if(L.fitting == fitting) if(!user.drop_item(L, src, failmsg = TRUE)) return to_chat(user, "You insert \the [L.name].") current_bulb = L on = has_power() update() if(on && current_bulb.rigged) log_admin("LOG: Rigged light explosion, last touched by [fingerprintslast]") message_admins("LOG: Rigged light explosion, last touched by [fingerprintslast]") explode(get_mob_by_key(fingerprintslast)) else to_chat(user, "This type of light requires a [fitting].") return // attempt to break the light //If xenos decide they want to smash a light bulb with a toolbox, who am I to stop them? else if(current_bulb && current_bulb.status != LIGHT_BROKEN) user.do_attack_animation(src, W) if(prob(1+W.force * 5)) to_chat(user, "You hit the light, and it smashes!") for(var/mob/M in viewers(src)) if(M == user) continue M.show_message("[user.name] smashed the light!", 1, "You hear a tinkle of breaking glass", 2) if(on && (W.is_conductor())) //if(!user.mutations & M_RESIST_COLD) if (prob(12)) electrocute_mob(user, get_area(src), src, 0.3) broken() else to_chat(user, "You hit the light!") // attempt to deconstruct / stick weapon into light socket else if(!current_bulb) if(W.is_wirecutter(user)) //If it's a wirecutter take out the wires W.playtoolsound(src, 75) user.visible_message("[user.name] removes \the [src]'s wires.", \ "You remove \the [src]'s wires.", "You hear a noise.") var/obj/machinery/light_construct/newlight = null if(istype(src, /obj/machinery/light/floor)) newlight = new /obj/machinery/light_construct/floor(src.loc) else switch(fitting) if("tube") newlight = new /obj/machinery/light_construct(src.loc) newlight.icon_state = "tube-construct-stage1" if("bulb") newlight = new /obj/machinery/light_construct/small(src.loc) newlight.icon_state = "bulb-construct-stage1" new /obj/item/stack/cable_coil(get_turf(src.loc), 1, "red") newlight.dir = src.dir newlight.stage = 1 newlight.fingerprints = src.fingerprints newlight.fingerprintshidden = src.fingerprintshidden newlight.fingerprintslast = src.fingerprintslast qdel(src) return to_chat(user, "You stick \the [W] into the light socket!")//If not stick it in the socket. if(has_power() && (W.is_conductor())) spark(src) //if(!user.mutations & M_RESIST_COLD) if (prob(75)) electrocute_mob(user, get_area(src), src, rand(7,10)/10) /* * Returns whether this light has power * TRUE if area has power and lightswitch is on otherwise FALSE. */ /obj/machinery/light/proc/has_power() var/area/this_area = get_area(src) var/success = FALSE if(!this_area || !this_area.power_light) return FALSE if(!this_area.haslightswitch || !this_area.requires_power) return TRUE for(var/obj/machinery/light_switch/L in this_area.lightswitches) if(L.on) success = TRUE break return success /obj/machinery/light/proc/flicker(var/amount = rand(10, 20)) if(flickering) return flickering = 1 spawn(0) if(on && current_bulb.status == LIGHT_OK) for(var/i = 0; i < amount; i++) if(current_bulb.status != LIGHT_OK) break on = !on update(0) sleep(rand(5, 15)) on = (current_bulb.status == LIGHT_OK) update(0) flickering = 0 on = has_power() update(0) /obj/machinery/light/attack_ghost(mob/user) if(!can_spook()) return src.add_hiddenprint(user) src.flicker(1) investigation_log(I_GHOST, "|| was made to flicker by [key_name(user)][user.locked_to ? ", who was haunting [user.locked_to]" : ""]") return // ai attack - make lights flicker, because why not /obj/machinery/light/attack_ai(mob/user) // attack_robot is flaky. if(isMoMMI(user)) return attack_hand(user) src.add_hiddenprint(user) src.flicker(1) return /obj/machinery/light/attack_robot(mob/user) if(isMoMMI(user)) return attack_hand(user) else return attack_ai(user) // Aliens smash the bulb but do not get electrocuted./N /obj/machinery/light/attack_alien(mob/living/carbon/alien/humanoid/user)//So larva don't go breaking light bulbs. if(!current_bulb || current_bulb.status == LIGHT_BROKEN) to_chat(user, "<span class='good'>That object is useless to you.</span>") return else if (current_bulb.status == LIGHT_OK || current_bulb.status == LIGHT_BURNED) user.do_attack_animation(src, user) for(var/mob/M in viewers(src)) M.show_message("<span class='attack'>[user.name] smashed the light!</span>", 1, "You hear a tinkle of breaking glass", 2) broken() return /obj/machinery/light/attack_animal(mob/living/simple_animal/M) if(M.melee_damage_upper == 0) return if(!current_bulb || current_bulb.status == LIGHT_BROKEN) to_chat(M, "<span class='warning'>That object is useless to you.</span>") return else if (current_bulb.status == LIGHT_OK || current_bulb.status == LIGHT_BURNED) M.do_attack_animation(src, M) for(var/mob/O in viewers(src)) O.show_message("<span class='attack'>[M.name] smashed the light!</span>", 1, "You hear a tinkle of breaking glass", 2) if (isspider(M)) var/datum/faction/spider_infestation/infestation = find_active_faction_by_type(/datum/faction/spider_infestation) if (infestation) var/datum/objective/spider/S = locate() in infestation.objective_holder.objectives if (S) S.broken_lights++ broken() return // attack with hand - remove tube/bulb // if hands aren't protected and the light is on, burn the player /obj/machinery/light/attack_hand(mob/user) if(isobserver(user)) return if(!Adjacent(user)) return add_fingerprint(user) if(!current_bulb) to_chat(user, "There is no [fitting] in this light.") return // make it burn hands if not wearing fire-insulated gloves if(on) var/prot = 0 if(ishuman(user)) var/mob/living/carbon/human/H = user if(H.gloves) var/obj/item/clothing/gloves/G = H.gloves if(G.max_heat_protection_temperature) prot = (G.max_heat_protection_temperature > 360) else prot = 1 var/datum/organ/external/active_hand_organ = user.get_active_hand_organ() if(prot > 0 || (M_RESIST_HEAT in user.mutations) || active_hand_organ?.is_robotic()) to_chat(user, "You remove the light [fitting]") else to_chat(user, "You try to remove the light [fitting], but it's too hot and you don't want to burn your hand.") return // if burned, don't remove the light current_bulb.update() current_bulb.add_fingerprint(user) if(!user.put_in_active_hand(current_bulb)) //puts it in our active hand if possible current_bulb.forceMove(get_turf(user)) current_bulb = null update() // break the light and make sparks if was on /obj/machinery/light/proc/broken(var/skip_sound_and_sparks = 0) if(!current_bulb) return if(!skip_sound_and_sparks) if(current_bulb.status == LIGHT_OK || current_bulb.status == LIGHT_BURNED) playsound(src, 'sound/effects/Glasshit.ogg', 75, 1) if(on) spark(src) current_bulb.status = LIGHT_BROKEN update() /obj/machinery/light/proc/fix() if(current_bulb.status == LIGHT_OK) return current_bulb.status = LIGHT_OK on = 1 update() // explosion effect // destroy the whole light fixture or just shatter it /obj/machinery/light/ex_act(severity) switch(severity) if(1.0) qdel(src) return if(2.0) if (prob(75)) broken() if(3.0) if (prob(50)) broken() return //blob effect /obj/machinery/light/blob_act() if(prob(75)) broken() /* * Called when area power state changes. */ /obj/machinery/light/power_change(var/non_instant = TRUE) spawn(10 * non_instant) seton(has_power()) // called when on fire /obj/machinery/light/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume) if(prob(max(0, exposed_temperature - 673))) //0% at <400C, 100% at >500C broken() /* * Explode the light. */ /obj/machinery/light/proc/explode(var/mob/user) spawn(0) broken() // Break it first to give a warning. sleep(2) explosion(get_turf(src), 0, 0, 2, 2, whodunnit = user) sleep(1) qdel(src) /obj/machinery/light/clean_act(cleanliness) . = ..() if(current_bulb && current_bulb.brightness_color == COLOR_PULSEDEMON) current_bulb.brightness_color = initial(current_bulb.brightness_color) update(0) // the light item // can be tube or bulb subtypes // will fit into empty /obj/machinery/light of the corresponding type /obj/item/weapon/light icon = 'icons/obj/lighting.dmi' flags = FPRINT force = 2 throwforce = 5 w_class = W_CLASS_TINY var/status = 0 // LIGHT_OK, LIGHT_BURNED or LIGHT_BROKEN var/base_state var/switchcount = 0 // number of times switched //starting_materials = list(MAT_IRON = 60) //Not necessary, as this exact type should never appear and each subtype has its materials defined. var/rigged = 0 // true if rigged to explode var/brightness_range = 2 //how much light it gives off var/brightness_power = 1 var/brightness_color = null var/cost = 2 //How much power does it consume in an idle state? var/fitting = "tube" var/frequency = 1500 //for smart lights /obj/item/weapon/light/tube name = "light tube" desc = "A replacement light tube." icon_state = "tube" base_state = "tube" item_state = "c_tube" starting_materials = list(MAT_GLASS = 100, MAT_IRON = 60) w_type = RECYK_GLASS brightness_range = 6 brightness_power = 1.5 brightness_color = LIGHT_COLOR_TUNGSTEN cost = 8 /obj/item/weapon/light/tube/he name = "high efficiency light tube" desc = "An efficient light used to reduce strain on the station's power grid." base_state = "hetube" starting_materials = list(MAT_GLASS = 300, MAT_IRON = 60) brightness_range = 8 brightness_power = 4 brightness_color = LIGHT_COLOR_HALOGEN cost = 2 /obj/item/weapon/light/tube/smart name = "smart light tube" desc = "An LED light tube with built-in electronics to control various properties." base_state = "hetube" starting_materials = list(MAT_GLASS = 200, MAT_IRON = 60) brightness_range = 8 brightness_power = 4 brightness_color = "#FFFFFF" cost = 2 /obj/item/weapon/light/tube/broken status = LIGHT_BROKEN /obj/item/weapon/light/tube/burned status = LIGHT_BURNED /obj/item/weapon/light/tube/he/broken status = LIGHT_BROKEN /obj/item/weapon/light/tube/he/burned status = LIGHT_BURNED /obj/item/weapon/light/tube/large w_class = W_CLASS_SMALL name = "large light tube" brightness_range = 15 brightness_power = 4 starting_materials = list(MAT_GLASS = 200, MAT_IRON = 100) cost = 15 /obj/item/weapon/light/bulb name = "light bulb" desc = "A replacement light bulb." icon_state = "bulb" base_state = "bulb" item_state = "contvapour" fitting = "bulb" brightness_range = 3.5 brightness_power = 2 brightness_color = LIGHT_COLOR_TUNGSTEN starting_materials = list(MAT_GLASS = 50, MAT_IRON = 30) cost = 5 w_type = RECYK_GLASS /obj/item/weapon/light/bulb/broken status = LIGHT_BROKEN /obj/item/weapon/light/bulb/he name = "high efficiency light bulb" desc = "An efficient light used to reduce strain on the station's power grid." base_state = "hebulb" brightness_range = 6 brightness_power = 3 brightness_color = LIGHT_COLOR_HALOGEN cost = 1 starting_materials = list(MAT_GLASS = 150, MAT_IRON = 30) /obj/item/weapon/light/bulb/smart name = "smart light bulb" desc = "An LED light bulb with built-in electronics to control various properties." base_state = "hebulb" brightness_range = 6 brightness_power = 3 brightness_color = "#FFFFFF" cost = 1 starting_materials = list(MAT_GLASS = 100, MAT_IRON = 30) /obj/item/weapon/light/throw_impact(atom/hit_atom) if(!..()) shatter() /obj/item/weapon/light/bulb/fire name = "fire bulb" desc = "A replacement fire bulb." icon_state = "fbulb" base_state = "fbulb" item_state = "egg4" brightness_range = 5 brightness_power = 2 starting_materials = list(MAT_GLASS = 300, MAT_IRON = 60) /obj/item/weapon/light/clean_act(cleanliness) . = ..() if(brightness_color == COLOR_PULSEDEMON) brightness_color = initial(brightness_color) // update the icon state and description of the light /obj/item/weapon/light/proc/update() switch(status) if(LIGHT_OK) icon_state = base_state desc = "A replacement [name]." if(LIGHT_BURNED) icon_state = "[base_state]-burned" desc = "A burnt-out [name]." if(LIGHT_BROKEN) icon_state = "[base_state]-broken" desc = "A broken [name]." /obj/item/weapon/light/New() ..() update() // A syringe can inject plasma to make the light explode when it turns on. /obj/item/weapon/light/on_syringe_injection(var/mob/user, var/obj/item/weapon/reagent_containers/syringe/tool) var/datum/reagents/syringe_reagents = tool.reagents if(rigged) to_chat(user, "<span class='warning'>\The [src] is already full!</span>") return INJECTION_RESULT_FAIL if(!(syringe_reagents.reagent_list.len == 1 && syringe_reagents.has_reagent(PLASMA, 5))) to_chat(user, "<span class='warning'>Injecting this solution wouldn't have any effect on \the [src].</span>") return INJECTION_RESULT_FAIL if(syringe_reagents.remove_reagent(PLASMA, 5)) stack_trace("Couldn't remove plasma from the syringe?") return INJECTION_RESULT_FAIL log_admin("LOG: [user.name] ([user.ckey]) injected a light with plasma, rigging it to explode.") message_admins("LOG: [user.name] ([user.ckey]) injected a light with plasma, rigging it to explode.") rigged = 1 return INJECTION_RESULT_SUCCESS_BUT_SKIP_REAGENT_TRANSFER /obj/item/weapon/light/attack_self(var/mob/user) if(user.a_intent == I_HURT) to_chat(user, "<span class='warning'>You clench \the [src] in your hand, crushing it.</span>") shatter() // called after an attack with a light item // shatter light, unless it was an attempt to put it in a light socket // now only shatter if the intent was harm /obj/item/weapon/light/afterattack(var/atom/target, var/mob/user) if (!user.Adjacent(target)) return if(istype(target, /obj/machinery/light)) return if(user.a_intent != I_HURT) return to_chat(user, "<span class='warning'>\The [src] shatters as you whack it against \the [target].</span>") shatter() /obj/item/weapon/light/proc/shatter(verbose = TRUE) if(status == LIGHT_OK || status == LIGHT_BURNED) if(verbose) visible_message("<span class='warning'>[name] shatters.</span>","<span class='warning'>You hear a small glass object shatter.</span>") status = LIGHT_BROKEN force = 5 playsound(src, 'sound/effects/Glasshit.ogg', 75, 1) update() // Floor light frame item - used to construct floor lights /obj/item/floor_light_frame name = "floor light frame" desc = "A frame for constructing a floor light. Use it on a floor to install." icon = 'icons/obj/lighting.dmi' icon_state = "floor-empty" flags = FPRINT /obj/item/floor_light_frame/afterattack(atom/target, mob/user, proximity_flag) if(!proximity_flag) return ..() if(!istype(target, /turf/simulated/floor)) to_chat(user, "<span class='rose'>[src] can only be installed on a floor.</span>") return var/turf/T = get_turf(target) if(locate(/obj/machinery/light_construct/floor) in T || locate(/obj/machinery/light/floor) in T) to_chat(user, "<span class='warning'>There is already a floor light here!</span>") return to_chat(user, "You begin installing [src] into the floor.") playsound(src, 'sound/machines/click.ogg', 75, 1) if(!do_after(user, target, 30)) return var/obj/machinery/light_construct/floor/newlight = new(T) newlight.fingerprints = src.fingerprints newlight.fingerprintshidden = src.fingerprintshidden newlight.fingerprintslast = src.fingerprintslast user.visible_message("[user] installs [src] into the floor.", \ "You install [src] into the floor.") qdel(src) /obj/item/floor_light_frame/attackby(obj/item/weapon/W, mob/user) if(W.is_wrench(user)) var/obj/item/stack/sheet/metal/M = new(get_turf(src)) M.amount = 2 qdel(src) return ..()