diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index 9c32b654ec3..8c77b8faba5 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -7,7 +7,7 @@ // Toilets are a type of disposal bin for small objects only and work on magic. By magic, I mean torque rotation #define SEND_PRESSURE 0.05*ONE_ATMOSPHERE -/obj/machinery/disposal +/obj/machinery/disposal/ name = "disposal unit" desc = "A pneumatic waste disposal unit." icon = 'icons/obj/pipes/disposal.dmi' @@ -25,463 +25,452 @@ active_power_usage = 600 idle_power_usage = 100 - // create a new disposal - // find the attached trunk (if present) and init gas resvr. - New() - ..() - spawn(5) - trunk = locate() in src.loc - if(!trunk) +// create a new disposal +// find the attached trunk (if present) and init gas resvr. +/obj/machinery/disposal/New() + ..() + spawn(5) + trunk = locate() in src.loc + if(!trunk) + mode = 0 + flush = 0 + else + trunk.linked = src // link the pipe trunk to self + + air_contents = new/datum/gas_mixture() + //gas.volume = 1.05 * CELLSTANDARD + update() + + +// attack by item places it in to disposal +/obj/machinery/disposal/attackby(var/obj/item/I, var/mob/user, params) + if(stat & BROKEN || !I || !user || (I.flags & NODROP)) + return + + if(isrobot(user) && !istype(I, /obj/item/weapon/storage/bag/trash)) + return + src.add_fingerprint(user) + if(mode<=0) // It's off + if(istype(I, /obj/item/weapon/screwdriver)) + if(contents.len > 0) + user << "Eject the items first!" + return + if(mode==0) // It's off but still not unscrewed + mode=-1 // Set it to doubleoff l0l + playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) + user << "You remove the screws around the power connection." + return + else if(mode==-1) + mode=0 + playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) + user << "You attach the screws around the power connection." + return + else if(istype(I,/obj/item/weapon/weldingtool) && mode==-1) + if(contents.len > 0) + user << "Eject the items first!" + return + var/obj/item/weapon/weldingtool/W = I + if(W.remove_fuel(0,user)) + playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) + user << "You start slicing the floorweld off the disposal unit." + + if(do_after(user,20)) + if(!src || !W.isOn()) return + user << "You sliced the floorweld off the disposal unit." + var/obj/structure/disposalconstruct/C = new (src.loc) + src.transfer_fingerprints_to(C) + C.ptype = 6 // 6 = disposal unit + C.anchored = 1 + C.density = 1 + C.update() + qdel(src) + return + else + user << "You need more welding fuel to complete this task." + return + + if(istype(I, /obj/item/weapon/melee/energy/blade)) + user << "You can't place that item inside the disposal unit." + return + + if(istype(I, /obj/item/weapon/storage)) + var/obj/item/weapon/storage/S = I + if((S.allow_quick_empty || S.allow_quick_gather) && S.contents.len) + S.hide_from(user) + user.visible_message("[user] empties \the [S] into \the [src].", "You empty \the [S] into \the [src].") + for(var/obj/item/O in S.contents) + S.remove_from_storage(O, src) + S.update_icon() // For content-sensitive icons + update() + return + + var/obj/item/weapon/grab/G = I + if(istype(G)) // handle grabbed mob + if(ismob(G.affecting)) + var/mob/GM = G.affecting + for (var/mob/V in viewers(usr)) + V.show_message("[usr] starts putting [GM.name] into the disposal.", 3) + if(do_after(usr, 20)) + if (GM.client) + GM.client.perspective = EYE_PERSPECTIVE + GM.client.eye = src + GM.loc = src + for (var/mob/C in viewers(src)) + C.show_message("\red [GM.name] has been placed in the [src] by [user].", 3) + qdel(G) + usr.attack_log += text("\[[time_stamp()]\] Has placed [GM.name] ([GM.ckey]) in disposals.") + GM.attack_log += text("\[[time_stamp()]\] Has been placed in disposals by [usr.name] ([usr.ckey])") + if(GM.ckey) + msg_admin_attack("[usr] ([usr.ckey])[isAntag(usr) ? "(ANTAG)" : ""] placed [GM] ([GM.ckey]) in a disposals unit. (JMP)") + return + + if(!I) return + + user.drop_item() + if(I) + I.loc = src + + user << "You place \the [I] into the [src]." + for(var/mob/M in viewers(src)) + if(M == user) + continue + M.show_message("[user.name] places \the [I] into the [src].", 3) + + update() + +// mouse drop another mob or self +// +/obj/machinery/disposal/MouseDrop_T(mob/target, mob/user) + if (!istype(target) || target.buckled || get_dist(user, src) > 1 || get_dist(user, target) > 1 || user.stat || istype(user, /mob/living/silicon/ai)) + return + if(isanimal(user) && target != user) return //animals cannot put mobs other than themselves into disposal + src.add_fingerprint(user) + var/target_loc = target.loc + var/msg + for (var/mob/V in viewers(usr)) + if(target == user && !user.stat && !user.weakened && !user.stunned && !user.paralysis) + V.show_message("[usr] starts climbing into the disposal.", 3) + if(target != user && !user.restrained() && !user.stat && !user.weakened && !user.stunned && !user.paralysis) + if(target.anchored) return + V.show_message("[usr] starts stuffing [target.name] into the disposal.", 3) + if(!do_after(usr, 20)) + return + if(target_loc != target.loc) + return + if(target == user && !user.stat && !user.weakened && !user.stunned && !user.paralysis) // if drop self, then climbed in + // must be awake, not stunned or whatever + msg = "[user.name] climbs into the [src]." + user << "You climb into the [src]." + else if(target != user && !user.restrained() && !user.stat && !user.weakened && !user.stunned && !user.paralysis) + msg = "[user.name] stuffs [target.name] into the [src]!" + user << "You stuff [target.name] into the [src]!" + + user.attack_log += text("\[[time_stamp()]\] Has placed [target.name] ([target.ckey]) in disposals.") + target.attack_log += text("\[[time_stamp()]\] Has been placed in disposals by [user.name] ([user.ckey])") + if(target.ckey) + msg_admin_attack("[user] ([user.ckey])[isAntag(user) ? "(ANTAG)" : ""] placed [target] ([target.ckey]) in a disposals unit. (JMP)") + else + return + if (target.client) + target.client.perspective = EYE_PERSPECTIVE + target.client.eye = src + target.loc = src + + for (var/mob/C in viewers(src)) + if(C == user) + continue + C.show_message(msg, 3) + + update() + return + +// can breath normally in the disposal +/obj/machinery/disposal/alter_health() + return get_turf(src) + +// attempt to move while inside +/obj/machinery/disposal/relaymove(mob/user as mob) + if(user.stat || src.flushing) + return + src.go_out(user) + return + +// leave the disposal +/obj/machinery/disposal/proc/go_out(mob/user) + + if (user.client) + user.client.eye = user.client.mob + user.client.perspective = MOB_PERSPECTIVE + user.loc = src.loc + update() + return + + +// ai as human but can't flush +/obj/machinery/disposal/attack_ai(mob/user as mob) + ui_interact(user) + +// human interact with machine +/obj/machinery/disposal/attack_hand(mob/user as mob) + if(..(user)) + return 1 + + if(stat & BROKEN) + return + + if(user && user.loc == src) + usr << "\red You cannot reach the controls from inside." + return + + // Clumsy folks can only flush it. + if(user.IsAdvancedToolUser(1)) + ui_interact(user) + else + flush = !flush + update() + return + +/obj/machinery/disposal/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) + var/data[0] + + var/pressure = 100 * air_contents.return_pressure() / (SEND_PRESSURE) + var/pressure_round = round(pressure,1) + + data["isAI"] = isAI(user) + data["flushing"] = flush + data["mode"] = mode + if(mode <= 0) + data["pumpstatus"] = "" + else if(mode == 1 && pressure_round != "100") + data["pumpstatus"] = "(pressurizing)" + else if(mode == 2) + data["pumpstatus"] = "(flushing)" + else + data["pumpstatus"] = "(idle)" + data["pressure"] = pressure_round + + ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) + + if (!ui) + ui = new(user, src, ui_key, "disposal_bin.tmpl", "Waste Disposal Unit", 375, 250) + ui.set_initial_data(data) + ui.open() + ui.set_auto_update(1) + +/obj/machinery/disposal/Topic(href, href_list) + if(usr.loc == src) + usr << "\red You cannot reach the controls from inside." + return + + if(mode==-1 && !href_list["eject"]) // only allow ejecting if mode is -1 + usr << "\red The disposal units power is disabled." + return + + if(..()) + return + + if(stat & BROKEN) + return + + src.add_fingerprint(usr) + + if(usr.stat || usr.restrained() || src.flushing) + return + + if (istype(src.loc, /turf)) + if(href_list["pump"]) + if(text2num(href_list["pump"])) + mode = 1 + else mode = 0 - flush = 0 - else - trunk.linked = src // link the pipe trunk to self - - air_contents = new/datum/gas_mixture() - //gas.volume = 1.05 * CELLSTANDARD update() - - // attack by item places it in to disposal - attackby(var/obj/item/I, var/mob/user, params) - if(stat & BROKEN || !I || !user || (I.flags & NODROP)) - return - - if(isrobot(user) && !istype(I, /obj/item/weapon/storage/bag/trash)) - return - src.add_fingerprint(user) - if(mode<=0) // It's off - if(istype(I, /obj/item/weapon/screwdriver)) - if(contents.len > 0) - user << "Eject the items first!" - return - if(mode==0) // It's off but still not unscrewed - mode=-1 // Set it to doubleoff l0l - playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) - user << "You remove the screws around the power connection." - return - else if(mode==-1) - mode=0 - playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) - user << "You attach the screws around the power connection." - return - else if(istype(I,/obj/item/weapon/weldingtool) && mode==-1) - if(contents.len > 0) - user << "Eject the items first!" - return - var/obj/item/weapon/weldingtool/W = I - if(W.remove_fuel(0,user)) - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - user << "You start slicing the floorweld off the disposal unit." - - if(do_after(user,20)) - if(!src || !W.isOn()) return - user << "You sliced the floorweld off the disposal unit." - var/obj/structure/disposalconstruct/C = new (src.loc) - src.transfer_fingerprints_to(C) - C.ptype = 6 // 6 = disposal unit - C.anchored = 1 - C.density = 1 - C.update() - qdel(src) - return - else - user << "You need more welding fuel to complete this task." - return - - if(istype(I, /obj/item/weapon/melee/energy/blade)) - user << "You can't place that item inside the disposal unit." - return - - if(istype(I, /obj/item/weapon/storage)) - var/obj/item/weapon/storage/S = I - if((S.allow_quick_empty || S.allow_quick_gather) && S.contents.len) - S.hide_from(user) - user.visible_message("[user] empties \the [S] into \the [src].", "You empty \the [S] into \the [src].") - for(var/obj/item/O in S.contents) - S.remove_from_storage(O, src) - S.update_icon() // For content-sensitive icons - update() - return - - var/obj/item/weapon/grab/G = I - if(istype(G)) // handle grabbed mob - if(ismob(G.affecting)) - var/mob/GM = G.affecting - for (var/mob/V in viewers(usr)) - V.show_message("[usr] starts putting [GM.name] into the disposal.", 3) - if(do_after(usr, 20)) - if (GM.client) - GM.client.perspective = EYE_PERSPECTIVE - GM.client.eye = src - GM.loc = src - for (var/mob/C in viewers(src)) - C.show_message("\red [GM.name] has been placed in the [src] by [user].", 3) - qdel(G) - usr.attack_log += text("\[[time_stamp()]\] Has placed [GM.name] ([GM.ckey]) in disposals.") - GM.attack_log += text("\[[time_stamp()]\] Has been placed in disposals by [usr.name] ([usr.ckey])") - if(GM.ckey) - msg_admin_attack("[usr] ([usr.ckey])[isAntag(usr) ? "(ANTAG)" : ""] placed [GM] ([GM.ckey]) in a disposals unit. (JMP)") - return - - if(!I) return - - user.drop_item() - if(I) - I.loc = src - - user << "You place \the [I] into the [src]." - for(var/mob/M in viewers(src)) - if(M == user) - continue - M.show_message("[user.name] places \the [I] into the [src].", 3) - - update() - - // mouse drop another mob or self - // - MouseDrop_T(mob/target, mob/user) - if (!istype(target) || target.buckled || get_dist(user, src) > 1 || get_dist(user, target) > 1 || user.stat || istype(user, /mob/living/silicon/ai)) - return - if(isanimal(user) && target != user) return //animals cannot put mobs other than themselves into disposal - src.add_fingerprint(user) - var/target_loc = target.loc - var/msg - for (var/mob/V in viewers(usr)) - if(target == user && !user.stat && !user.weakened && !user.stunned && !user.paralysis) - V.show_message("[usr] starts climbing into the disposal.", 3) - if(target != user && !user.restrained() && !user.stat && !user.weakened && !user.stunned && !user.paralysis) - if(target.anchored) return - V.show_message("[usr] starts stuffing [target.name] into the disposal.", 3) - if(!do_after(usr, 20)) - return - if(target_loc != target.loc) - return - if(target == user && !user.stat && !user.weakened && !user.stunned && !user.paralysis) // if drop self, then climbed in - // must be awake, not stunned or whatever - msg = "[user.name] climbs into the [src]." - user << "You climb into the [src]." - else if(target != user && !user.restrained() && !user.stat && !user.weakened && !user.stunned && !user.paralysis) - msg = "[user.name] stuffs [target.name] into the [src]!" - user << "You stuff [target.name] into the [src]!" - - user.attack_log += text("\[[time_stamp()]\] Has placed [target.name] ([target.ckey]) in disposals.") - target.attack_log += text("\[[time_stamp()]\] Has been placed in disposals by [user.name] ([user.ckey])") - if(target.ckey) - msg_admin_attack("[user] ([user.ckey])[isAntag(user) ? "(ANTAG)" : ""] placed [target] ([target.ckey]) in a disposals unit. (JMP)") - else - return - if (target.client) - target.client.perspective = EYE_PERSPECTIVE - target.client.eye = src - target.loc = src - - for (var/mob/C in viewers(src)) - if(C == user) - continue - C.show_message(msg, 3) - - update() - return - - // can breath normally in the disposal - alter_health() - return get_turf(src) - - // attempt to move while inside - relaymove(mob/user as mob) - if(user.stat || src.flushing) - return - src.go_out(user) - return - - // leave the disposal - proc/go_out(mob/user) - - if (user.client) - user.client.eye = user.client.mob - user.client.perspective = MOB_PERSPECTIVE - user.loc = src.loc - update() - return - - - // ai as human but can't flush - attack_ai(mob/user as mob) - interact(user, 1) - - // human interact with machine - attack_hand(mob/user as mob) - if(stat & BROKEN) - return - - if(user && user.loc == src) - usr << "\red You cannot reach the controls from inside." - return - - // Clumsy folks can only flush it. - if(user.IsAdvancedToolUser(1)) - interact(user, 0) - else - flush = !flush - update() - return - - // user interaction - interact(mob/user, var/ai=0) - - src.add_fingerprint(user) - if(stat & BROKEN) - user.unset_machine() - return - - var/dat = "