Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes rear dropship doors solid again and refactors multi door filler turf logic #4837

Merged
merged 13 commits into from
Nov 9, 2023
1 change: 0 additions & 1 deletion code/game/machinery/doors/airlock_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@
opacity = 0
assembly_type = /obj/structure/airlock_assembly/airlock_assembly_research
glass = 1
heat_proof = 1
req_one_access = list(ACCESS_CIVILIAN_RESEARCH, ACCESS_CIVILIAN_COMMAND, ACCESS_WY_COLONIAL)

/obj/structure/machinery/door/airlock/glass_mining/colony
Expand Down
156 changes: 73 additions & 83 deletions code/game/machinery/doors/door.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/obj/structure/machinery/door
name = "\improper Door"
desc = "It opens and closes."
Expand All @@ -7,72 +6,85 @@
anchored = TRUE
opacity = TRUE
density = TRUE
throwpass = 0
throwpass = FALSE
layer = DOOR_OPEN_LAYER
minimap_color = MINIMAP_DOOR
var/open_layer = DOOR_OPEN_LAYER
var/closed_layer = DOOR_CLOSED_LAYER
var/id = ""
var/width = 1

var/secondsElectrified = 0
var/visible = 1
var/visible = TRUE
var/panel_open = FALSE
var/operating = 0
var/autoclose = 0
var/glass = 0
var/normalspeed = 1
var/openspeed = 10 //How many seconds does it take to open it? Default 1 second. Use only if you have long door opening animations
var/heat_proof = 0 // For glass airlocks/opacity firedoors
var/air_properties_vary_with_direction = 0
var/turf/filler //Fixes double door opacity issue
var/operating = FALSE
var/autoclose = FALSE
var/glass = FALSE
/// If FALSE it speeds up the autoclosing timing.
var/normalspeed = TRUE
/// Time to open/close airlock, default is 1 second.
var/openspeed = 1 SECONDS
/// Fixes multi_tile doors opacity issues.
var/list/filler_turfs = list() //Previously this was just var, because no one had forseen someone creating doors more than 2 tiles wide
/// Stops it being forced open through normal means (Hunters/Zombies/Aliens).
var/heavy = FALSE
/// Resistance to masterkey
var/masterkey_resist = FALSE
var/masterkey_mod = 0.1


//Multi-tile doors
dir = EAST
var/width = 1
dir = EAST //So multitile doors are directioned properly

/obj/structure/machinery/door/Initialize(mapload, ...)
. = ..()
if(density)
layer = closed_layer
update_flags_heat_protection(get_turf(src))
else
layer = open_layer

layer = density ? closed_layer : open_layer
handle_multidoor()

/obj/structure/machinery/door/Destroy()
. = ..()
if(filler && width > 1)
filler.set_opacity(0)// Ehh... let's hope there are no walls there. Must fix this
filler = null
if(length(filler_turfs) && width > 1)
change_filler_opacity(0) // It still doesn't check for walls, might want to add checking that in the future
filler_turfs = null
density = FALSE

/obj/structure/machinery/door/initialize_pass_flags(datum/pass_flags_container/PF)
..()
if (PF)
PF.flags_can_pass_all = NONE

/// Also refreshes filler_turfs list.
/obj/structure/machinery/door/proc/change_filler_opacity(new_opacity)
// I have no idea why do we null opacity first before... changing it
for(var/turf/filler_turf in filler_turfs)
Das15 marked this conversation as resolved.
Show resolved Hide resolved
filler_turf.set_opacity(null)

filler_turfs = list()
for(var/turf/filler in locate_filler_turfs())
Das15 marked this conversation as resolved.
Show resolved Hide resolved
filler.set_opacity(new_opacity)
filler_turfs += filler

/// Updates collision box and opacity of multi_tile airlocks.
/obj/structure/machinery/door/proc/handle_multidoor()
if(width > 1)
if(dir in list(EAST, WEST))
bound_width = width * world.icon_size
bound_height = world.icon_size
filler = get_step(src,EAST)
filler.set_opacity(opacity)
else
bound_width = world.icon_size
bound_height = width * world.icon_size
filler = get_step(src,NORTH)
filler.set_opacity(opacity)
change_filler_opacity(opacity)

//process()
//return
/// Finds turfs which should be filler ones.
/obj/structure/machinery/door/proc/locate_filler_turfs()
var/turf/filler_temp
var/list/located_turfs = list()

