From 4c84253c34ee88180ef06ae6b15c31b1b3a0eab3 Mon Sep 17 00:00:00 2001 From: silicons Date: Thu, 6 Jul 2023 20:25:18 -0700 Subject: [PATCH] less magic strings in animations, simplemobs can now use doors if allowed() --- citadel.dme | 1 + code/__DEFINES/machines/door.dm | 15 +++++++++ code/datums/wires/airlock.dm | 2 +- .../changeling/powers/electric_lockpick.dm | 2 +- code/game/machinery/doors/airlock.dm | 27 +++++----------- code/game/machinery/doors/door.dm | 31 +++++++------------ 6 files changed, 37 insertions(+), 41 deletions(-) create mode 100644 code/__DEFINES/machines/door.dm diff --git a/citadel.dme b/citadel.dme index d44ffa91397..a5330f20ddc 100644 --- a/citadel.dme +++ b/citadel.dme @@ -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" diff --git a/code/__DEFINES/machines/door.dm b/code/__DEFINES/machines/door.dm new file mode 100644 index 00000000000..14e0494201f --- /dev/null +++ b/code/__DEFINES/machines/door.dm @@ -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 diff --git a/code/datums/wires/airlock.dm b/code/datums/wires/airlock.dm index 60103b244a3..f1b15da6cac 100644 --- a/code/datums/wires/airlock.dm +++ b/code/datums/wires/airlock.dm @@ -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). diff --git a/code/game/gamemodes/changeling/powers/electric_lockpick.dm b/code/game/gamemodes/changeling/powers/electric_lockpick.dm index d8210dfe2ed..a93bf2dc026 100644 --- a/code/game/gamemodes/changeling/powers/electric_lockpick.dm +++ b/code/game/gamemodes/changeling/powers/electric_lockpick.dm @@ -62,7 +62,7 @@ to_chat(user, "We send an electrical pulse up our finger, and into \the [target], attempting to open it.") 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)) diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index a581a0bd596..fe4bb79db42 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -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 @@ -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("\The [user] begins digging into \the [src] internals!") - src.do_animate("deny") + src.do_animate(DOOR_ANIMATION_DENY) if(do_after(user,5 SECONDS,src)) visible_message("\The [user] forces \the [src] open, sparks flying from its electronics!") - 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 @@ -278,7 +271,7 @@ GLOBAL_REAL_VAR(airlock_typecache) = typecacheof(list( visible_message("\The [user] forces \the [src] closed!") close(1) else - src.do_animate("deny") + src.do_animate(DOOR_ANIMATION_DENY) visible_message("\The [user] strains fruitlessly to force \the [src] [density ? "open" : "closed"].") return ..() @@ -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) diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index a8018efd93f..a1cb606f3be 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -131,7 +131,7 @@ 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 @@ -139,7 +139,7 @@ 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)) @@ -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) ..() @@ -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 @@ -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 @@ -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)