From 90b894fe665914d2fec522a323276008ba4b591f Mon Sep 17 00:00:00 2001 From: Aranclanos Date: Wed, 3 Jul 2013 13:16:53 -0300 Subject: [PATCH] Made all the machinery use ..() on the Topic(), instead of having a copy pasta everywhere to see if the human is dead or others. This will stop dead AIs interacting with machineries or others. --- code/game/gamemodes/nuclear/nuclearbomb.dm | 124 ++++++++--------- code/game/machinery/Freezer.dm | 27 ++-- code/game/machinery/ai_slipper.dm | 3 +- code/game/machinery/alarm.dm | 42 +++--- code/game/machinery/bots/secbot.dm | 3 +- code/game/machinery/computer/power.dm | 3 +- .../machinery/computer/syndicate_shuttle.dm | 8 +- code/game/machinery/cryo.dm | 23 ++-- code/game/machinery/magnet.dm | 3 +- code/game/machinery/navbeacon.dm | 82 ++++++----- code/game/machinery/spaceheater.dm | 54 ++++---- code/game/machinery/syndicatebeacon.dm | 3 +- .../telecomms/machine_interactions.dm | 6 +- code/game/machinery/turrets.dm | 16 +-- code/game/machinery/vending.dm | 96 ++++++------- code/game/mecha/mech_bay.dm | 2 + code/game/mecha/mech_fabricator.dm | 3 +- .../items/weapons/implants/implantchair.dm | 30 ++-- .../awaymissions/bluespaceartillery.dm | 30 ++-- code/modules/hydroponics/biogenerator.dm | 5 +- code/modules/paperwork/photocopier.dm | 2 + code/modules/power/antimatter/control.dm | 6 +- code/modules/power/apc.dm | 3 +- code/modules/power/generator.dm | 3 +- code/modules/power/generator_type2.dm | 3 +- code/modules/power/gravitygenerator.dm | 8 +- .../particle_accelerator/particle_control.dm | 6 +- code/modules/power/smes.dm | 128 ++++++++---------- code/modules/power/turbine.dm | 36 ++--- code/modules/reagents/Chemistry-Machinery.dm | 6 +- code/modules/recycling/disposal.dm | 47 +++---- .../security levels/keycard authentication.dm | 7 +- 32 files changed, 367 insertions(+), 451 deletions(-) diff --git a/code/game/gamemodes/nuclear/nuclearbomb.dm b/code/game/gamemodes/nuclear/nuclearbomb.dm index e3c63e3d4f6..2b3dcfaa71e 100644 --- a/code/game/gamemodes/nuclear/nuclearbomb.dm +++ b/code/game/gamemodes/nuclear/nuclearbomb.dm @@ -86,78 +86,68 @@ var/bomb_set src.deployable = 1 /obj/machinery/nuclearbomb/Topic(href, href_list) - ..() - if (!usr.canmove || usr.stat || usr.restrained()) + if(..()) return - if (!ishuman(usr)) - usr << "\red You don't have the dexterity to do this!" - return 1 - if ((usr.contents.Find(src) || (in_range(src, usr) && istype(src.loc, /turf)))) - usr.set_machine(src) - if (href_list["auth"]) - if (src.auth) - src.auth.loc = src.loc - src.yes_code = 0 - src.auth = null - else - var/obj/item/I = usr.get_active_hand() - if (istype(I, /obj/item/weapon/disk/nuclear)) - usr.drop_item() - I.loc = src - src.auth = I + usr.set_machine(src) + if (href_list["auth"]) if (src.auth) - if (href_list["type"]) - if (href_list["type"] == "E") - if (src.code == src.r_code) - src.yes_code = 1 - src.code = null - else - src.code = "ERROR" + src.auth.loc = src.loc + src.yes_code = 0 + src.auth = null + else + var/obj/item/I = usr.get_active_hand() + if (istype(I, /obj/item/weapon/disk/nuclear)) + usr.drop_item() + I.loc = src + src.auth = I + if (src.auth) + if (href_list["type"]) + if (href_list["type"] == "E") + if (src.code == src.r_code) + src.yes_code = 1 + src.code = null else - if (href_list["type"] == "R") - src.yes_code = 0 - src.code = null + src.code = "ERROR" + else + if (href_list["type"] == "R") + src.yes_code = 0 + src.code = null + else + src.code += text("[]", href_list["type"]) + if (length(src.code) > 5) + src.code = "ERROR" + if (src.yes_code) + if (href_list["time"]) + var/time = text2num(href_list["time"]) + src.timeleft += time + src.timeleft = min(max(round(src.timeleft), 60), 600) + if (href_list["timer"]) + if (src.timing == -1.0) + return + if (src.safety) + usr << "\red The safety is still on." + return + src.timing = !( src.timing ) + if (src.timing) + src.icon_state = "nuclearbomb2" + if(!src.safety) + bomb_set = 1//There can still be issues with this reseting when there are multiple bombs. Not a big deal tho for Nuke/N else - src.code += text("[]", href_list["type"]) - if (length(src.code) > 5) - src.code = "ERROR" - if (src.yes_code) - if (href_list["time"]) - var/time = text2num(href_list["time"]) - src.timeleft += time - src.timeleft = min(max(round(src.timeleft), 60), 600) - if (href_list["timer"]) - if (src.timing == -1.0) - return - if (src.safety) - usr << "\red The safety is still on." - return - src.timing = !( src.timing ) - if (src.timing) - src.icon_state = "nuclearbomb2" - if(!src.safety) - bomb_set = 1//There can still be issues with this reseting when there are multiple bombs. Not a big deal tho for Nuke/N - else - bomb_set = 0 - else - src.icon_state = "nuclearbomb1" bomb_set = 0 - if (href_list["safety"]) - src.safety = !( src.safety ) - if(safety) - src.timing = 0 - bomb_set = 0 - if (href_list["anchor"]) - src.anchored = !( src.anchored ) - src.add_fingerprint(usr) - for(var/mob/M in viewers(1, src)) - if ((M.client && M.machine == src)) - src.attack_hand(M) - else - usr << browse(null, "window=nuclearbomb") - return - return - + else + src.icon_state = "nuclearbomb1" + bomb_set = 0 + if (href_list["safety"]) + src.safety = !( src.safety ) + if(safety) + src.timing = 0 + bomb_set = 0 + if (href_list["anchor"]) + src.anchored = !( src.anchored ) + src.add_fingerprint(usr) + for(var/mob/M in viewers(1, src)) + if ((M.client && M.machine == src)) + src.attack_hand(M) /obj/machinery/nuclearbomb/ex_act(severity) return diff --git a/code/game/machinery/Freezer.dm b/code/game/machinery/Freezer.dm index 41f4fc3fe53..6f307f6c84c 100644 --- a/code/game/machinery/Freezer.dm +++ b/code/game/machinery/Freezer.dm @@ -66,20 +66,19 @@ popup.open() Topic(href, href_list) - if ((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon/ai))) - usr.set_machine(src) - if (href_list["start"]) - src.on = !src.on - update_icon() - if(href_list["temp"]) - var/amount = text2num(href_list["temp"]) - if(amount > 0) - src.current_temperature = min(T20C, src.current_temperature+amount) - else - src.current_temperature = max((T0C - 200), src.current_temperature+amount) + if(..()) + return + usr.set_machine(src) + if (href_list["start"]) + src.on = !src.on + update_icon() + if(href_list["temp"]) + var/amount = text2num(href_list["temp"]) + if(amount > 0) + src.current_temperature = min(T20C, src.current_temperature+amount) + else + src.current_temperature = max((T0C - 200), src.current_temperature+amount) src.updateUsrDialog() - src.add_fingerprint(usr) - return process() ..() @@ -150,6 +149,8 @@ onclose(user, "heater") Topic(href, href_list) + if(..()) + return if ((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon/ai))) usr.set_machine(src) if (href_list["start"]) diff --git a/code/game/machinery/ai_slipper.dm b/code/game/machinery/ai_slipper.dm index 08f138d19d5..87e4b8d6098 100644 --- a/code/game/machinery/ai_slipper.dm +++ b/code/game/machinery/ai_slipper.dm @@ -83,7 +83,8 @@ return /obj/machinery/ai_slipper/Topic(href, href_list) - ..() + if(..()) + return if (src.locked) if (!istype(usr, /mob/living/silicon)) usr << "Control panel is locked!" diff --git a/code/game/machinery/alarm.dm b/code/game/machinery/alarm.dm index dccfb930f63..f58249b3b7d 100644 --- a/code/game/machinery/alarm.dm +++ b/code/game/machinery/alarm.dm @@ -695,7 +695,6 @@ table tr:first-child th:first-child { border: none;} /obj/machinery/alarm/Topic(href, href_list) if(..()) return - src.add_fingerprint(usr) usr.set_machine(src) if ( (get_dist(src, usr) > 1 )) @@ -1313,35 +1312,27 @@ FIRE ALARM return /obj/machinery/firealarm/Topic(href, href_list) - ..() - if (usr.stat || stat & (BROKEN|NOPOWER)) + if(..()) return if (buildstage != 2) return - if ((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon))) - usr.set_machine(src) - if (href_list["reset"]) - src.reset() - else if (href_list["alarm"]) - src.alarm() - else if (href_list["time"]) - src.timing = text2num(href_list["time"]) - last_process = world.timeofday - processing_objects.Add(src) - else if (href_list["tp"]) - var/tp = text2num(href_list["tp"]) - src.time += tp - src.time = min(max(round(src.time), 0), 120) + usr.set_machine(src) + if (href_list["reset"]) + src.reset() + else if (href_list["alarm"]) + src.alarm() + else if (href_list["time"]) + src.timing = text2num(href_list["time"]) + last_process = world.timeofday + processing_objects.Add(src) + else if (href_list["tp"]) + var/tp = text2num(href_list["tp"]) + src.time += tp + src.time = min(max(round(src.time), 0), 120) - src.updateUsrDialog() - - src.add_fingerprint(usr) - else - usr << browse(null, "window=firealarm") - return - return + src.updateUsrDialog() /obj/machinery/firealarm/proc/reset() if (!( src.working )) @@ -1533,7 +1524,8 @@ Code shamelessly copied from apc_frame return /obj/machinery/partyalarm/Topic(href, href_list) - ..() + if(..()) + return if (usr.stat || stat & (BROKEN|NOPOWER)) return if ((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon/ai))) diff --git a/code/game/machinery/bots/secbot.dm b/code/game/machinery/bots/secbot.dm index 8d08f44641f..15b484f1b7b 100644 --- a/code/game/machinery/bots/secbot.dm +++ b/code/game/machinery/bots/secbot.dm @@ -132,8 +132,9 @@ Auto Patrol: []"}, return /obj/machinery/bot/secbot/Topic(href, href_list) + if(..()) + return usr.set_machine(src) - src.add_fingerprint(usr) if((href_list["power"]) && (src.allowed(usr))) if(src.on) turn_off() diff --git a/code/game/machinery/computer/power.dm b/code/game/machinery/computer/power.dm index dcbf492551d..4c841e12734 100644 --- a/code/game/machinery/computer/power.dm +++ b/code/game/machinery/computer/power.dm @@ -118,7 +118,8 @@ popup.open() /obj/machinery/power/monitor/Topic(href, href_list) - ..() + if(..()) + return if( href_list["close"] ) usr << browse(null, "window=powcomp") usr.unset_machine() diff --git a/code/game/machinery/computer/syndicate_shuttle.dm b/code/game/machinery/computer/syndicate_shuttle.dm index 2223456e08b..febb48eb700 100644 --- a/code/game/machinery/computer/syndicate_shuttle.dm +++ b/code/game/machinery/computer/syndicate_shuttle.dm @@ -70,11 +70,12 @@ /obj/machinery/computer/syndicate_station/Topic(href, href_list) - if(!isliving(usr)) return + if(..()) + return + var/mob/living/user = usr - if(in_range(src, user) || istype(user, /mob/living/silicon)) - user.set_machine(src) + user.set_machine(src) if(href_list["syndicate"]) syndicate_move_to(/area/syndicate_station/start) @@ -95,7 +96,6 @@ else if(href_list["mining"]) syndicate_move_to(/area/syndicate_station/mining) - add_fingerprint(usr) updateUsrDialog() return diff --git a/code/game/machinery/cryo.dm b/code/game/machinery/cryo.dm index 5178d32db8f..4634fd0eb9c 100644 --- a/code/game/machinery/cryo.dm +++ b/code/game/machinery/cryo.dm @@ -128,19 +128,18 @@ /obj/machinery/atmospherics/unary/cryo_cell/Topic(href, href_list) - if((get_dist(src, usr) <= 1) || istype(usr, /mob/living/silicon/ai)) - if(href_list["start"]) - on = !on - update_icon() - if(href_list["eject"]) - if(beaker) - var/obj/item/weapon/reagent_containers/glass/B = beaker - B.loc = get_step(loc, SOUTH) - beaker = null - - updateUsrDialog() - add_fingerprint(usr) + if(..()) + return + if(href_list["start"]) + on = !on + update_icon() + if(href_list["eject"]) + if(beaker) + var/obj/item/weapon/reagent_containers/glass/B = beaker + B.loc = get_step(loc, SOUTH) + beaker = null + updateUsrDialog() /obj/machinery/atmospherics/unary/cryo_cell/attackby(obj/item/I, mob/user) if(istype(I, /obj/item/weapon/reagent_containers/glass)) diff --git a/code/game/machinery/magnet.dm b/code/game/machinery/magnet.dm index a2dd432d991..cb7dc75e7d4 100644 --- a/code/game/machinery/magnet.dm +++ b/code/game/machinery/magnet.dm @@ -275,10 +275,9 @@ onclose(user, "magnet") Topic(href, href_list) - if(stat & (BROKEN|NOPOWER)) + if(..()) return usr.set_machine(src) - src.add_fingerprint(usr) if(href_list["radio-op"]) diff --git a/code/game/machinery/navbeacon.dm b/code/game/machinery/navbeacon.dm index 71f450e70fe..55eac77d77f 100644 --- a/code/game/machinery/navbeacon.dm +++ b/code/game/machinery/navbeacon.dm @@ -181,63 +181,61 @@ Transponder Codes: