mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-13 19:52:40 +00:00
Merge pull request #6569 from TheFurryFeline/TFF-Bulbs_Recycling
Light Replacer QOL
This commit is contained in:
@@ -54,6 +54,11 @@
|
|||||||
var/failmsg = ""
|
var/failmsg = ""
|
||||||
var/charge = 0
|
var/charge = 0
|
||||||
|
|
||||||
|
// Eating used bulbs gives us bulb shards
|
||||||
|
var/bulb_shards = 0
|
||||||
|
// when we get this many shards, we get a free bulb.
|
||||||
|
var/shards_required = 4
|
||||||
|
|
||||||
/obj/item/device/lightreplacer/New()
|
/obj/item/device/lightreplacer/New()
|
||||||
failmsg = "The [name]'s refill light blinks red."
|
failmsg = "The [name]'s refill light blinks red."
|
||||||
..()
|
..()
|
||||||
@@ -76,18 +81,55 @@
|
|||||||
to_chat(user, "<span class='warning'>You need one sheet of glass to replace lights.</span>")
|
to_chat(user, "<span class='warning'>You need one sheet of glass to replace lights.</span>")
|
||||||
|
|
||||||
if(istype(W, /obj/item/weapon/light))
|
if(istype(W, /obj/item/weapon/light))
|
||||||
|
var/new_bulbs = 0
|
||||||
var/obj/item/weapon/light/L = W
|
var/obj/item/weapon/light/L = W
|
||||||
if(L.status == 0) // LIGHT OKAY
|
if(L.status == 0) // LIGHT OKAY
|
||||||
if(uses < max_uses)
|
if(uses < max_uses)
|
||||||
|
if(!user.unEquip(W))
|
||||||
|
return
|
||||||
add_uses(1)
|
add_uses(1)
|
||||||
to_chat(user, "You insert \the [L.name] into \the [src.name]. You have [uses] light\s remaining.")
|
|
||||||
user.drop_item()
|
|
||||||
qdel(L)
|
qdel(L)
|
||||||
return
|
|
||||||
else
|
else
|
||||||
to_chat(user, "You need a working light.")
|
if(!user.unEquip(W))
|
||||||
|
return
|
||||||
|
new_bulbs += AddShards(1)
|
||||||
|
qdel(L)
|
||||||
|
if(new_bulbs != 0)
|
||||||
|
playsound(src.loc, 'sound/machines/ding.ogg', 50, 1)
|
||||||
|
to_chat(user, "You insert \the [L.name] into \the [src.name]. You have [uses] light\s remaining.")
|
||||||
|
return
|
||||||
|
|
||||||
|
if(istype(W, /obj/item/weapon/storage))
|
||||||
|
var/obj/item/weapon/storage/S = W
|
||||||
|
var/found_lightbulbs = FALSE
|
||||||
|
var/replaced_something = TRUE
|
||||||
|
|
||||||
|
for(var/obj/item/I in S.contents)
|
||||||
|
if(istype(I,/obj/item/weapon/light))
|
||||||
|
var/obj/item/weapon/light/L = I
|
||||||
|
found_lightbulbs = TRUE
|
||||||
|
if(src.uses >= max_uses)
|
||||||
|
break
|
||||||
|
if(L.status == LIGHT_OK)
|
||||||
|
replaced_something = TRUE
|
||||||
|
add_uses(1)
|
||||||
|
qdel(L)
|
||||||
|
|
||||||
|
else if(L.status == LIGHT_BROKEN || L.status == LIGHT_BURNED)
|
||||||
|
replaced_something = TRUE
|
||||||
|
AddShards(1)
|
||||||
|
qdel(L)
|
||||||
|
|
||||||
|
if(!found_lightbulbs)
|
||||||
|
to_chat(user, "<span class='warning'>\The [S] contains no bulbs.</span>")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if(!replaced_something && src.uses == max_uses)
|
||||||
|
to_chat(user, "<span class='warning'>\The [src] is full!</span>")
|
||||||
|
return
|
||||||
|
|
||||||
|
to_chat(user, "<span class='notice'>You fill \the [src] with lights from \the [S].</span>")
|
||||||
|
|
||||||
/obj/item/device/lightreplacer/attack_self(mob/user)
|
/obj/item/device/lightreplacer/attack_self(mob/user)
|
||||||
/* // This would probably be a bit OP. If you want it though, uncomment the code.
|
/* // This would probably be a bit OP. If you want it though, uncomment the code.
|
||||||
if(isrobot(user))
|
if(isrobot(user))
|
||||||
@@ -113,6 +155,15 @@
|
|||||||
/obj/item/device/lightreplacer/proc/add_uses(var/amount = 1)
|
/obj/item/device/lightreplacer/proc/add_uses(var/amount = 1)
|
||||||
uses = min(max(uses + amount, 0), max_uses)
|
uses = min(max(uses + amount, 0), max_uses)
|
||||||
|
|
||||||
|
|
||||||
|
/obj/item/device/lightreplacer/proc/AddShards(amount = 1)
|
||||||
|
bulb_shards += amount
|
||||||
|
var/new_bulbs = round(bulb_shards / shards_required)
|
||||||
|
if(new_bulbs > 0)
|
||||||
|
add_uses(new_bulbs)
|
||||||
|
bulb_shards = bulb_shards % shards_required
|
||||||
|
return new_bulbs
|
||||||
|
|
||||||
/obj/item/device/lightreplacer/proc/Charge(var/mob/user, var/amount = 1)
|
/obj/item/device/lightreplacer/proc/Charge(var/mob/user, var/amount = 1)
|
||||||
charge += amount
|
charge += amount
|
||||||
if(charge > 6)
|
if(charge > 6)
|
||||||
@@ -121,18 +172,41 @@
|
|||||||
|
|
||||||
/obj/item/device/lightreplacer/proc/ReplaceLight(var/obj/machinery/light/target, var/mob/living/U)
|
/obj/item/device/lightreplacer/proc/ReplaceLight(var/obj/machinery/light/target, var/mob/living/U)
|
||||||
|
|
||||||
if(target.status == LIGHT_OK)
|
if(target.status != LIGHT_OK)
|
||||||
|
if(CanUse(U))
|
||||||
|
if(!Use(U)) return
|
||||||
|
to_chat(U, "<span class='notice'>You replace the [target.get_fitting_name()] with the [src].</span>")
|
||||||
|
|
||||||
|
if(target.status != LIGHT_EMPTY)
|
||||||
|
var/new_bulbs = AddShards(1)
|
||||||
|
if(new_bulbs != 0)
|
||||||
|
to_chat(U, "<span class='notice'>\The [src] has fabricated a new bulb from the broken bulbs it has stored. It now has [uses] uses.</span>")
|
||||||
|
playsound(src.loc, 'sound/machines/ding.ogg', 50, 1)
|
||||||
|
target.status = LIGHT_EMPTY
|
||||||
|
target.update()
|
||||||
|
|
||||||
|
var/obj/item/weapon/light/L2 = new target.light_type()
|
||||||
|
|
||||||
|
target.status = L2.status
|
||||||
|
target.switchcount = L2.switchcount
|
||||||
|
target.rigged = emagged
|
||||||
|
target.brightness_range = L2.brightness_range
|
||||||
|
target.brightness_power = L2.brightness_power
|
||||||
|
target.brightness_color = L2.brightness_color
|
||||||
|
target.on = target.has_power()
|
||||||
|
target.update()
|
||||||
|
qdel(L2)
|
||||||
|
|
||||||
|
if(target.on && target.rigged)
|
||||||
|
target.explode()
|
||||||
|
return
|
||||||
|
|
||||||
|
else
|
||||||
|
to_chat(U, failmsg)
|
||||||
|
return
|
||||||
|
else
|
||||||
to_chat(U, "There is a working [target.get_fitting_name()] already inserted.")
|
to_chat(U, "There is a working [target.get_fitting_name()] already inserted.")
|
||||||
else if(!CanUse(U))
|
return
|
||||||
to_chat(U, failmsg)
|
|
||||||
else if(Use(U))
|
|
||||||
to_chat(U, "<span class='notice'>You replace the [target.get_fitting_name()] with the [src].</span>")
|
|
||||||
|
|
||||||
if(target.status != LIGHT_EMPTY)
|
|
||||||
target.remove_bulb()
|
|
||||||
|
|
||||||
var/obj/item/weapon/light/L = new target.light_type()
|
|
||||||
target.insert_bulb(L)
|
|
||||||
|
|
||||||
/obj/item/device/lightreplacer/emag_act(var/remaining_charges, var/mob/user)
|
/obj/item/device/lightreplacer/emag_act(var/remaining_charges, var/mob/user)
|
||||||
emagged = !emagged
|
emagged = !emagged
|
||||||
@@ -153,4 +227,4 @@
|
|||||||
#undef LIGHT_OK
|
#undef LIGHT_OK
|
||||||
#undef LIGHT_EMPTY
|
#undef LIGHT_EMPTY
|
||||||
#undef LIGHT_BROKEN
|
#undef LIGHT_BROKEN
|
||||||
#undef LIGHT_BURNED
|
#undef LIGHT_BURNED
|
||||||
36
html/changelogs/TheFurryFeline - Bulbs_Recycling.yml
Normal file
36
html/changelogs/TheFurryFeline - Bulbs_Recycling.yml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
################################
|
||||||
|
# Example Changelog File
|
||||||
|
#
|
||||||
|
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
|
||||||
|
#
|
||||||
|
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
|
||||||
|
# When it is, any changes listed below will disappear.
|
||||||
|
#
|
||||||
|
# Valid Prefixes:
|
||||||
|
# bugfix
|
||||||
|
# wip (For works in progress)
|
||||||
|
# tweak
|
||||||
|
# soundadd
|
||||||
|
# sounddel
|
||||||
|
# rscadd (general adding of nice things)
|
||||||
|
# rscdel (general deleting of nice things)
|
||||||
|
# imageadd
|
||||||
|
# imagedel
|
||||||
|
# maptweak
|
||||||
|
# spellcheck (typo fixes)
|
||||||
|
# experiment
|
||||||
|
#################################
|
||||||
|
|
||||||
|
# Your name.
|
||||||
|
author: TheFurryFeline
|
||||||
|
|
||||||
|
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
|
||||||
|
delete-after: True
|
||||||
|
|
||||||
|
# Any changes you've made. See valid prefix list above.
|
||||||
|
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
|
||||||
|
# SCREW THIS UP AND IT WON'T WORK.
|
||||||
|
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
|
||||||
|
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
|
||||||
|
changes:
|
||||||
|
- tweak: "Changes light replacers to allow you to automatically transfer used bulbs into the item and get a new one every 4 bulbs replaced. Additionally, this allows you to both use the replacer on a box of bulbs to get the bulbs added as well as clicking the item with a box of bulbs to put them inside it."
|
||||||
Reference in New Issue
Block a user