Files
Paradise/code/game/objects/items/devices/lightreplacer.dm
TullyBurnalot 9634181318 Janitorial Quality of Life Update (#5239)
* Janitorial Quality of Life

- Trash Bags fit in satchels/bags/duffelbags
- Advanced Mops clean faster, can clean more
- Holosign Projectors can create more signs
- New Closet added, with janitorial stuff that was previously on the
ground
- Ghosts can no longer create dirt
- Dirt creation slowed down
- Janitorial Closet tidied up

* Removes redundant check

* Trash Bags become heavier with use

* Fixes Map Merge not being done

* Re-adds Box Refilling because I am an idiot

Missing parenthesis, not even ONCE

* Unblocks MULEbot docking area

* Adds broken bulb recycling

* Addresses Fox's/DZD's concerns

* Adds sanity checks for NODROP
2016-08-17 17:23:19 -04:00

252 lines
7.4 KiB
Plaintext

// Light Replacer (LR)
//
// ABOUT THE DEVICE
//
// This is a device supposedly to be used by Janitors and Janitor Cyborgs which will
// allow them to easily replace lights. This was mostly designed for Janitor Cyborgs since
// they don't have hands or a way to replace lightbulbs.
//
// HOW IT WORKS
//
// You attack a light fixture with it, if the light fixture is broken it will replace the
// light fixture with a working light; the broken light is then placed on the floor for the
// user to then pickup with a trash bag. If it's empty then it will just place a light in the fixture.
//
// HOW TO REFILL THE DEVICE
//
// It will need to be manually refilled with lights.
// If it's part of a robot module, it will charge when the Robot is inside a Recharge Station.
//
// EMAGGED FEATURES
//
// NOTICE: The Cyborg cannot use the emagged Light Replacer and the light's explosion was nerfed. It cannot create holes in the station anymore.
//
// I'm not sure everyone will react the emag's features so please say what your opinions are of it.
//
// When emagged it will rig every light it replaces, which will explode when the light is on.
// This is VERY noticable, even the device's name changes when you emag it so if anyone
// examines you when you're holding it in your hand, you will be discovered.
// It will also be very obvious who is setting all these lights off, since only Janitor Borgs and Janitors have easy
// access to them, and only one of them can emag their device.
//
// The explosion cannot insta-kill anyone with 30% or more health.
#define LIGHT_OK 0
#define LIGHT_EMPTY 1
#define LIGHT_BROKEN 2
#define LIGHT_BURNED 3
/obj/item/device/lightreplacer
name = "light replacer"
desc = "A device to automatically replace lights. Refill with working lightbulbs."
icon = 'icons/obj/janitor.dmi'
icon_state = "lightreplacer0"
item_state = "electronic"
flags = CONDUCT
slot_flags = SLOT_BELT
origin_tech = "magnets=3;materials=2"
var/max_uses = 20
var/uses = 0
var/shards = 0
var/recycle = 3
var/emagged = 0
var/failmsg = ""
// How much to increase per each glass?
var/increment = 5
// How much to take from the glass?
var/decrement = 1
var/charge = 1
/obj/item/device/lightreplacer/New()
uses = max_uses / 2
failmsg = "The [name]'s refill light blinks red."
..()
/obj/item/device/lightreplacer/examine(mob/user)
if(..(user, 2))
to_chat(user, "It has [uses] lights and [shards] shards remaining.")
/obj/item/device/lightreplacer/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/stack/sheet/glass))
var/obj/item/stack/sheet/glass/G = W
if(G.amount - decrement >= 0 && uses < max_uses)
var/remaining = max(G.amount - decrement, 0)
if(!remaining && !(G.amount - decrement) == 0)
to_chat(user, "There isn't enough glass.")
return
G.amount = remaining
if(!G.amount)
user.drop_item()
qdel(G)
AddUses(increment)
to_chat(user, "You insert a piece of glass into the [src.name]. You have [uses] lights remaining.")
return
if(istype(W, /obj/item/weapon/light))
var/obj/item/weapon/light/L = W
if(L.status == 0) // LIGHT OKAY
if(!user.drop_item())
to_chat(user, "[L] is stuck to your hand!")
return
if(uses < max_uses)
AddUses(1)
to_chat(user, "You insert the [L.name] into the [src.name]. You have [uses] lights remaining.")
user.drop_item()
qdel(L)
return
else if(L.status == 2 || L.status == 3)
if(!user.drop_item())
to_chat(user, "[L] is stuck to your hand!")
return
else
AddShards(1)
to_chat(user, "You insert [L] into [src]. You have [shards] shards remaining.")
user.drop_item()
qdel(L)
return
if(istype(W, /obj/item/weapon/storage))
var/obj/item/weapon/storage/S = W
var/found_lightbulbs = 0
for(var/obj/item/I in S.contents)
if(istype(I,/obj/item/weapon/light))
var/obj/item/weapon/light/L = I
found_lightbulbs = 1
if(uses >= max_uses)
to_chat(user, "<span class='warning'>[src] is full!</span>")
break
if(L.status == 0)
AddUses(1)
qdel(L)
else if(L.status == 2 || L.status == 3)
AddShards(1)
qdel(L)
to_chat(user, "<span class='notice'>You fill [src] with lights from [S].")
if(!found_lightbulbs)
to_chat(user, "<span class='warning'>[S] contains no bulbs.</span>")
return
/obj/item/device/lightreplacer/emag_act(user as mob)
if(!emagged)
Emag()
/obj/item/device/lightreplacer/attack_self(mob/user)
/* // This would probably be a bit OP. If you want it though, uncomment the code.
if(isrobot(user))
var/mob/living/silicon/robot/R = user
if(R.emagged)
src.Emag()
to_chat(usr, "You shortcircuit the [src].")
return
*/
to_chat(usr, "It has [uses] lights remaining.")
/obj/item/device/lightreplacer/update_icon()
icon_state = "lightreplacer[emagged]"
/obj/item/device/lightreplacer/proc/Use(var/mob/user)
playsound(src.loc, 'sound/machines/click.ogg', 50, 1)
AddUses(-1)
return 1
// Negative numbers will subtract
/obj/item/device/lightreplacer/proc/AddUses(var/amount = 1)
uses = min(max(uses + amount, 0), max_uses)
/obj/item/device/lightreplacer/proc/AddShards(amount = 1)
shards += amount
var/recycled_lights = round(shards / recycle)
if(recycled_lights > 0)
AddUses(recycled_lights)
shards = shards % recycle
return recycled_lights
/obj/item/device/lightreplacer/proc/Charge(var/mob/user)
charge += 1
if(charge > 7)
AddUses(1)
charge = 1
/obj/item/device/lightreplacer/proc/ReplaceLight(var/obj/machinery/light/target, var/mob/living/U)
if(target.status != LIGHT_OK)
if(CanUse(U))
if(!Use(U)) return
to_chat(U, "<span class='notice'>You replace the [target.fitting] with the [src].</span>")
if(target.status != LIGHT_EMPTY)
var/obj/item/weapon/light/L1 = new target.light_type(target.loc)
L1.status = target.status
L1.rigged = target.rigged
L1.brightness_range = target.brightness_range
L1.brightness_power = target.brightness_power
L1.brightness_color = target.brightness_color
L1.switchcount = target.switchcount
target.switchcount = 0
L1.update()
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.fitting] already inserted.")
return
/obj/item/device/lightreplacer/proc/Emag()
emagged = !emagged
playsound(src.loc, "sparks", 100, 1)
if(emagged)
name = "Shortcircuited [initial(name)]"
else
name = initial(name)
update_icon()
//Can you use it?
/obj/item/device/lightreplacer/proc/janicart_insert(mob/user, obj/structure/janitorialcart/J)
J.put_in_cart(src, user)
J.myreplacer = src
J.update_icon()
/obj/item/device/lightreplacer/proc/CanUse(var/mob/living/user)
src.add_fingerprint(user)
//Not sure what else to check for. Maybe if clumsy?
if(uses > 0)
return 1
else
return 0
#undef LIGHT_OK
#undef LIGHT_EMPTY
#undef LIGHT_BROKEN
#undef LIGHT_BURNED