GLOBAL_LIST_BOILERPLATE(all_janitorial_carts, /obj/structure/janitorialcart)
/obj/structure/janitorialcart
name = "janitorial cart"
desc = "The ultimate in janitorial carts! Has space for water, mops, signs, trash bags, and more!"
description_info = "You can use alt-click while holding a mop to stow the mop. Alt-click holding a reagent container will empty the contents into the bucket without trying to put the container in any attached trash bag."
icon = 'icons/obj/janitor.dmi'
icon_state = "cart"
anchored = 0
density = 1
flags = OPENCONTAINER
climbable = TRUE
//copypaste sorry
var/amount_per_transfer_from_this = 5 //shit I dunno, adding this so syringes stop runtime erroring. --NeoFite
var/obj/item/weapon/storage/bag/trash/mybag = null
var/obj/item/weapon/mop/mymop = null
var/obj/item/weapon/reagent_containers/spray/myspray = null
var/obj/item/device/lightreplacer/myreplacer = null
var/obj/structure/mopbucket/mybucket = null
var/has_items = FALSE
var/dismantled = TRUE
var/signs = 0 //maximum capacity hardcoded below
/obj/structure/janitorialcart/Destroy()
QDEL_NULL(mybag)
QDEL_NULL(mymop)
QDEL_NULL(myspray)
QDEL_NULL(myreplacer)
QDEL_NULL(mybucket)
return ..()
/obj/structure/janitorialcart/examine(mob/user)
. = ..(user)
if(istype(mybucket))
var/contains = mybucket.reagents.total_volume
. += "[bicon(src)] The bucket contains [contains] unit\s of liquid!"
else
. += "[bicon(src)] There is no bucket mounted on it!"
/obj/structure/janitorialcart/MouseDrop_T(atom/movable/O as mob|obj, mob/living/user as mob)
if (istype(O, /obj/structure/mopbucket) && !mybucket)
O.forceMove(src)
mybucket = O
to_chat(user, "You mount the [O] on the janicart.")
update_icon()
else
..()
/obj/structure/janitorialcart/attackby(obj/item/I, mob/user)
if(istype(I, /obj/item/weapon/mop) || istype(I, /obj/item/weapon/reagent_containers/glass/rag) || istype(I, /obj/item/weapon/soap))
if (mybucket)
if(I.reagents.total_volume < I.reagents.maximum_volume)
if(mybucket.reagents.total_volume < 1)
to_chat(user, "[mybucket] is empty!")
else
mybucket.reagents.trans_to_obj(I, 5) //
to_chat(user, "You wet [I] in [mybucket].")
playsound(loc, 'sound/effects/slosh.ogg', 25, 1)
else
to_chat(user, "[I] can't absorb anymore liquid!")
else
to_chat(user, "There is no bucket mounted here to dip [I] into!")
return 1
else if (istype(I, /obj/item/weapon/reagent_containers/glass/bucket) && mybucket)
I.afterattack(mybucket, usr, 1)
update_icon()
return 1
else if(istype(I, /obj/item/weapon/reagent_containers/spray) && !myspray)
user.unEquip(I, 0, src)
myspray = I
update_icon()
updateUsrDialog()
to_chat(user, "You put [I] into [src].")
return 1
else if(istype(I, /obj/item/device/lightreplacer) && !myreplacer)
user.unEquip(I, 0, src)
myreplacer = I
update_icon()
updateUsrDialog()
to_chat(user, "You put [I] into [src].")
return 1
else if(istype(I, /obj/item/weapon/storage/bag/trash) && !mybag)
user.unEquip(I, 0, src)
mybag = I
update_icon()
updateUsrDialog()
to_chat(user, "You put [I] into [src].")
return 1
else if(istype(I, /obj/item/clothing/suit/caution))
if(signs < 4)
user.unEquip(I, 0, src)
signs++
update_icon()
updateUsrDialog()
to_chat(user, "You put [I] into [src].")
else
to_chat(user, "[src] can't hold any more signs.")
return 1
else if(mybag)
return mybag.attackby(I, user)
//This return will prevent afterattack from executing if the object goes into the trashbag,
//This prevents dumb stuff like splashing the cart with the contents of a container, after putting said container into trash
else if (!has_items)
if (I.is_wrench())
if (do_after(user, 5 SECONDS, src))
dismantle(user)
return
..()
//New Altclick functionality!
//Altclick the cart with a mop to stow the mop away
//Altclick the cart with a reagent container to pour things into the bucket without putting the bottle in trash
/obj/structure/janitorialcart/AltClick(mob/living/user)
if(user.incapacitated() || !Adjacent(user)) return
var/obj/I = usr.get_active_hand()
if(istype(I, /obj/item/weapon/mop))
if(!mymop)
usr.drop_from_inventory(I,src)
mymop = I
update_icon()
updateUsrDialog()
to_chat(usr, "You put [I] into [src].")
update_icon()
else
to_chat(usr, "The cart already has a mop attached")
return
else if(istype(I, /obj/item/weapon/reagent_containers) && mybucket)
var/obj/item/weapon/reagent_containers/C = I
C.afterattack(mybucket, usr, 1)
update_icon()
/obj/structure/janitorialcart/attack_hand(mob/user)
ui_interact(user)
return
/obj/structure/janitorialcart/ui_interact(var/mob/user, var/ui_key = "main", var/datum/nanoui/ui = null, var/force_open = TRUE)
var/data[0]
data["name"] = capitalize(name)
data["bag"] = mybag ? capitalize(mybag.name) : null
data["bucket"] = mybucket ? capitalize(mybucket.name) : null
data["mop"] = mymop ? capitalize(mymop.name) : null
data["spray"] = myspray ? capitalize(myspray.name) : null
data["replacer"] = myreplacer ? capitalize(myreplacer.name) : null
data["signs"] = signs ? "[signs] sign\s" : null
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if(!ui)
ui = new(user, src, ui_key, "janitorcart.tmpl", "Janitorial cart", 240, 160)
ui.set_initial_data(data)
ui.open()
/obj/structure/janitorialcart/Topic(href, href_list)
if(!in_range(src, usr))
return
if(!isliving(usr))
return
var/mob/living/user = usr
if(href_list["take"])
switch(href_list["take"])
if("garbage")
if(mybag)
user.put_in_hands(mybag)
to_chat(user, "You take [mybag] from [src].")
mybag = null
if("mop")
if(mymop)
user.put_in_hands(mymop)
to_chat(user, "You take [mymop] from [src].")
mymop = null
if("spray")
if(myspray)
user.put_in_hands(myspray)
to_chat(user, "You take [myspray] from [src].")
myspray = null
if("replacer")
if(myreplacer)
user.put_in_hands(myreplacer)
to_chat(user, "You take [myreplacer] from [src].")
myreplacer = null
if("sign")
if(signs)
var/obj/item/clothing/suit/caution/Sign = locate() in src
if(Sign)
user.put_in_hands(Sign)
to_chat(user, "You take \a [Sign] from [src].")
signs--
else
warning("[src] signs ([signs]) didn't match contents")
signs = 0
if("bucket")
if(mybucket)
mybucket.forceMove(get_turf(user))
to_chat(user, "You unmount [mybucket] from [src].")
mybucket = null
update_icon()
updateUsrDialog()
/obj/structure/janitorialcart/update_icon()
overlays.Cut()
if(mybucket)
overlays += "cart_bucket"
if(mybucket.reagents.total_volume >= 1)
overlays += "water_cart"
if(mybag)
overlays += "cart_garbage"
if(mymop)
overlays += "cart_mop"
if(myspray)
overlays += "cart_spray"
if(myreplacer)
overlays += "cart_replacer"
if(signs)
overlays += "cart_sign[signs]"
//This is called if the cart is caught in an explosion, or destroyed by weapon fire
/obj/structure/janitorialcart/proc/spill(var/chance = 100)
var/turf/dropspot = get_turf(src)
if (mymop && prob(chance))
mymop.forceMove(dropspot)
mymop.tumble(2)
mymop = null
if (myspray && prob(chance))
myspray.forceMove(dropspot)
myspray.tumble(3)
myspray = null
if (myreplacer && prob(chance))
myreplacer.forceMove(dropspot)
myreplacer.tumble(3)
myreplacer = null
if (mybucket && prob(chance*0.5))//bucket is heavier, harder to knock off
mybucket.forceMove(dropspot)
mybucket.tumble(1)
mybucket = null
if (signs)
for (var/obj/item/clothing/suit/caution/Sign in src)
if (prob(min((chance*2),100)))
signs--
Sign.forceMove(dropspot)
Sign.tumble(3)
if (signs < 0)//safety for something that shouldn't happen
signs = 0
update_icon()
return
if (mybag && prob(min((chance*2),100)))//Bag is flimsy
mybag.forceMove(dropspot)
mybag.tumble(1)
mybag.spill()//trashbag spills its contents too
mybag = null
update_icon()
/obj/structure/janitorialcart/proc/dismantle(var/mob/user = null)
if (!dismantled)
if (has_items)
spill()
new /obj/item/stack/material/steel(src.loc, 10)
new /obj/item/stack/material/plastic(src.loc, 10)
new /obj/item/stack/rods(src.loc, 20)
dismantled = 1
qdel(src)
/obj/structure/janitorialcart/ex_act(severity)
spill(100 / severity)
..()
//old style retardo-cart
/obj/structure/bed/chair/janicart
name = "janicart"
icon = 'icons/obj/vehicles.dmi'
icon_state = "pussywagon"
anchored = 1
density = 1
flags = OPENCONTAINER
//copypaste sorry
var/amount_per_transfer_from_this = 5 //shit I dunno, adding this so syringes stop runtime erroring. --NeoFite
var/obj/item/weapon/storage/bag/trash/mybag = null
var/callme = "pimpin' ride" //how do people refer to it?
/obj/structure/bed/chair/janicart/New()
create_reagents(300)
update_layer()
/obj/structure/bed/chair/janicart/examine(mob/user)
. = ..()
if(Adjacent(user))
. += "This [callme] contains [reagents.total_volume] unit\s of water!"
if(mybag)
. += "\A [mybag] is hanging on the [callme]."
/obj/structure/bed/chair/janicart/attackby(obj/item/I, mob/user)
if(istype(I, /obj/item/weapon/mop))
if(reagents.total_volume > 1)
reagents.trans_to_obj(I, 2)
to_chat(user, "You wet [I] in the [callme].")
playsound(src, 'sound/effects/slosh.ogg', 25, 1)
else
to_chat(user, "This [callme] is out of water!")
else if(istype(I, /obj/item/key))
to_chat(user, "Hold [I] in one of your hands while you drive this [callme].")
else if(istype(I, /obj/item/weapon/storage/bag/trash))
to_chat(user, "You hook the trashbag onto the [callme].")
user.drop_item()
I.loc = src
mybag = I
/obj/structure/bed/chair/janicart/attack_hand(mob/user)
if(mybag)
mybag.loc = get_turf(user)
user.put_in_hands(mybag)
mybag = null
else
..()
/obj/structure/bed/chair/janicart/relaymove(mob/living/user, direction)
if(user.stat || user.stunned || user.weakened || user.paralysis)
unbuckle_mob()
if(user.get_type_in_hands(/obj/item/key))
step(src, direction)
update_mob()
else
to_chat(user, "You'll need the keys in one of your hands to drive this [callme].")
/obj/structure/bed/chair/janicart/post_buckle_mob(mob/living/M)
update_mob()
return ..()
/obj/structure/bed/chair/janicart/update_layer()
if(dir == SOUTH)
layer = FLY_LAYER
else
layer = OBJ_LAYER
/obj/structure/bed/chair/janicart/unbuckle_mob()
var/mob/living/M = ..()
if(M)
M.pixel_x = 0
M.pixel_y = 0
return M
/obj/structure/bed/chair/janicart/set_dir()
..()
update_layer()
if(has_buckled_mobs())
for(var/A in buckled_mobs)
var/mob/living/L = A
if(L.loc != loc)
L.buckled = null //Temporary, so Move() succeeds.
L.buckled = src //Restoring
update_mob()
/obj/structure/bed/chair/janicart/proc/update_mob()
if(has_buckled_mobs())
for(var/A in buckled_mobs)
var/mob/living/L = A
L.set_dir(dir)
switch(dir)
if(SOUTH)
L.pixel_x = 0
L.pixel_y = 7
if(WEST)
L.pixel_x = 13
L.pixel_y = 7
if(NORTH)
L.pixel_x = 0
L.pixel_y = 4
if(EAST)
L.pixel_x = -13
L.pixel_y = 7
/obj/structure/bed/chair/janicart/bullet_act(var/obj/item/projectile/Proj)
if(has_buckled_mobs())
if(prob(85))
var/mob/living/L = pick(buckled_mobs)
return L.bullet_act(Proj)
visible_message("[Proj] ricochets off the [callme]!")
/obj/item/key
name = "key"
desc = "A keyring with a small steel key, and a pink fob reading \"Pussy Wagon\"."
icon = 'icons/obj/vehicles.dmi'
icon_state = "keys"
w_class = ITEMSIZE_TINY