for(var/i = 1, i < width, i++)
Das15 marked this conversation as resolved.
Show resolved Hide resolved
if (dir in list(EAST, WEST))
filler_temp = locate(x + i, y, z)
else
filler_temp = locate(x, y + i, z)
if (filler_temp)
located_turfs += filler_temp
return located_turfs

/obj/structure/machinery/door/proc/borders_space()
for(var/turf/target in range(1, src))
Expand All @@ -81,37 +93,37 @@
return FALSE

/obj/structure/machinery/door/Collided(atom/movable/AM)
if(panel_open || operating) return
if(panel_open || operating)
return
if(ismob(AM))
var/mob/M = AM
if(world.time - M.last_bumped <= openspeed) return //Can bump-open one airlock per second. This is to prevent shock spam.
M.last_bumped = world.time
if(!M.is_mob_restrained() && M.mob_size > MOB_SIZE_SMALL)
bumpopen(M)
return

if(istype(AM, /obj))
var/obj/O = AM
if(O.buckled_mob)
Collided(O.buckled_mob)

if(istype(AM, /obj/structure/machinery/bot))
var/obj/structure/machinery/bot/bot = AM
if(src.check_access(bot.botcard))
if(density)
open()
return


/obj/structure/machinery/door/proc/bumpopen(mob/user as mob)
if(operating) return
if(operating)
return
src.add_fingerprint(user)
if(!src.requiresID())
user = null

if(density)
if(allowed(user)) open()
else flick("door_deny", src)
if(allowed(user))
open()
else
flick("door_deny", src)
return

/obj/structure/machinery/door/attack_remote(mob/user)
Expand All @@ -124,9 +136,7 @@
add_fingerprint(user)
if(operating)
return
if(!Adjacent(user))
user = null //so allowed(user) always succeeds
if(!requiresID())
if(!Adjacent(user) || !requiresID())
user = null //so allowed(user) always succeeds
if(allowed(user))
if(density)
Expand All @@ -137,64 +147,57 @@
if(density)
flick("door_deny", src)


/obj/structure/machinery/door/attackby(obj/item/I, mob/user)
if(!(I.flags_item & NOBLUDGEON))
try_to_activate_door(user)
return 1
return TRUE

/obj/structure/machinery/door/emp_act(severity)
if(prob(20/severity) && (istype(src,/obj/structure/machinery/door/airlock) || istype(src,/obj/structure/machinery/door/window)) )
open()
if(prob(20/severity))
if((istype(src, /obj/structure/machinery/door/airlock) || istype(src, /obj/structure/machinery/door/window)))
open()
Das15 marked this conversation as resolved.
Show resolved Hide resolved
if(prob(40/severity))
if(secondsElectrified == 0)
secondsElectrified = -1
spawn(30 SECONDS)
secondsElectrified = 0
..()


/obj/structure/machinery/door/ex_act(severity)
if(unacidable) return
if(unacidable)
return

if(density)
switch(severity)
if(0 to EXPLOSION_THRESHOLD_LOW)
if(prob(80))
var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
s.set_up(2, 1, src)
s.start()
var/datum/effect_system/spark_spread/spark = new /datum/effect_system/spark_spread
spark.set_up(2, 1, src)
spark.start()
if(EXPLOSION_THRESHOLD_LOW to INFINITY)
qdel(src)
else
switch(severity)
if(0 to EXPLOSION_THRESHOLD_MEDIUM)
if(prob(80))
var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
s.set_up(2, 1, src)
s.start()
var/datum/effect_system/spark_spread/spark = new /datum/effect_system/spark_spread
spark.set_up(2, 1, src)
spark.start()
else
qdel(src)
return


/obj/structure/machinery/door/get_explosion_resistance()
if(density)
if(unacidable)
return 1000000
return 1000000 //Used for negation of explosions, should probably be made into define in the future
else
return EXPLOSION_THRESHOLD_LOW //this should exactly match the amount of damage needed to destroy the door
else
return 0


/obj/structure/machinery/door/update_icon()
if(density)
icon_state = "door1"
else
icon_state = "door0"
return

icon_state = density ? "door1" : "door0"

/obj/structure/machinery/door/proc/do_animate(animation)
switch(animation)
Expand All @@ -212,7 +215,6 @@
flick("door_deny", src)
return


