Misc windoor/airlock fixes

This started as me making robots able to rename windoors and turned into something a little more.
This commit is contained in:
Nerezza
2016-11-19 20:49:48 -06:00
parent a0448aed34
commit df5906dc6b
5 changed files with 166 additions and 120 deletions
+25 -20
View File
@@ -138,14 +138,19 @@
bound_width = world.icon_size
bound_height = width * world.icon_size
/obj/structure/door_assembly/proc/rename_door(mob/living/user)
var/t = sanitizeSafe(input(user, "Enter the name for the windoor.", src.name, src.created_name), MAX_NAME_LEN)
if(!in_range(src, user) && src.loc != user) return
created_name = t
update_state()
/obj/structure/door_assembly/attack_robot(mob/living/user)
if(Adjacent(user))
rename_door(user)
/obj/structure/door_assembly/attackby(obj/item/W as obj, mob/user as mob)
if(istype(W, /obj/item/weapon/pen))
var/t = sanitizeSafe(input(user, "Enter the name for the door.", src.name, src.created_name), MAX_NAME_LEN)
if(!t) return
if(!in_range(src, usr) && src.loc != usr) return
created_name = t
rename_door(user)
return
if(istype(W, /obj/item/weapon/weldingtool) && ( (istext(glass)) || (glass == 1) || (!anchored) ))
@@ -156,7 +161,7 @@
user.visible_message("[user] welds the [glass] plating off the airlock assembly.", "You start to weld the [glass] plating off the airlock assembly.")
if(do_after(user, 40))
if(!src || !WT.isOn()) return
user << "<span class='notice'>You welded the [glass] plating off!</span>"
to_chat(user, "<span class='notice'>You welded the [glass] plating off!</span>")
var/M = text2path("/obj/item/stack/material/[glass]")
new M(src.loc, 2)
glass = 0
@@ -164,18 +169,18 @@
user.visible_message("[user] welds the glass panel out of the airlock assembly.", "You start to weld the glass panel out of the airlock assembly.")
if(do_after(user, 40))
if(!src || !WT.isOn()) return
user << "<span class='notice'>You welded the glass panel out!</span>"
to_chat(user, "<span class='notice'>You welded the glass panel out!</span>")
new /obj/item/stack/material/glass/reinforced(src.loc)
glass = 0
else if(!anchored)
user.visible_message("[user] dissassembles the airlock assembly.", "You start to dissassemble the airlock assembly.")
if(do_after(user, 40))
if(!src || !WT.isOn()) return
user << "<span class='notice'>You dissasembled the airlock assembly!</span>"
to_chat(user, "<span class='notice'>You dissasembled the airlock assembly!</span>")
new /obj/item/stack/material/steel(src.loc, 4)
qdel (src)
else
user << "<span class='notice'>You need more welding fuel.</span>"
to_chat(user, "<span class='notice'>You need more welding fuel.</span>")
return
else if(istype(W, /obj/item/weapon/wrench) && state == 0)
@@ -187,19 +192,19 @@
if(do_after(user, 40))
if(!src) return
user << "<span class='notice'>You [anchored? "un" : ""]secured the airlock assembly!</span>"
to_chat(user, "<span class='notice'>You [anchored? "un" : ""]secured the airlock assembly!</span>")
anchored = !anchored
else if(istype(W, /obj/item/stack/cable_coil) && state == 0 && anchored)
var/obj/item/stack/cable_coil/C = W
if (C.get_amount() < 1)
user << "<span class='warning'>You need one length of coil to wire the airlock assembly.</span>"
to_chat(user, "<span class='warning'>You need one length of coil to wire the airlock assembly.</span>")
return
user.visible_message("[user] wires the airlock assembly.", "You start to wire the airlock assembly.")
if(do_after(user, 40) && state == 0 && anchored)
if (C.use(1))
src.state = 1
user << "<span class='notice'>You wire the airlock.</span>"
to_chat(user, "<span class='notice'>You wire the airlock.</span>")
else if(istype(W, /obj/item/weapon/wirecutters) && state == 1 )
playsound(src.loc, 'sound/items/Wirecutter.ogg', 100, 1)
@@ -207,7 +212,7 @@
if(do_after(user, 40))
if(!src) return
user << "<span class='notice'>You cut the airlock wires.!</span>"
to_chat(user, "<span class='notice'>You cut the airlock wires.!</span>")
new/obj/item/stack/cable_coil(src.loc, 1)
src.state = 0
@@ -219,14 +224,14 @@
if(!src) return
user.drop_item()
W.loc = src
user << "<span class='notice'>You installed the airlock electronics!</span>"
to_chat(user, "<span class='notice'>You installed the airlock electronics!</span>")
src.state = 2
src.electronics = W
else if(istype(W, /obj/item/weapon/crowbar) && state == 2 )
//This should never happen, but just in case I guess
if (!electronics)
user << "<span class='notice'>There was nothing to remove.</span>"
to_chat(user, "<span class='notice'>There was nothing to remove.</span>")
src.state = 1
return
@@ -235,7 +240,7 @@
if(do_after(user, 40))
if(!src) return
user << "<span class='notice'>You removed the airlock electronics!</span>"
to_chat(user, "<span class='notice'>You removed the airlock electronics!</span>")
src.state = 1
electronics.loc = src.loc
electronics = null
@@ -250,28 +255,28 @@
user.visible_message("[user] adds [S.name] to the airlock assembly.", "You start to install [S.name] into the airlock assembly.")
if(do_after(user, 40) && !glass)
if (S.use(1))
user << "<span class='notice'>You installed reinforced glass windows into the airlock assembly.</span>"
to_chat(user, "<span class='notice'>You installed reinforced glass windows into the airlock assembly.</span>")
glass = 1
else if(material_name)
// Ugly hack, will suffice for now. Need to fix it upstream as well, may rewrite mineral walls. ~Z
if(!(material_name in list("gold", "silver", "diamond", "uranium", "phoron", "sandstone")))
user << "You cannot make an airlock out of that material."
to_chat(user, "You cannot make an airlock out of that material.")
return
if(S.get_amount() >= 2)
playsound(src.loc, 'sound/items/Crowbar.ogg', 100, 1)
user.visible_message("[user] adds [S.name] to the airlock assembly.", "You start to install [S.name] into the airlock assembly.")
if(do_after(user, 40) && !glass)
if (S.use(2))
user << "<span class='notice'>You installed [material_display_name(material_name)] plating into the airlock assembly.</span>"
to_chat(user, "<span class='notice'>You installed [material_display_name(material_name)] plating into the airlock assembly.</span>")
glass = material_name
else if(istype(W, /obj/item/weapon/screwdriver) && state == 2 )
playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1)
user << "<span class='notice'>Now finishing the airlock.</span>"
to_chat(user, "<span class='notice'>Now finishing the airlock.</span>")
if(do_after(user, 40))
if(!src) return
user << "<span class='notice'>You finish the airlock!</span>"
to_chat(user, "<span class='notice'>You finish the airlock!</span>")
var/path
if(istext(glass))
path = text2path("/obj/machinery/door/airlock/[glass]")
@@ -25,6 +25,7 @@ obj/structure/windoor_assembly
var/facing = "l" //Does the windoor open to the left or right?
var/secure = "" //Whether or not this creates a secure windoor
var/state = "01" //How far the door assembly has progressed in terms of sprites
var/step = null //How far the door assembly has progressed in terms of steps
obj/structure/windoor_assembly/secure
name = "secure windoor assembly"
@@ -41,6 +42,7 @@ obj/structure/windoor_assembly/New(Loc, start_dir=NORTH, constructed=0)
set_dir(start_dir)
else //If the user is facing northeast. northwest, southeast, southwest or north, default to north
set_dir(NORTH)
update_state()
update_nearby_tiles(need_rebuild=1)
@@ -69,13 +71,19 @@ obj/structure/windoor_assembly/Destroy()
else
return 1
/obj/structure/windoor_assembly/proc/rename_door(mob/living/user)
var/t = sanitizeSafe(input(user, "Enter the name for the windoor.", src.name, src.created_name), MAX_NAME_LEN)
if(!in_range(src, user) && src.loc != user) return
created_name = t
update_state()
/obj/structure/windoor_assembly/attack_robot(mob/living/user)
if(Adjacent(user))
rename_door(user)
/obj/structure/windoor_assembly/attackby(obj/item/W as obj, mob/user as mob)
if(istype(W, /obj/item/weapon/pen))
var/t = sanitizeSafe(input(user, "Enter the name for the windoor.", src.name, src.created_name), MAX_NAME_LEN)
if(!t) return
if(!in_range(src, usr) && src.loc != usr) return
created_name = t
rename_door(user)
return
switch(state)
@@ -88,14 +96,14 @@ obj/structure/windoor_assembly/Destroy()
if(do_after(user, 40))
if(!src || !WT.isOn()) return
user << "<span class='notice'>You disassembled the windoor assembly!</span>"
to_chat(user,"<span class='notice'>You disassembled the windoor assembly!</span>")
if(secure)
new /obj/item/stack/material/glass/reinforced(get_turf(src), 2)
else
new /obj/item/stack/material/glass(get_turf(src), 2)
qdel(src)
else
user << "<span class='notice'>You need more welding fuel to disassemble the windoor assembly.</span>"
to_chat(user,"<span class='notice'>You need more welding fuel to disassemble the windoor assembly.</span>")
return
//Wrenching an unsecure assembly anchors it in place. Step 4 complete
@@ -105,12 +113,9 @@ obj/structure/windoor_assembly/Destroy()
if(do_after(user, 40))
if(!src) return
user << "<span class='notice'>You've secured the windoor assembly!</span>"
to_chat(user,"<span class='notice'>You've secured the windoor assembly!</span>")
src.anchored = 1
if(src.secure)
src.name = "secure anchored windoor assembly"
else
src.name = "anchored windoor assembly"
step = 0
//Unwrenching an unsecure assembly un-anchors it. Step 4 undone
else if(istype(W, /obj/item/weapon/wrench) && anchored)
@@ -119,12 +124,9 @@ obj/structure/windoor_assembly/Destroy()
if(do_after(user, 40))
if(!src) return
user << "<span class='notice'>You've unsecured the windoor assembly!</span>"
to_chat(user,"<span class='notice'>You've unsecured the windoor assembly!</span>")
src.anchored = 0
if(src.secure)
src.name = "secure windoor assembly"
else
src.name = "windoor assembly"
step = null
//Adding cable to the assembly. Step 5 complete.
else if(istype(W, /obj/item/stack/cable_coil) && anchored)
@@ -133,12 +135,9 @@ obj/structure/windoor_assembly/Destroy()
var/obj/item/stack/cable_coil/CC = W
if(do_after(user, 40))
if (CC.use(1))
user << "<span class='notice'>You wire the windoor!</span>"
to_chat(user,"<span class='notice'>You wire the windoor!</span>")
src.state = "02"
if(src.secure)
src.name = "secure wired windoor assembly"
else
src.name = "wired windoor assembly"
step = 1
else
..()
@@ -152,16 +151,13 @@ obj/structure/windoor_assembly/Destroy()
if(do_after(user, 40))
if(!src) return
user << "<span class='notice'>You cut the windoor wires.!</span>"
to_chat(user,"<span class='notice'>You cut the windoor wires.!</span>")
new/obj/item/stack/cable_coil(get_turf(user), 1)
src.state = "01"
if(src.secure)
src.name = "secure anchored windoor assembly"
else
src.name = "anchored windoor assembly"
step = 0
//Adding airlock electronics for access. Step 6 complete.
else if(istype(W, /obj/item/weapon/airlock_electronics) && W:icon_state != "door_electronics_smoked")
else if(istype(W, /obj/item/weapon/airlock_electronics))
playsound(src.loc, 'sound/items/Screwdriver.ogg', 100, 1)
user.visible_message("[user] installs the electronics into the airlock assembly.", "You start to install electronics into the airlock assembly.")
@@ -170,8 +166,8 @@ obj/structure/windoor_assembly/Destroy()
user.drop_item()
W.loc = src
user << "<span class='notice'>You've installed the airlock electronics!</span>"
src.name = "near finished windoor assembly"
to_chat(user,"<span class='notice'>You've installed the airlock electronics!</span>")
step = 2
src.electronics = W
else
W.loc = src.loc
@@ -183,11 +179,8 @@ obj/structure/windoor_assembly/Destroy()
if(do_after(user, 40))
if(!src || !src.electronics) return
user << "<span class='notice'>You've removed the airlock electronics!</span>"
if(src.secure)
src.name = "secure wired windoor assembly"
else
src.name = "wired windoor assembly"
to_chat(user,"<span class='notice'>You've removed the airlock electronics!</span>")
step = 1
var/obj/item/weapon/airlock_electronics/ae = electronics
electronics = null
ae.loc = src.loc
@@ -195,9 +188,12 @@ obj/structure/windoor_assembly/Destroy()
//Crowbar to complete the assembly, Step 7 complete.
else if(istype(W, /obj/item/weapon/crowbar))
if(!src.electronics)
usr << "<span class='warning'>The assembly is missing electronics.</span>"
to_chat(usr,"<span class='warning'>The assembly is missing electronics.</span>")
return
usr << browse(null, "window=windoor_access")
if(src.electronics && istype(src.electronics, /obj/item/weapon/circuitboard/broken))
to_chat(usr,"<span class='warning'>The assembly has broken airlock electronics.</span>")
return
to_chat(usr,browse(null, "window=windoor_access")) //Not sure what this actually does... -Ner
playsound(src.loc, 'sound/items/Crowbar.ogg', 100, 1)
user.visible_message("[user] pries the windoor into the frame.", "You start prying the windoor into the frame.")
@@ -206,7 +202,7 @@ obj/structure/windoor_assembly/Destroy()
if(!src) return
density = 1 //Shouldn't matter but just incase
user << "<span class='notice'>You finish the windoor!</span>"
to_chat(user,"<span class='notice'>You finish the windoor!</span>")
if(secure)
var/obj/machinery/door/window/brigdoor/windoor = new /obj/machinery/door/window/brigdoor(src.loc)
@@ -218,7 +214,8 @@ obj/structure/windoor_assembly/Destroy()
windoor.base_state = "rightsecure"
windoor.set_dir(src.dir)
windoor.density = 0
windoor.name = created_name
if(created_name)
windoor.name = created_name
spawn(0)
windoor.close()
@@ -239,7 +236,8 @@ obj/structure/windoor_assembly/Destroy()
windoor.base_state = "right"
windoor.set_dir(src.dir)
windoor.density = 0
windoor.name = created_name
if(created_name)
windoor.name = created_name
spawn(0)
windoor.close()
@@ -263,7 +261,15 @@ obj/structure/windoor_assembly/Destroy()
/obj/structure/windoor_assembly/proc/update_state()
update_icon()
name += " ([created_name])"
name = ""
switch(step)
if (0)
name = "anchored "
if (1)
name = "wired "
if (2)
name = "near finished "
name += "[secure ? "secure " : ""]windoor assembly[created_name ? " ([created_name])" : ""]"
//Rotates the windoor assembly clockwise
/obj/structure/windoor_assembly/verb/revrotate()
@@ -272,7 +278,7 @@ obj/structure/windoor_assembly/Destroy()
set src in oview(1)
if (src.anchored)
usr << "It is fastened to the floor; therefore, you can't rotate it!"
to_chat(usr,"It is fastened to the floor; therefore, you can't rotate it!")
return 0
if(src.state != "01")
update_nearby_tiles(need_rebuild=1) //Compel updates before
@@ -292,11 +298,11 @@ obj/structure/windoor_assembly/Destroy()
set src in oview(1)
if(src.facing == "l")
usr << "The windoor will now slide to the right."
to_chat(usr,"The windoor will now slide to the right.")
src.facing = "r"
else
src.facing = "l"
usr << "The windoor will now slide to the left."
to_chat(usr,"The windoor will now slide to the left.")
update_icon()
return