Skip to content

Commit

Permalink
* Added a default proc for prying open unpowered/broken machines usin…
Browse files Browse the repository at this point in the history
…g a crowbar

* Added an option to not set the machine when checking for attackhand() in machine class (prevent infitine loops if a machine doesn't have a dialog and called ..())
* Sleepers, cryo cells and DNA scanners can now be pried open when non-fonctional
* Cleaned and standardized DNA scanners code by using the general machine class
* Made sure destroyed machines drop their contents

* Added icon updating for mech bay power console and mecha control console (operational, powerless and broken states)
* Cleaned up and aligned the borg recharger station code with its parent code
* Added powerless codersprites for the borg recharger station
* Non operational borg recharger station can now be pried open from the outside.
  • Loading branch information
Menshin committed Jan 6, 2015
1 parent ac57c70 commit 9e235dd
Show file tree
Hide file tree
Showing 8 changed files with 173 additions and 186 deletions.
159 changes: 72 additions & 87 deletions code/game/dna.dm
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,7 @@
icon_state = "scanner"
density = 1
var/locked = 0
var/open = 0
anchored = 1
interact_offline = 1
use_power = 1
idle_power_usage = 50
active_power_usage = 300
Expand Down Expand Up @@ -328,11 +326,11 @@

//no power or maintenance
if(stat & (NOPOWER|BROKEN))
icon_state = initial(icon_state)+ (open ? "_open" : "") + "_unpowered"
icon_state = initial(icon_state)+ (state_open ? "_open" : "") + "_unpowered"
return

if((stat & MAINT) || panel_open)
icon_state = initial(icon_state)+ (open ? "_open" : "") + "_maintenance"
icon_state = initial(icon_state)+ (state_open ? "_open" : "") + "_maintenance"
return

//running and someone in there
Expand All @@ -341,128 +339,115 @@
return

//running
icon_state = initial(icon_state)+ (open ? "_open" : "")
icon_state = initial(icon_state)+ (state_open ? "_open" : "")

/obj/machinery/dna_scannernew/power_change()
..()
update_icon()

/obj/machinery/dna_scannernew/proc/toggle_open(mob/user=usr)
if(!user)
/obj/machinery/dna_scannernew/proc/toggle_open(var/mob/user)
if(panel_open)
user << "<span class='notice'>Close the maintenance panel first.</span>"
return
if(open) return close(user)
else return open(user)

if(state_open)
close_machine()
return

else if(locked)
user << "<span class='notice'>The bolts are locked down, securing the door shut.</span>"
return

open_machine()

/obj/machinery/dna_scannernew/container_resist()
var/mob/living/user = usr
var/breakout_time = 2
if(open || !locked) //Open and unlocked, no need to escape
open = 1
if(state_open || !locked) //Open and unlocked, no need to escape
state_open = 1
return
user.changeNext_move(CLICK_CD_BREAKOUT)
user.last_special = world.time + CLICK_CD_BREAKOUT
user << "<span class='notice'>You lean on the back of [src] and start pushing the door open. (this will take about [breakout_time] minutes.)</span>"
user.visible_message("<span class='warning'>You hear a metallic creaking from [src]!</span>")

if(do_after(user,(breakout_time*60*10))) //minutes * 60seconds * 10deciseconds
if(!user || user.stat != CONSCIOUS || user.loc != src || open || !locked)
if(!user || user.stat != CONSCIOUS || user.loc != src || state_open || !locked)
return

locked = 0
visible_message("<span class='danger'>[user] successfully broke out of [src]!</span>")
user << "<span class='notice'>You successfully break out of [src]!</span>"

open(user)

/obj/machinery/dna_scannernew/proc/close(mob/user)
if(open)
if(panel_open)
user << "<span class='notice'>Close the maintenance panel first.</span>"
return 0
open = 0
density = 1
for(var/mob/living/carbon/C in loc)
if(C.buckled) continue
if(C.client)
C.client.perspective = EYE_PERSPECTIVE
C.client.eye = src
occupant = C
C.loc = src
C.stop_pulling()
break
update_icon()

// search for ghosts, if the corpse is empty and the scanner is connected to a cloner
if(occupant)
if(locate(/obj/machinery/computer/cloning, get_step(src, NORTH)) \
|| locate(/obj/machinery/computer/cloning, get_step(src, SOUTH)) \
|| locate(/obj/machinery/computer/cloning, get_step(src, EAST)) \
|| locate(/obj/machinery/computer/cloning, get_step(src, WEST)))

var/mob/dead/observer/ghost = occupant.get_ghost()
if(ghost)
ghost << "<span class='ghostalert'>Your corpse has been placed into a cloning scanner. Return to your body if you want to be cloned!</span> (Verbs -> Ghost -> Re-enter corpse)"
ghost << sound('sound/effects/genetics.ogg')
return 1

/obj/machinery/dna_scannernew/proc/open(mob/user)
if(!open)
if(panel_open)
user << "<span class='notice'>Close the maintenance panel first.</span>"
return
if(locked)
user << "<span class='notice'>The bolts are locked down, securing the door shut.</span>"
return
var/turf/T = get_turf(src)
if(T)
open = 1
density = 0
T.contents += contents
if(occupant)
if(occupant.client)
occupant.client.eye = occupant
occupant.client.perspective = MOB_PERSPECTIVE
occupant = null
update_icon()
return 1
open_machine()

/obj/machinery/dna_scannernew/close_machine()
if(!state_open)
return 0

..()

// search for ghosts, if the corpse is empty and the scanner is connected to a cloner
if(occupant)
if(locate(/obj/machinery/computer/cloning, get_step(src, NORTH)) \
|| locate(/obj/machinery/computer/cloning, get_step(src, SOUTH)) \
|| locate(/obj/machinery/computer/cloning, get_step(src, EAST)) \
|| locate(/obj/machinery/computer/cloning, get_step(src, WEST)))

var/mob/dead/observer/ghost = occupant.get_ghost()
if(ghost)
ghost << "<span class='ghostalert'>Your corpse has been placed into a cloning scanner. Return to your body if you want to be cloned!</span> (Verbs -> Ghost -> Re-enter corpse)"
ghost << sound('sound/effects/genetics.ogg')
return 1

/obj/machinery/dna_scannernew/open_machine()
if(state_open)
return 0

..()

return 1

/obj/machinery/dna_scannernew/relaymove(mob/user as mob)
if(user.stat)
return
open(user)
open_machine()
return

/obj/machinery/dna_scannernew/attackby(obj/item/weapon/grab/G, mob/user)
/obj/machinery/dna_scannernew/attackby(var/obj/item/I, mob/user)

if(!occupant && default_deconstruction_screwdriver(user, icon_state, icon_state, G))//sent icon_state is irrelevant...
if(!occupant && default_deconstruction_screwdriver(user, icon_state, icon_state, I))//sent icon_state is irrelevant...
update_icon()//..since we're updating the icon here, since the scanner can be unpowered when opened/closed
return

if(exchange_parts(user, G))
if(exchange_parts(user, I))
return

if(istype(G, /obj/item/weapon/crowbar))
if(panel_open)
for(var/obj/I in contents) // in case there is something in the scanner
I.loc = src.loc
default_deconstruction_crowbar(G)
if(default_pry_open(I))
return

if(!istype(G, /obj/item/weapon/grab) || !ismob(G.affecting))
return
if(!open)
user << "<span class='notice'>Open the scanner first.</span>"
if(default_deconstruction_crowbar(I))
return
var/mob/M = G.affecting
M.loc = loc
user.stop_pulling()
qdel(G)

if(istype(I, /obj/item/weapon/grab))
var/obj/item/weapon/grab/G = I
if(!ismob(G.affecting))
return

if(!state_open)
user << "<span class='notice'>Open the scanner first.</span>"
return

var/mob/M = G.affecting
M.loc = loc
user.stop_pulling()
qdel(G)

/obj/machinery/dna_scannernew/attack_hand(mob/user)
if(..())
if(..(user,1,0)) //don't set the machine, since there's no dialog
return

toggle_open(user)
add_fingerprint(user)

/obj/machinery/dna_scannernew/blob_act()
if(prob(75))
Expand Down Expand Up @@ -556,7 +541,7 @@
else
occupant_status += "<span class='bad'>No subject detected</span></div></div>"

if(connected.open)
if(connected.state_open)
scanner_status = "Open"
else
scanner_status = "Closed"
Expand Down Expand Up @@ -594,8 +579,8 @@
status += "</div>" // Close statusDisplay div
var/buttons = "<a href='?src=\ref[src];'>Scan</a> "
if(connected)
buttons += " <a href='?src=\ref[src];task=toggleopen;'>[connected.open ? "Close" : "Open"] Scanner</a> "
if (connected.open)
buttons += " <a href='?src=\ref[src];task=toggleopen;'>[connected.state_open ? "Close" : "Open"] Scanner</a> "
if (connected.state_open)
buttons += "<span class='linkOff'>[connected.locked ? "Unlock" : "Lock"] Scanner</span> "
else
buttons += "<a href='?src=\ref[src];task=togglelock;'>[connected.locked ? "Unlock" : "Lock"] Scanner</a> "
Expand Down
15 changes: 4 additions & 11 deletions code/game/machinery/Sleeper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
icon_state = "sleeper-open"
density = 0
anchored = 1
interact_offline = 1
state_open = 1
var/efficiency
var/initial_bin_rating = 1
Expand Down Expand Up @@ -82,6 +81,9 @@
if(exchange_parts(user, I))
return

if(default_pry_open(I))
return

default_deconstruction_crowbar(I)

/obj/machinery/sleeper/ex_act(severity, target)
Expand Down Expand Up @@ -118,16 +120,7 @@
if(..())
return

//powerless interaction
if(!is_operational())
user.unset_machine()//essential to prevent infinite loops of opening/closing the machine
if(state_open)
close_machine()
else
open_machine()

else
sleeperUI(user)
sleeperUI(user)

/obj/machinery/sleeper/proc/sleeperUI(mob/user)
var/dat
Expand Down
15 changes: 4 additions & 11 deletions code/game/machinery/cryo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
icon_state = "cell-off"
density = 1
anchored = 1.0
interact_offline = 1
layer = 4

var/on = 0
Expand Down Expand Up @@ -103,16 +102,7 @@
if(..())
return

//powerless interaction
if(!is_operational())
user.unset_machine()//essential to prevent infinite loops of opening/closing the machine
if(state_open)
close_machine()
else
open_machine()

else
ui_interact(user)
ui_interact(user)


/**
Expand Down Expand Up @@ -242,6 +232,9 @@
if(exchange_parts(user, I))
return

if(default_pry_open(I))
return

default_deconstruction_crowbar(I)

/obj/machinery/atmospherics/unary/cryo_cell/open_machine()
Expand Down
21 changes: 17 additions & 4 deletions code/game/machinery/machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Class Procs:
Called by the 'master_controller' once per game tick for each machine that is listed in the 'machines' list.
is_operational()
Returns 0 if the machine is unpowered, broken or undergoing maintenance, 1 if not
Returns 0 if the machine is unpowered, broken or undergoing maintenance, something else if not
Compiled by Aygar
*/
Expand Down Expand Up @@ -120,7 +120,7 @@ Class Procs:
/obj/machinery/Destroy()
machines.Remove(src)
if(occupant)
open_machine()
dropContents()
..()

/obj/machinery/process()//If you dont use process or power why are you here
Expand Down Expand Up @@ -206,6 +206,7 @@ Class Procs:
/obj/machinery/proc/is_operational()
return !(stat & (NOPOWER|BROKEN|MAINT))


////////////////////////////////////////////////////////////////////////////////////////////

/mob/proc/canUseTopic() //TODO: once finished, place these procs on the respective mob files
Expand Down Expand Up @@ -266,10 +267,13 @@ Class Procs:
/obj/machinery/attack_paw(mob/user as mob)
return src.attack_hand(user)

/obj/machinery/attack_hand(mob/user as mob, var/check_power = 1)
//set_machine must be 0 if clicking the machinery doesn't bring up a dialog
/obj/machinery/attack_hand(mob/user as mob, var/check_power = 1, var/set_machine = 1)
if(check_power && stat & NOPOWER)
user << "<span class='danger'>\The [src] seems unpowered.</span>"
return 1
if(!interact_offline && stat & (BROKEN|MAINT))
user << "<span class='danger'>\The [src] seems broken.</span>"
return 1
if(user.lying || user.stat)
return 1
Expand All @@ -291,7 +295,8 @@ Class Procs:
return 1

src.add_fingerprint(user)
user.set_machine(src)
if(set_machine)
user.set_machine(src)
return 0

/obj/machinery/CheckParts()
Expand All @@ -305,6 +310,14 @@ Class Procs:
uid = gl_uid
gl_uid++

/obj/machinery/proc/default_pry_open(var/obj/item/weapon/crowbar/C)
. = !(state_open || panel_open || is_operational()) && istype(C)
if(.)
playsound(src.loc, 'sound/items/Crowbar.ogg', 50, 1)
visible_message("<span class = 'notice'>[usr] pry open \the [src].</span>", "<span class = 'notice'>You pry open \the [src].</span>")
open_machine()
return 1

/obj/machinery/proc/default_deconstruction_crowbar(var/obj/item/weapon/crowbar/C, var/ignore_panel = 0)
. = istype(C) && (panel_open || ignore_panel)
if(.)
Expand Down
Loading

0 comments on commit 9e235dd

Please sign in to comment.