diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index 0c49e41078a..e392d3ee432 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -7,10 +7,8 @@ /atom/proc/attackby(obj/item/W, mob/user, params) return -/atom/movable/attackby(obj/item/W, mob/living/user, params) - user.do_attack_animation(src) - if(W && !(W.flags & NOBLUDGEON)) - visible_message("[user] has hit [src] with [W]!") +/obj/attackby(obj/item/I, mob/living/user, params) + return I.attack_obj(src, user) //phil235 /mob/living/attackby(obj/item/I, mob/user, params) user.changeNext_move(CLICK_CD_MELEE) @@ -21,42 +19,54 @@ playsound(loc, 'sound/weapons/slice.ogg', 50, 1, -1) if(do_mob(user, src, 80/sharpness)) harvest(user) - return - I.attack(src, user) + return 1 + return I.attack(src, user) //phil235 should we return 1 if successful special attack() so we don't call afterattack? + //see the attack() procs if it'd be useful. -/mob/living/proc/attacked_by(obj/item/I, mob/living/user, def_zone) - apply_damage(I.force, I.damtype, def_zone) - if(I.damtype == "brute") - if(prob(33) && I.force) - var/turf/location = get_turf(src) - location.add_blood_floor(src) - var/message_verb = "" - if(I.attack_verb && I.attack_verb.len) - message_verb = "[pick(I.attack_verb)]" - else if(I.force) - message_verb = "attacked" +/obj/item/proc/attack(mob/living/M, mob/living/user, def_zone) + if(flags & (NOBLUDGEON|ABSTRACT)) //phil235 check that no abstract item uses attack or attack_obj + return + if(!force) + playsound(loc, 'sound/weapons/tap.ogg', get_clamped_volume(), 1, -1) + else if(hitsound) + playsound(loc, hitsound, get_clamped_volume(), 1, -1) - var/attack_message = "[src] has been [message_verb] with [I]." - if(user) + user.lastattacked = M + M.lastattacker = user + + M.attacked_by(src, user, def_zone) + + add_logs(user, M, "attacked", src.name, "(INTENT: [uppertext(user.a_intent)]) (DAMTYPE: [uppertext(damtype)])") + add_fingerprint(user) + + +//the equivalent of the standard version of attack() but for object targets. +/obj/item/proc/attack_obj(obj/O, mob/living/user) + if(flags & (NOBLUDGEON|ABSTRACT)) //phil235 + return + user.changeNext_move(CLICK_CD_MELEE) + user.do_attack_animation(O) + O.attacked_by(src, user) + + + +/atom/movable/proc/attacked_by() + return + +/obj/attacked_by(obj/item/I, mob/living/user) + if(I.force) + user.visible_message("[user] has hit [src] with [I]!", "You hit [src] with [I]!") + +/mob/living/attacked_by(obj/item/I, mob/living/user, def_zone) + if(user != src) user.do_attack_animation(src) - if(user in viewers(src, null)) - attack_message = "[user] has [message_verb] [src] with [I]!" - if(message_verb) - visible_message("[attack_message]", - "[attack_message]") - -/mob/living/simple_animal/attacked_by(var/obj/item/I, var/mob/living/user) - if(!I.force) - user.visible_message("[user] gently taps [src] with [I].",\ - "This weapon is ineffective, it does no damage!") - else if(I.force >= force_threshold && I.damtype != STAMINA) - ..() - else - visible_message("[I] bounces harmlessly off of [src].",\ - "[I] bounces harmlessly off of [src]!") - - + if(send_item_attack_message(I, user, def_zone)) + if(apply_damage(I.force, I.damtype, def_zone)) + if(I.damtype == BRUTE) + if(prob(33)) + var/turf/location = get_turf(src) + location.add_blood_floor(src) // Proximity_flag is 1 if this afterattack was called on something adjacent, in your square, or on your person. // Click parameters is the params string from byond Click() code, see that documentation. @@ -65,30 +75,35 @@ /obj/item/proc/get_clamped_volume() - if(src.force && src.w_class) - return Clamp((src.force + src.w_class) * 4, 30, 100)// Add the item's force to its weight class and multiply by 4, then clamp the value between 30 and 100 - else if(!src.force && src.w_class) - return Clamp(src.w_class * 6, 10, 100) // Multiply the item's weight class by 6, then clamp the value between 10 and 100 + if(w_class) + if(force) + return Clamp((force + w_class) * 4, 30, 100)// Add the item's force to its weight class and multiply by 4, then clamp the value between 30 and 100 + else + return Clamp(w_class * 6, 10, 100) // Multiply the item's weight class by 6, then clamp the value between 10 and 100 -/obj/item/proc/attack(mob/living/M, mob/living/user, def_zone) - - if (!istype(M)) // not sure if this is the right thing... - return - - if (hitsound && force > 0) //If an item's hitsound is defined and the item's force is greater than zero... - playsound(loc, hitsound, get_clamped_volume(), 1, -1) //...play the item's hitsound at get_clamped_volume() with varying frequency and -1 extra range. - else if (force == 0)//Otherwise, if the item's force is zero... - playsound(loc, 'sound/weapons/tap.ogg', get_clamped_volume(), 1, -1)//...play tap.ogg at get_clamped_volume() - ///////////////////////// - user.lastattacked = M - M.lastattacker = user - - //spawn(1800) // this wont work right - // M.lastattacker = null - ///////////////////////// - M.attacked_by(src, user, def_zone) - - add_logs(user, M, "attacked", src.name, "(INTENT: [uppertext(user.a_intent)]) (DAMTYPE: [uppertext(damtype)])") - add_fingerprint(user) +/mob/living/proc/send_item_attack_message(obj/item/I, mob/living/user, hit_area) + var/message_verb = "attacked" + if(I.attack_verb.len) + message_verb = "[pick(I.attack_verb)]" + else if(!I.force) + return 0 + var/message_hit_area = "" + if(hit_area) + message_hit_area = " in the [hit_area]" + var/attack_message = "[src] has been [message_verb][message_hit_area] with [I]." + if(user in viewers(src, null)) + attack_message = "[user] has [message_verb] [src][message_hit_area] with [I]!" + visible_message("[attack_message]", + "[attack_message]") return 1 + +/mob/living/simple_animal/send_item_attack_message(obj/item/I, mob/living/user, hit_area) + if(!I.force) + user.visible_message("[user] gently taps [src] with [I].",\ + "This weapon is ineffective, it does no damage!") + else if(I.force < force_threshold || I.damtype == STAMINA) + visible_message("[I] bounces harmlessly off of [src].",\ + "[I] bounces harmlessly off of [src]!") + else + return ..() \ No newline at end of file diff --git a/code/game/gamemodes/gang/dominator.dm b/code/game/gamemodes/gang/dominator.dm index 6f32e5c427c..83f6da190fe 100644 --- a/code/game/gamemodes/gang/dominator.dm +++ b/code/game/gamemodes/gang/dominator.dm @@ -9,8 +9,9 @@ var/maxhealth = 200 var/health = 200 var/datum/gang/gang - var/operating = 0 //-1=broken, 0=standby, 1=takeover + var/operating = 0 //0=standby or broken, 1=takeover var/warned = 0 //if this device has set off the warning at <3 minutes yet + var/datum/effect_system/spark_spread/spark_system /obj/machinery/dominator/tesla_act() qdel(src) @@ -19,10 +20,12 @@ ..() SetLuminosity(2) poi_list |= src + spark_system = new + spark_system.set_up(5, 1, src) /obj/machinery/dominator/examine(mob/user) ..() - if(operating == -1) + if(stat & BROKEN) user << "It looks completely busted." return @@ -52,30 +55,31 @@ else SSmachine.processing -= src -/obj/machinery/dominator/proc/healthcheck(damage) - var/iconname = "dominator" - if(gang) - iconname += "-[gang.color]" - SetLuminosity(3) - - var/datum/effect_system/spark_spread/sparks = new /datum/effect_system/spark_spread - +/obj/machinery/dominator/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BURN) + if(sound_effect) + playsound(src.loc, 'sound/items/Welder.ogg', 100, 1) + if(BRUTE) + if(sound_effect) + if(damage) + playsound(src, 'sound/effects/bang.ogg', 50, 1) + else + playsound(loc, 'sound/weapons/tap.ogg', 50, 1) + else + return health -= damage if(health > (maxhealth/2)) if(prob(damage*2)) - sparks.set_up(5, 1, src) - sparks.start() - else if(operating >= 0) - sparks.set_up(5, 1, src) - sparks.start() + spark_system.start() + else if(!(stat & BROKEN)) + spark_system.start() overlays += "damage" - if(operating != -1) + if(!(stat & BROKEN)) if(health <= 0) set_broken() - else - icon_state = iconname if(health <= -100) new /obj/item/stack/sheet/plasteel(src.loc) @@ -107,17 +111,19 @@ SetLuminosity(0) icon_state = "dominator-broken" overlays.Cut() - operating = -1 + operating = 0 + stat |= BROKEN SSmachine.processing -= src /obj/machinery/dominator/Destroy() - if(operating != -1) + if(!(stat & BROKEN)) set_broken() poi_list.Remove(src) + qdel(spark_system) return ..() /obj/machinery/dominator/emp_act(severity) - healthcheck(100) + take_damage(100, BURN, 0) ..() /obj/machinery/dominator/ex_act(severity, target) @@ -128,31 +134,26 @@ if(1) qdel(src) if(2) - healthcheck(120) + take_damage(120, BRUTE, 0) if(3) - healthcheck(30) + take_damage(30, BRUTE, 0) return -/obj/machinery/dominator/bullet_act(obj/item/projectile/Proj) - if(Proj.damage) - if((Proj.damage_type == BRUTE || Proj.damage_type == BURN)) - var/damage = Proj.damage - if(Proj.forcedodge) - damage *= 0.5 - playsound(src, 'sound/effects/bang.ogg', 50, 1) - visible_message("[src] was hit by [Proj].") - healthcheck(damage) - ..() +/obj/machinery/dominator/bullet_act(obj/item/projectile/P) + . = ..() + if(P.damage) + var/damage_amount = P.damage + if(P.forcedodge) + damage_amount *= 0.5 + visible_message("[src] was hit by [P].") + take_damage(damage_amount, P.damage_type, 0) + /obj/machinery/dominator/blob_act() - healthcheck(110) - -/obj/machinery/dominator/attackby(obj/I, mob/user, params) - - return + take_damage(110, BRUTE, 0) /obj/machinery/dominator/attack_hand(mob/user) - if(operating) + if(operating || (stat & BROKEN)) examine(user) return @@ -185,8 +186,9 @@ priority_announce("Network breach detected in [locname]. The [gang.name] Gang is attempting to seize control of the station!","Network Alert") gang.domination() src.name = "[gang.name] Gang [src.name]" - healthcheck(0) operating = 1 + icon_state = "dominator-[gang.color]" + SetLuminosity(3) SSmachine.processing += src gang.message_gangtools("Hostile takeover in progress: Estimated [time] minutes until victory.[gang.dom_attempts ? "" : " This is your final attempt."]") @@ -194,46 +196,14 @@ if(G != gang) G.message_gangtools("Enemy takeover attempt detected in [locname]: Estimated [time] minutes until our defeat.",1,1) -/obj/machinery/dominator/attack_alien(mob/living/user) - user.do_attack_animation(src) - playsound(src, 'sound/effects/bang.ogg', 50, 1) - user.visible_message("[user] smashes against [src] with its claws.",\ - "You smash against [src] with your claws.",\ - "You hear metal scraping.") - healthcheck(15) - -/obj/machinery/dominator/attack_animal(mob/living/user) - if(!isanimal(user)) - return - var/mob/living/simple_animal/M = user - M.do_attack_animation(src) - if(M.melee_damage_upper <= 0) - return - healthcheck(M.melee_damage_upper) - -/obj/machinery/dominator/mech_melee_attack(obj/mecha/M) - if(M.damtype == "brute") - playsound(src, 'sound/effects/bang.ogg', 50, 1) - visible_message("[M.name] has hit [src].") - healthcheck(M.force) - return - /obj/machinery/dominator/attack_hulk(mob/user) - playsound(src, 'sound/effects/bang.ogg', 50, 1) user.visible_message("[user] smashes [src].",\ "You punch [src].",\ "You hear metal being slammed.") - healthcheck(5) + take_damage(5) + +/obj/machinery/dominator/attacked_by(obj/item/I, mob/living/user) + add_fingerprint(user) + ..() + -/obj/machinery/dominator/attackby(obj/item/weapon/I, mob/living/user, params) - if(istype(I, /obj/item/weapon)) - add_fingerprint(user) - user.changeNext_move(CLICK_CD_MELEE) - user.do_attack_animation(src) - if( (I.flags&NOBLUDGEON) || !I.force ) - return - playsound(src, 'sound/weapons/smash.ogg', 50, 1) - visible_message("[user] has hit \the [src] with [I].") - if(I.damtype == BURN || I.damtype == BRUTE) - healthcheck(I.force) - return diff --git a/code/game/machinery/PDApainter.dm b/code/game/machinery/PDApainter.dm index fce5479c697..4ff95775e70 100644 --- a/code/game/machinery/PDApainter.dm +++ b/code/game/machinery/PDApainter.dm @@ -7,6 +7,7 @@ anchored = 1 var/obj/item/device/pda/storedpda = null var/list/colorlist = list() + var/health = 100 /obj/machinery/pdapainter/update_icon() @@ -45,7 +46,7 @@ power_change() return - if(istype(O, /obj/item/device/pda)) + else if(istype(O, /obj/item/device/pda)) if(storedpda) user << "There is already a PDA inside!" return @@ -59,27 +60,65 @@ P.add_fingerprint(user) update_icon() + else if(istype(O, /obj/item/weapon/weldingtool) && user.a_intent != "harm") + var/obj/item/weapon/weldingtool/WT = O + if(stat & BROKEN) + if(WT.remove_fuel(0,user)) + user.visible_message("[user] is repairing [src].", \ + "You begin repairing [src]...", \ + "You hear welding.") + playsound(loc, 'sound/items/Welder.ogg', 40, 1) + if(do_after(user,40/WT.toolspeed, 1, target = src)) + if(!WT.isOn() || !(stat & BROKEN)) + return + user << "You repair [src]." + playsound(loc, 'sound/items/Welder2.ogg', 50, 1) + stat &= ~BROKEN + health = initial(health) + update_icon() + else + user << "[src] does not need repairs." + else + return ..() + +/obj/machinery/pdapainter/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BRUTE) + if(sound_effect) + if(damage) + playsound(loc, 'sound/weapons/smash.ogg', 50, 1) + else + playsound(loc, 'sound/weapons/tap.ogg', 50, 1) + if(BURN) + if(sound_effect) + playsound(src.loc, 'sound/items/Welder.ogg', 100, 1) + else + return + if(!(stat & BROKEN)) + health -= damage + if(health <= 0) + stat |= BROKEN + update_icon() /obj/machinery/pdapainter/attack_hand(mob/user) - ..() + if(..()) + add_fingerprint(user) - src.add_fingerprint(user) + if(storedpda) + var/obj/item/device/pda/P + P = input(user, "Select your color!", "PDA Painting") as null|anything in colorlist + if(!P) + return + if(!in_range(src, user)) + return + if(!storedpda)//is the pda still there? + return + storedpda.icon_state = P.icon_state + storedpda.desc = P.desc + ejectpda() - if(storedpda) - var/obj/item/device/pda/P - P = input(user, "Select your color!", "PDA Painting") as null|anything in colorlist - if(!P) - return - if(!in_range(src, user)) - return - if(!storedpda)//is the pda still there? - return - storedpda.icon_state = P.icon_state - storedpda.desc = P.desc - ejectpda() - - else - user << "The [src] is empty." + else + user << "The [src] is empty." /obj/machinery/pdapainter/verb/ejectpda() diff --git a/code/game/machinery/announcement_system.dm b/code/game/machinery/announcement_system.dm index e83bff6774a..29af1ab1e18 100644 --- a/code/game/machinery/announcement_system.dm +++ b/code/game/machinery/announcement_system.dm @@ -73,26 +73,19 @@ var/list/announcement_systems = list() /obj/machinery/announcement_system/attackby(obj/item/P, mob/user, params) if(istype(P, /obj/item/weapon/screwdriver)) + playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) + panel_open = !panel_open if(!panel_open) - playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) - user << "You open the maintenance hatch of [src]." - panel_open = 1 - else - playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) - user << "You close the maintenance hatch of [src]." - panel_open = 0 + user << "You [panel_open ? "open" : "close"] the maintenance hatch of [src]." update_icon() + else if(default_deconstruction_crowbar(P)) return - - if(panel_open) - default_deconstruction_crowbar(P) - if(istype(P, /obj/item/device/multitool) && broken) - user << "You reset [src]'s firmware." - broken = 0 - update_icon() - return - - return ..() + else if(istype(P, /obj/item/device/multitool) && panel_open && broken) + user << "You reset [src]'s firmware." + broken = 0 + update_icon() + else + return ..() /obj/machinery/announcement_system/proc/CompileText(str, user, rank) //replaces user-given variables with actual thingies. str = replacetext(str, "%PERSON", "[user]") diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index 600f0793715..648339bcbf7 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -63,7 +63,7 @@ if(assembly) qdel(assembly) assembly = null - if(istype(bug)) + if(bug) bug.bugged_cameras -= src.c_tag if(bug.current == src) bug.current = null @@ -110,9 +110,13 @@ /obj/machinery/camera/ex_act(severity, target) if(src.invuln) return - else - ..() - return + switch(severity) + if(1) + qdel(src) + if(2) + take_damage(50, BRUTE, 0) + else + take_damage(rand(30,60), BRUTE, 0) /obj/machinery/camera/proc/setViewRange(num = 7) src.view_range = num @@ -123,17 +127,6 @@ return user.electrocute_act(10, src) -/obj/machinery/camera/attack_paw(mob/living/carbon/alien/humanoid/user) - if(!istype(user)) - return - user.do_attack_animation(src) - add_hiddenprint(user) - visible_message("\The [user] slashes at [src]!") - playsound(src.loc, 'sound/weapons/slash.ogg', 100, 1) - health = max(0, health - 30) - if(!health && status) - toggle_cam(user, 0) - /obj/machinery/camera/attackby(obj/W, mob/living/user, params) var/msg = "You attach [W] into the assembly's inner circuits." var/msg2 = "[src] already has that upgrade!" @@ -173,6 +166,7 @@ user << "[msg]" else user << "[msg2]" + return else if(istype(W, /obj/item/stack/sheet/mineral/plasma)) if(!isEmpProof()) @@ -181,6 +175,8 @@ qdel(W) else user << "[msg2]" + return + else if(istype(W, /obj/item/device/assembly/prox_sensor)) if(!isMotion()) upgradeMotion() @@ -188,6 +184,7 @@ qdel(W) else user << "[msg2]" + return // OTHER if((istype(W, /obj/item/weapon/paper) || istype(W, /obj/item/device/pda)) && isliving(user)) @@ -220,34 +217,52 @@ else if (O.client && O.client.eye == src) O << "[U] holds \a [itemname] up to one of the cameras ..." O << browse(text("[][]", itemname, info), text("window=[]", itemname)) + return - else if (istype(W, /obj/item/device/camera_bug)) - if (!src.can_use()) + else if(istype(W, /obj/item/device/camera_bug)) + if(!can_use()) user << "Camera non-functional." return - if(istype(src.bug)) + if(bug) user << "Camera bug removed." - src.bug.bugged_cameras -= src.c_tag - src.bug = null + bug.bugged_cameras -= src.c_tag + bug = null else user << "Camera bugged." - src.bug = W - src.bug.bugged_cameras[src.c_tag] = src + bug = W + bug.bugged_cameras[src.c_tag] = src + return + + else if(istype(W, /obj/item/weapon/pai_cable)) + var/obj/item/weapon/pai_cable/cable = W + cable.plugin(src, user) + return else if(istype(W, /obj/item/device/laser_pointer)) var/obj/item/device/laser_pointer/L = W L.laser_act(src, user) + return + return ..() - else - if(W.force >= 10) //fairly simplistic, but will do for now. - user.changeNext_move(CLICK_CD_MELEE) - visible_message("[user] hits [src] with [W]!", "You hit [src] with [W]!") - health = max(0, health - W.force) - user.do_attack_animation(src) - if(!health && status) - triggerCameraAlarm() - toggle_cam(user, 1) - return +/obj/machinery/camera/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BRUTE) + if(sound_effect) + if(damage) + playsound(src, 'sound/weapons/smash.ogg', 50, 1) + else + playsound(src, 'sound/weapons/tap.ogg', 50, 1) + if(BURN) + if(sound_effect) + playsound(src.loc, 'sound/items/Welder.ogg', 100, 1) + else + return + if(damage < 10) //camera has a damage resistance threshold + return + health = max(0, health - damage) + if(!health && status) + triggerCameraAlarm() + toggle_cam(null, 0) /obj/machinery/camera/proc/toggle_cam(mob/user, displaymessage = 1) status = !status @@ -373,12 +388,9 @@ else src.SetLuminosity(0) -/obj/machinery/camera/bullet_act(obj/item/projectile/proj) - if(proj.damage_type == BRUTE) - health = max(0, health - proj.damage) - if(!health && status) - triggerCameraAlarm() - toggle_cam(null, 1) +/obj/machinery/camera/bullet_act(obj/item/projectile/P) + . = ..() + take_damage(P.damage, P.damage_type, 0) /obj/machinery/camera/portable //Cameras which are placed inside of things, such as helmets. var/turf/prev_turf diff --git a/code/game/machinery/computer/computer.dm b/code/game/machinery/computer/computer.dm index c67b1b2f56b..a6f8eb6eb01 100644 --- a/code/game/machinery/computer/computer.dm +++ b/code/game/machinery/computer/computer.dm @@ -12,6 +12,7 @@ var/brightness_on = 2 var/icon_keyboard = "generic_key" var/icon_screen = "generic" + var/computer_health = 25 /obj/machinery/computer/New(location, obj/item/weapon/circuitboard/C) ..(location) @@ -32,7 +33,10 @@ return 1 /obj/machinery/computer/emp_act(severity) - if(prob(20/severity)) set_broken() + if(severity == 1) + take_damage(rand(15,30), BRUTE, 0) + else + take_damage(rand(15,25), BRUTE, 0) ..() /obj/machinery/computer/ex_act(severity, target) @@ -42,25 +46,17 @@ switch(severity) if(1) qdel(src) - return if(2) - if (prob(25)) + if(prob(25)) qdel(src) - return - if (prob(50)) - verbs.Cut() - set_broken() + else + take_damage(rand(20,30), BRUTE, 0) if(3) - if (prob(25)) - verbs.Cut() - set_broken() - else - return + take_damage(rand(10,30), BRUTE, 0) -/obj/machinery/computer/bullet_act(obj/item/projectile/Proj) - if(prob(Proj.damage)) - if((Proj.damage_type == BRUTE || Proj.damage_type == BURN)) - set_broken() + +/obj/machinery/computer/bullet_act(obj/item/projectile/P) + take_damage(P.damage, P.damage_type, 0) ..() /obj/machinery/computer/update_icon() @@ -83,24 +79,19 @@ update_icon() return -/obj/machinery/computer/proc/set_broken() - if(circuit) //no circuit, no breaking - stat |= BROKEN - update_icon() - return - /obj/machinery/computer/attackby(obj/item/I, mob/user, params) if(istype(I, /obj/item/weapon/screwdriver) && circuit && !(flags&NODECONSTRUCT)) playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) user << " You start to disconnect the monitor..." if(do_after(user, 20/I.toolspeed, target = src)) + deconstruction() var/obj/structure/computerframe/A = new /obj/structure/computerframe( src.loc ) A.circuit = circuit A.anchored = 1 circuit = null for (var/obj/C in src) C.loc = src.loc - if (src.stat & BROKEN) + if (stat & BROKEN) user << "The broken glass falls out." new /obj/item/weapon/shard( src.loc ) A.state = 3 @@ -110,30 +101,25 @@ A.state = 4 A.icon_state = "4" qdel(src) - return + else + return ..() -/obj/machinery/computer/attack_paw(mob/living/user) - user.do_attack_animation(src) - if(circuit) - if(prob(10)) - user.visible_message("[user.name] smashes the [src.name] with its paws.",\ - "You smash the [src.name] with your paws.",\ - "You hear a smashing sound.") - set_broken() +/obj/machinery/computer/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BRUTE) + if(sound_effect) + if(stat & BROKEN) + playsound(src.loc, 'sound/effects/hit_on_shattered_glass.ogg', 70, 1) + else + playsound(src.loc, 'sound/effects/Glasshit.ogg', 75, 1) + if(BURN) + if(sound_effect) + playsound(src.loc, 'sound/items/Welder.ogg', 100, 1) + else return - user.visible_message("[user.name] smashes against the [src.name] with its paws.",\ - "You smash against the [src.name] with your paws.",\ - "You hear hear a clicking sound.") - -/obj/machinery/computer/attack_alien(mob/living/user) - user.do_attack_animation(src) - if(circuit) - if(prob(80)) - user.visible_message("[user.name] smashes the [src.name] with its claws.",\ - "You smash the [src.name] with your claws.",\ - "You hear a smashing sound.") - set_broken() - return - user.visible_message("[user.name] smashes against the [src.name] with its claws.",\ - "You smash against the [src.name] with your claws.",\ - "You hear a clicking sound.") + computer_health = max(computer_health - damage, 0) + if(circuit) //no circuit, no breaking + if(!computer_health && !(stat & BROKEN)) + playsound(loc, 'sound/effects/Glassbr3.ogg', 100, 1) + stat |= BROKEN + update_icon() diff --git a/code/game/machinery/droneDispenser.dm b/code/game/machinery/droneDispenser.dm index 159e115888a..c2743105444 100644 --- a/code/game/machinery/droneDispenser.dm +++ b/code/game/machinery/droneDispenser.dm @@ -172,7 +172,7 @@ visible_message("[src] [end_create_message]") icon_state = icon_recharging sleep(cooldownTime) - if(stat != BROKEN) + if(!(stat & BROKEN)) icon_state = icon_on else icon_state = icon_off @@ -210,36 +210,50 @@ user << "You insert [stack] sheet[stack > 1 ? "s" : ""] to [src]." if((O && O.loc == src) || !stack) qdel(O) - return - if(istype(O, /obj/item/weapon/weldingtool) && (stat & BROKEN)) - var/obj/item/weapon/weldingtool/WT = O - if(!WT.isOn()) + else if(istype(O, /obj/item/weapon/weldingtool)) + if(stat & BROKEN) + var/obj/item/weapon/weldingtool/WT = O + if(!WT.isOn()) + return + if(WT.get_fuel() < 1) + user << "You need more fuel to complete this task!" + return + playsound(src, 'sound/items/Welder.ogg', 50, 1) + user.visible_message("[user] begins patching up [src] with [WT].", \ + "You begin restoring the damage to [src]...") + if(!do_after(user, 40/O.toolspeed, target = src)) + return + if(!src || !WT.remove_fuel(1, user)) return + user.visible_message("[user] fixes [src]!", \ + "You restore [src] to operation.") + stat &= ~BROKEN + health = max_health + if(!stat) + icon_state = icon_on + else + user << "[src] doesn't need repairs." + else + return ..() + +/obj/machinery/droneDispenser/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BURN) + if(sound_effect) + playsound(src.loc, 'sound/items/Welder.ogg', 100, 1) + if(BRUTE) + if(sound_effect) + if(damage) + playsound(loc, 'sound/weapons/smash.ogg', 50, 1) + else + playsound(loc, 'sound/weapons/tap.ogg', 50, 1) + else return - if(WT.get_fuel() < 1) - user << "You need more fuel to complete this task!" - return - playsound(src, 'sound/items/Welder.ogg', 50, 1) - user.visible_message("[user] begins patching up [src] with [WT].", \ - "You begin restoring the damage to [src]...") - if(!do_after(user, 40/O.toolspeed, target = src)) - return - if(!src || !WT.remove_fuel(1, user)) return - user.visible_message("[user] fixes [src]!", \ - "You restore [src] to operation.") - stat -= BROKEN - icon_state = icon_on - return - if(O.force && stat != BROKEN) - user.visible_message("[user] hits [src] with [O]!", \ - "You hit [src] with [O]!") - playsound(src, O.hitsound, 50, 1) - health = Clamp(health - O.force, 0, max_health) - if(health <= 0) - if(break_message) - audible_message("[src] [break_message]") - if(break_sound) - playsound(src, break_sound, 50, 1) - stat = BROKEN - icon_state = icon_off - return - ..() + health = max(health - damage, 0) + if(!health && !(stat & BROKEN)) + if(break_message) + audible_message("[src] [break_message]") + if(break_sound) + playsound(src, break_sound, 50, 1) + stat |= BROKEN + icon_state = icon_off + diff --git a/code/game/machinery/firealarm.dm b/code/game/machinery/firealarm.dm index 0965843654a..95276267b3b 100644 --- a/code/game/machinery/firealarm.dm +++ b/code/game/machinery/firealarm.dm @@ -21,6 +21,7 @@ power_channel = ENVIRON var/detecting = 1 var/buildstage = 2 // 2 = complete, 1 = no wires, 0 = circuit gone + var/health = 50 /obj/machinery/firealarm/New(loc, dir, building) ..() @@ -61,9 +62,9 @@ else overlays += "overlay_fire" -/obj/machinery/firealarm/bullet_act(BLAH) - if(prob(50)) - alarm() +/obj/machinery/firealarm/bullet_act(obj/item/projectile/P) + . = ..() + take_damage(P.damage, P.damage_type, 0) /obj/machinery/firealarm/emp_act(severity) if(prob(50 / severity)) @@ -74,11 +75,11 @@ emagged = 1 if(user) user.visible_message("Sparks fly out of the [src]!", - "You emag the [src], disabling its thermal sensors.") + "You emag [src], disabling its thermal sensors.") playsound(src.loc, 'sound/effects/sparks4.ogg', 50, 1) /obj/machinery/firealarm/temperature_expose(datum/gas_mixture/air, temperature, volume) - if(!emagged && detecting && temperature > T0C + 200) + if(!emagged && detecting && !stat && temperature > T0C + 200) alarm() /obj/machinery/firealarm/proc/alarm() @@ -200,4 +201,25 @@ playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) qdel(src) return - return ..() \ No newline at end of file + return ..() + +/obj/machinery/firealarm/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BRUTE) + if(sound_effect) + if(damage) + playsound(loc, 'sound/weapons/smash.ogg', 50, 1) + else + playsound(loc, 'sound/weapons/tap.ogg', 50, 1) + if(BURN) + if(sound_effect) + playsound(src.loc, 'sound/items/Welder.ogg', 100, 1) + else + return + if(!(stat & BROKEN)) + health -= damage + if(health <= 0) + stat |= BROKEN + update_icon() + else if(prob(33)) + alarm() diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index 1c32cd0aeee..12e87f98ee9 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -137,10 +137,6 @@ Class Procs: dropContents() return ..() -/obj/machinery/attackby(obj/item/weapon/W, mob/user, params) - user.changeNext_move(CLICK_CD_MELEE) - ..() - /obj/machinery/proc/locate_machinery() return @@ -243,6 +239,61 @@ Class Procs: //////////////////////////////////////////////////////////////////////////////////////////// +/obj/machinery/mech_melee_attack(obj/mecha/M) + if(M.damtype == BRUTE || M.damtype == BURN) + visible_message("[M.name] has hit [src].") + take_damage(M.force*2, M.damtype) // multiplied by 2 so we can hit machines hard but not be overpowered against mobs. + return 1 + return 0 + +/obj/machinery/attacked_by(obj/item/I, mob/living/user) + ..() + take_damage(I.force, I.damtype, 1) + +/obj/machinery/proc/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BRUTE) + if(sound_effect) + if(damage) + playsound(loc, 'sound/weapons/smash.ogg', 50, 1) + else + playsound(loc, 'sound/weapons/tap.ogg', 50, 1) + if(BURN) + if(sound_effect) + playsound(src.loc, 'sound/items/Welder.ogg', 100, 1) + +//phil235 + + + +/obj/machinery/attack_alien(mob/living/carbon/alien/humanoid/user) + user.changeNext_move(CLICK_CD_MELEE) + user.do_attack_animation(src) + add_hiddenprint(user) + visible_message("\The [user] slashes at [src]!") + playsound(src.loc, 'sound/weapons/slash.ogg', 100, 1) + take_damage(20, BRUTE, 0) + +/obj/machinery/attack_animal(mob/living/simple_animal/M) + M.changeNext_move(CLICK_CD_MELEE) + M.do_attack_animation(src) + if(M.melee_damage_upper > 0) // phil235 use M.attack_text verb? + M.visible_message("[M.name] smashes against \the [src.name].",\ + "You smash against the [src.name].") + take_damage(M.melee_damage_upper, M.melee_damage_type, 1) + + +/obj/machinery/attack_paw(mob/living/user) + if(user.a_intent != "harm") + return attack_hand(user) + else + user.changeNext_move(CLICK_CD_MELEE) + user.do_attack_animation(src) + user.visible_message("[user.name] smashes against \the [src.name] with its paws.",\ + "You smash against the [src.name] with your paws.") + take_damage(4, BRUTE, 1) + + /obj/machinery/attack_ai(mob/user) if(isrobot(user))// For some reason attack_robot doesn't work var/mob/living/silicon/robot/R = user @@ -251,8 +302,6 @@ Class Procs: else return attack_hand(user) -/obj/machinery/attack_paw(mob/user) - return attack_hand(user) //set_machine must be 0 if clicking the machinery doesn't bring up a dialog /obj/machinery/attack_hand(mob/user, check_power = 1, set_machine = 1) diff --git a/code/game/machinery/newscaster.dm b/code/game/machinery/newscaster.dm index 3eedfeec907..4005154672f 100644 --- a/code/game/machinery/newscaster.dm +++ b/code/game/machinery/newscaster.dm @@ -175,8 +175,6 @@ var/list/obj/machinery/newscaster/allCasters = list() verb_say = "beeps" verb_ask = "beeps" verb_exclaim = "beeps" - var/isbroken = 0 - var/ispowered = 1 var/screen = 0 var/paper_remaining = 15 var/securityCaster = 0 @@ -188,11 +186,12 @@ var/list/obj/machinery/newscaster/allCasters = list() var/obj/item/weapon/photo/photo = null var/channel_name = "" var/c_locked=0 - var/hitstaken = 0 + var/health = 60 var/datum/newscaster/feed_channel/viewing_channel = null var/allow_comments = 1 luminosity = 0 anchored = 1 + var/hitstaken = 0 //phil235 to be removed, it's used in a map var edit. /obj/machinery/newscaster/security_unit name = "security newscaster" @@ -217,32 +216,35 @@ var/list/obj/machinery/newscaster/allCasters = list() return ..() /obj/machinery/newscaster/update_icon() - if(!ispowered || isbroken) - icon_state = "newscaster_off" - if(isbroken) - overlays.Cut() - overlays += image(icon, "crack3") - return overlays.Cut() - if(news_network.wanted_issue.active) - icon_state = "newscaster_wanted" - return - if(alert) - overlays += "newscaster_alert" - if(hitstaken > 0) - overlays += image(icon, "crack[hitstaken]") - icon_state = "newscaster_normal" + if(stat & (NOPOWER|BROKEN)) + icon_state = "newscaster_off" + else + if(news_network.wanted_issue.active) + icon_state = "newscaster_wanted" + else + icon_state = "newscaster_normal" + if(alert) + overlays += "newscaster_alert" + switch(health) + if(45 to 60) + return + if(30 to 45) + overlays += "crack1" + if(15 to 30) + overlays += "crack2" + else + overlays += "crack3" + /obj/machinery/newscaster/power_change() - if(isbroken) + if(stat & BROKEN) return if(powered()) - ispowered = 1 stat &= ~NOPOWER update_icon() else spawn(rand(0, 15)) - ispowered = 0 stat |= NOPOWER update_icon() @@ -251,21 +253,18 @@ var/list/obj/machinery/newscaster/allCasters = list() if(1) qdel(src) if(2) - isbroken=1 if(prob(50)) qdel(src) else - update_icon() + take_damage(rand(40,80), BRUTE, 0) else - if(prob(50)) - isbroken=1 - update_icon() + take_damage(rand(20,40), BRUTE, 0) /obj/machinery/newscaster/attack_ai(mob/user) return attack_hand(user) /obj/machinery/newscaster/attack_hand(mob/user) - if(!ispowered || isbroken) + if(stat & (NOPOWER|BROKEN)) return if(istype(user, /mob/living/carbon/human) || istype(user,/mob/living/silicon) ) var/mob/living/human_or_robot_user = user @@ -327,11 +326,11 @@ var/list/obj/machinery/newscaster/allCasters = list() if(6) dat+="ERROR: Could not submit Feed story to Network.

