Merge pull request #7937 from VOREStation/Arokha/janicart

New janicart sprites/features
This commit is contained in:
Aronai Sieyes
2020-05-17 22:39:53 -04:00
committed by GitHub
5 changed files with 198 additions and 42 deletions

View File

@@ -729,3 +729,12 @@
/obj/item/weapon/storage/AllowDrop() /obj/item/weapon/storage/AllowDrop()
return TRUE return TRUE
//Useful for spilling the contents of containers all over the floor
/obj/item/weapon/storage/proc/spill(var/dist = 2, var/turf/T = null)
if (!istype(T))//If its not on the floor this might cause issues
T = get_turf(src)
for (var/obj/O in contents)
remove_from_storage(O, T)
O.tumble(2)

View File

@@ -203,3 +203,14 @@
/obj/proc/container_resist(var/mob/living) /obj/proc/container_resist(var/mob/living)
return return
//To be called from things that spill objects on the floor.
//Makes an object move around randomly for a couple of tiles
/obj/proc/tumble(var/dist = 2)
set waitfor = FALSE
if (dist >= 1)
dist += rand(0,1)
for(var/i = 1, i <= dist, i++)
if(src)
step(src, pick(NORTH,SOUTH,EAST,WEST))
sleep(rand(2,4))

View File

