mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-21 20:13:45 +01:00
Refactor mineral door code
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
//machineryness
|
||||
|
||||
/obj/structure/mineral_door
|
||||
name = "mineral door"
|
||||
name = "metal door"
|
||||
density = 1
|
||||
anchored = 1
|
||||
opacity = 1
|
||||
@@ -10,16 +10,20 @@
|
||||
icon = 'icons/obj/doors/mineral_doors.dmi'
|
||||
icon_state = "metal"
|
||||
|
||||
var/mineralType = "metal"
|
||||
var/initial_state
|
||||
var/state = 0 //closed, 1 == open
|
||||
var/isSwitchingStates = 0
|
||||
var/close_delay = -1 //-1 if does not auto close.
|
||||
|
||||
var/hardness = 1
|
||||
var/oreAmount = 7
|
||||
var/sheetType = /obj/item/stack/sheet/metal
|
||||
var/sheetAmount = 7
|
||||
var/openSound = 'sound/effects/stonedoor_openclose.ogg'
|
||||
var/closeSound = 'sound/effects/stonedoor_openclose.ogg'
|
||||
|
||||
/obj/structure/mineral_door/New(location)
|
||||
..()
|
||||
icon_state = mineralType
|
||||
name = "[mineralType] door"
|
||||
initial_state = icon_state
|
||||
|
||||
/obj/structure/mineral_door/initialize()
|
||||
..()
|
||||
@@ -39,17 +43,18 @@
|
||||
..()
|
||||
if(!state)
|
||||
return TryToSwitchState(user)
|
||||
return
|
||||
|
||||
/obj/structure/mineral_door/attack_ai(mob/user) //those aren't machinery, they're just big fucking slabs of a mineral
|
||||
if(isAI(user)) //so the AI can't open it
|
||||
return
|
||||
else if(isrobot(user)) //but cyborgs can
|
||||
if(get_dist(user,src) <= 1) //not remotely though
|
||||
return TryToSwitchState(user)
|
||||
else if(isrobot(user) && Adjacent(user)) //but cyborgs can, but not remotely
|
||||
return TryToSwitchState(user)
|
||||
|
||||
/obj/structure/mineral_door/attack_hand(mob/user)
|
||||
return TryToSwitchState(user)
|
||||
|
||||
/obj/structure/mineral_door/attack_animal(mob/user)
|
||||
return TryToSwitchState(user)
|
||||
|
||||
/obj/structure/mineral_door/attack_ghost(mob/user)
|
||||
if(user.can_advanced_admin_interact())
|
||||
@@ -68,9 +73,10 @@
|
||||
/obj/structure/mineral_door/proc/TryToSwitchState(atom/user)
|
||||
if(isSwitchingStates)
|
||||
return
|
||||
if(ismob(user))
|
||||
var/mob/M = user
|
||||
if(world.time - user.last_bumped <= 60) return //NOTE do we really need that?
|
||||
if(isliving(user))
|
||||
var/mob/living/M = user
|
||||
if(world.time - user.last_bumped <= 60)
|
||||
return //NOTE do we really need that?
|
||||
if(M.client)
|
||||
if(iscarbon(M))
|
||||
var/mob/living/carbon/C = M
|
||||
@@ -89,81 +95,77 @@
|
||||
|
||||
/obj/structure/mineral_door/proc/Open()
|
||||
isSwitchingStates = 1
|
||||
playsound(loc, 'sound/effects/stonedoor_openclose.ogg', 100, 1)
|
||||
flick("[mineralType]opening",src)
|
||||
playsound(loc, openSound, 100, 1)
|
||||
flick("[initial_state]opening",src)
|
||||
sleep(10)
|
||||
density = 0
|
||||
opacity = 0
|
||||
state = 1
|
||||
air_update_turf(1)
|
||||
update_icon()
|
||||
isSwitchingStates = 0
|
||||
air_update_turf(1)
|
||||
|
||||
if(close_delay != -1)
|
||||
spawn(close_delay)
|
||||
Close()
|
||||
|
||||
/obj/structure/mineral_door/proc/Close()
|
||||
if(isSwitchingStates || state != 1)
|
||||
return
|
||||
var/turf/T = get_turf(src)
|
||||
for(var/mob/living/L in T)
|
||||
return
|
||||
isSwitchingStates = 1
|
||||
playsound(loc, 'sound/effects/stonedoor_openclose.ogg', 100, 1)
|
||||
flick("[mineralType]closing",src)
|
||||
playsound(loc, closeSound, 100, 1)
|
||||
flick("[initial_state]closing",src)
|
||||
sleep(10)
|
||||
density = 1
|
||||
opacity = 1
|
||||
state = 0
|
||||
air_update_turf(1)
|
||||
update_icon()
|
||||
isSwitchingStates = 0
|
||||
air_update_turf(1)
|
||||
|
||||
/obj/structure/mineral_door/update_icon()
|
||||
if(state)
|
||||
icon_state = "[mineralType]open"
|
||||
icon_state = "[initial_state]open"
|
||||
else
|
||||
icon_state = mineralType
|
||||
icon_state = initial_state
|
||||
|
||||
/obj/structure/mineral_door/attackby(obj/item/weapon/W, mob/user, params)
|
||||
if(istype(W,/obj/item/weapon/pickaxe))
|
||||
if(istype(W, /obj/item/weapon/pickaxe))
|
||||
var/obj/item/weapon/pickaxe/digTool = W
|
||||
to_chat(user, "You start digging the [name].")
|
||||
if(do_after(user,digTool.digspeed*hardness, target = src) && src)
|
||||
to_chat(user, "<span class='notice'>You start digging the [name].</span>")
|
||||
if(do_after(user, digTool.digspeed * hardness, target = src) && src)
|
||||
to_chat(user, "You finished digging.")
|
||||
Dismantle()
|
||||
else if(istype(W,/obj/item/weapon)) //not sure, can't not just weapons get passed to this proc?
|
||||
deconstruct(TRUE)
|
||||
else if(istype(W, /obj/item/weapon)) //not sure, can't not just weapons get passed to this proc?
|
||||
hardness -= W.force/100
|
||||
to_chat(user, "You hit the [name] with your [W.name]!")
|
||||
to_chat(user, "<span class='danger'>You hit the [name] with your [W.name]!</span>")
|
||||
CheckHardness()
|
||||
else
|
||||
attack_hand(user)
|
||||
return
|
||||
|
||||
/obj/structure/mineral_door/proc/CheckHardness()
|
||||
if(hardness <= 0)
|
||||
Dismantle(1)
|
||||
deconstruct(FALSE)
|
||||
|
||||
/obj/structure/mineral_door/proc/Dismantle(devastated = 0)
|
||||
if(!devastated)
|
||||
if(mineralType == "metal")
|
||||
var/ore = /obj/item/stack/sheet/metal
|
||||
for(var/i = 1, i <= oreAmount, i++)
|
||||
new ore(get_turf(src))
|
||||
/obj/structure/mineral_door/proc/deconstruct(disassembled = TRUE)
|
||||
var/turf/T = get_turf(src)
|
||||
if(sheetType)
|
||||
if(disassembled)
|
||||
new sheetType(T, sheetAmount)
|
||||
else
|
||||
var/ore = text2path("/obj/item/stack/sheet/mineral/[mineralType]")
|
||||
for(var/i = 1, i <= oreAmount, i++)
|
||||
new ore(get_turf(src))
|
||||
else
|
||||
if(mineralType == "metal")
|
||||
var/ore = /obj/item/stack/sheet/metal
|
||||
for(var/i = 3, i <= oreAmount, i++)
|
||||
new ore(get_turf(src))
|
||||
else
|
||||
var/ore = text2path("/obj/item/stack/sheet/mineral/[mineralType]")
|
||||
for(var/i = 3, i <= oreAmount, i++)
|
||||
new ore(get_turf(src))
|
||||
new sheetType(T, max(sheetAmount - 2, 1))
|
||||
qdel(src)
|
||||
|
||||
/obj/structure/mineral_door/ex_act(severity = 1)
|
||||
switch(severity)
|
||||
if(1)
|
||||
Dismantle(1)
|
||||
deconstruct(FALSE)
|
||||
if(2)
|
||||
if(prob(20))
|
||||
Dismantle(1)
|
||||
deconstruct(FALSE)
|
||||
else
|
||||
hardness--
|
||||
CheckHardness()
|
||||
@@ -172,23 +174,30 @@
|
||||
CheckHardness()
|
||||
|
||||
/obj/structure/mineral_door/iron
|
||||
mineralType = "metal"
|
||||
hardness = 3
|
||||
|
||||
/obj/structure/mineral_door/silver
|
||||
mineralType = "silver"
|
||||
name = "silver door"
|
||||
icon_state = "silver"
|
||||
sheetType = /obj/item/stack/sheet/mineral/silver
|
||||
hardness = 3
|
||||
|
||||
/obj/structure/mineral_door/gold
|
||||
mineralType = "gold"
|
||||
name = "gold door"
|
||||
icon_state = "gold"
|
||||
sheetType = /obj/item/stack/sheet/mineral/gold
|
||||
|
||||
/obj/structure/mineral_door/uranium
|
||||
mineralType = "uranium"
|
||||
name = "uranium door"
|
||||
icon_state = "uranium"
|
||||
sheetType = /obj/item/stack/sheet/mineral/uranium
|
||||
hardness = 3
|
||||
light_range = 2
|
||||
|
||||
/obj/structure/mineral_door/sandstone
|
||||
mineralType = "sandstone"
|
||||
name = "sandstone door"
|
||||
icon_state = "sandstone"
|
||||
sheetType = /obj/item/stack/sheet/mineral/sandstone
|
||||
hardness = 0.5
|
||||
|
||||
/obj/structure/mineral_door/transparent
|
||||
@@ -199,14 +208,17 @@
|
||||
set_opacity(0)
|
||||
|
||||
/obj/structure/mineral_door/transparent/plasma
|
||||
mineralType = "plasma"
|
||||
name = "plasma door"
|
||||
icon_state = "plasma"
|
||||
sheetType = /obj/item/stack/sheet/mineral/plasma
|
||||
|
||||
/obj/structure/mineral_door/transparent/plasma/attackby(obj/item/weapon/W, mob/user)
|
||||
if(is_hot(W))
|
||||
message_admins("Plasma mineral door ignited by [key_name_admin(user)] in ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
|
||||
log_game("Plasma mineral door ignited by [key_name(user)] in ([x],[y],[z])")
|
||||
message_admins("Plasma mineral door ignited by [key_name_admin(user)] in ([x], [y], [z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)", 0, 1)
|
||||
log_game("Plasma mineral door ignited by [key_name(user)] in ([x], [y], [z])")
|
||||
TemperatureAct(100)
|
||||
..()
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/structure/mineral_door/transparent/plasma/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)
|
||||
if(exposed_temperature > 300)
|
||||
@@ -214,85 +226,37 @@
|
||||
|
||||
/obj/structure/mineral_door/transparent/plasma/proc/TemperatureAct(temperature)
|
||||
atmos_spawn_air(SPAWN_HEAT | SPAWN_TOXINS, 500)
|
||||
hardness = 0
|
||||
CheckHardness()
|
||||
deconstruct(FALSE)
|
||||
|
||||
/obj/structure/mineral_door/transparent/diamond
|
||||
mineralType = "diamond"
|
||||
name = "diamond door"
|
||||
icon_state = "diamond"
|
||||
sheetType = /obj/item/stack/sheet/mineral/diamond
|
||||
hardness = 10
|
||||
|
||||
/obj/structure/mineral_door/wood
|
||||
mineralType = "wood"
|
||||
name = "wood door"
|
||||
icon_state = "wood"
|
||||
openSound = 'sound/effects/doorcreaky.ogg'
|
||||
closeSound = 'sound/effects/doorcreaky.ogg'
|
||||
sheetType = /obj/item/stack/sheet/wood
|
||||
hardness = 1
|
||||
burn_state = FLAMMABLE
|
||||
burntime = 30
|
||||
|
||||
/obj/structure/mineral_door/wood/Open()
|
||||
isSwitchingStates = 1
|
||||
playsound(loc, 'sound/effects/doorcreaky.ogg', 100, 1)
|
||||
flick("[mineralType]opening",src)
|
||||
sleep(10)
|
||||
density = 0
|
||||
set_opacity(0)
|
||||
state = 1
|
||||
update_icon()
|
||||
isSwitchingStates = 0
|
||||
|
||||
/obj/structure/mineral_door/wood/Close()
|
||||
isSwitchingStates = 1
|
||||
playsound(loc, 'sound/effects/doorcreaky.ogg', 100, 1)
|
||||
flick("[mineralType]closing",src)
|
||||
sleep(10)
|
||||
density = 1
|
||||
set_opacity(1)
|
||||
state = 0
|
||||
update_icon()
|
||||
isSwitchingStates = 0
|
||||
|
||||
/obj/structure/mineral_door/wood/Dismantle(devastated = 0)
|
||||
if(!devastated)
|
||||
for(var/i = 1, i <= oreAmount, i++)
|
||||
new/obj/item/stack/sheet/wood(get_turf(src))
|
||||
qdel(src)
|
||||
|
||||
/obj/structure/mineral_door/resin
|
||||
mineralType = "resin"
|
||||
name = "resin door"
|
||||
icon_state = "resin"
|
||||
hardness = 1.5
|
||||
var/close_delay = 100
|
||||
close_delay = 100
|
||||
openSound = 'sound/effects/attackblob.ogg'
|
||||
closeSound = 'sound/effects/attackblob.ogg'
|
||||
sheetType = null
|
||||
|
||||
/obj/structure/mineral_door/resin/TryToSwitchState(atom/user)
|
||||
if(isalien(user))
|
||||
return ..()
|
||||
|
||||
/obj/structure/mineral_door/resin/Open()
|
||||
isSwitchingStates = 1
|
||||
playsound(loc, 'sound/effects/attackblob.ogg', 100, 1)
|
||||
flick("[mineralType]opening",src)
|
||||
sleep(10)
|
||||
density = 0
|
||||
set_opacity(0)
|
||||
state = 1
|
||||
update_icon()
|
||||
isSwitchingStates = 0
|
||||
|
||||
spawn(close_delay)
|
||||
if(!isSwitchingStates && state == 1)
|
||||
Close()
|
||||
|
||||
/obj/structure/mineral_door/resin/Close()
|
||||
isSwitchingStates = 1
|
||||
playsound(loc, 'sound/effects/attackblob.ogg', 100, 1)
|
||||
flick("[mineralType]closing",src)
|
||||
sleep(10)
|
||||
density = 1
|
||||
set_opacity(1)
|
||||
state = 0
|
||||
update_icon()
|
||||
isSwitchingStates = 0
|
||||
|
||||
/obj/structure/mineral_door/resin/Dismantle(devastated = 0)
|
||||
qdel(src)
|
||||
|
||||
/obj/structure/mineral_door/resin/CheckHardness()
|
||||
playsound(loc, 'sound/effects/attackblob.ogg', 100, 1)
|
||||
..()
|
||||
|
||||
Reference in New Issue
Block a user