" if(channel_name=="") - dat+="•Invalid receiving channel name.
" + dat+="?Invalid receiving channel name.
" if(scanned_user=="Unknown") - dat+="•Channel author unverified.
" + dat+="?Channel author unverified.
" if(msg == "" || msg == "\[REDACTED\]") - dat+="•Invalid message body.
" + dat+="?Invalid message body.
" dat+="
Return
" if(7) dat+="ERROR: Could not submit Feed Channel to Network.

" @@ -342,18 +341,18 @@ var/list/obj/machinery/newscaster/allCasters = list() else existing_authors += FC.author if(scanned_user in existing_authors) - dat+="•There already exists a Feed channel under your name.
" + dat+="?There already exists a Feed channel under your name.
" if(channel_name=="" || channel_name == "\[REDACTED\]") - dat+="•Invalid channel name.
" + dat+="?Invalid channel name.
" var/check = 0 for(var/datum/newscaster/feed_channel/FC in news_network.network_channels) if(FC.channel_name == channel_name) check = 1 break if(check) - dat+="•Channel name already in use.
" + dat+="?Channel name already in use.
" if(scanned_user=="Unknown") - dat+="•Channel author unverified.
" + dat+="?Channel author unverified.
" dat+="
Return
" if(8) var/total_num=length(news_network.network_channels) @@ -472,11 +471,11 @@ var/list/obj/machinery/newscaster/allCasters = list() if(16) dat+="ERROR: Wanted Issue rejected by Network.

