Skip to content

Commit

Permalink
less magic strings in animations, simplemobs can now use doors if all…
Browse files Browse the repository at this point in the history
…owed()
  • Loading branch information
silicons committed Jul 7, 2023
1 parent f8ad672 commit 4c84253
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 41 deletions.
1 change: 1 addition & 0 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
#include "code\__DEFINES\languages\ids.dm"
#include "code\__DEFINES\languages\legacy.dm"
#include "code\__DEFINES\languages\translation.dm"
#include "code\__DEFINES\machines\door.dm"
#include "code\__DEFINES\mapping\levels.dm"
#include "code\__DEFINES\mapping\maploader.dm"
#include "code\__DEFINES\mapping\maps.dm"
Expand Down
15 changes: 15 additions & 0 deletions code/__DEFINES/machines/door.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// door do_animate animations
#define DOOR_ANIMATION_OPEN "open"
#define DOOR_ANIMATION_CLOSE "close"
#define DOOR_ANIMATION_EMAG "emag"
#define DOOR_ANIMATION_DENY "deny"
#define DOOR_ANIMATION_SPARK "spark"

// airlock var/state

#define AIRLOCK_CLOSED 1
#define AIRLOCK_CLOSING 2
#define AIRLOCK_OPEN 3
#define AIRLOCK_OPENING 4
#define AIRLOCK_DENY 5
#define AIRLOCK_EMAG 6
2 changes: 1 addition & 1 deletion code/datums/wires/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
if(WIRE_IDSCAN)
//Sending a pulse through flashes the red light on the door (if the door has power).
if(A.arePowerSystemsOn() && A.density)
A.do_animate("deny")
A.do_animate(DOOR_ANIMATION_DENY)

if(WIRE_MAIN_POWER1, WIRE_MAIN_POWER2)
//Sending a pulse through either one causes a breaker to trip, disabling the door for 10 seconds if backup power is connected, or 1 minute if not (or until backup power comes back on, whichever is shorter).
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/changeling/powers/electric_lockpick.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
to_chat(user, "<span class='notice'>We send an electrical pulse up our finger, and into \the [target], attempting to open it.</span>")

if(door.density && door.operable())
door.do_animate("spark")
door.do_animate(DOOR_ANIMATION_SPARK)
sleep(6)
//More typechecks, because windoors can't be locked. Fun.
if(istype(target,/obj/machinery/door/airlock))
Expand Down
27 changes: 7 additions & 20 deletions code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ GLOBAL_REAL_VAR(airlock_typecache) = typecacheof(list(
/obj/spawner/window
)) //the spawner is there specifically because doors are initializing weird.

#define AIRLOCK_CLOSED 1
#define AIRLOCK_CLOSING 2
#define AIRLOCK_OPEN 3
#define AIRLOCK_OPENING 4
#define AIRLOCK_DENY 5
#define AIRLOCK_EMAG 6

