Skip to content

Commit

Permalink
FIXABLE DOOOOOOOORS (Darkrp-community#1060)
Browse files Browse the repository at this point in the history
Co-authored-by: La Villa Strangiato <[email protected]~>
Co-authored-by: NPC1314 <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2024
1 parent 07ddf30 commit 5c5f4b1
Showing 1 changed file with 84 additions and 1 deletion.
85 changes: 84 additions & 1 deletion code/game/objects/structures/mineral_doors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@

damage_deflection = 10

var/repairable = FALSE
var/repair_state = 0
var/obj/item/repair_cost_first = null
var/obj/item/repair_cost_second = null
var/repair_skill = null

/obj/structure/mineral_door/onkick(mob/user)
if(isSwitchingStates)
return
Expand Down Expand Up @@ -294,6 +300,18 @@
/obj/structure/mineral_door/update_icon()
icon_state = "[base_state][door_opened ? "open":""]"

/obj/structure/mineral_door/examine(mob/user)
. = ..()
if(repairable)
var/obj/cast_repair_cost_first = repair_cost_first
var/obj/cast_repair_cost_second = repair_cost_second
if((repair_state == 0) && (obj_integrity < max_integrity))
. += span_notice("A [initial(cast_repair_cost_first.name)] can be used to repair it.")
if(brokenstate)
. += span_notice("An additional [initial(cast_repair_cost_second.name)] is needed to finish repairs.")
if(repair_state == 1)
. += span_notice("An additional [initial(cast_repair_cost_second.name)] is needed to finish repairs.")

/obj/structure/mineral_door/attackby(obj/item/I, mob/user)
if(istype(I, /obj/item/roguekey) || istype(I, /obj/item/keyring))
trykeylock(I, user)
Expand All @@ -302,7 +320,56 @@
if(istype(I, /obj/item/lockpick))
trypicklock(I, user)
else
return ..()
if(repairable && (user.mind.get_skill_level(repair_skill) > 0) && ((istype(I, repair_cost_first)) || (istype(I, repair_cost_second)))) // At least 1 skill level needed
repairdoor(I,user)
else
return ..()

/obj/structure/mineral_door/proc/repairdoor(obj/item/I, mob/user)
if(brokenstate)
switch(repair_state)
if(0)
if(istype(I, repair_cost_first))
user.visible_message(span_notice("[user] starts repairing [src]."), \
span_notice("I start repairing [src]."))
playsound(user, 'sound/misc/wood_saw.ogg', 100, TRUE)
if(do_after(user, (300 / user.mind.get_skill_level(repair_skill)), target = src)) // 1 skill = 30 secs, 2 skill = 15 secs etc.
qdel(I)
playsound(user, 'sound/misc/wood_saw.ogg', 100, TRUE)
repair_state = 1
var/obj/cast_repair_cost_second = repair_cost_second
to_chat(user, span_notice("An additional [initial(cast_repair_cost_second.name)] is needed to finish the job."))
if(1)
if(istype(I, repair_cost_second))
user.visible_message(span_notice("[user] starts repairing [src]."), \
span_notice("I start repairing [src]."))
playsound(user, 'sound/misc/wood_saw.ogg', 100, TRUE)
if(do_after(user, (300 / user.mind.get_skill_level(repair_skill)), target = src)) // 1 skill = 30 secs, 2 skill = 15 secs etc.
qdel(I)
playsound(user, 'sound/misc/wood_saw.ogg', 100, TRUE)
icon_state = "[base_state]"
density = TRUE
opacity = TRUE
brokenstate = FALSE
obj_broken = FALSE
obj_integrity = max_integrity
repair_state = 0
user.visible_message(span_notice("[user] repaired [src]."), \
span_notice("I repaired [src]."))
else
if(obj_integrity < max_integrity && istype(I, repair_cost_first))
to_chat(user, span_warning("[obj_integrity]"))
user.visible_message(span_notice("[user] starts repairing [src]."), \
span_notice("I start repairing [src]."))
playsound(user, 'sound/misc/wood_saw.ogg', 100, TRUE)
if(do_after(user, (300 / user.mind.get_skill_level(repair_skill)), target = src)) // 1 skill = 30 secs, 2 skill = 15 secs etc.
qdel(I)
playsound(user, 'sound/misc/wood_saw.ogg', 100, TRUE)
obj_integrity = obj_integrity + (max_integrity/2)
if(obj_integrity > max_integrity)
obj_integrity = max_integrity
user.visible_message(span_notice("[user] repaired [src]."), \
span_notice("I repaired [src]."))

/obj/structure/mineral_door/proc/trykeylock(obj/item/I, mob/user)
if(door_opened || isSwitchingStates)
Expand Down Expand Up @@ -651,6 +718,10 @@
break_sound = 'sound/combat/hits/onwood/destroywalldoor.ogg'
attacked_sound = list('sound/combat/hits/onwood/woodimpact (1).ogg','sound/combat/hits/onwood/woodimpact (2).ogg')
var/over_state = "woodover"
repairable = TRUE
repair_cost_first = /obj/item/grown/log/tree/small
repair_cost_second = /obj/item/grown/log/tree/small
repair_skill = /datum/skill/craft/carpentry

/obj/structure/mineral_door/wood/Initialize()
if(icon_state =="woodhandle")
Expand Down Expand Up @@ -710,6 +781,10 @@
blade_dulling = DULLING_BASHCHOP
break_sound = 'sound/combat/hits/onwood/destroywalldoor.ogg'
attacked_sound = list('sound/combat/hits/onwood/woodimpact (1).ogg','sound/combat/hits/onwood/woodimpact (2).ogg')
repairable = TRUE
repair_cost_first = /obj/item/grown/log/tree/small
repair_cost_second = /obj/item/grown/log/tree/small
repair_skill = /datum/skill/craft/carpentry

/obj/structure/mineral_door/wood/window
opacity = FALSE
Expand Down Expand Up @@ -771,6 +846,8 @@
unlocksound = 'sound/foley/doors/lockmetal.ogg'
rattlesound = 'sound/foley/doors/lockrattlemetal.ogg'
attacked_sound = list("sound/combat/hits/onmetal/metalimpact (1).ogg", "sound/combat/hits/onmetal/metalimpact (2).ogg")
repair_cost_second = /obj/item/ingot/iron
repair_skill = /datum/skill/craft/carpentry

/obj/structure/mineral_door/wood/donjon/stone
desc = ""
Expand All @@ -780,6 +857,9 @@
max_integrity = 1000
over_state = "stoneopen"
attacked_sound = list('sound/combat/hits/onwood/woodimpact (1).ogg','sound/combat/hits/onwood/woodimpact (2).ogg')
repair_cost_first = /obj/item/natural/stone
repair_cost_second = /obj/item/natural/stone
repair_skill = /datum/skill/craft/masonry

/obj/structure/mineral_door/wood/donjon/stone/attack_right(mob/user)
return
Expand Down Expand Up @@ -840,6 +920,9 @@
attacked_sound = list("sound/combat/hits/onmetal/metalimpact (1).ogg", "sound/combat/hits/onmetal/metalimpact (2).ogg")
ridethrough = TRUE
swing_closed = FALSE
repair_cost_first = /obj/item/ingot/iron
repair_cost_second = /obj/item/ingot/iron
repair_skill = /datum/skill/craft/blacksmithing

/obj/structure/mineral_door/bars/Initialize()
. = ..()
Expand Down

0 comments on commit 5c5f4b1

Please sign in to comment.