" if(channel_name=="" || channel_name == "\[REDACTED\]") - dat+="•Invalid name for person wanted.
" + dat+="?Invalid name for person wanted.
" if(scanned_user=="Unknown") - dat+="•Issue author unverified.
" + dat+="?Issue author unverified.
" if(msg == "" || msg == "\[REDACTED\]") - dat+="•Invalid description.
" + dat+="?Invalid description.
" dat+="
Return
" if(17) dat+="Wanted Issue successfully deleted from Circulation
" @@ -724,39 +723,66 @@ var/list/obj/machinery/newscaster/allCasters = list() user << "You start [anchored ? "un" : ""]securing [name]..." playsound(loc, 'sound/items/Ratchet.ogg', 50, 1) if(do_after(user, 60/I.toolspeed, target = src)) - user << "You [anchored ? "un" : ""]secure [name]." - new /obj/item/wallframe/newscaster(loc) playsound(loc, 'sound/items/Deconstruct.ogg', 50, 1) - qdel(src) - return - if(isbroken) - playsound(loc, 'sound/effects/hit_on_shattered_glass.ogg', 100, 1) - audible_message("[user.name] further abuses the shattered [name].", null, 5 ) - else - if(istype(I, /obj/item/weapon)) - user.do_attack_animation(src) - var/obj/item/weapon/W = I - if(W.damtype == STAMINA) - return - if(W.force <15) - audible_message("[user.name] hits the [name] with the [W.name] with no visible effect.", null , 5 ) - playsound(loc, 'sound/effects/Glasshit.ogg', 100, 1) + if(stat & BROKEN) + user << "The broken remains of [src] fall on the ground." + new /obj/item/stack/sheet/metal(loc, 5) + new /obj/item/weapon/shard(loc) + new /obj/item/weapon/shard(loc) else - hitstaken++ - if(hitstaken==3) - audible_message("[user.name] smashes the [name]!", null, 5 ) - isbroken=1 - playsound(loc, 'sound/effects/Glassbr3.ogg', 100, 1) - else - audible_message("[user.name] forcefully slams the [name] with the [I.name]!", null, 5 ) - playsound(loc, 'sound/effects/Glasshit.ogg', 100, 1) + user << "You [anchored ? "un" : ""]secure [name]." + new /obj/item/wallframe/newscaster(loc) + qdel(src) + else if(istype(I, /obj/item/weapon/weldingtool) && user.a_intent != "harm") + var/obj/item/weapon/weldingtool/WT = I + if(stat & BROKEN) + if(WT.remove_fuel(0,user)) + user.visible_message("[user] is repairing [src].", \ + "You begin repairing [src]...", \ + "You hear welding.") + playsound(loc, 'sound/items/Welder.ogg', 40, 1) + if(do_after(user,40/WT.toolspeed, 1, target = src)) + if(!WT.isOn() || !(stat & BROKEN)) + return + user << "You repair [src]." + playsound(loc, 'sound/items/Welder2.ogg', 50, 1) + stat &= ~BROKEN + update_icon() else - user << "This does nothing!" - update_icon() + user << "[src] does not need repairs." + else + return ..() + +/obj/machinery/newscaster/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BRUTE) + if(sound_effect) + if(stat & BROKEN) + playsound(loc, 'sound/effects/hit_on_shattered_glass.ogg', 100, 1) + else + playsound(loc, 'sound/effects/Glasshit.ogg', 90, 1) + if(BURN) + if(sound_effect) + playsound(src.loc, 'sound/items/Welder.ogg', 100, 1) + else + return + if(damage < 15) //so it can't be broken with a small weapon. + return + if(!(stat & BROKEN)) + health -= damage + if(health <= 0) + stat |= BROKEN + playsound(loc, 'sound/effects/Glassbr3.ogg', 100, 1) + update_icon() + /obj/machinery/newscaster/attack_paw(mob/user) - user << "The newscaster controls are far too complicated for your tiny brain!" - return + if(user.a_intent != "harm") + user << "The newscaster controls are far too complicated for your tiny brain!" + else + take_damage(5) + +//phil235 missing attack_alien, attack_animal, bullet_act, etc... /obj/machinery/newscaster/proc/AttachPhoto(mob/user) if(photo) @@ -895,7 +921,7 @@ var/list/obj/machinery/newscaster/allCasters = list() switch(screen) if(0) //Cover dat+="
The Griffon
" - dat+="
Nanotrasen-standard newspaper, for use on Nanotrasen© Space Facilities

" + dat+="
Nanotrasen-standard newspaper, for use on Nanotrasen? Space Facilities

