diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index e595cea9333..858436ac8ee 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -855,7 +855,7 @@ About the new airlock wires panel: return src.add_fingerprint(user) - if((istype(C, /obj/item/weapon/weldingtool) && !( src.operating > 0 ) && src.density)) + if(!repairing && (istype(C, /obj/item/weapon/weldingtool) && !( src.operating > 0 ) && src.density)) var/obj/item/weapon/weldingtool/W = C if(W.remove_fuel(0,user)) if(!src.welded) @@ -869,7 +869,7 @@ About the new airlock wires panel: else if(istype(C, /obj/item/weapon/screwdriver)) if (src.p_open) if (stat & BROKEN) - usr << "The airlock control panel is too damaged to be closed!" + usr << "The panel is broken and cannot be closed." else src.p_open = 0 else @@ -884,7 +884,7 @@ About the new airlock wires panel: else if(istype(C, /obj/item/weapon/pai_cable)) // -- TLE var/obj/item/weapon/pai_cable/cable = C cable.plugin(src, user) - else if(istype(C, /obj/item/weapon/crowbar)) + else if(!repairing && istype(C, /obj/item/weapon/crowbar)) var/beingcrowbarred = null if(istype(C, /obj/item/weapon/crowbar) ) beingcrowbarred = 1 //derp, Agouri @@ -1117,7 +1117,7 @@ About the new airlock wires panel: update_icon() /obj/machinery/door/airlock/proc/hasPower() - return ((src.secondsMainPowerLost==0 || src.secondsBackupPowerLost==0) && !(stat & NOPOWER)) + return ((src.secondsMainPowerLost==0 || src.secondsBackupPowerLost==0) && !(stat & NOPOWER|BROKEN)) /obj/machinery/door/airlock/proc/prison_open() src.unlock() diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index bc8719060f4..81b9246dd05 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -2,6 +2,8 @@ #define DOOR_OPEN_LAYER 2.7 //Under all objects if opened. 2.7 due to tables being at 2.6 #define DOOR_CLOSED_LAYER 3.1 //Above most items if closed +#define DOOR_REPAIR_AMOUNT 50 //amount of health regained per stack amount used + /obj/machinery/door name = "Door" desc = "It opens and closes." @@ -27,6 +29,7 @@ var/health var/min_force = 10 //minimum amount of force needed to damage the door with a melee weapon var/hitsound = 'sound/weapons/smash.ogg' //sound door makes when hit with a weapon + var/obj/item/stack/sheet/metal/repairing //Multi-tile doors dir = EAST @@ -147,7 +150,6 @@ tforce = AM:throwforce playsound(src.loc, hitsound, 100, 1) take_damage(tforce) - //..() //Does this really need to be here twice? The parent proc doesn't even do anything yet. - Nodrak return /obj/machinery/door/attack_ai(mob/user as mob) @@ -170,27 +172,69 @@ user = null if(!src.requiresID()) user = null + if(istype(I, /obj/item/stack/sheet/metal)) if(stat & BROKEN) - user << "\blue [src.name] is damaged beyond repair and must be reconstructed!" + user << "It looks like \the [src] is pretty busted. It's going to need more than just patching up now." return if(health >= maxhealth) - user << "\blue Nothing to fix!" + user << "Nothing to fix!" return + if(!density) + user << "\The [src] must be closed before you can repair it." + return + + //figure out how much metal we need + var/amount_needed = (maxhealth - health) / DOOR_REPAIR_AMOUNT + amount_needed = (round(amount_needed) == amount_needed)? amount_needed : round(amount_needed) + 1 //Why does BYOND not have a ceiling proc? + var/obj/item/stack/sheet/metal/metalstack = I - var/health_per_sheet = 50 - var/initialhealth = health - src.health = min(maxhealth, health + 100, health + (metalstack.amount * health_per_sheet)) - user.visible_message("\The [user] patches some dents on \the [src] with \the [metalstack].") - metalstack.use(round((health - initialhealth)/health_per_sheet)) + var/transfer + if (repairing) + transfer = metalstack.transfer_to(repairing, amount_needed - repairing.amount) + if (!transfer) + user << "You must weld or remove \the [repairing] from \the [src] before you can add anything else." + else + repairing = metalstack.split(amount_needed) + if (repairing) + repairing.loc = src + transfer = repairing.amount + + if (transfer) + user << "You fit [transfer] [metalstack.singular_name]\s to damaged and broken parts on \the [src]." + return - if(src.density && ((operable() && istype(I, /obj/item/weapon/card/emag)) || istype(I, /obj/item/weapon/melee/energy/blade))) + if(repairing && istype(I, /obj/item/weapon/weldingtool)) + if(!density) + user << "\The [src] must be closed before you can repair it." + return + + var/obj/item/weapon/weldingtool/welder = I + if(welder.remove_fuel(0,user)) + user << "You start to fix dents and weld \the [repairing] into place." + playsound(src, 'sound/items/Welder.ogg', 100, 1) + if(do_after(user, 5 * repairing.amount) && welder && welder.isOn()) + user << "You finish repairing the damage to \the [src]." + health = between(health, health + repairing.amount*DOOR_REPAIR_AMOUNT, maxhealth) + update_icon() + del(repairing) + return + + if(repairing && istype(I, /obj/item/weapon/crowbar)) + user << "You remove \the [repairing]." + playsound(src.loc, 'sound/items/Crowbar.ogg', 100, 1) + repairing.loc = user.loc + repairing = null + return + + if(src.density && (operable() && istype(I, /obj/item/weapon/card/emag))) flick("door_spark", src) sleep(6) open() operating = -1 return 1 + //psa to whoever coded this, there are plenty of objects that need to call attack() on doors without bludgeoning them. if(src.density && istype(I, /obj/item/weapon) && user.a_intent == "hurt" && !istype(I, /obj/item/weapon/card)) var/obj/item/weapon/W = I @@ -198,16 +242,18 @@ if(W.force < min_force) user.visible_message("\red \The [user] hits \the [src] with \the [W] with no visible effect." ) else - user.visible_message("\red \The [user] forcefully slams \the [src] with \the [W]!" ) + user.visible_message("\red \The [user] forcefully strikes \the [src] with \the [W]!" ) playsound(src.loc, hitsound, 100, 1) take_damage(W.force) return + if(src.allowed(user) && operable()) if(src.density) open() else close() return + if(src.density && !(stat & (NOPOWER|BROKEN))) flick("door_deny", src) return diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 68ee7bf335c..483caf07e87 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -220,8 +220,12 @@ var/transfer = max(min(tamount, src.amount, initial(max_amount)), 0) + var/orig_amount = src.amount if (transfer && src.use(transfer)) - return new src.type(loc, transfer) + var/obj/item/stack/newstack = new src.type(loc, transfer) + if (prob(transfer/orig_amount * 100)) + newstack.copy_evidences(src) + return newstack return null /obj/item/stack/proc/get_amount()