@@ -7,95 +7,147 @@ GLOBAL_LIST_BOILERPLATE(all_janitorial_carts, /obj/structure/janitorialcart)
icon_state = "cart" icon_state = "cart"
anchored = 0 anchored = 0
density = 1 density = 1
climbable = 1
flags = OPENCONTAINER flags = OPENCONTAINER
climbable = TRUE
//copypaste sorry //copypaste sorry
var/amount_per_transfer_from_this = 5 //shit I dunno, adding this so syringes stop runtime erroring. --NeoFite 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/storage/bag/trash/mybag = null
var/obj/item/weapon/mop/mymop = null var/obj/item/weapon/mop/mymop = null
var/obj/item/weapon/reagent_containers/spray/myspray = null var/obj/item/weapon/reagent_containers/spray/myspray = null
var/obj/item/device/lightreplacer/myreplacer = 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 var/signs = 0 //maximum capacity hardcoded below
/obj/structure/janitorialcart/New()
create_reagents(300)
..()
/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) /obj/structure/janitorialcart/examine(mob/user)
. = ..() if(..(user, 1))
if(Adjacent(user)) if (mybucket)
. += "It contains [reagents.total_volume] unit\s of liquid!" var/contains = mybucket.reagents.total_volume
to_chat(user, "\icon[src] The bucket contains [contains] unit\s of liquid!")
else
to_chat(user, "\icon[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) /obj/structure/janitorialcart/attackby(obj/item/I, mob/user)
if(istype(I, /obj/item/weapon/storage/bag/trash) && !mybag) if(istype(I, /obj/item/weapon/mop) || istype(I, /obj/item/weapon/reagent_containers/glass/rag) || istype(I, /obj/item/weapon/soap))
user.drop_item() if (mybucket)
mybag = I if(I.reagents.total_volume < I.reagents.maximum_volume)
I.loc = src if(mybucket.reagents.total_volume < 1)
update_icon() to_chat(user, "<span class='notice'>[mybucket] is empty!</span>")
updateUsrDialog() else
to_chat(user, "<span class='notice'>You put [I] into [src].</span>") mybucket.reagents.trans_to_obj(I, 5) //
to_chat(user, "<span class='notice'>You wet [I] in [mybucket].</span>")
else if(istype(I, /obj/item/weapon/mop)) playsound(loc, 'sound/effects/slosh.ogg', 25, 1)
if(I.reagents.total_volume < I.reagents.maximum_volume) //if it's not completely soaked we assume they want to wet it, otherwise store it
if(reagents.total_volume < 1)
to_chat(user, "<span class='warning'>[src] is out of water!</span>")
else else
reagents.trans_to_obj(I, 5) // to_chat(user, "<span class='notice'>[I] can't absorb anymore liquid!</span>")
to_chat(user, "<span class='notice'>You wet [I] in [src].</span>") else
playsound(loc, 'sound/effects/slosh.ogg', 25, 1) to_chat(user, "<span class='notice'>There is no bucket mounted here to dip [I] into!</span>")
return return 1
if(!mymop)
user.drop_item() else if (istype(I, /obj/item/weapon/reagent_containers/glass/bucket) && mybucket)
mymop = I I.afterattack(mybucket, usr, 1)
I.loc = src update_icon()
update_icon() return 1
updateUsrDialog()
to_chat(user, "<span class='notice'>You put [I] into [src].</span>")
else if(istype(I, /obj/item/weapon/reagent_containers/spray) && !myspray) else if(istype(I, /obj/item/weapon/reagent_containers/spray) && !myspray)
user.drop_item() user.unEquip(I, 0, src)
myspray = I myspray = I
I.loc = src
update_icon() update_icon()
updateUsrDialog() updateUsrDialog()
to_chat(user, "<span class='notice'>You put [I] into [src].</span>") to_chat(user, "<span class='notice'>You put [I] into [src].</span>")
return 1
else if(istype(I, /obj/item/device/lightreplacer) && !myreplacer) else if(istype(I, /obj/item/device/lightreplacer) && !myreplacer)
user.drop_item() user.unEquip(I, 0, src)
myreplacer = I myreplacer = I
I.loc = src
update_icon() update_icon()
updateUsrDialog() updateUsrDialog()
to_chat(user, "<span class='notice'>You put [I] into [src].</span>") to_chat(user, "<span class='notice'>You put [I] into [src].</span>")
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, "<span class='notice'>You put [I] into [src].</span>")
return 1
else if(istype(I, /obj/item/weapon/caution)) else if(istype(I, /obj/item/weapon/caution))
if(signs < 4) if(signs < 4)
user.drop_item() user.unEquip(I, 0, src)
I.loc = src
signs++ signs++
update_icon() update_icon()
updateUsrDialog() updateUsrDialog()
to_chat(user, "<span class='notice'>You put [I] into [src].</span>") to_chat(user, "<span class='notice'>You put [I] into [src].</span>")
else else
to_chat(user, "<span class='notice'>[src] can't hold any more signs.</span>") to_chat(user, "<span class='notice'>[src] can't hold any more signs.</span>")
return 1
else if(istype(I, /obj/item/weapon/reagent_containers/glass))
return // So we do not put them in the trash bag as we mean to fill the mop bucket
else if(mybag) else if(mybag)
mybag.attackby(I, user) 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, "<span class='notice'>You put [I] into [src].</span>")
update_icon()
else
to_chat(usr, "<span class='notice'>The cart already has a mop attached</span>")
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) /obj/structure/janitorialcart/attack_hand(mob/user)
ui_interact(user) ui_interact(user)
return return
/obj/structure/janitorialcart/ui_interact(var/mob/user, var/ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) /obj/structure/janitorialcart/ui_interact(var/mob/user, var/ui_key = "main", var/datum/nanoui/ui = null, var/force_open = TRUE)
var/data[0] var/data[0]
data["name"] = capitalize(name) data["name"] = capitalize(name)
data["bag"] = mybag ? capitalize(mybag.name) : null data["bag"] = mybag ? capitalize(mybag.name) : null
data["bucket"] = mybucket ? capitalize(mybucket.name) : null
data["mop"] = mymop ? capitalize(mymop.name) : null data["mop"] = mymop ? capitalize(mymop.name) : null
data["spray"] = myspray ? capitalize(myspray.name) : null data["spray"] = myspray ? capitalize(myspray.name) : null
data["replacer"] = myreplacer ? capitalize(myreplacer.name) : null data["replacer"] = myreplacer ? capitalize(myreplacer.name) : null
@@ -107,6 +159,7 @@ GLOBAL_LIST_BOILERPLATE(all_janitorial_carts, /obj/structure/janitorialcart)
ui.set_initial_data(data) ui.set_initial_data(data)
ui.open() ui.open()
/obj/structure/janitorialcart/Topic(href, href_list) /obj/structure/janitorialcart/Topic(href, href_list)
if(!in_range(src, usr)) if(!in_range(src, usr))
return return
@@ -146,13 +199,24 @@ GLOBAL_LIST_BOILERPLATE(all_janitorial_carts, /obj/structure/janitorialcart)
else else
warning("[src] signs ([signs]) didn't match contents") warning("[src] signs ([signs]) didn't match contents")
signs = 0 signs = 0
if("bucket")
if(mybucket)
mybucket.forceMove(get_turf(user))
to_chat(user, "<span class='notice'>You unmount [mybucket] from [src].</span>")
mybucket = null
update_icon() update_icon()
updateUsrDialog() updateUsrDialog()
/obj/structure/janitorialcart/update_icon() /obj/structure/janitorialcart/update_icon()
overlays = null overlays.Cut()
if(mybucket)
overlays += "cart_bucket"
if(mybucket.reagents.total_volume >= 1)
overlays += "water_cart"
if(mybag) if(mybag)
overlays += "cart_garbage" overlays += "cart_garbage"
if(mymop) if(mymop)
@@ -165,6 +229,73 @@ GLOBAL_LIST_BOILERPLATE(all_janitorial_carts, /obj/structure/janitorialcart)
overlays += "cart_sign[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/weapon/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 //old style retardo-cart
/obj/structure/bed/chair/janicart /obj/structure/bed/chair/janicart
name = "janicart" name = "janicart"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -27,4 +27,9 @@
{{:helper.link(data.signs, '', { 'take' : 'sign' })}} {{:helper.link(data.signs, '', { 'take' : 'sign' })}}
</div> </div>
{{/if}} {{/if}}
{{if data.bucket}}
<div>
{{:helper.link(data.bucket, '', { 'take' : 'bucket' })}}
</div>
{{/if}}
</div> </div>