" if(isemptylist(news_content)) if(wantedAuthor) dat+="Contents:
" @@ -1022,4 +1048,6 @@ var/list/obj/machinery/newscaster/allCasters = list() return scribble_page = curr_page scribble = s - attack_self(user) \ No newline at end of file + attack_self(user) + else + return ..() \ No newline at end of file diff --git a/code/game/machinery/requests_console.dm b/code/game/machinery/requests_console.dm index f367cb641b5..aa169ff97b6 100644 --- a/code/game/machinery/requests_console.dm +++ b/code/game/machinery/requests_console.dm @@ -64,7 +64,7 @@ var/list/obj/machinery/requests_console/allConsoles = list() /obj/machinery/requests_console/update_icon() if(open) - if(hackState == 0) + if(!hackState) icon_state="req_comp_open" else icon_state="req_comp_rewired" @@ -135,7 +135,7 @@ var/list/obj/machinery/requests_console/allConsoles = list() dat += "" dat += "[dpt]" dat += "Normal High" - if (hackState == 1) + if(hackState) dat += "EXTREME" dat += "" dat += "" @@ -150,7 +150,7 @@ var/list/obj/machinery/requests_console/allConsoles = list() dat += "" dat += "[dpt]" dat += "Normal High" - if (hackState == 1) + if(hackState) dat += "EXTREME" dat += "" dat += "" @@ -165,7 +165,7 @@ var/list/obj/machinery/requests_console/allConsoles = list() dat += "" dat += "[dpt]" dat += "Normal High" - if (hackState == 1) + if(hackState) dat += "EXTREME" dat += "" dat += "" @@ -479,34 +479,29 @@ var/list/obj/machinery/requests_console/allConsoles = list() SetLuminosity(2) /obj/machinery/requests_console/attackby(obj/item/weapon/O, mob/user, params) - if (istype(O, /obj/item/weapon/crowbar)) + if(istype(O, /obj/item/weapon/crowbar)) if(open) user << "You close the maintenance panel." open = 0 - icon_state="req_comp0" else user << "You open the maintenance panel." open = 1 - if(hackState == 0) - icon_state="req_comp_open" - else if(hackState == 1) - icon_state="req_comp_rewired" - if (istype(O, /obj/item/weapon/screwdriver)) + update_icon() + return + if(istype(O, /obj/item/weapon/screwdriver)) if(open) - if(hackState == 0) + hackState = !hackState + if(hackState) user << "You modify the wiring." - hackState = 1 - icon_state="req_comp_rewired" - else if(hackState == 1) + else user << "You reset the wiring." - hackState = 0 - icon_state="req_comp_open" + update_icon() else - user << "You can't do much with that!" - update_icon() + user << "You must open the maintenance panel first!" + return var/obj/item/weapon/card/id/ID = O.GetID() - if (ID) + if(ID) if(screen == 9) msgVerified = "Verified by [ID.registered_name] ([ID.assignment])" updateUsrDialog() @@ -517,9 +512,11 @@ var/list/obj/machinery/requests_console/allConsoles = list() announceAuth = 0 user << "You are not authorized to send announcements!" updateUsrDialog() + return if (istype(O, /obj/item/weapon/stamp)) if(screen == 9) var/obj/item/weapon/stamp/T = O msgStamped = "Stamped with the [T.name]" updateUsrDialog() - return + return + return ..() diff --git a/code/game/machinery/shieldgen.dm b/code/game/machinery/shieldgen.dm index a00cbf3d205..a26b66350de 100644 --- a/code/game/machinery/shieldgen.dm +++ b/code/game/machinery/shieldgen.dm @@ -33,35 +33,25 @@ /obj/machinery/shield/CanAtmosPass(turf/T) return !density -/obj/machinery/shield/attackby(obj/item/weapon/W, mob/user, params) - ..() - if(W.damtype == BRUTE || W.damtype == BURN) - take_damage(W.force) - -/obj/machinery/shield/bullet_act(obj/item/projectile/Proj) - ..() - take_damage(Proj.damage) +/obj/machinery/shield/bullet_act(obj/item/projectile/P) + . = ..() + take_damage(P.damage, P.damage_type) /obj/machinery/shield/ex_act(severity, target) switch(severity) if(1) - if (prob(75)) - qdel(src) + take_damage(rand(180,260), BRUTE, 0) if(2) - if (prob(50)) - qdel(src) + take_damage(rand(150,230), BRUTE, 0) if(3) - if (prob(25)) - qdel(src) - return + take_damage(rand(80,150), BRUTE, 0) /obj/machinery/shield/emp_act(severity) switch(severity) if(1) qdel(src) if(2) - if(prob(50)) - qdel(src) + take_damage(50, BRUTE, 0) /obj/machinery/shield/blob_act() qdel(src) @@ -77,14 +67,21 @@ ..() take_damage(tforce) -/obj/machinery/shield/proc/take_damage(damage) - playsound(loc, 'sound/effects/EMPulse.ogg', 75, 1) +/obj/machinery/shield/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BURN) + if(sound_effect) + playsound(loc, 'sound/effects/EMPulse.ogg', 75, 1) + if(BRUTE) + if(sound_effect) + playsound(loc, 'sound/effects/EMPulse.ogg', 75, 1) + else + return opacity = 1 spawn(20) opacity = 0 health -= damage if(health <= 0) - visible_message("[src] dissipates.") qdel(src) /obj/machinery/shieldgen @@ -100,9 +97,7 @@ var/const/max_health = 100 var/health = max_health var/active = 0 - var/malfunction = 0 //Malfunction causes parts of the shield to slowly dissapate var/list/deployed_shields = list() - var/is_open = 0 //Whether or not the wires are exposed var/locked = 0 var/shield_range = 4 @@ -114,20 +109,22 @@ /obj/machinery/shieldgen/proc/shields_up() - if(active) return 0 //If it's already turned on, how did this get called? + if(active) + return 0 //If it's already turned on, how did this get called? - src.active = 1 + active = 1 update_icon() for(var/turf/target_tile in range(shield_range, src)) if (istype(target_tile,/turf/open/space) && !(locate(/obj/machinery/shield) in target_tile)) - if (malfunction && prob(33) || !malfunction) + if(!(stat & BROKEN) || prob(33)) deployed_shields += new /obj/machinery/shield(target_tile) /obj/machinery/shieldgen/proc/shields_down() - if(!active) return 0 //If it's already off, how did this get called? + if(!active) + return 0 //If it's already off, how did this get called? - src.active = 0 + active = 0 update_icon() for(var/obj/machinery/shield/shield_tile in deployed_shields) @@ -135,66 +132,70 @@ deployed_shields.Cut() /obj/machinery/shieldgen/process() - if(malfunction && active) + if((stat & BROKEN) && active) if(deployed_shields.len && prob(5)) qdel(pick(deployed_shields)) - return -/obj/machinery/shieldgen/proc/checkhp() - if(health <= 30) - src.malfunction = 1 - if(health <= 0) - qdel(src) - update_icon() - return +/obj/machinery/shieldgen/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BRUTE) + if(sound_effect) + if(damage) + playsound(loc, 'sound/weapons/smash.ogg', 50, 1) + else + playsound(loc, 'sound/weapons/tap.ogg', 50, 1) + if(BURN) + if(sound_effect) + playsound(loc, 'sound/items/Welder.ogg', 40, 1) + else + return + health = max(health - damage, 0) + if(health <= 0 && !(stat && BROKEN)) + stat |= BROKEN + update_icon() /obj/machinery/shieldgen/ex_act(severity, target) switch(severity) if(1) - src.health -= 75 - src.checkhp() + qdel(src) if(2) - src.health -= 30 - if (prob(15)) - src.malfunction = 1 - src.checkhp() + if(prob(33)) + qdel(src) + else + take_damage(rand(80,120), BRUTE, 0) if(3) - src.health -= 10 - src.checkhp() - return + take_damage(rand(40,80), BRUTE, 0) /obj/machinery/shieldgen/emp_act(severity) switch(severity) if(1) - src.health /= 2 //cut health in half - malfunction = 1 + health = 0 + stat |= BROKEN locked = pick(0,1) + update_icon() if(2) - if(prob(50)) - src.health *= 0.3 //chop off a third of the health - malfunction = 1 - checkhp() + take_damage(rand(80,120), BRUTE, 0) /obj/machinery/shieldgen/attack_hand(mob/user) if(locked) user << "The machine is locked, you are unable to use it!" return - if(is_open) + if(panel_open) user << "The panel must be closed before operating this machine!" return - if (src.active) + if (active) user.visible_message("[user] deactivated \the [src].", \ "You deactivate \the [src].", \ "You hear heavy droning fade out.") - src.shields_down() + shields_down() else if(anchored) user.visible_message("[user] activated \the [src].", \ "You activate \the [src].", \ "You hear heavy droning.") - src.shields_up() + shields_up() else user << "The device must first be secured to the floor!" return @@ -202,14 +203,12 @@ /obj/machinery/shieldgen/attackby(obj/item/weapon/W, mob/user, params) if(istype(W, /obj/item/weapon/screwdriver)) playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1) - if(is_open) - user << "You close the panel." - is_open = 0 - else + panel_open = !panel_open + if(panel_open) user << "You open the panel and expose the wiring." - is_open = 1 - - else if(istype(W, /obj/item/stack/cable_coil) && malfunction && is_open) + else + user << "You close the panel." + else if(istype(W, /obj/item/stack/cable_coil) && (stat & BROKEN) && panel_open) var/obj/item/stack/cable_coil/coil = W if (coil.get_amount() < 1) user << "You need one length of cable to repair [src]!" @@ -220,7 +219,7 @@ return coil.use(1) health = max_health - malfunction = 0 + stat &= ~BROKEN user << "You repair \the [src]." update_icon() @@ -237,31 +236,30 @@ user << "You unsecure \the [src] from the floor!" if(active) user << "\The [src] shuts off!" - src.shields_down() + shields_down() anchored = 0 - - else if(istype(W, /obj/item/weapon/card/id) || istype(W, /obj/item/device/pda)) - if(src.allowed(user)) - src.locked = !src.locked - user << "You [src.locked ? "lock" : "unlock"] the controls." + else if(W.GetID()) + if(allowed(user)) + locked = !locked + user << "You [locked ? "lock" : "unlock"] the controls." else user << "Access denied." else - ..() + return ..() /obj/machinery/shieldgen/emag_act() - if(!malfunction) - malfunction = 1 + if(!(stat & BROKEN)) + stat |= BROKEN + health = 0 update_icon() /obj/machinery/shieldgen/update_icon() if(active) - src.icon_state = malfunction ? "shieldonbr":"shieldon" + icon_state = (stat & BROKEN) ? "shieldonbr":"shieldon" else - src.icon_state = malfunction ? "shieldoffbr":"shieldoff" - return + icon_state = (stat & BROKEN) ? "shieldoffbr":"shieldoff" ////FIELD GEN START //shameless copypasta from fieldgen, powersink, and grille #define maxstoredpower 500 @@ -273,6 +271,8 @@ anchored = 0 density = 1 req_access = list(access_teleporter) + flags = CONDUCT + use_power = 0 var/active = 0 var/power = 0 var/steps = 0 @@ -280,8 +280,6 @@ var/check_delay = 10 var/recalc = 0 var/locked = 1 - var/destroyed = 0 -// var/maxshieldload = 200 var/obj/structure/cable/attached // the attached cable var/storedpower = 0 flags = CONDUCT @@ -312,8 +310,6 @@ if(PN) //runtime errors fixer. They were caused by PN.newload trying to access missing network in case of working on stored power. storedpower += shieldload PN.load += shieldload //uses powernet power. -// message_admins("[PN.load]") -// use_power(250) //uses APC power /obj/machinery/shieldwallgen/attack_hand(mob/user) if(!anchored) @@ -326,21 +322,21 @@ user << "\The [src] needs to be powered by wire underneath!" return 1 - if(src.active >= 1) - src.active = 0 + if(active >= 1) + active = 0 icon_state = "Shield_Gen" user.visible_message("[user] turned \the [src] off.", \ "You turn off \the [src].", \ "You hear heavy droning fade out.") - src.cleanup() + cleanup() else - src.active = 1 + active = 1 icon_state = "Shield_Gen +a" user.visible_message("[user] turned \the [src] on.", \ "You turn on \the [src].", \ "You hear heavy droning.") - src.add_fingerprint(user) + add_fingerprint(user) /obj/machinery/shieldwallgen/process() power() @@ -350,28 +346,26 @@ storedpower = maxstoredpower if(storedpower <= 0) storedpower = 0 -// if(shieldload >= maxshieldload) //there was a loop caused by specifics of process(), so this was needed. -// shieldload = maxshieldload - if(src.active == 1) + if(active == 1) if(!anchored) - src.active = 0 + active = 0 return setup_field(1) setup_field(2) setup_field(4) setup_field(8) src.active = 2 - if(src.active >= 1) - if(src.power == 0) - src.visible_message("The [src.name] shuts down due to lack of power!", \ + if(active >= 1) + if(power == 0) + visible_message("The [src.name] shuts down due to lack of power!", \ "You hear heavy droning fade out.") icon_state = "Shield_Gen" - src.active = 0 - src.cleanup(1) - src.cleanup(2) - src.cleanup(4) - src.cleanup(8) + active = 0 + cleanup(1) + cleanup(2) + cleanup(4) + cleanup(8) /obj/machinery/shieldwallgen/proc/setup_field(NSEW = 0) var/turf/T = src.loc @@ -436,16 +430,16 @@ anchored = 0 return - if(istype(W, /obj/item/weapon/card/id)||istype(W, /obj/item/device/pda)) - if (src.allowed(user)) - src.locked = !src.locked + if(W.GetID()) + if (allowed(user)) + locked = !locked user << "You [src.locked ? "lock" : "unlock"] the controls." else user << "Access denied." else add_fingerprint(user) - ..() + return ..() /obj/machinery/shieldwallgen/proc/cleanup(NSEW) var/obj/machinery/shieldwall/F @@ -466,15 +460,16 @@ break /obj/machinery/shieldwallgen/Destroy() - src.cleanup(1) - src.cleanup(2) - src.cleanup(4) - src.cleanup(8) + cleanup(1) + cleanup(2) + cleanup(4) + cleanup(8) return ..() -/obj/machinery/shieldwallgen/bullet_act(obj/item/projectile/Proj) - storedpower -= Proj.damage - ..() +/obj/machinery/shieldwallgen/bullet_act(obj/item/projectile/P) + . = ..() + storedpower -= P.damage + //////////////Containment Field START @@ -525,16 +520,15 @@ gen_secondary.storedpower -=10 -/obj/machinery/shieldwall/bullet_act(obj/item/projectile/Proj) +/obj/machinery/shieldwall/bullet_act(obj/item/projectile/P) + . = ..() if(needs_power) var/obj/machinery/shieldwallgen/G if(prob(50)) G = gen_primary else G = gen_secondary - G.storedpower -= Proj.damage - ..() - return + G.storedpower -= P.damage /obj/machinery/shieldwall/ex_act(severity, target) diff --git a/code/game/machinery/teleporter.dm b/code/game/machinery/teleporter.dm index 86d8993b928..27dc7cba695 100644 --- a/code/game/machinery/teleporter.dm +++ b/code/game/machinery/teleporter.dm @@ -47,8 +47,7 @@ locked = L user << "You insert the GPS device into the [name]'s slot." else - ..() - return + return ..() /obj/machinery/computer/teleporter/attack_ai(mob/user) src.attack_hand(user) @@ -299,11 +298,11 @@ /obj/machinery/teleport/hub/attackby(obj/item/W, mob/user, params) if(default_deconstruction_screwdriver(user, "tele-o", "tele0", W)) return - if(exchange_parts(user, W)) return - - default_deconstruction_crowbar(W) + if(default_deconstruction_crowbar(W)) + return + return ..() /obj/machinery/teleport/hub/proc/teleport(atom/movable/M as mob|obj, turf/T) var/obj/machinery/computer/teleporter/com = power_station.teleporter_console @@ -405,34 +404,37 @@ return ..() /obj/machinery/teleport/station/attackby(obj/item/weapon/W, mob/user, params) - if(istype(W, /obj/item/device/multitool) && !panel_open) + if(istype(W, /obj/item/device/multitool)) var/obj/item/device/multitool/M = W - if(M.buffer && istype(M.buffer, /obj/machinery/teleport/station) && M.buffer != src) - if(linked_stations.len < efficiency) - linked_stations.Add(M.buffer) - M.buffer = null - user << "You upload the data from the [W.name]'s buffer." - else - user << "This station can't hold more information, try to use better parts." - if(default_deconstruction_screwdriver(user, "controller-o", "controller", W)) + if(panel_open) + M.buffer = src + user << "You download the data to the [W.name]'s buffer." + else + if(M.buffer && istype(M.buffer, /obj/machinery/teleport/station) && M.buffer != src) + if(linked_stations.len < efficiency) + linked_stations.Add(M.buffer) + M.buffer = null + user << "You upload the data from the [W.name]'s buffer." + else + user << "This station can't hold more information, try to use better parts." + return + else if(default_deconstruction_screwdriver(user, "controller-o", "controller", W)) update_icon() return - if(exchange_parts(user, W)) + else if(exchange_parts(user, W)) return - default_deconstruction_crowbar(W) + else if(default_deconstruction_crowbar(W)) + return - if(panel_open) - if(istype(W, /obj/item/device/multitool)) - var/obj/item/device/multitool/M = W - M.buffer = src - user << "You download the data to the [W.name]'s buffer." - return - if(istype(W, /obj/item/weapon/wirecutters)) + else if(istype(W, /obj/item/weapon/wirecutters)) + if(panel_open) link_console_and_hub() user << "You reconnect the station to nearby machinery." return + else + return ..() /obj/machinery/teleport/station/attack_paw() src.attack_hand() diff --git a/code/game/machinery/vending.dm b/code/game/machinery/vending.dm index 756f07068ee..cbc30cb5ede 100644 --- a/code/game/machinery/vending.dm +++ b/code/game/machinery/vending.dm @@ -179,9 +179,8 @@ user << "You insert [W] into [src]'s chef compartment." else user << "[src]'s chef compartment does not accept junk food." - return - if(istype(W, /obj/item/weapon/storage/bag/tray)) + else if(istype(W, /obj/item/weapon/storage/bag/tray)) if(!compartment_access_check(user)) return var/obj/item/weapon/storage/T = W @@ -203,7 +202,8 @@ updateUsrDialog() return - ..() + else + return ..() /obj/machinery/vending/snack/proc/compartment_access_check(user) req_access_txt = chef_compartment_access @@ -237,16 +237,20 @@ if(default_unfasten_wrench(user, W, time = 60)) return - if(component_parts && istype(W, /obj/item/weapon/crowbar)) - default_deconstruction_crowbar(W) + if(component_parts) + if(default_deconstruction_crowbar(W)) + return - if(istype(W, /obj/item/weapon/screwdriver) && anchored) - panel_open = !panel_open - user << "You [panel_open ? "open" : "close"] the maintenance panel." - overlays.Cut() - if(panel_open) - overlays += image(icon, "[initial(icon_state)]-panel") - updateUsrDialog() + if(istype(W, /obj/item/weapon/screwdriver)) + if(anchored) + panel_open = !panel_open + user << "You [panel_open ? "open" : "close"] the maintenance panel." + overlays.Cut() + if(panel_open) + overlays += image(icon, "[initial(icon_state)]-panel") + updateUsrDialog() + else + user << "You must first secure [src]." return else if(istype(W, /obj/item/device/multitool)||istype(W, /obj/item/weapon/wirecutters)) if(panel_open) @@ -273,14 +277,14 @@ user << "You loaded [transfered] items in \the [name]." else user << "The [name] is fully stocked." - return; + return else user << "You should probably unscrew the service panel first." else - ..() + return ..() -/obj/machinery/vending/default_deconstruction_crowbar(obj/item/O) +/obj/machinery/vending/deconstruction() var/product_list = list(product_records, hidden_records, coin_records) for(var/i=1, i<=3, i++) for(var/datum/data/vending_product/machine_content in product_list[i]) diff --git a/code/modules/atmospherics/machinery/atmosmachinery.dm b/code/modules/atmospherics/machinery/atmosmachinery.dm index a84f002506a..7997c832e00 100644 --- a/code/modules/atmospherics/machinery/atmosmachinery.dm +++ b/code/modules/atmospherics/machinery/atmosmachinery.dm @@ -122,40 +122,43 @@ Pipelines + Other Objects -> Pipe network return /obj/machinery/atmospherics/attackby(obj/item/weapon/W, mob/user, params) - if(can_unwrench && istype(W, /obj/item/weapon/wrench)) - var/turf/T = get_turf(src) - if (level==1 && isturf(T) && T.intact) - user << "You must remove the plating first!" - return 1 - var/datum/gas_mixture/int_air = return_air() - var/datum/gas_mixture/env_air = loc.return_air() - add_fingerprint(user) + if(istype(W, /obj/item/weapon/wrench)) + if(can_unwrench(user)) + var/turf/T = get_turf(src) + if (level==1 && isturf(T) && T.intact) + user << "You must remove the plating first!" + return 1 + var/datum/gas_mixture/int_air = return_air() + var/datum/gas_mixture/env_air = loc.return_air() + add_fingerprint(user) - var/unsafe_wrenching = FALSE - var/internal_pressure = int_air.return_pressure()-env_air.return_pressure() + var/unsafe_wrenching = FALSE + var/internal_pressure = int_air.return_pressure()-env_air.return_pressure() - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user << "You begin to unfasten \the [src]..." - if (internal_pressure > 2*ONE_ATMOSPHERE) - user << "As you begin unwrenching \the [src] a gush of air blows in your face... maybe you should reconsider?" - unsafe_wrenching = TRUE //Oh dear oh dear + playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) + user << "You begin to unfasten \the [src]..." + if (internal_pressure > 2*ONE_ATMOSPHERE) + user << "As you begin unwrenching \the [src] a gush of air blows in your face... maybe you should reconsider?" + unsafe_wrenching = TRUE //Oh dear oh dear - if (do_after(user, 20/W.toolspeed, target = src) && !qdeleted(src)) - user.visible_message( \ - "[user] unfastens \the [src].", \ - "You unfasten \the [src].", \ - "You hear ratchet.") - investigate_log("was REMOVED by [key_name(usr)]", "atmos") - - //You unwrenched a pipe full of pressure? Let's splat you into the wall, silly. - if(unsafe_wrenching) - unsafe_pressure_release(user, internal_pressure) - Deconstruct() + if (do_after(user, 20/W.toolspeed, target = src) && !qdeleted(src)) + user.visible_message( \ + "[user] unfastens \the [src].", \ + "You unfasten \the [src].", \ + "You hear ratchet.") + investigate_log("was REMOVED by [key_name(usr)]", "atmos") + //You unwrenched a pipe full of pressure? Let's splat you into the wall, silly. + if(unsafe_wrenching) + unsafe_pressure_release(user, internal_pressure) + Deconstruct() else return ..() +/obj/machinery/atmospherics/proc/can_unwrench(mob/user) + return can_unwrench + // Throws the user when they unwrench a pipe with a major difference between the internal and environmental pressure. /obj/machinery/atmospherics/proc/unsafe_pressure_release(mob/user, pressures = null) if(!user) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm b/code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm index 7ddc1f518c9..7e5074c6388 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm @@ -166,10 +166,10 @@ Passive gate is similar to the regular pump except: ..() update_icon() -/obj/machinery/atmospherics/components/binary/passive_gate/attackby(obj/item/weapon/W, mob/user, params) - if(!istype(W, /obj/item/weapon/wrench)) - return ..() - if(on) - user << "You cannot unwrench this [src], turn it off first!" - return 1 - return ..() +/obj/machinery/atmospherics/components/binary/passive_gate/can_unwrench(mob/user) + if(..()) + if(on) + user << "You cannot unwrench this [src], turn it off first!" + else + return 1 + diff --git a/code/modules/atmospherics/machinery/components/binary_devices/pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/pump.dm index 1304c1b12ca..a500b3841de 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/pump.dm @@ -173,11 +173,10 @@ Thus, the two variables affect pump operation are set in New(): ..() update_icon() -/obj/machinery/atmospherics/components/binary/pump/attackby(obj/item/weapon/W, mob/user, params) - if (!istype(W, /obj/item/weapon/wrench)) - return ..() - if (!(stat & NOPOWER) && on) - user << "You cannot unwrench this [src], turn it off first!" - return 1 - return ..() +/obj/machinery/atmospherics/components/binary/pump/can_unwrench(mob/user) + if(..()) + if(!(stat & NOPOWER) && on) + user << "You cannot unwrench this [src], turn it off first!" + else + return 1 diff --git a/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm index 8a09e99b93e..6b4bc164574 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm @@ -169,10 +169,10 @@ Thus, the two variables affect pump operation are set in New(): ..() update_icon() -/obj/machinery/atmospherics/components/binary/volume_pump/attackby(obj/item/weapon/W, mob/user, params) - if (!istype(W, /obj/item/weapon/wrench)) - return ..() - if (!(stat & NOPOWER) && on) - user << "You cannot unwrench this [src], turn it off first!" - return 1 - return ..() +/obj/machinery/atmospherics/components/binary/volume_pump/can_unwrench(mob/user) + if(..()) + if(!(stat & NOPOWER) && on) + user << "You cannot unwrench this [src], turn it off first!" + else + return 1 + diff --git a/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm b/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm index 91a7a2d8ad0..d896d93a9a3 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm @@ -164,17 +164,17 @@ /obj/machinery/atmospherics/components/unary/cryo_cell/attackby(obj/item/I, mob/user, params) if(istype(I, /obj/item/weapon/reagent_containers/glass)) - if(isrobot(user)) + . = 1 //no afterattack + if(!user.drop_item()) return if(beaker) user << "A beaker is already loaded into [src]!" return - if(!user.drop_item()) - return beaker = I I.loc = src user.visible_message("[user] places [I] in [src].", \ "You place [I] in [src].") + return if(!on && !occupant && !state_open) if(default_deconstruction_screwdriver(user, "cell-o", "cell-off", I)) return @@ -186,6 +186,7 @@ return if(default_deconstruction_crowbar(I)) return + return ..() /obj/machinery/atmospherics/components/unary/cryo_cell/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, \ datum/tgui/master_ui = null, datum/ui_state/state = notcontained_state) diff --git a/code/modules/atmospherics/machinery/components/unary_devices/portables_connector.dm b/code/modules/atmospherics/machinery/components/unary_devices/portables_connector.dm index e4b9622b481..8d1c435b10c 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/portables_connector.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/portables_connector.dm @@ -27,12 +27,12 @@ connected_device.disconnect() return ..() -/obj/machinery/atmospherics/components/unary/portables_connector/attackby(obj/item/weapon/W, mob/user, params) - if(istype(W, /obj/item/weapon/wrench)) +/obj/machinery/atmospherics/components/unary/portables_connector/can_unwrench(mob/user) + if(..()) if(connected_device) - user << "You cannot unwrench this [src], dettach [connected_device] first!" + user << "You cannot unwrench this [src], detach [connected_device] first!" + else return 1 - return ..() /obj/machinery/atmospherics/components/unary/portables_connector/portableConnectorReturnAir() return connected_device.portableConnectorReturnAir() diff --git a/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm b/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm index 3ac314d3b6b..ed142bbf4ed 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm @@ -85,6 +85,7 @@ return if(default_deconstruction_crowbar(I)) return + return ..() /obj/machinery/atmospherics/components/unary/thermomachine/default_change_direction_wrench(mob/user, obj/item/weapon/wrench/W) if(!..()) diff --git a/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm b/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm index f00c99897d1..55ac2266861 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm @@ -244,9 +244,6 @@ return /obj/machinery/atmospherics/components/unary/vent_pump/attackby(obj/item/W, mob/user, params) - if (istype(W, /obj/item/weapon/wrench)&& !(stat & NOPOWER) && on) - user << "You cannot unwrench this [src], turn it off first!" - return 1 if(istype(W, /obj/item/weapon/weldingtool)) var/obj/item/weapon/weldingtool/WT = W if (WT.remove_fuel(0,user)) @@ -267,6 +264,13 @@ else return ..() +/obj/machinery/atmospherics/components/unary/vent_pump/can_unwrench(mob/user) + if(..()) + if(!(stat & NOPOWER) && on) + user << "You cannot unwrench this [src], turn it off first!" + else + return 1 + /obj/machinery/atmospherics/components/unary/vent_pump/examine(mob/user) ..() if(welded) diff --git a/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm b/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm index cdefd24e240..b9c727da0a6 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/vent_scrubber.dm @@ -310,12 +310,15 @@ update_icon() pipe_vision_img = image(src, loc, layer = 20, dir = dir) return 0 - if (!istype(W, /obj/item/weapon/wrench)) + else return ..() - if (!(stat & NOPOWER) && on) - user << "You cannot unwrench this [src], turn it off first!" - return 1 - return ..() + +/obj/machinery/atmospherics/components/unary/vent_scrubber/can_unwrench(mob/user) + if(..()) + if (!(stat & NOPOWER) && on) + user << "You cannot unwrench this [src], turn it off first!" + else + return 1 /obj/machinery/atmospherics/components/unary/vent_scrubber/can_crawl_through() return !welded diff --git a/code/modules/atmospherics/machinery/portable/canister.dm b/code/modules/atmospherics/machinery/portable/canister.dm index 212e1ccef37..00d7fab4602 100644 --- a/code/modules/atmospherics/machinery/portable/canister.dm +++ b/code/modules/atmospherics/machinery/portable/canister.dm @@ -149,14 +149,25 @@ /obj/machinery/portable_atmospherics/canister/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume) if(exposed_temperature > temperature_resistance) - health -= 5 - healthcheck() + take_damage(5, BRUTE, 0) -/obj/machinery/portable_atmospherics/canister/proc/healthcheck() +/obj/machinery/portable_atmospherics/canister/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BRUTE) + if(sound_effect) + if(damage) + playsound(loc, 'sound/weapons/smash.ogg', 50, 1) + else + playsound(loc, 'sound/weapons/tap.ogg', 50, 1) + if(BURN) + if(sound_effect) + playsound(src.loc, 'sound/items/Welder.ogg', 100, 1) + else + return if(stat & BROKEN) return - - if(health <= 10) + health = max( health - damage, 0) + if(!health) disconnect() var/datum/gas_mixture/expelled_gas = air_contents.remove(air_contents.total_moles()) var/turf/T = get_turf(src) @@ -193,42 +204,33 @@ update_icon() /obj/machinery/portable_atmospherics/canister/blob_act() - health = 0 - healthcheck() + take_damage(100, BRUTE, 0) /obj/machinery/portable_atmospherics/canister/bullet_act(obj/item/projectile/P) - if((P.damage_type == BRUTE || P.damage_type == BURN)) - if(P.damage) - health -= round(P.damage / 2) - healthcheck() - ..() + . = ..() + take_damage(P.damage / 2, P.damage_type, 0) /obj/machinery/portable_atmospherics/canister/ex_act(severity, target) switch(severity) if(1) if((stat & BROKEN) || prob(30)) qdel(src) - return else - health = 0 + take_damage(100, BRUTE, 0) if(2) if(stat & BROKEN) qdel(src) - return else - health -= rand(40, 100) + take_damage(rand(40, 110), BRUTE, 0) if(3) - health -= rand(15, 40) - healthcheck() + take_damage(rand(15, 40), BRUTE, 0) -/obj/machinery/portable_atmospherics/canister/attackby(obj/item/weapon/W, mob/user, params) - if(!istype(W, /obj/item/weapon/wrench) && !istype(W, /obj/item/weapon/tank) && !istype(W, /obj/item/device/analyzer) && !istype(W, /obj/item/device/pda)) - investigate_log("was smacked with \a [W] by [key_name(user)].", "atmos") - health -= W.force - add_fingerprint(user) - healthcheck() - playsound(loc, 'sound/weapons/smash.ogg', 60, 1) - ..() +/obj/machinery/portable_atmospherics/canister/attacked_by(obj/item/I, mob/user) + if(I.force) + user.visible_message("[user] has hit [src] with [I]!", "You hit [src] with [I]!") + investigate_log("was smacked with \a [I] by [key_name(user)].", "atmos") + add_fingerprint(user) + take_damage(I.force, I.damtype, 1) /obj/machinery/portable_atmospherics/canister/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, \ datum/tgui/master_ui = null, datum/ui_state/state = physical_state) diff --git a/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm b/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm index f2b12e19c45..44f59644a2f 100644 --- a/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm +++ b/code/modules/atmospherics/machinery/portable/portable_atmospherics.dm @@ -69,38 +69,40 @@ return air_contents /obj/machinery/portable_atmospherics/attackby(obj/item/weapon/W, mob/user, params) - if(istype(W, /obj/item/weapon/tank) && !(stat & BROKEN)) - var/obj/item/weapon/tank/T = W - if(holding || !user.drop_item()) - return - T.loc = src - holding = T - update_icon() - else if(istype(W, /obj/item/weapon/wrench) && !(stat & BROKEN)) - if(connected_port) - disconnect() - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user.visible_message( \ - "[user] disconnects [src].", \ - "You unfasten [src] from the port.", \ - "You hear a ratchet.") - update_icon() - return - else - var/obj/machinery/atmospherics/components/unary/portables_connector/possible_port = locate(/obj/machinery/atmospherics/components/unary/portables_connector) in loc - if(!possible_port) - user << "Nothing happens." + if(istype(W, /obj/item/weapon/tank)) + if(!(stat & BROKEN)) + var/obj/item/weapon/tank/T = W + if(holding || !user.drop_item()) return - if(!connect(possible_port)) - user << "[name] failed to connect to the port." - return - playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) - user.visible_message( \ - "[user] connects [src].", \ - "You fasten [src] to the port.", \ - "You hear a ratchet.") + T.loc = src + holding = T update_icon() - else if((istype(W, /obj/item/device/analyzer)) && Adjacent(user)) + else if(istype(W, /obj/item/weapon/wrench)) + if(!(stat & BROKEN)) + if(connected_port) + disconnect() + playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) + user.visible_message( \ + "[user] disconnects [src].", \ + "You unfasten [src] from the port.", \ + "You hear a ratchet.") + update_icon() + return + else + var/obj/machinery/atmospherics/components/unary/portables_connector/possible_port = locate(/obj/machinery/atmospherics/components/unary/portables_connector) in loc + if(!possible_port) + user << "Nothing happens." + return + if(!connect(possible_port)) + user << "[name] failed to connect to the port." + return + playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1) + user.visible_message( \ + "[user] connects [src].", \ + "You fasten [src] to the port.", \ + "You hear a ratchet.") + update_icon() + else if(istype(W, /obj/item/device/analyzer) && Adjacent(user)) atmosanalyzer_scan(air_contents, user) else - ..() \ No newline at end of file + return ..() \ No newline at end of file diff --git a/code/modules/food&drinks/kitchen machinery/processor.dm b/code/modules/food&drinks/kitchen machinery/processor.dm index 46cbf39ef83..afbb781a6e1 100644 --- a/code/modules/food&drinks/kitchen machinery/processor.dm +++ b/code/modules/food&drinks/kitchen machinery/processor.dm @@ -170,7 +170,8 @@ if(default_unfasten_wrench(user, O)) return - default_deconstruction_crowbar(O) + if(default_deconstruction_crowbar(O)) + return var/atom/movable/what = O if(istype(O, /obj/item/weapon/grab)) @@ -183,15 +184,17 @@ what = G.affecting var/datum/food_processor_process/P = select_recipe(what) - if (!P) - user << "That probably won't blend!" - return 1 - - user.visible_message("[user] put [what] into [src].", \ - "You put the [what] into [src].") - user.drop_item() - what.loc = src - return + if(P) + user.visible_message("[user] put [what] into [src].", \ + "You put the [what] into [src].") + user.drop_item() + what.loc = src + else + if(user.a_intent != "harm") + user << "That probably won't blend!" + return 1 + else + return ..() /obj/machinery/processor/attack_hand(mob/user) if (src.stat != 0) //NOPOWER etc diff --git a/code/modules/food&drinks/kitchen machinery/smartfridge.dm b/code/modules/food&drinks/kitchen machinery/smartfridge.dm index 7c312cbf91f..1eac74d44c7 100644 --- a/code/modules/food&drinks/kitchen machinery/smartfridge.dm +++ b/code/modules/food&drinks/kitchen machinery/smartfridge.dm @@ -66,7 +66,9 @@ power_change() return - default_deconstruction_crowbar(O) + if(default_deconstruction_crowbar(O)) + updateUsrDialog() + return if(stat) return 0 @@ -81,38 +83,36 @@ updateUsrDialog() return 1 - var/loaded = 0 - if(istype(O, /obj/item/weapon/storage/bag)) var/obj/item/weapon/storage/P = O + var/loaded = 0 for(var/obj/G in P.contents) if(contents.len >= max_n_of_items) break if(accept_check(G)) load(G) loaded++ - else + updateUsrDialog() + + if(loaded) + if(contents.len >= max_n_of_items) + user.visible_message("[user] loads \the [src] with \the [O].", \ + "You fill \the [src] with \the [O].") + else + user.visible_message("[user] loads \the [src] with \the [O].", \ + "You load \the [src] with \the [O].") + if(O.contents.len > 0) + user << "Some items are refused." + else + user << "There is nothing in [O] to put in [src]!" + return 0 + + else if(user.a_intent != "harm") user << "\The [src] smartly refuses [O]." updateUsrDialog() return 0 - - // this is a little backwards but it avoids duplication. - // this code follows storage items and trays only. - if(loaded) - if(contents.len >= max_n_of_items) - user.visible_message("[user] loads \the [src] with \the [O].", \ - "You fill \the [src] with \the [O].") - else - user.visible_message("[user] loads \the [src] with \the [O].", \ - "You load \the [src] with \the [O].") - if(O.contents.len > 0) - user << "Some items are refused." else - user << "There is nothing in [O] to put in [src]!" - return 0 - - updateUsrDialog() - return 1 + return ..() diff --git a/code/modules/hydroponics/biogenerator.dm b/code/modules/hydroponics/biogenerator.dm index 48a05c0bd27..978c4d191d9 100644 --- a/code/modules/hydroponics/biogenerator.dm +++ b/code/modules/hydroponics/biogenerator.dm @@ -54,40 +54,59 @@ return /obj/machinery/biogenerator/attackby(obj/item/O, mob/user, params) - if(istype(O, /obj/item/weapon/reagent_containers/glass) && !panel_open) - if(beaker) - user << "A container is already loaded into the machine." - else - user.unEquip(O) - O.loc = src - beaker = O - user << "You add the container to the machine." - updateUsrDialog() - else if(processing) + if(processing) user << "The biogenerator is currently processing." + return + + if(default_deconstruction_screwdriver(user, "biogen-empty-o", "biogen-empty", O)) + if(beaker) + var/obj/item/weapon/reagent_containers/glass/B = beaker + B.loc = loc + beaker = null + update_icon() + return + + if(exchange_parts(user, O)) + return + + if(default_deconstruction_crowbar(O)) + return + + if(istype(O, /obj/item/weapon/reagent_containers/glass)) + if(!panel_open) + if(beaker) + user << "A container is already loaded into the machine." + else + user.unEquip(O) + O.loc = src + beaker = O + user << "You add the container to the machine." + update_icon() + updateUsrDialog() + return 1 //no afterattack + else if(istype(O, /obj/item/weapon/storage/bag/plants)) + var/obj/item/weapon/storage/bag/plants/PB = O var/i = 0 for(var/obj/item/weapon/reagent_containers/food/snacks/grown/G in contents) i++ if(i >= max_items) user << "The biogenerator is already full! Activate it." else - for(var/obj/item/weapon/reagent_containers/food/snacks/grown/G in O.contents) + for(var/obj/item/weapon/reagent_containers/food/snacks/grown/G in PB.contents) if(i >= max_items) break - G.loc = src + PB.remove_from_storage(G, src) i++ if(iYou empty the plant bag into the biogenerator." - else if(O.contents.len == 0) + else if(PB.contents.len == 0) user << "You empty the plant bag into the biogenerator, filling it to its capacity." else user << "You fill the biogenerator to its capacity." + return 1 //no afterattack - - else if(!istype(O, /obj/item/weapon/reagent_containers/food/snacks/grown)) - user << "You cannot put this in [src.name]!" - else + else if(istype(O, /obj/item/weapon/reagent_containers/food/snacks/grown)) var/i = 0 for(var/obj/item/weapon/reagent_containers/food/snacks/grown/G in contents) i++ @@ -97,21 +116,12 @@ user.unEquip(O) O.loc = src user << "You put [O.name] in [src.name]" + return 1 //no afterattack - if(!processing) - if(default_deconstruction_screwdriver(user, "biogen-empty-o", "biogen-empty", O)) - if(beaker) - var/obj/item/weapon/reagent_containers/glass/B = beaker - B.loc = loc - beaker = null - - if(exchange_parts(user, O)) - return - - default_deconstruction_crowbar(O) - - update_icon() - return + else if(user.a_intent != "harm") + user << "You cannot put this in [src.name]!" + else + return ..() /obj/machinery/biogenerator/interact(mob/user) if(stat & BROKEN || panel_open) diff --git a/code/modules/hydroponics/seed_extractor.dm b/code/modules/hydroponics/seed_extractor.dm index 7e479069c3c..d30378251f5 100644 --- a/code/modules/hydroponics/seed_extractor.dm +++ b/code/modules/hydroponics/seed_extractor.dm @@ -6,12 +6,16 @@ else t_max = rand(1,4) + var/seedloc = O.loc + if(extractor) + seedloc = extractor.loc + if(istype(O, /obj/item/weapon/reagent_containers/food/snacks/grown/)) var/obj/item/weapon/reagent_containers/food/snacks/grown/F = O if(F.seed) while(t_amount < t_max) var/obj/item/seeds/t_prod = F.seed.Copy() - t_prod.loc = O.loc + t_prod.loc = seedloc t_amount++ qdel(O) return 1 @@ -21,19 +25,12 @@ if(F.seed) while(t_amount < t_max) var/obj/item/seeds/t_prod = F.seed.Copy() - t_prod.loc = O.loc + t_prod.loc = seedloc t_amount++ qdel(O) return 1 - /*else if(istype(O, /obj/item/stack/tile/grass)) - var/obj/item/stack/tile/grass/S = O - new /obj/item/seeds/grassseed(O.loc) - S.use(1) - return 1*/ - - else - return 0 + return 0 /obj/machinery/seed_extractor @@ -75,9 +72,7 @@ if(default_unfasten_wrench(user, O)) return - default_deconstruction_crowbar(O) - - if(isrobot(user)) + if(default_deconstruction_crowbar(O)) return if (istype(O,/obj/item/weapon/storage/bag/plants)) @@ -87,7 +82,7 @@ if(contents.len >= max_seeds) break ++loaded - add(G) + add_seed(G) if (loaded) user << "You put the seeds from \the [O.name] into [src]." else @@ -98,19 +93,18 @@ user << "\The [O] is stuck to your hand, you cannot put it in the seed extractor!" return - if(O && O.loc) - O.loc = src.loc - - if(seedify(O,-1)) + else if(seedify(O,-1, src)) user << "You extract some seeds." return else if (istype(O,/obj/item/seeds)) - add(O) + add_seed(O) user << "You add [O] to [src.name]." updateUsrDialog() return - else + else if(user.a_intent != "harm") user << "You can't extract any seeds from \the [O.name]!" + else + return ..() /datum/seed_pile var/name = "" @@ -187,7 +181,7 @@ src.updateUsrDialog() return -/obj/machinery/seed_extractor/proc/add(obj/item/seeds/O) +/obj/machinery/seed_extractor/proc/add_seed(obj/item/seeds/O) if(contents.len >= 999) usr << "\The [src] is full." return 0 diff --git a/code/modules/mining/equipment_locker.dm b/code/modules/mining/equipment_locker.dm index 12ec53f1011..7d52a164b8c 100644 --- a/code/modules/mining/equipment_locker.dm +++ b/code/modules/mining/equipment_locker.dm @@ -93,7 +93,7 @@ if (!powered()) return if(istype(W,/obj/item/weapon/card/id)) - var/obj/item/weapon/card/id/I = usr.get_active_hand() + var/obj/item/weapon/card/id/I = user.get_active_hand() if(istype(I) && !istype(inserted_id)) if(!user.drop_item()) return @@ -112,12 +112,13 @@ if(default_deconstruction_screwdriver(user, "ore_redemption-open", "ore_redemption", W)) updateUsrDialog() return - if(panel_open) - if(istype(W, /obj/item/weapon/crowbar)) - empty_content() - default_deconstruction_crowbar(W) - return 1 - ..() + if(default_deconstruction_crowbar(W)) + return + + return ..() + +/obj/machinery/mineral/ore_redemption/deconstruction() + empty_content() /obj/machinery/mineral/ore_redemption/proc/SmeltMineral(obj/item/weapon/ore/O) if(O.refined_type) @@ -407,11 +408,9 @@ if(default_deconstruction_screwdriver(user, "mining-open", "mining", I)) updateUsrDialog() return - if(panel_open) - if(istype(I, /obj/item/weapon/crowbar)) - default_deconstruction_crowbar(I) - return 1 - ..() + if(default_deconstruction_crowbar(I)) + return + return ..() /obj/machinery/mineral/equipment_vendor/proc/RedeemVoucher(obj/item/weapon/mining_voucher/voucher, mob/redeemer) var/selection = input(redeemer, "Pick your equipment", "Mining Voucher Redemption") as null|anything in list("Two Survival Capsules", "Resonator", "Mining Drone", "Advanced Scanner") @@ -767,8 +766,8 @@ icon_state = "door_electronics" icon = 'icons/obj/module.dmi' -/obj/item/device/mine_bot_ugprade/afterattack(mob/living/simple_animal/hostile/mining_drone/M, mob/user) - if(!istype(M)) +/obj/item/device/mine_bot_ugprade/afterattack(mob/living/simple_animal/hostile/mining_drone/M, mob/user, proximity) + if(!istype(M) || !proximity) return upgrade_bot(M, user) diff --git a/code/modules/ninja/suit/n_suit_verbs/energy_net_nets.dm b/code/modules/ninja/suit/n_suit_verbs/energy_net_nets.dm index 9a3849e202e..a2b9add6e23 100644 --- a/code/modules/ninja/suit/n_suit_verbs/energy_net_nets.dm +++ b/code/modules/ninja/suit/n_suit_verbs/energy_net_nets.dm @@ -20,20 +20,29 @@ It is possible to destroy the net by the occupant or someone else. -/obj/effect/energy_net/proc/healthcheck() +/obj/effect/energy_net/proc/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BRUTE) + if(sound_effect) + playsound(src.loc, 'sound/weapons/slash.ogg', 80, 1) + if(BURN) + if(sound_effect) + playsound(src.loc, 'sound/weapons/slash.ogg', 80, 1) + else + return + health -= damage if(health <=0) - density = 0 - if(affecting) - var/mob/living/carbon/M = affecting - M.anchored = 0 - for(var/mob/O in viewers(src, 3)) - O.show_message("[M.name] was recovered from the energy net!", 1, "You hear a grunt.", 2) - if(!isnull(master))//As long as they still exist. - master << "ERROR: unable to initiate transport protocol. Procedure terminated." qdel(src) - return - +/obj/effect/energy_net/Destroy() + if(affecting) + var/mob/living/carbon/M = affecting + M.anchored = 0 + for(var/mob/O in viewers(src, 3)) + O.show_message("[M.name] was recovered from the energy net!", 1, "You hear a grunt.", 2) + if(master)//As long as they still exist. + master << "ERROR: unable to initiate transport protocol. Procedure terminated." + return ..() /obj/effect/energy_net/process(mob/living/carbon/M) var/check = 30//30 seconds before teleportation. Could be extended I guess. @@ -98,53 +107,39 @@ It is possible to destroy the net by the occupant or someone else. /obj/effect/energy_net/bullet_act(obj/item/projectile/Proj) - health -= Proj.damage - healthcheck() - ..() + . = ..() + take_damage(Proj.damage, Proj.damage_type) /obj/effect/energy_net/ex_act(severity, target) switch(severity) if(1) - health-=50 + qdel(src) if(2) - health-=50 + qdel(src) if(3) - health-=prob(50)?50:25 - healthcheck() - return - - + take_damage(rand(10,25), BRUTE, 0) /obj/effect/energy_net/blob_act() - health-=50 - healthcheck() - return + qdel(src) - - -/obj/effect/energy_net/hitby(AM as mob|obj) +/obj/effect/energy_net/hitby(atom/movable/AM) ..() var/tforce = 0 if(ismob(AM)) tforce = 10 - else - tforce = AM:throwforce - playsound(src.loc, 'sound/weapons/slash.ogg', 80, 1) - health = max(0, health - tforce) - healthcheck() - ..() - return - + else if(isobj(AM)) + var/obj/O = AM + tforce = O.throwforce + take_damage(tforce) /obj/effect/energy_net/attack_hulk(mob/living/carbon/human/user) ..(user, 1) user.visible_message("[user] rips the energy net apart!", \ "You easily destroy the energy net.") - health-=50 - healthcheck() + qdel(src) @@ -155,25 +150,17 @@ It is possible to destroy the net by the occupant or someone else. /obj/effect/energy_net/attack_alien(mob/living/user) user.do_attack_animation(src) - if (islarva(user)) - return + user.changeNext_move(CLICK_CD_MELEE) playsound(src.loc, 'sound/weapons/slash.ogg', 80, 1) - health -= rand(10, 20) - if(health > 0) - user.visible_message("[user] claws at the energy net!", \ - "\green You claw at the net.") - else - user.visible_message("[user] slices the energy net apart!", \ + user.visible_message("[user] slices the energy net apart!", \ "\green You slice the energy net to pieces.") - healthcheck() - return + qdel(src) -/obj/effect/energy_net/attackby(obj/item/weapon/W, mob/user, params) - var/aforce = W.force - health = max(0, health - aforce) - healthcheck() +/obj/effect/energy_net/attacked_by(obj/item/weapon/W, mob/user) ..() - return + take_damage(W.force, W.damtype) + + diff --git a/code/modules/paperwork/paperbin.dm b/code/modules/paperwork/paperbin.dm index d21ac7a912c..71117b114db 100644 --- a/code/modules/paperwork/paperbin.dm +++ b/code/modules/paperwork/paperbin.dm @@ -78,19 +78,19 @@ add_fingerprint(user) -/obj/item/weapon/paper_bin/attackby(obj/item/weapon/paper/i, mob/user, params) - if(!istype(i)) +/obj/item/weapon/paper_bin/attackby(obj/item/I, mob/user, params) + if(istype(I, /obj/item/weapon/paper)) + var/obj/item/weapon/paper/P = I + if(!user.unEquip(P)) + return + P.loc = src + user << "You put [P] in [src]." + papers.Add(P) + amount++ + update_icon() + else return ..() - if(!user.unEquip(i)) - return - i.loc = src - user << "You put [i] in [src]." - papers.Add(i) - amount++ - update_icon() - - /obj/item/weapon/paper_bin/examine(mob/user) ..() if(amount) diff --git a/code/modules/power/antimatter/control.dm b/code/modules/power/antimatter/control.dm index 985247e2203..3f10566dde8 100644 --- a/code/modules/power/antimatter/control.dm +++ b/code/modules/power/antimatter/control.dm @@ -127,9 +127,10 @@ /obj/machinery/power/am_control_unit/bullet_act(obj/item/projectile/Proj) + . = ..() if(Proj.flag != "bullet") stability -= Proj.force - return 0 + check_stability() /obj/machinery/power/am_control_unit/power_change() @@ -158,15 +159,14 @@ else if(!linked_shielding.len > 0) playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1) user.visible_message("[user.name] unsecures the [src.name].", \ - "YYou remove the anchor bolts.", \ + "You remove the anchor bolts.", \ "You hear a ratchet.") src.anchored = 0 disconnect_from_network() else user << "Once bolted and linked to a shielding unit it the [src.name] is unable to be moved!" - return - if(istype(W, /obj/item/weapon/am_containment)) + else if(istype(W, /obj/item/weapon/am_containment)) if(fueljar) user << "There is already a [fueljar] inside!" return @@ -179,20 +179,29 @@ user.visible_message("[user.name] loads an [W.name] into the [src.name].", \ "You load an [W.name].", \ "You hear a thunk.") - return + else + return ..() - if(W.force >= 20) - stability -= W.force/2 +/obj/machinery/power/am_control_unit/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BRUTE) + if(sound_effect) + if(damage) + playsound(loc, 'sound/weapons/smash.ogg', 50, 1) + else + playsound(loc, 'sound/weapons/tap.ogg', 50, 1) + if(BURN) + if(sound_effect) + playsound(src.loc, 'sound/items/Welder.ogg', 100, 1) + else + return + if(damage >= 20) + stability -= damage/2 check_stability() - ..() - - /obj/machinery/power/am_control_unit/attack_hand(mob/user) if(anchored) interact(user) - return - /obj/machinery/power/am_control_unit/proc/add_shielding(obj/machinery/am_shielding/AMS, AMS_linking = 0) if(!istype(AMS)) diff --git a/code/modules/power/antimatter/shielding.dm b/code/modules/power/antimatter/shielding.dm index 1fa86b2fb12..f4cc4163c7d 100644 --- a/code/modules/power/antimatter/shielding.dm +++ b/code/modules/power/antimatter/shielding.dm @@ -112,9 +112,10 @@ /obj/machinery/am_shielding/bullet_act(obj/item/projectile/Proj) + . = ..() if(Proj.flag != "bullet") stability -= Proj.force/2 - return 0 + check_stability() /obj/machinery/am_shielding/update_icon() @@ -132,11 +133,22 @@ shutdown_core() -/obj/machinery/am_shielding/attackby(obj/item/W, mob/user, params) - if(W.force > 10) - stability -= W.force/2 +/obj/machinery/am_shielding/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BRUTE) + if(sound_effect) + if(damage) + playsound(loc, 'sound/weapons/smash.ogg', 50, 1) + else + playsound(loc, 'sound/weapons/tap.ogg', 50, 1) + if(BURN) + if(sound_effect) + playsound(src.loc, 'sound/items/Welder.ogg', 100, 1) + else + return + if(damage >= 10) + stability -= damage/2 check_stability() - ..() //Call this to link a detected shilding unit to the controller @@ -219,6 +231,5 @@ if(istype(I, /obj/item/device/multitool) && istype(src.loc,/turf)) new/obj/machinery/am_shielding(src.loc) qdel(src) - return - ..() - return \ No newline at end of file + else + return ..() diff --git a/code/modules/power/lighting.dm b/code/modules/power/lighting.dm index bb6b4f5fd45..47b0d481de9 100644 --- a/code/modules/power/lighting.dm +++ b/code/modules/power/lighting.dm @@ -114,7 +114,7 @@ transfer_fingerprints_to(newlight) qdel(src) return - ..() + return ..() /obj/machinery/light_construct/small @@ -148,6 +148,7 @@ // this is used to calc the probability the light burns out var/rigged = 0 // true if rigged to explode + var/health = 20 // the smaller bulb light fixture @@ -158,6 +159,7 @@ brightness = 4 desc = "A small lighting fixture." light_type = /obj/item/weapon/light/bulb + health = 15 /obj/machinery/light/Move() @@ -276,16 +278,12 @@ //Light replacer code if(istype(W, /obj/item/device/lightreplacer)) var/obj/item/device/lightreplacer/LR = W - if(isliving(user)) - var/mob/living/U = user - LR.ReplaceLight(src, U) - return + LR.ReplaceLight(src, user) // attempt to insert light - if(istype(W, /obj/item/weapon/light)) + else if(istype(W, /obj/item/weapon/light)) if(status != LIGHT_EMPTY) user << "There is a [fitting] already inserted!" - return else src.add_fingerprint(user) var/obj/item/weapon/light/L = W @@ -306,28 +304,6 @@ explode() else user << "This type of light requires a [fitting]!" - return - - // attempt to break the light - //If xenos decide they want to smash a light bulb with a toolbox, who am I to stop them? /N - - else if(status != LIGHT_BROKEN && status != LIGHT_EMPTY) - user.changeNext_move(CLICK_CD_MELEE) - user.do_attack_animation(src) - if(W.damtype == STAMINA) - return - if(prob(1+W.force * 5)) - - user.visible_message("[user.name] smashed the light!", \ - "You hit the light, and it smashes!", \ - "You hear a tinkle of breaking glass.") - if(on && (W.flags & CONDUCT)) - if (prob(12)) - electrocute_mob(user, get_area(src), src, 0.3) - broken() - - else - user.visible_message("[user.name] hits the light!") // attempt to stick weapon into light socket else if(status == LIGHT_EMPTY) @@ -348,15 +324,43 @@ newlight.stage = 2 transfer_fingerprints_to(newlight) qdel(src) - return + else + user << "You stick \the [W] into the light socket!" + if(has_power() && (W.flags & CONDUCT)) + var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread + s.set_up(3, 1, src) + s.start() + if (prob(75)) + electrocute_mob(user, get_area(src), src, rand(0.7,1.0)) + else + return ..() - user << "You stick \the [W] into the light socket!" - if(has_power() && (W.flags & CONDUCT)) - var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread - s.set_up(3, 1, src) - s.start() - if (prob(75)) - electrocute_mob(user, get_area(src), src, rand(0.7,1.0)) +/obj/machinery/light/attacked_by(obj/item/I, mob/living/user) + ..() + if(status == LIGHT_BROKEN || status == LIGHT_EMPTY) + if(on && (I.flags & CONDUCT)) + if(prob(12)) + electrocute_mob(user, get_area(src), src, 0.3) + +/obj/machinery/light/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BRUTE) + if(sound_effect) + switch(status) + if(LIGHT_EMPTY) + playsound(loc, 'sound/weapons/smash.ogg', 50, 1) + if(LIGHT_BROKEN) + playsound(loc, 'sound/effects/hit_on_shattered_glass.ogg', 90, 1) + else + playsound(loc, 'sound/effects/Glasshit.ogg', 90, 1) + if(BURN) + if(sound_effect) + playsound(src.loc, 'sound/items/Welder.ogg', 100, 1) + else + return + health -= damage + if(health <= 0) + broken() // returns whether this light has power @@ -385,28 +389,20 @@ src.flicker(1) return -// Aliens smash the bulb but do not get electrocuted./N -/obj/machinery/light/attack_alien(mob/living/carbon/alien/humanoid/user)//So larva don't go breaking light bulbs. - if(status == LIGHT_EMPTY||status == LIGHT_BROKEN) - user << "\green That object is useless to you." - return - else if (status == LIGHT_OK||status == LIGHT_BURNED) - user.do_attack_animation(src) - visible_message("[user.name] smashed the light!", "You hear a tinkle of breaking glass.") - broken() - return +/obj/machinery/light/bullet_act(obj/item/projectile/P) + . = ..() + take_damage(P.damage, P.damage_type, 0) + +/obj/machinery/light/hitby(AM as mob|obj) + ..() + var/tforce = 0 + if(ismob(AM)) + tforce = 40 + else if(isobj(AM)) + var/obj/item/I = AM + tforce = I.throwforce + take_damage(tforce) -/obj/machinery/light/attack_animal(mob/living/simple_animal/M) - if(M.melee_damage_upper == 0) - return - if(status == LIGHT_EMPTY||status == LIGHT_BROKEN) - M << "That object is useless to you." - return - else if (status == LIGHT_OK||status == LIGHT_BURNED) - M.do_attack_animation(src) - visible_message("[M.name] smashed the light!", "You hear a tinkle of breaking glass.") - broken() - return // attack with hand - remove tube/bulb // if hands aren't protected and the light is on, burn the player @@ -584,8 +580,8 @@ brightness = 4 /obj/item/weapon/light/throw_impact(atom/hit_atom) - ..() - shatter() + if(!..()) //not caught by a mob + shatter() // update the icon state and description of the light @@ -625,17 +621,12 @@ ..() return -// called after an attack with a light item -// shatter light, unless it was an attempt to put it in a light socket -// now only shatter if the intent was harm - -/obj/item/weapon/light/afterattack(atom/target, mob/user,proximity) - if(!proximity) return - if(istype(target, /obj/machinery/light)) - return - if(user.a_intent != "harm") - return +/obj/item/weapon/light/attack(mob/living/M, mob/living/user, def_zone) + ..() + shatter() +/obj/item/weapon/light/attack_obj(obj/O, mob/living/user) + ..() shatter() /obj/item/weapon/light/proc/shatter() diff --git a/code/modules/power/singularity/collector.dm b/code/modules/power/singularity/collector.dm index 304e5a37a1f..60a44a6f8bc 100644 --- a/code/modules/power/singularity/collector.dm +++ b/code/modules/power/singularity/collector.dm @@ -10,7 +10,7 @@ var/global/list/rad_collectors = list() density = 1 req_access = list(access_engine_equip) // use_power = 0 - var/obj/item/weapon/tank/internals/plasma/P = null + var/obj/item/weapon/tank/internals/plasma/loaded_tank = null var/last_power = 0 var/active = 0 var/locked = 0 @@ -25,13 +25,13 @@ var/global/list/rad_collectors = list() return ..() /obj/machinery/power/rad_collector/process() - if(P) - if(!P.air_contents.gases["plasma"]) + if(loaded_tank) + if(!loaded_tank.air_contents.gases["plasma"]) investigate_log("out of fuel.","singulo") eject() else - P.air_contents.gases["plasma"][MOLES] -= 0.001*drainratio - P.air_contents.garbage_collect() + loaded_tank.air_contents.gases["plasma"][MOLES] -= 0.001*drainratio + loaded_tank.air_contents.garbage_collect() return @@ -43,7 +43,7 @@ var/global/list/rad_collectors = list() toggle_power() user.visible_message("[user.name] turns the [src.name] [active? "on":"off"].", \ "You turn the [src.name] [active? "on":"off"].") - investigate_log("turned [active?"on":"off"] by [user.key]. [P?"Fuel: [round(P.air_contents.gases["plasma"][MOLES]/0.29)]%":"It is empty"].","singulo") + investigate_log("turned [active?"on":"off"] by [user.key]. [loaded_tank?"Fuel: [round(loaded_tank.air_contents.gases["plasma"][MOLES]/0.29)]%":"It is empty"].","singulo") return else user << "The controls are locked!" @@ -55,26 +55,26 @@ var/global/list/rad_collectors = list() if(istype(W, /obj/item/device/multitool)) user << "The [W.name] detects that [last_power]W were recently produced." return 1 - else if(istype(W, /obj/item/device/analyzer) && P) - atmosanalyzer_scan(P.air_contents, user) + else if(istype(W, /obj/item/device/analyzer) && loaded_tank) + atmosanalyzer_scan(loaded_tank.air_contents, user) else if(istype(W, /obj/item/weapon/tank/internals/plasma)) - if(!src.anchored) + if(!anchored) user << "The [src] needs to be secured to the floor first!" return 1 - if(src.P) + if(loaded_tank) user << "There's already a plasma tank loaded!" return 1 if(!user.drop_item()) return 1 - src.P = W + loaded_tank = W W.loc = src update_icons() else if(istype(W, /obj/item/weapon/crowbar)) - if(P && !src.locked) + if(loaded_tank && !src.locked) eject() return 1 else if(istype(W, /obj/item/weapon/wrench)) - if(P) + if(loaded_tank) user << "Remove the plasma tank first!" return 1 if(!anchored && !isinspace()) @@ -91,20 +91,18 @@ var/global/list/rad_collectors = list() "You unsecure the external bolts.", \ "You hear a ratchet.") disconnect_from_network() - else if(istype(W, /obj/item/weapon/card/id)||istype(W, /obj/item/device/pda)) - if (src.allowed(user)) + else if(W.GetID()) + if(allowed(user)) if(active) - src.locked = !src.locked - user << "You [src.locked ? "lock" : "unlock"] the controls." + locked = !locked + user << "You [locked ? "lock" : "unlock"] the controls." else - src.locked = 0 //just in case it somehow gets locked user << "The controls can only be locked when \the [src] is active!" else user << "Access denied." return 1 else - ..() - return 1 + return ..() /obj/machinery/power/rad_collector/ex_act(severity, target) @@ -116,20 +114,20 @@ var/global/list/rad_collectors = list() /obj/machinery/power/rad_collector/proc/eject() locked = 0 - var/obj/item/weapon/tank/internals/plasma/Z = src.P + var/obj/item/weapon/tank/internals/plasma/Z = src.loaded_tank if (!Z) return Z.loc = get_turf(src) Z.layer = initial(Z.layer) - src.P = null + src.loaded_tank = null if(active) toggle_power() else update_icons() /obj/machinery/power/rad_collector/proc/receive_pulse(pulse_strength) - if(P && active) - var/power_produced = P.air_contents.gases["plasma"] ? P.air_contents.gases["plasma"][MOLES] : 0 + if(loaded_tank && active) + var/power_produced = loaded_tank.air_contents.gases["plasma"] ? loaded_tank.air_contents.gases["plasma"][MOLES] : 0 power_produced *= pulse_strength*20 add_avail(power_produced) last_power = power_produced @@ -139,7 +137,7 @@ var/global/list/rad_collectors = list() /obj/machinery/power/rad_collector/proc/update_icons() overlays.Cut() - if(P) + if(loaded_tank) overlays += image('icons/obj/singularity.dmi', "ptank") if(stat & (NOPOWER|BROKEN)) return diff --git a/code/modules/power/solar.dm b/code/modules/power/solar.dm index 836cfc8853a..9b953b22373 100644 --- a/code/modules/power/solar.dm +++ b/code/modules/power/solar.dm @@ -12,7 +12,7 @@ idle_power_usage = 0 active_power_usage = 0 var/id = 0 - var/health = 10 + var/health = 20 var/obscured = 0 var/sunfrac = 0 var/adir = SOUTH // actual dir @@ -66,24 +66,46 @@ playsound(src.loc, 'sound/items/Deconstruct.ogg', 50, 1) user.visible_message("[user] takes the glass off the solar panel.", "You take the glass off the solar panel.") qdel(src) - return - else if (W) - src.add_fingerprint(user) - src.health -= W.force - src.healthcheck() + else + return ..() + +/obj/machinery/power/solar/bullet_act(obj/item/projectile/P) + . = ..() + take_damage(P.damage, P.damage_type) + +/obj/machinery/power/solar/hitby(AM as mob|obj) ..() + var/tforce = 0 + if(ismob(AM)) + tforce = 20 + else if(isobj(AM)) + var/obj/item/I = AM + tforce = I.throwforce + take_damage(tforce) -/obj/machinery/power/solar/proc/healthcheck() - if (src.health <= 0) - if(!(stat & BROKEN)) - set_broken() +/obj/machinery/power/solar/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BRUTE) + if(sound_effect) + if(stat & BROKEN) + playsound(loc, 'sound/effects/hit_on_shattered_glass.ogg', 60, 1) + else + playsound(loc, 'sound/effects/Glasshit.ogg', 90, 1) + if(BURN) + if(sound_effect) + playsound(loc, 'sound/items/Welder.ogg', 100, 1) else - new /obj/item/weapon/shard(src.loc) - new /obj/item/weapon/shard(src.loc) - qdel(src) return - return - + health -= damage + if(health <= 0) + playsound(src, "shatter", 70, 1) + new /obj/item/weapon/shard(src.loc) + new /obj/item/weapon/shard(src.loc) + qdel(src) + else if(health <= 10) + if(!(stat & BROKEN)) + playsound(loc, 'sound/effects/Glassbr3.ogg', 100, 1) + set_broken() /obj/machinery/power/solar/update_icon() ..() @@ -132,7 +154,6 @@ stat |= BROKEN unset_control() update_icon() - return /obj/machinery/power/solar/ex_act(severity, target) @@ -140,11 +161,9 @@ if(!qdeleted(src)) switch(severity) if(2) - if(prob(50)) - set_broken() + take_damage(rand(10,20), BRUTE, 0) if(3) - if(prob(25)) - set_broken() + take_damage(rand(5,15), BRUTE, 0) /obj/machinery/power/solar/fake/New(var/turf/loc, var/obj/item/solar_assembly/S) ..(loc, S, 0) @@ -255,7 +274,7 @@ tracker = 0 user.visible_message("[user] takes out the electronics from the solar assembly.", "You take out the electronics from the solar assembly.") return 1 - ..() + return ..() // // Solar Control Computer @@ -270,6 +289,7 @@ density = 1 use_power = 1 idle_power_usage = 250 + var/health = 25 var/icon_screen = "solar" var/icon_keyboard = "power_key" var/id = 0 @@ -443,9 +463,33 @@ A.icon_state = "4" A.anchored = 1 qdel(src) - else + else if(user.a_intent != "harm" && !(I.flags & NOBLUDGEON)) src.attack_hand(user) - return + else + return ..() + +/obj/machinery/power/solar_control/bullet_act(obj/item/projectile/P) + . = ..() + take_damage(P.damage, P.damage_type) + +/obj/machinery/power/solar_control/take_damage(damage, damage_type = BRUTE, sound_effect = 1) + switch(damage_type) + if(BRUTE) + if(sound_effect) + if(stat & BROKEN) + playsound(src.loc, 'sound/effects/hit_on_shattered_glass.ogg', 70, 1) + else + playsound(src.loc, 'sound/effects/Glasshit.ogg', 75, 1) + if(BURN) + if(sound_effect) + playsound(src.loc, 'sound/items/Welder.ogg', 100, 1) + else + return + health -= damage + if(health <= 0 && !(stat & BROKEN)) + playsound(loc, 'sound/effects/Glassbr3.ogg', 100, 1) + stat |= BROKEN + update_icon() /obj/machinery/power/solar_control/process() lastgen = gen @@ -489,11 +533,9 @@ if(!qdeleted(src)) switch(severity) if(2) - if(prob(50)) - set_broken() + take_damage(rand(20,30), BRUTE, 0) if(3) - if(prob(25)) - set_broken() + take_damage(rand(10,20), BRUTE, 0) /obj/machinery/power/solar_control/blob_act() if (prob(75)) diff --git a/code/modules/reagents/chemistry/machinery/chem_dispenser.dm b/code/modules/reagents/chemistry/machinery/chem_dispenser.dm index 7a3c9eb472f..758a41d0d64 100644 --- a/code/modules/reagents/chemistry/machinery/chem_dispenser.dm +++ b/code/modules/reagents/chemistry/machinery/chem_dispenser.dm @@ -147,28 +147,28 @@ if(default_unfasten_wrench(user, I)) return - if(isrobot(user)) - return + if(istype(I, /obj/item/weapon/reagent_containers) && (I.flags & OPENCONTAINER)) + var/obj/item/weapon/reagent_containers/B = I + . = 1 //no afterattack + if(beaker) + user << "A container is already loaded into the machine!" + return - var/obj/item/weapon/reagent_containers/B = I // Get a beaker from it? - if(!istype(B)) - return // Not a beaker? + if(!user.drop_item()) // Can't let go? + return - if(beaker) - user << "A beaker is already loaded into the machine!" - return + beaker = B + beaker.loc = src + user << "You add \the [B] to the machine." - if(!user.drop_item()) // Can't let go? - return - - beaker = B - beaker.loc = src - user << "You add the beaker to the machine." - - if(!icon_beaker) - icon_beaker = image('icons/obj/chemical.dmi', src, "disp_beaker") //randomize beaker overlay position. - icon_beaker.pixel_x = rand(-10,5) - overlays += icon_beaker + if(!icon_beaker) + icon_beaker = image('icons/obj/chemical.dmi', src, "disp_beaker") //randomize beaker overlay position. + icon_beaker.pixel_x = rand(-10,5) + overlays += icon_beaker + else if(user.a_intent != "harm") + user << "You can't load \the [I] into the machine!" + else + return ..() /obj/machinery/chem_dispenser/constructable name = "portable chem dispenser" @@ -252,7 +252,7 @@ dispensable_reagents |= dispensable_reagent_tiers[i] dispensable_reagents = sortList(dispensable_reagents) -/obj/machinery/chem_dispenser/constructable/attackby(var/obj/item/I, var/mob/user, params) +/obj/machinery/chem_dispenser/constructable/attackby(obj/item/I, mob/user, params) ..() if(default_deconstruction_screwdriver(user, "minidispenser-o", "minidispenser", I)) return @@ -260,13 +260,14 @@ if(exchange_parts(user, I)) return - if(panel_open) - if(istype(I, /obj/item/weapon/crowbar)) - if(beaker) - beaker.loc = loc - beaker = null - default_deconstruction_crowbar(I) - return 1 + if(default_deconstruction_crowbar(I)) + return + return ..() + +/obj/machinery/chem_dispenser/constructable/deconstruction() + if(beaker) + beaker.loc = loc + beaker = null /obj/machinery/chem_dispenser/drinks name = "soda dispenser" @@ -296,20 +297,6 @@ "lemonjuice" ) -/obj/machinery/chem_dispenser/drinks/attackby(obj/item/I, mob/user) - if(default_unfasten_wrench(user, I)) - return - - if(istype(I, /obj/item/weapon/reagent_containers) && (I.flags & OPENCONTAINER)) - if (beaker) - return 1 - else - if(!user.drop_item()) - return 1 - src.beaker = I - beaker.loc = src - update_icon() - return /obj/machinery/chem_dispenser/drinks/beer name = "booze dispenser" diff --git a/code/modules/reagents/chemistry/machinery/chem_heater.dm b/code/modules/reagents/chemistry/machinery/chem_heater.dm index 092953d1243..edd2c9dd055 100644 --- a/code/modules/reagents/chemistry/machinery/chem_heater.dm +++ b/code/modules/reagents/chemistry/machinery/chem_heater.dm @@ -39,10 +39,17 @@ beaker.reagents.handle_reactions() /obj/machinery/chem_heater/attackby(obj/item/I, mob/user, params) - if(isrobot(user)) + if(default_deconstruction_screwdriver(user, "mixer0b", "mixer0b", I)) + return + + if(exchange_parts(user, I)) + return + + if(default_deconstruction_crowbar(I)) return if(istype(I, /obj/item/weapon/reagent_containers) && (I.flags & OPENCONTAINER)) + . = 1 //no afterattack if(beaker) user << "A beaker is already loaded into the machine!" return @@ -53,18 +60,11 @@ I.loc = src user << "You add the beaker to the machine." icon_state = "mixer1b" - - if(default_deconstruction_screwdriver(user, "mixer0b", "mixer0b", I)) return + return ..() - if(exchange_parts(user, I)) - return - - if(panel_open) - if(istype(I, /obj/item/weapon/crowbar)) - eject_beaker() - default_deconstruction_crowbar(I) - return 1 +/obj/machinery/chem_heater/deconstruction() + eject_beaker() /obj/machinery/chem_heater/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, \ datum/tgui/master_ui = null, datum/ui_state/state = default_state) diff --git a/code/modules/reagents/chemistry/machinery/chem_master.dm b/code/modules/reagents/chemistry/machinery/chem_master.dm index 9d6337baf4a..3343bee85cd 100644 --- a/code/modules/reagents/chemistry/machinery/chem_master.dm +++ b/code/modules/reagents/chemistry/machinery/chem_master.dm @@ -37,10 +37,12 @@ return if(istype(I, /obj/item/weapon/reagent_containers) && (I.flags & OPENCONTAINER)) - if(isrobot(user)) + . = 1 // no afterattack + if(panel_open) + user << "You can't use the [src.name] while its panel is opened!" return if(beaker) - user << "A beaker is already loaded into the machine!" + user << "A container is already loaded in the machine!" return if(!user.drop_item()) return @@ -62,8 +64,8 @@ bottle.loc = src user << "You add the pill bottle into the dispenser slot." src.updateUsrDialog() - - return + else + return ..() /obj/machinery/chem_master/Topic(href, href_list) if(..()) @@ -341,7 +343,6 @@ component_parts += new /obj/item/weapon/reagent_containers/glass/beaker(null) /obj/machinery/chem_master/constructable/attackby(obj/item/B, mob/user, params) - if(default_deconstruction_screwdriver(user, "mixer0_nopower", "mixer0", B)) if(beaker) beaker.loc = src.loc @@ -352,40 +353,9 @@ bottle = null return - if(exchange_parts(user, B)) + else if(exchange_parts(user, B)) return - - if(panel_open) - if(istype(B, /obj/item/weapon/crowbar)) - default_deconstruction_crowbar(B) - return 1 - else - user << "You can't use the [src.name] while it's panel is opened!" - return 1 - - if(istype(B, /obj/item/weapon/reagent_containers) && (B.flags & OPENCONTAINER)) - if(beaker) - user << "A beaker is already loaded into the machine!" - return - if(!user.drop_item()) - return - - beaker = B - beaker.loc = src - user << "You add the beaker to the machine." - src.updateUsrDialog() - icon_state = "mixer1" - - else if(!condi && istype(B, /obj/item/weapon/storage/pill_bottle)) - if(bottle) - user << "A pill bottle is already loaded into the machine!" - return - if(!user.drop_item()) - return - - src.bottle = B - B.loc = src - user << "You add the pill bottle into the dispenser slot." - src.updateUsrDialog() - - return + else if(default_deconstruction_crowbar(B)) + return + else + return ..() \ No newline at end of file diff --git a/code/modules/recycling/conveyor2.dm b/code/modules/recycling/conveyor2.dm index 2e12d38cbf6..c15e48ea344 100644 --- a/code/modules/recycling/conveyor2.dm +++ b/code/modules/recycling/conveyor2.dm @@ -122,22 +122,19 @@ transfer_fingerprints_to(C) user << "You remove the conveyor belt." qdel(src) - return - if(istype(I, /obj/item/weapon/wrench)) + + else if(istype(I, /obj/item/weapon/wrench)) if(!(stat & BROKEN)) playsound(loc, 'sound/items/Ratchet.ogg', 50, 1) dir = turn(dir,-45) update_move_direction() user << "You rotate [src]." - return - if(isrobot(user)) - return //Carn: fix for borgs dropping their modules on conveyor belts - if(!user.drop_item()) - user << "\The [I] is stuck to your hand, you cannot place it on the conveyor!" - return - if(I && I.loc) - I.loc = src.loc - return + + else if(user.a_intent != "harm") + if(user.drop_item()) + I.loc = src.loc + else + return ..() // attack with hand, move pulled object onto conveyor /obj/machinery/conveyor/attack_hand(mob/user) diff --git a/code/modules/recycling/disposal-construction.dm b/code/modules/recycling/disposal-construction.dm index 74e52fc92c8..dd7ae2b0f36 100644 --- a/code/modules/recycling/disposal-construction.dm +++ b/code/modules/recycling/disposal-construction.dm @@ -27,7 +27,7 @@ dir = direction // update iconstate and dpdir due to dir and type -/obj/structure/disposalconstruct/proc/update() +/obj/structure/disposalconstruct/update_icon() var/flip = turn(dir, 180) var/left = turn(dir, 90) var/right = turn(dir, -90) @@ -87,7 +87,7 @@ // change visibility status and force update of icon /obj/structure/disposalconstruct/hide(var/intact) invisibility = (intact && level==1) ? 101: 0 // hide if floor is intact - update() + update_icon() // flip and rotate verbs @@ -104,7 +104,7 @@ return dir = turn(dir, -90) - update() + update_icon() /obj/structure/disposalconstruct/AltClick(mob/user) ..() @@ -138,7 +138,7 @@ if(DISP_SORTJUNCTION_FLIP) ptype = DISP_SORTJUNCTION - update() + update_icon() // returns the type path of disposalpipe corresponding to this item dtype /obj/structure/disposalconstruct/proc/dpipetype() @@ -210,7 +210,7 @@ return else if(CP) - update() + update_icon() var/pdir = CP.dpdir if(istype(CP, /obj/structure/disposalpipe/broken)) pdir = CP.dir @@ -223,7 +223,7 @@ density = 0 user << "You attach the [nicetype] to the underfloor." playsound(loc, 'sound/items/Ratchet.ogg', 100, 1) - update() + update_icon() else if(istype(I, /obj/item/weapon/weldingtool)) if(anchored) @@ -235,7 +235,7 @@ if(!loc || !W.isOn()) return user << "The [nicetype] has been welded in place." - update() // TODO: Make this neat + update_icon() // TODO: Make this neat if(ispipe) var/pipetype = dpipetype() diff --git a/code/modules/recycling/disposal-structures.dm b/code/modules/recycling/disposal-structures.dm index b13585f9c1d..3f00548adba 100644 --- a/code/modules/recycling/disposal-structures.dm +++ b/code/modules/recycling/disposal-structures.dm @@ -358,24 +358,27 @@ //weldingtool: unfasten and convert to obj/disposalconstruct /obj/structure/disposalpipe/attackby(obj/item/I, mob/user, params) - var/turf/T = src.loc if(T.intact) return // prevent interaction with T-scanner revealed pipes - src.add_fingerprint(user) + add_fingerprint(user) if(istype(I, /obj/item/weapon/weldingtool)) var/obj/item/weapon/weldingtool/W = I + if(can_be_deconstructed(user)) + if(W.remove_fuel(0,user)) + playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) + user << "You start slicing the disposal pipe..." + // check if anything changed over 2 seconds + if(do_after(user,30, target = src)) + if(!src || !W.isOn()) return + Deconstruct() + user << "You slice the disposal pipe." + else + return ..() - if(W.remove_fuel(0,user)) - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - user << "You start slicing the disposal pipe..." - // check if anything changed over 2 seconds - if(do_after(user,30, target = src)) - if(!src || !W.isOn()) return - Deconstruct() - user << "You slice the disposal pipe." - else - return +//checks if something is blocking the deconstruction (e.g. trunk with a bin still linked to it) +/obj/structure/disposalpipe/proc/can_be_deconstructed() + . = 1 // called when pipe is cut with welder /obj/structure/disposalpipe/Deconstruct() @@ -386,7 +389,7 @@ stored.dir = dir stored.density = 0 stored.anchored = 1 - stored.update() + stored.update_icon() ..() /obj/structure/disposalpipe/singularity_pull(S, current_size) @@ -514,9 +517,6 @@ return /obj/structure/disposalpipe/sortjunction/attackby(obj/item/I, mob/user, params) - if(..()) - return - if(istype(I, /obj/item/device/destTagger)) var/obj/item/device/destTagger/O = I @@ -528,6 +528,8 @@ sortTypes |= O.currTag user << "Added \"[TAGGERLOCATIONS[O.currTag]]\" filter." playsound(src.loc, 'sound/machines/twobeep.ogg', 100, 1) + else + return ..() // next direction to move @@ -635,47 +637,11 @@ update() return - // Override attackby so we disallow trunkremoval when somethings ontop -/obj/structure/disposalpipe/trunk/attackby(obj/item/I, mob/user, params) - - //Disposal bins or chutes - /* - These shouldn't be required - var/obj/machinery/disposal/D = locate() in src.loc - if(D && D.anchored) - return - - //Disposal outlet - var/obj/structure/disposaloutlet/O = locate() in src.loc - if(O && O.anchored) - return - */ - - //Disposal constructors - var/obj/structure/disposalconstruct/C = locate() in src.loc - if(C && C.anchored) - return - - var/turf/T = src.loc - if(T.intact) - return // prevent interaction with T-scanner revealed pipes - src.add_fingerprint(user) - if(istype(I, /obj/item/weapon/weldingtool)) - var/obj/item/weapon/weldingtool/W = I - - if(linked) - user << "You need to deconstruct disposal machinery above this pipe!" - return - - if(W.remove_fuel(0,user)) - playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) - user << "You start slicing the disposal pipe..." - if(do_after(user,30/I.toolspeed, target = src)) - if(!src || !W.isOn()) return - Deconstruct() - user << "You slice the disposal pipe." - else - return +/obj/structure/disposalpipe/trunk/can_be_deconstructed(mob/user) + if(linked) + user << "You need to deconstruct disposal machinery above this pipe!" + else + . = 1 // would transfer to next pipe segment, but we are in a trunk // if not entering from disposal bin, @@ -781,20 +747,17 @@ return /obj/structure/disposaloutlet/attackby(obj/item/I, mob/user, params) - if(!I || !user) - return - src.add_fingerprint(user) + add_fingerprint(user) if(istype(I, /obj/item/weapon/screwdriver)) if(mode==0) mode=1 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) var/obj/item/weapon/weldingtool/W = I if(W.remove_fuel(0,user)) @@ -805,13 +768,12 @@ user << "You slice the floorweld off \the [src]." stored.loc = loc src.transfer_fingerprints_to(stored) - stored.update() + stored.update_icon() stored.anchored = 0 stored.density = 1 qdel(src) - return - else - return + else + return ..() diff --git a/code/modules/recycling/disposal-unit.dm b/code/modules/recycling/disposal-unit.dm index d71557e4518..b2296e9c746 100644 --- a/code/modules/recycling/disposal-unit.dm +++ b/code/modules/recycling/disposal-unit.dm @@ -34,7 +34,7 @@ air_contents = new/datum/gas_mixture() //gas.volume = 1.05 * CELLSTANDARD - update() + update_icon() /obj/machinery/disposal/proc/trunk_check() trunk = locate() in src.loc @@ -66,11 +66,8 @@ trunk_check() /obj/machinery/disposal/attackby(obj/item/I, mob/user, params) - if(stat & BROKEN || !I || !user) - return - add_fingerprint(user) - if(mode<=0) // It's off + if(mode<=0) if(istype(I, /obj/item/weapon/screwdriver)) if(contents.len > 0) user << "Eject the items first!" @@ -96,7 +93,21 @@ user << "You slice the floorweld off \the [src]." Deconstruct() return - return 1 + + if(user.a_intent != "harm") + if(!user.drop_item() || (I.flags & ABSTRACT)) + return + place_item_in_disposal(I, user) + update_icon() + return 1 //no afterattack + else + return ..() + +/obj/machinery/disposal/proc/place_item_in_disposal(obj/item/I, mob/user) + I.loc = src + user.visible_message("[user.name] places \the [I] into \the [src].", \ + "You place \the [I] into \the [src].") + // mouse drop another mob or self @@ -133,7 +144,7 @@ "[user] has placed [target] in [src].") add_logs(user, target, "stuffed", addition="into [src]") target.LAssailant = user - update() + update_icon() // can breath normally in the disposal /obj/machinery/disposal/alter_health() @@ -157,7 +168,7 @@ user.loc = src.loc user.reset_perspective(null) - update() + update_icon() return @@ -166,7 +177,7 @@ if(stat & BROKEN) return flush = !flush - update() + update_icon() // ai as human but can't flush /obj/machinery/disposal/attack_ai(mob/user) @@ -198,10 +209,10 @@ for(var/atom/movable/AM in src) AM.forceMove(T) AM.pipe_eject(0) - update() + update_icon() // update the icon & overlays to reflect mode & status -/obj/machinery/disposal/proc/update() +/obj/machinery/disposal/update_icon() return /obj/machinery/disposal/proc/flush() @@ -222,12 +233,6 @@ flushing = 0 flush = 0 -/obj/machinery/disposal/bin/flush() - ..() - if(mode == 2) - mode = 1 - update() - /obj/machinery/disposal/proc/newHolderDestination(obj/structure/disposalholder/H) for(var/obj/item/smallDelivery/O in src) H.tomail = 1 @@ -239,7 +244,7 @@ // called when area power changes /obj/machinery/disposal/power_change() ..() // do default setting/reset of stat NOPOWER bit - update() // update icon + update_icon() // update icon return @@ -267,7 +272,7 @@ src.transfer_fingerprints_to(stored) stored.anchored = 0 stored.density = 1 - stored.update() + stored.update_icon() ..() //How disposal handles getting a storage dump from a storage object @@ -294,26 +299,15 @@ // attack by item places it in to disposal /obj/machinery/disposal/bin/attackby(obj/item/I, mob/user, params) - if(!..()) - return - if(istype(I, /obj/item/weapon/storage/bag/trash)) var/obj/item/weapon/storage/bag/trash/T = I user << "You empty the bag." for(var/obj/item/O in T.contents) T.remove_from_storage(O,src) T.update_icon() - update() - return - - if(!user.drop_item() || I.flags & ABSTRACT) // Dunno why this wasn't here before? - return - - I.loc = src - user.visible_message("[user.name] places \the [I] into \the [src].", \ - "You place \the [I] into \the [src].") - - update() + update_icon() + else + return ..() // user interaction /obj/machinery/disposal/bin/interact(mob/user, ai=0) @@ -373,11 +367,11 @@ mode = 1 else mode = 0 - update() + update_icon() if(href_list["handle"]) flush = text2num(href_list["handle"]) - update() + update_icon() if(href_list["eject"]) eject() @@ -391,14 +385,20 @@ if(prob(75)) I.loc = src visible_message("\the [I] lands in \the [src].") - update() + update_icon() else visible_message("\the [I] bounces off of \the [src]'s rim!") return 0 else return ..(mover, target, height) -/obj/machinery/disposal/bin/update() +/obj/machinery/disposal/bin/flush() + ..() + if(mode == 2) + mode = 1 + update_icon() + +/obj/machinery/disposal/bin/update_icon() overlays.Cut() if(stat & BROKEN) mode = 0 @@ -473,7 +473,7 @@ // if full enough, switch to ready mode if(air_contents.return_pressure() >= SEND_PRESSURE) mode = 2 - update() + update_icon() return /obj/machinery/disposal/bin/get_remote_view_fullscreens(mob/user) @@ -498,6 +498,11 @@ if(trunk) trunk.linked = src // link the pipe trunk to self +/obj/machinery/disposal/deliveryChute/place_item_in_disposal(obj/item/I, mob/user) + if(I.disposalEnterTry()) + ..() + flush() + /obj/machinery/disposal/deliveryChute/Bumped(atom/movable/AM) //Go straight into the chute if(!AM.disposalEnterTry()) return diff --git a/code/modules/recycling/sortingmachinery.dm b/code/modules/recycling/sortingmachinery.dm index 77e9d350cd3..ec75e1a1d75 100644 --- a/code/modules/recycling/sortingmachinery.dm +++ b/code/modules/recycling/sortingmachinery.dm @@ -44,6 +44,8 @@ icon_state = "gift[icon_state]" else user << "You need more paper!" + else + return ..() /obj/structure/bigDelivery/relay_container_resist(mob/living/user, obj/O) if(istype(loc, /atom/movable)) diff --git a/code/modules/research/circuitprinter.dm b/code/modules/research/circuitprinter.dm index 3b40c550c27..86a65b89bbf 100644 --- a/code/modules/research/circuitprinter.dm +++ b/code/modules/research/circuitprinter.dm @@ -74,71 +74,55 @@ using metal and glass, it uses glass and reagents (usually sulfuric acis). /obj/machinery/r_n_d/circuit_imprinter/proc/TotalMaterials() return g_amount + gold_amount + diamond_amount -/obj/machinery/r_n_d/circuit_imprinter/attackby(obj/item/O, mob/user, params) - if (shocked) - shock(user,50) - if (default_deconstruction_screwdriver(user, "circuit_imprinter_t", "circuit_imprinter", O)) - if(linked_console) - linked_console.linked_imprinter = null - linked_console = null - return +//we drop the minerals in the machine onto the ground when deconstructed. +/obj/machinery/r_n_d/circuit_imprinter/deconstruction() + for(var/obj/item/weapon/reagent_containers/glass/G in component_parts) + reagents.trans_to(G, G.reagents.maximum_volume) + if(g_amount >= MINERAL_MATERIAL_AMOUNT) + var/obj/item/stack/sheet/glass/G = new /obj/item/stack/sheet/glass(src.loc) + G.amount = round(g_amount / MINERAL_MATERIAL_AMOUNT) + if(gold_amount >= MINERAL_MATERIAL_AMOUNT) + var/obj/item/stack/sheet/mineral/gold/G = new /obj/item/stack/sheet/mineral/gold(src.loc) + G.amount = round(gold_amount / MINERAL_MATERIAL_AMOUNT) + if(diamond_amount >= MINERAL_MATERIAL_AMOUNT) + var/obj/item/stack/sheet/mineral/diamond/G = new /obj/item/stack/sheet/mineral/diamond(src.loc) + G.amount = round(diamond_amount / MINERAL_MATERIAL_AMOUNT) + ..() - if(exchange_parts(user, O)) - return +/obj/machinery/r_n_d/circuit_imprinter/Insert_Item(obj/item/O, mob/user) - if (panel_open) - if(istype(O, /obj/item/weapon/crowbar)) - for(var/obj/item/weapon/reagent_containers/glass/G in component_parts) - reagents.trans_to(G, G.reagents.maximum_volume) - if(g_amount >= MINERAL_MATERIAL_AMOUNT) - var/obj/item/stack/sheet/glass/G = new /obj/item/stack/sheet/glass(src.loc) - G.amount = round(g_amount / MINERAL_MATERIAL_AMOUNT) - if(gold_amount >= MINERAL_MATERIAL_AMOUNT) - var/obj/item/stack/sheet/mineral/gold/G = new /obj/item/stack/sheet/mineral/gold(src.loc) - G.amount = round(gold_amount / MINERAL_MATERIAL_AMOUNT) - if(diamond_amount >= MINERAL_MATERIAL_AMOUNT) - var/obj/item/stack/sheet/mineral/diamond/G = new /obj/item/stack/sheet/mineral/diamond(src.loc) - G.amount = round(diamond_amount / MINERAL_MATERIAL_AMOUNT) - default_deconstruction_crowbar(O) - return - else - user << "You can't load the [src.name] while it's opened!" - return - if (disabled) - return - if (!linked_console) - user << "The [name] must be linked to an R&D console first!" + if (O.is_open_container()) //inserting reagents into the machine return 1 - if (O.is_open_container()) - return - if (!istype(O, /obj/item/stack/sheet/glass) && !istype(O, /obj/item/stack/sheet/mineral/gold) && !istype(O, /obj/item/stack/sheet/mineral/diamond)) + + if (istype(O, /obj/item/stack/sheet/glass) || istype(O, /obj/item/stack/sheet/mineral/gold) || istype(O, /obj/item/stack/sheet/mineral/diamond)) + . = 1 + if(!is_insertion_ready(user)) + return + var/obj/item/stack/sheet/stack = O + if ((TotalMaterials() + stack.perunit) > max_material_amount) + user << "The [name] is full! Please remove glass from the protolathe in order to insert more." + return + + var/amount = round(input("How many sheets do you want to add?") as num) + if(amount <= 0 || stack.amount <= 0) + return + if(amount > stack.amount) + amount = min(stack.amount, round((max_material_amount-TotalMaterials())/stack.perunit)) + + busy = 1 + use_power(max(1000, (MINERAL_MATERIAL_AMOUNT*amount/10))) + user << "You add [amount] sheets to the [src.name]." + if(istype(stack, /obj/item/stack/sheet/glass)) + g_amount += amount * MINERAL_MATERIAL_AMOUNT + else if(istype(stack, /obj/item/stack/sheet/mineral/gold)) + gold_amount += amount * MINERAL_MATERIAL_AMOUNT + else if(istype(stack, /obj/item/stack/sheet/mineral/diamond)) + diamond_amount += amount * MINERAL_MATERIAL_AMOUNT + stack.use(amount) + busy = 0 + src.updateUsrDialog() + + else if(user.a_intent != "harm") user << "You cannot insert this item into the [name]!" - return - if (stat) - return - if (busy) - user << "The [name] is busy! Please wait for completion of previous operation." - return - var/obj/item/stack/sheet/stack = O - if ((TotalMaterials() + stack.perunit) > max_material_amount) - user << "The [name] is full! Please remove glass from the protolathe in order to insert more." - return - - var/amount = round(input("How many sheets do you want to add?") as num) - if(amount <= 0 || stack.amount <= 0) - return - if(amount > stack.amount) - amount = min(stack.amount, round((max_material_amount-TotalMaterials())/stack.perunit)) - - busy = 1 - use_power(max(1000, (MINERAL_MATERIAL_AMOUNT*amount/10))) - user << "You add [amount] sheets to the [src.name]." - if(istype(stack, /obj/item/stack/sheet/glass)) - g_amount += amount * MINERAL_MATERIAL_AMOUNT - else if(istype(stack, /obj/item/stack/sheet/mineral/gold)) - gold_amount += amount * MINERAL_MATERIAL_AMOUNT - else if(istype(stack, /obj/item/stack/sheet/mineral/diamond)) - diamond_amount += amount * MINERAL_MATERIAL_AMOUNT - stack.use(amount) - busy = 0 - src.updateUsrDialog() + else + return 0 \ No newline at end of file diff --git a/code/modules/research/destructive_analyzer.dm b/code/modules/research/destructive_analyzer.dm index 6fef356857b..76a65f9015d 100644 --- a/code/modules/research/destructive_analyzer.dm +++ b/code/modules/research/destructive_analyzer.dm @@ -11,7 +11,6 @@ Note: Must be placed within 3 tiles of the R&D Console name = "Destructive Analyzer" desc = "Learn science by destroying things!" icon_state = "d_analyzer" - var/obj/item/weapon/loaded_item = null var/decon_mod = 0 /obj/machinery/r_n_d/destructive_analyzer/New() @@ -36,30 +35,11 @@ Note: Must be placed within 3 tiles of the R&D Console temp_list[O] = text2num(temp_list[O]) return temp_list - -/obj/machinery/r_n_d/destructive_analyzer/attackby(obj/item/O, mob/user, params) - if (shocked) - shock(user,50) - if (default_deconstruction_screwdriver(user, "d_analyzer_t", "d_analyzer", O)) - if(linked_console) - linked_console.linked_destroy = null - linked_console = null - return - - if(exchange_parts(user, O)) - return - - default_deconstruction_crowbar(O) - - if (disabled) - return - if (!linked_console) - user << "The [src.name] must be linked to an R&D console first!" - return - if (busy) - user << "The [src.name] is busy right now." - return - if (istype(O, /obj/item) && !loaded_item) +/obj/machinery/r_n_d/destructive_analyzer/Insert_Item(obj/item/O, mob/user) + if(user.a_intent != "harm") + . = 1 + if(!is_insertion_ready(user)) + return if(!O.origin_tech) user << "This doesn't seem to have a tech origin!" return @@ -75,7 +55,4 @@ Note: Must be placed within 3 tiles of the R&D Console O.loc = src user << "You add the [O.name] to the [src.name]!" flick("d_analyzer_la", src) - spawn(10) - icon_state = "d_analyzer_l" - busy = 0 - return + diff --git a/code/modules/research/experimentor.dm b/code/modules/research/experimentor.dm index d37f8715f1f..7ae08a0338b 100644 --- a/code/modules/research/experimentor.dm +++ b/code/modules/research/experimentor.dm @@ -25,7 +25,6 @@ var/recentlyExperimented = 0 var/mob/trackedIan var/mob/trackedRuntime - var/obj/item/loaded_item = null var/badThingCoeff = 0 var/resetTime = 15 var/cloneMode = FALSE @@ -111,36 +110,14 @@ return FALSE return TRUE -/obj/machinery/r_n_d/experimentor/attackby(obj/item/O, mob/user, params) - if (shocked) - shock(user,50) - - if (default_deconstruction_screwdriver(user, "h_lathe_maint", "h_lathe", O)) - if(linked_console) - linked_console.linked_destroy = null - linked_console = null - return - - if(exchange_parts(user, O)) - return - - if(panel_open && istype(O, /obj/item/weapon/crowbar)) - default_deconstruction_crowbar(O) - return - - if(!checkCircumstances(O)) - user << "The [O] is not yet valid for the [src] and must be completed!" - return - - if (disabled) - return - if (!linked_console) - user << "The [src] must be linked to an R&D console first!" - return - if (loaded_item) - user << "The [src] is already loaded." - return - if (istype(O, /obj/item)) +/obj/machinery/r_n_d/experimentor/Insert_Item(obj/item/O, mob/user) + if(user.a_intent != "harm") + . = 1 + if(!is_insertion_ready(user)) + return + if(!checkCircumstances(O)) + user << "The [O] is not yet valid for the [src] and must be completed!" + return if(!O.origin_tech) user << "This doesn't seem to have a tech origin!" return @@ -158,7 +135,7 @@ user << "You add the [O.name] to the machine." flick("h_lathe_load", src) - return + /obj/machinery/r_n_d/experimentor/default_deconstruction_crowbar(obj/item/O) ejectItem() @@ -640,7 +617,7 @@ spawn(cooldownMax) cooldown = FALSE else - user << "You aren't quite sure what to do with this yet." + user << "You aren't quite sure what to do with this, yet." //////////////// RELIC PROCS ///////////////////////////// diff --git a/code/modules/research/protolathe.dm b/code/modules/research/protolathe.dm index 0d390b517de..428ee5947a4 100644 --- a/code/modules/research/protolathe.dm +++ b/code/modules/research/protolathe.dm @@ -72,61 +72,45 @@ Note: Must be placed west/left of and R&D console to function. A = A / max(1, (being_built.materials[M])) return A -/obj/machinery/r_n_d/protolathe/attackby(obj/item/O, mob/user, params) - if (shocked) - shock(user,50) - if (default_deconstruction_screwdriver(user, "protolathe_t", "protolathe", O)) - if(linked_console) - linked_console.linked_lathe = null - linked_console = null - return +//we eject the materials upon deconstruction. +/obj/machinery/r_n_d/protolathe/deconstruction() + for(var/obj/item/weapon/reagent_containers/glass/G in component_parts) + reagents.trans_to(G, G.reagents.maximum_volume) + materials.retrieve_all() + ..() - if(exchange_parts(user, O)) - return +/obj/machinery/r_n_d/protolathe/Insert_Item(obj/item/O, mob/user) - if (panel_open) - if(istype(O, /obj/item/weapon/crowbar)) - for(var/obj/item/weapon/reagent_containers/glass/G in component_parts) - reagents.trans_to(G, G.reagents.maximum_volume) - materials.retrieve_all() - default_deconstruction_crowbar(O) + if(O.is_open_container()) //inserting reagents into the machine + return 1 + + if(istype(O,/obj/item/stack/sheet)) + . = 1 + if(!is_insertion_ready(user)) + return + if(!materials.has_space( materials.get_item_material_amount(O) )) + user << "The [src.name]'s material bin is full! Please remove material before adding more." + return 1 + + var/obj/item/stack/sheet/stack = O + var/amount = round(input("How many sheets do you want to add?") as num)//No decimals + if(!in_range(src, stack) || !user.Adjacent(src)) + return + var/amount_inserted = materials.insert_stack(O,amount) + if(!amount_inserted) return 1 else - user << "You can't load the [src.name] while it's opened!" - return 1 - if (disabled) - return - if (!linked_console) - user << "The [src.name] must be linked to an R&D console first!" - return 1 - if (busy) - user << "The [src.name] is busy! Please wait for completion of previous operation." - return 1 - if (O.is_open_container()) - return - if (stat) - return 1 - if(!istype(O,/obj/item/stack/sheet)) - return 1 + var/stack_name = stack.name + busy = 1 + use_power(max(1000, (MINERAL_MATERIAL_AMOUNT*amount_inserted/10))) + user << "You add [amount_inserted] sheets to the [src.name]." + overlays += "protolathe_[stack_name]" + sleep(10) + overlays -= "protolathe_[stack_name]" + busy = 0 + updateUsrDialog() - if(!materials.has_space( materials.get_item_material_amount(O) )) - user << "The [src.name]'s material bin is full! Please remove material before adding more." - return 1 - - var/obj/item/stack/sheet/stack = O - var/amount = round(input("How many sheets do you want to add?") as num)//No decimals - if(!in_range(src, stack) || !user.Adjacent(src)) - return - var/amount_inserted = materials.insert_stack(O,amount) - if(!amount_inserted) - return 1 + else if(user.a_intent != "harm") + user << "You cannot insert this item into the [name]!" else - var/stack_name = stack.name - busy = 1 - use_power(max(1000, (MINERAL_MATERIAL_AMOUNT*amount_inserted/10))) - user << "You add [amount_inserted] sheets to the [src.name]." - overlays += "protolathe_[stack_name]" - sleep(10) - overlays -= "protolathe_[stack_name]" - busy = 0 - updateUsrDialog() + return 0 \ No newline at end of file diff --git a/code/modules/research/rdmachines.dm b/code/modules/research/rdmachines.dm index db4337bf670..7fb6e811822 100644 --- a/code/modules/research/rdmachines.dm +++ b/code/modules/research/rdmachines.dm @@ -14,6 +14,7 @@ var/disabled = 0 var/shocked = 0 var/obj/machinery/computer/rdconsole/linked_console + var/obj/item/loaded_item = null //the item loaded inside the machine (currently only used by experimentor and destructive analyzer) /obj/machinery/r_n_d/New() ..() @@ -39,9 +40,62 @@ /obj/machinery/r_n_d/attack_hand(mob/user) if(shocked) - shock(user,50) + if(shock(user,50)) + return if(panel_open) wires.interact(user) +/obj/machinery/r_n_d/attackby(obj/item/O, mob/user, params) + if (shocked) + if(shock(user,50)) + return 1 + if (default_deconstruction_screwdriver(user, "[initial(icon_state)]_t", initial(icon_state), O)) + if(linked_console) + linked_console.linked_lathe = null + linked_console = null + return + if(exchange_parts(user, O)) + return + if(default_deconstruction_crowbar(O)) + return + if(Insert_Item(O, user)) + return 1 + else + return ..() + +//proc used to handle inserting items or reagents into r_n_d machines +/obj/machinery/r_n_d/proc/Insert_Item(obj/item/I, mob/user) + return + +//whether the machine can have an item inserted in its current state. +/obj/machinery/r_n_d/proc/is_insertion_ready(mob/user) + if(panel_open) + user << "You can't load the [src.name] while it's opened!" + return + if (disabled) + return + if (!linked_console) + user << "The [name] must be linked to an R&D console first!" + return + if (busy) + user << "The [src.name] is busy right now." + return + if(stat & BROKEN) + user << "The [src.name] is broken." + return + if(stat & NOPOWER) + user << "The [src.name] has no power." + return + if(loaded_item) + user << "The [src] is already loaded." + return + return 1 + + +//we eject the loaded item when deconstructing the machine +/obj/machinery/r_n_d/deconstruction() + if(loaded_item) + loaded_item.loc = loc + ..() \ No newline at end of file diff --git a/code/modules/research/server.dm b/code/modules/research/server.dm index d60c092f25e..9377ac45165 100644 --- a/code/modules/research/server.dm +++ b/code/modules/research/server.dm @@ -124,20 +124,10 @@ env.merge(removed) air_update_turf() -/obj/machinery/r_n_d/server/attackby(obj/item/O, mob/user, params) - if (disabled) - return - if (shocked) - shock(user,50) - if (default_deconstruction_screwdriver(user, "server_o", "server", O)) - return - if(exchange_parts(user, O)) - return - if (panel_open) - if(istype(O, /obj/item/weapon/crowbar)) - griefProtection() - default_deconstruction_crowbar(O) - return 1 +//called when the server is deconstructed. +/obj/machinery/r_n_d/server/deconstruction() + griefProtection() + ..() /obj/machinery/r_n_d/server/attack_hand(mob/user as mob) // I guess only exists to stop ninjas or hell does it even work I dunno. See also ninja gloves. if (disabled) @@ -323,9 +313,8 @@ return /obj/machinery/computer/rdservercontrol/attackby(obj/item/weapon/D, mob/user, params) - ..() + . = ..() src.updateUsrDialog() - return /obj/machinery/computer/rdservercontrol/emag_act(mob/user) if(!emagged) diff --git a/code/modules/shuttle/emergency.dm b/code/modules/shuttle/emergency.dm index 764f3d3fa45..1a12c3eb759 100644 --- a/code/modules/shuttle/emergency.dm +++ b/code/modules/shuttle/emergency.dm @@ -7,46 +7,31 @@ var/list/authorized = list() -/obj/machinery/computer/emergency_shuttle/attackby(obj/item/weapon/card/W, mob/user, params) - if(stat & (BROKEN|NOPOWER)) - return - if(!istype(W, /obj/item/weapon/card)) - return - if(SSshuttle.emergency.mode != SHUTTLE_DOCKED) - return - if(!user) - return - if(SSshuttle.emergency.timeLeft() < 11) - return - if (istype(W, /obj/item/weapon/card/id)||istype(W, /obj/item/device/pda)) - if (istype(W, /obj/item/device/pda)) - var/obj/item/device/pda/pda = W - W = pda.id - if (!W:access) //no access - user << "The access level of [W:registered_name]\'s card is not high enough. " +/obj/machinery/computer/emergency_shuttle/attackby(obj/item/I, mob/user, params) + if(istype(I, /obj/item/weapon/card/id)) + var/obj/item/weapon/card/id/ID = I + if(stat & (BROKEN|NOPOWER)) return - - var/list/cardaccess = W:access - if(!istype(cardaccess, /list) || !cardaccess.len) //no access - user << "The access level of [W:registered_name]\'s card is not high enough. " + if(SSshuttle.emergency.mode != SHUTTLE_DOCKED) + return + if(SSshuttle.emergency.timeLeft() < 11) + return + if(!(access_heads in ID.access)) //doesn't have this access + user << "The access level of [ID.registered_name]\'s card is not high enough. " return - - if(!(access_heads in W:access)) //doesn't have this access - user << "The access level of [W:registered_name]\'s card is not high enough. " - return 0 var/choice = alert(user, text("Would you like to (un)authorize a shortened launch time? [] authorization\s are still needed. Use abort to cancel all authorizations.", src.auth_need - src.authorized.len), "Shuttle Launch", "Authorize", "Repeal", "Abort") - if(SSshuttle.emergency.mode != SHUTTLE_DOCKED || user.get_active_hand() != W) - return 0 + if(SSshuttle.emergency.mode != SHUTTLE_DOCKED || user.get_active_hand() != ID) + return var/seconds = SSshuttle.emergency.timeLeft() if(seconds <= 10) - return 0 + return switch(choice) if("Authorize") - if(!authorized.Find(W:registered_name)) - authorized += W:registered_name + if(!authorized.Find(ID.registered_name)) + authorized += ID.registered_name if(auth_need - authorized.len > 0) message_admins("[key_name_admin(user.client)](?) (FLW) has authorized early shuttle launch ",0,1) log_game("[key_name(user)] has authorized early shuttle launch in ([x],[y],[z])") @@ -58,13 +43,15 @@ SSshuttle.emergency.setTimer(100) if("Repeal") - if(authorized.Remove(W:registered_name)) + if(authorized.Remove(ID.registered_name)) minor_announce("[auth_need - authorized.len] authorizations needed until shuttle is launched early") if("Abort") if(authorized.len) minor_announce("All authorizations to launch the shuttle early have been revoked.") authorized.Cut() + else + return ..() /obj/machinery/computer/emergency_shuttle/emag_act(mob/user) if(!emagged && SSshuttle.emergency.mode == SHUTTLE_DOCKED) diff --git a/code/modules/telesci/telepad.dm b/code/modules/telesci/telepad.dm index 45d0a39adf9..8e640ed006d 100644 --- a/code/modules/telesci/telepad.dm +++ b/code/modules/telesci/telepad.dm @@ -40,7 +40,10 @@ if(exchange_parts(user, I)) return - default_deconstruction_crowbar(I) + if(default_deconstruction_crowbar(I)) + return + + return ..() //CARGO TELEPAD// @@ -64,7 +67,7 @@ else if(!anchored) anchored = 1 user << "\The [src] is now secured." - if(istype(W, /obj/item/weapon/screwdriver)) + else if(istype(W, /obj/item/weapon/screwdriver)) if(stage == 0) playsound(src, 'sound/items/Screwdriver.ogg', 50, 1) user << "You unscrew the telepad's tracking beacon." @@ -73,12 +76,20 @@ playsound(src, 'sound/items/Screwdriver.ogg', 50, 1) user << "You screw in the telepad's tracking beacon." stage = 0 - if(istype(W, /obj/item/weapon/weldingtool) && stage == 1) - playsound(src, 'sound/items/Welder.ogg', 50, 1) - user << "You disassemble the telepad." - new /obj/item/stack/sheet/metal(get_turf(src)) - new /obj/item/stack/sheet/glass(get_turf(src)) - qdel(src) + else if(istype(W, /obj/item/weapon/weldingtool) && stage == 1) + var/obj/item/weapon/weldingtool/WT = W + if(WT.remove_fuel(0,user)) + playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1) + user << "You start disassembling [src]..." + if(do_after(user,20/WT.toolspeed, target = src)) + if(!WT.isOn()) + return + user << "You disassemble [src]." + new /obj/item/stack/sheet/metal(get_turf(src)) + new /obj/item/stack/sheet/glass(get_turf(src)) + qdel(src) + else + return ..() ///TELEPAD CALLER/// /obj/item/device/telepad_beacon diff --git a/icons/obj/machines/research.dmi b/icons/obj/machines/research.dmi index de0b2780af9..741f770f686 100644 Binary files a/icons/obj/machines/research.dmi and b/icons/obj/machines/research.dmi differ