/obj/structure/machinery/door/proc/open(forced=0)
if(!density)
return TRUE
Expand All @@ -223,8 +225,8 @@
do_animate("opening")
icon_state = "door0"
set_opacity(FALSE)
if(filler)
filler.set_opacity(opacity)
if(length(filler_turfs))
change_filler_opacity(opacity)
addtimer(CALLBACK(src, PROC_REF(finish_open)), openspeed)
return TRUE

Expand All @@ -235,11 +237,9 @@

if(operating)
operating = FALSE

if(autoclose)
addtimer(CALLBACK(src, PROC_REF(autoclose)), normalspeed ? 150 + openspeed : 5)


/obj/structure/machinery/door/proc/close()
if(density)
return TRUE
Expand All @@ -256,20 +256,16 @@
update_icon()
if(visible && !glass)
set_opacity(TRUE)
if(filler)
filler.set_opacity(opacity)
if(length(filler_turfs))
change_filler_opacity(opacity)
operating = FALSE

/obj/structure/machinery/door/proc/requiresID()
return TRUE


/obj/structure/machinery/door/proc/update_flags_heat_protection(turf/source)


/obj/structure/machinery/door/proc/autoclose()
var/obj/structure/machinery/door/airlock/A = src
if(!A.density && !A.operating && !A.locked && !A.welded && A.autoclose)
var/obj/structure/machinery/door/airlock/airlock = src
Das15 marked this conversation as resolved.
Show resolved Hide resolved
if(!airlock.density && !airlock.operating && !airlock.locked && !airlock.welded && airlock.autoclose)
close()
return

Expand All @@ -279,16 +275,10 @@
if(dir in list(EAST, WEST))
bound_width = width * world.icon_size
bound_height = world.icon_size
filler.set_opacity(0)
filler = (get_step(src,EAST)) //Find new turf
filler.set_opacity(opacity)
else
bound_width = world.icon_size
bound_height = width * world.icon_size
filler.set_opacity(0)
filler = (get_step(src,NORTH)) //Find new turf
filler.set_opacity(opacity)

change_filler_opacity(opacity)

/obj/structure/machinery/door/morgue
icon = 'icons/obj/structures/doors/doormorgue.dmi'
38 changes: 0 additions & 38 deletions code/game/machinery/doors/multi_tile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

/obj/structure/machinery/door/airlock/multi_tile/Initialize()
. = ..()
handle_multidoor()
update_icon()

/obj/structure/machinery/door/airlock/multi_tile/glass
Expand Down Expand Up @@ -137,7 +136,6 @@
/obj/structure/window/framed/almayer,
/obj/structure/machinery/door/airlock,
)
var/multi_filler = list()

/obj/structure/machinery/door/airlock/multi_tile/almayer/Initialize()
. = ..()
Expand Down Expand Up @@ -233,42 +231,6 @@
req_access = null
req_one_access = list(ACCESS_CIVILIAN_BRIG, ACCESS_CIVILIAN_COMMAND, ACCESS_WY_COLONIAL)

/obj/structure/machinery/door/airlock/multi_tile/almayer/handle_multidoor()
. = ..()
if(!(width > 1)) return //Bubblewrap

update_filler_turfs()

//We have to find these again since these doors are used on shuttles a lot so the turfs changes
/obj/structure/machinery/door/airlock/multi_tile/almayer/proc/update_filler_turfs()
for(var/turf/T in multi_filler)
T.set_opacity(null)

multi_filler = list()
for(var/turf/T in get_filler_turfs())
T.set_opacity(opacity)
multi_filler += list(T)

/obj/structure/machinery/door/airlock/multi_tile/proc/get_filler_turfs()
. = list()
for(var/i = 1, i < width, i++)
if(dir in list(NORTH, SOUTH))
var/turf/T = locate(x, y + i, z)
if(T)
. += list(T)
else if(dir in list(EAST, WEST))
var/turf/T = locate(x + i, y, z)
if(T)
. += list(T)

/obj/structure/machinery/door/airlock/multi_tile/almayer/open()
. = ..()
update_filler_turfs()

/obj/structure/machinery/door/airlock/multi_tile/almayer/close()
. = ..()
update_filler_turfs()

//------Dropship Cargo Doors -----//

/obj/structure/machinery/door/airlock/multi_tile/almayer/dropshiprear
Expand Down
Loading