Adjusts door repair to use a welding tool

This commit is contained in:
mwerezak
2014-12-25 14:28:42 -05:00
parent f297f7cd0a
commit 07debf9405
3 changed files with 65 additions and 15 deletions

View File

@@ -855,7 +855,7 @@ About the new airlock wires panel:
return return
src.add_fingerprint(user) 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 var/obj/item/weapon/weldingtool/W = C
if(W.remove_fuel(0,user)) if(W.remove_fuel(0,user))
if(!src.welded) if(!src.welded)
@@ -869,7 +869,7 @@ About the new airlock wires panel:
else if(istype(C, /obj/item/weapon/screwdriver)) else if(istype(C, /obj/item/weapon/screwdriver))
if (src.p_open) if (src.p_open)
if (stat & BROKEN) if (stat & BROKEN)
usr << "The airlock control panel is too damaged to be closed!" usr << "<span class='warning'>The panel is broken and cannot be closed.</span>"
else else
src.p_open = 0 src.p_open = 0
else else
@@ -884,7 +884,7 @@ About the new airlock wires panel:
else if(istype(C, /obj/item/weapon/pai_cable)) // -- TLE else if(istype(C, /obj/item/weapon/pai_cable)) // -- TLE
var/obj/item/weapon/pai_cable/cable = C var/obj/item/weapon/pai_cable/cable = C
cable.plugin(src, user) cable.plugin(src, user)
else if(istype(C, /obj/item/weapon/crowbar)) else if(!repairing && istype(C, /obj/item/weapon/crowbar))
var/beingcrowbarred = null var/beingcrowbarred = null
if(istype(C, /obj/item/weapon/crowbar) ) if(istype(C, /obj/item/weapon/crowbar) )
beingcrowbarred = 1 //derp, Agouri beingcrowbarred = 1 //derp, Agouri
@@ -1117,7 +1117,7 @@ About the new airlock wires panel:
update_icon() update_icon()
/obj/machinery/door/airlock/proc/hasPower() /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() /obj/machinery/door/airlock/proc/prison_open()
src.unlock() src.unlock()

View File

@@ -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_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_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 /obj/machinery/door
name = "Door" name = "Door"
desc = "It opens and closes." desc = "It opens and closes."
@@ -27,6 +29,7 @@
var/health var/health
var/min_force = 10 //minimum amount of force needed to damage the door with a melee weapon 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/hitsound = 'sound/weapons/smash.ogg' //sound door makes when hit with a weapon
var/obj/item/stack/sheet/metal/repairing
//Multi-tile doors //Multi-tile doors
dir = EAST dir = EAST
@@ -147,7 +150,6 @@
tforce = AM:throwforce tforce = AM:throwforce
playsound(src.loc, hitsound, 100, 1) playsound(src.loc, hitsound, 100, 1)
take_damage(tforce) take_damage(tforce)
//..() //Does this really need to be here twice? The parent proc doesn't even do anything yet. - Nodrak
return return
/obj/machinery/door/attack_ai(mob/user as mob) /obj/machinery/door/attack_ai(mob/user as mob)
@@ -170,27 +172,69 @@
user = null user = null
if(!src.requiresID()) if(!src.requiresID())
user = null user = null
if(istype(I, /obj/item/stack/sheet/metal)) if(istype(I, /obj/item/stack/sheet/metal))
if(stat & BROKEN) if(stat & BROKEN)
user << "\blue [src.name] is damaged beyond repair and must be reconstructed!" user << "<span class='notice'>It looks like \the [src] is pretty busted. It's going to need more than just patching up now.</span>"
return return
if(health >= maxhealth) if(health >= maxhealth)
user << "\blue Nothing to fix!" user << "<span class='notice'>Nothing to fix!</span>"
return return
if(!density)
user << "<span class='warning'>\The [src] must be closed before you can repair it.</span>"
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/obj/item/stack/sheet/metal/metalstack = I
var/health_per_sheet = 50 var/transfer
var/initialhealth = health if (repairing)
src.health = min(maxhealth, health + 100, health + (metalstack.amount * health_per_sheet)) transfer = metalstack.transfer_to(repairing, amount_needed - repairing.amount)
user.visible_message("\The [user] patches some dents on \the [src] with \the [metalstack].") if (!transfer)
metalstack.use(round((health - initialhealth)/health_per_sheet)) user << "<span class='warning'>You must weld or remove \the [repairing] from \the [src] before you can add anything else.</span>"
else
repairing = metalstack.split(amount_needed)
if (repairing)
repairing.loc = src
transfer = repairing.amount
if (transfer)
user << "<span class='notice'>You fit [transfer] [metalstack.singular_name]\s to damaged and broken parts on \the [src].</span>"
return 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 << "<span class='warning'>\The [src] must be closed before you can repair it.</span>"
return
var/obj/item/weapon/weldingtool/welder = I
if(welder.remove_fuel(0,user))
user << "<span class='notice'>You start to fix dents and weld \the [repairing] into place.</span>"
playsound(src, 'sound/items/Welder.ogg', 100, 1)
if(do_after(user, 5 * repairing.amount) && welder && welder.isOn())
user << "<span class='notice'>You finish repairing the damage to \the [src].</span>"
health = between(health, health + repairing.amount*DOOR_REPAIR_AMOUNT, maxhealth)
update_icon()
del(repairing)
return
if(repairing && istype(I, /obj/item/weapon/crowbar))
user << "<span class='notice'>You remove \the [repairing].</span>"
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) flick("door_spark", src)
sleep(6) sleep(6)
open() open()
operating = -1 operating = -1
return 1 return 1
//psa to whoever coded this, there are plenty of objects that need to call attack() on doors without bludgeoning them. //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)) if(src.density && istype(I, /obj/item/weapon) && user.a_intent == "hurt" && !istype(I, /obj/item/weapon/card))
var/obj/item/weapon/W = I var/obj/item/weapon/W = I
@@ -198,16 +242,18 @@
if(W.force < min_force) if(W.force < min_force)
user.visible_message("\red <B>\The [user] hits \the [src] with \the [W] with no visible effect.</B>" ) user.visible_message("\red <B>\The [user] hits \the [src] with \the [W] with no visible effect.</B>" )
else else
user.visible_message("\red <B>\The [user] forcefully slams \the [src] with \the [W]!</B>" ) user.visible_message("\red <B>\The [user] forcefully strikes \the [src] with \the [W]!</B>" )
playsound(src.loc, hitsound, 100, 1) playsound(src.loc, hitsound, 100, 1)
take_damage(W.force) take_damage(W.force)
return return
if(src.allowed(user) && operable()) if(src.allowed(user) && operable())
if(src.density) if(src.density)
open() open()
else else
close() close()
return return
if(src.density && !(stat & (NOPOWER|BROKEN))) if(src.density && !(stat & (NOPOWER|BROKEN)))
flick("door_deny", src) flick("door_deny", src)
return return

View File

@@ -220,8 +220,12 @@
var/transfer = max(min(tamount, src.amount, initial(max_amount)), 0) var/transfer = max(min(tamount, src.amount, initial(max_amount)), 0)
var/orig_amount = src.amount
if (transfer && src.use(transfer)) 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 return null
/obj/item/stack/proc/get_amount() /obj/item/stack/proc/get_amount()