#define AIRLOCK_PAINTABLE 1
#define AIRLOCK_STRIPABLE 2
#define AIRLOCK_DETAILABLE 4
Expand Down Expand Up @@ -258,10 +251,10 @@ GLOBAL_REAL_VAR(airlock_typecache) = typecacheof(list(
if(istype(X.species, /datum/species/xenos))
if(src.locked || src.welded)
visible_message("<span class='green'>\The [user] begins digging into \the [src] internals!</span>")
src.do_animate("deny")
src.do_animate(DOOR_ANIMATION_DENY)
if(do_after(user,5 SECONDS,src))
visible_message("<span class='danger'>\The [user] forces \the [src] open, sparks flying from its electronics!</span>")
src.do_animate("spark")
src.do_animate(DOOR_ANIMATION_SPARK)
playsound(src.loc, 'sound/machines/airlock_creaking.ogg', 100, 1)
src.locked = 0
src.welded = 0
Expand All @@ -278,7 +271,7 @@ GLOBAL_REAL_VAR(airlock_typecache) = typecacheof(list(
visible_message("<span class='danger'>\The [user] forces \the [src] closed!</span>")
close(1)
else
src.do_animate("deny")
src.do_animate(DOOR_ANIMATION_DENY)
visible_message("<span class='notice'>\The [user] strains fruitlessly to force \the [src] [density ? "open" : "closed"].</span>")
return
..()
Expand Down Expand Up @@ -525,38 +518,32 @@ About the new airlock wires panel:

set_airlock_overlays(state)

return

/obj/machinery/door/airlock/custom_smooth()
return //we only custom smooth because we don't need to do anything else.

/obj/machinery/door/airlock/do_animate(animation)
if(overlays)
overlays.Cut()

switch(animation)
if("opening")
if(DOOR_ANIMATION_OPEN)
set_airlock_overlays(AIRLOCK_OPENING)
flick("opening", src)//[stat ? "_stat":]
update_icon(AIRLOCK_OPEN)
if("closing")
if(DOOR_ANIMATION_CLOSE)
set_airlock_overlays(AIRLOCK_CLOSING)
flick("closing", src)
update_icon(AIRLOCK_CLOSED)
if("deny")
if(DOOR_ANIMATION_DENY)
set_airlock_overlays(AIRLOCK_DENY)
if(density && arePowerSystemsOn())
flick("deny", src)
if(speaker)
playsound(loc, denied_sound, 50, 0)
update_icon(AIRLOCK_CLOSED)
if("emag")
if(DOOR_ANIMATION_EMAG)
set_airlock_overlays(AIRLOCK_EMAG)
if(density && arePowerSystemsOn())
flick("deny", src)
else
update_icon()
return

/obj/machinery/door/airlock/attack_ai(mob/user as mob)
ui_interact(user)
Expand Down
31 changes: 12 additions & 19 deletions code/game/machinery/doors/door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@
if(mecha.occupant && (src.allowed(mecha.occupant) || src.check_access_list(mecha.operation_req_access)))
open()
else
do_animate("deny")
do_animate(DOOR_ANIMATION_DENY)
return
if(istype(AM, /obj/structure/bed/chair/wheelchair))
var/obj/structure/bed/chair/wheelchair/wheel = AM
if(density)
if(wheel.pulling && (src.allowed(wheel.pulling)))
open()
else
do_animate("deny")
do_animate(DOOR_ANIMATION_DENY)

/obj/machinery/door/CanAllowThrough(atom/movable/mover, turf/target)
if(!opacity && mover.check_pass_flags(ATOM_PASS_GLASS))
Expand All @@ -161,12 +161,10 @@
return
src.add_fingerprint(user)
if(density)
if(istype(user, /mob/living/simple_mob) && !(user.ckey))
do_animate("smdeny")
else if(allowed(user))
if(allowed(user))
open()
else
do_animate("deny")
do_animate(DOOR_ANIMATION_DENY)

/obj/machinery/door/bullet_act(var/obj/projectile/Proj)
..()
Expand Down Expand Up @@ -302,12 +300,12 @@
return

if(src.density)
do_animate("deny")
do_animate(DOOR_ANIMATION_DENY)
return

/obj/machinery/door/emag_act(var/remaining_charges)
if(density && operable())
do_animate("spark")
do_animate(DOOR_ANIMATION_SPARK)
sleep(6)
open()
operating = -1
Expand Down Expand Up @@ -390,35 +388,30 @@

/obj/machinery/door/proc/do_animate(animation)
switch(animation)
if("opening")
if(DOOR_ANIMATION_OPEN)
if(p_open)
flick("o_doorc0", src)
else
flick("doorc0", src)
if("closing")
if(DOOR_ANIMATION_CLOSE)
if(p_open)
flick("o_doorc1", src)
else
flick("doorc1", src)
if("spark")
if(DOOR_ANIMATION_SPARK)
if(density)
flick("door_spark", src)
if("deny")
if(DOOR_ANIMATION_DENY)
if(density && !(machine_stat & (NOPOWER|BROKEN)))
flick("door_deny", src)
playsound(src.loc, 'sound/machines/buzz-two.ogg', 50, 0)
if("smdeny")
if(density && !(machine_stat & (NOPOWER|BROKEN)))
flick("door_deny", src)
return


/obj/machinery/door/proc/open(var/forced = 0)
if(!can_open(forced))
return
operating = 1

do_animate("opening")
do_animate(DOOR_ANIMATION_OPEN)
set_opacity(0)
sleep(3)
src.density = 0
Expand All @@ -445,7 +438,7 @@
operating = 1

close_door_at = 0
do_animate("closing")
do_animate(DOOR_ANIMATION_CLOSE)
sleep(3)
src.density = 1
explosion_resistance = initial(explosion_resistance)
Expand Down

0 comments on commit 4c84253

Please sign in to comment.