Skip to content

Commit

Permalink
refactor barricades files to hopfully have a more constant interactio…
Browse files Browse the repository at this point in the history
…n when trying to fix them with welder. (#5609)

# About the pull request
fixes: #5229
1-replace a bunch of single letter variable and in the same movement
standardize it for all the parent/child object...
2-create a proc that is a group of check to see if you can start fixing
a barricade with a welder.
3-implement this proc on metal,plasteel and deployable to have all the
check be the same as we want them to all react the same way...
<!-- Remove this text and explain what the purpose of your PR is.

Mention if you have tested your changes. If you changed a map, make sure
you used the mapmerge tool.
If this is an Issue Correction, you can type "Fixes Issue #169420" to
link the PR to the corresponding Issue number #169420.

Remember: something that is self-evident to you might not be to others.
Explain your rationale fully, even if you feel it goes without saying.
-->

# Explain why it's good for the game
# Testing Photographs and Procedure
i tested welding different different cades at the same time seem to work
i had some weirdness but it's working.
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
refactor: refactored files with the aim of making fixing barricade with
a welder more constant.
fix: being unable to repair more than one metal barricade at the time.
/:cl:

---------

Co-authored-by: Julien <[email protected]>
Co-authored-by: Birdtalon <[email protected]>
  • Loading branch information
3 people committed Feb 21, 2024
1 parent 5045c70 commit 8b99bc2
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 69 deletions.
43 changes: 35 additions & 8 deletions code/game/objects/structures/barricade/barricade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@
climbable = TRUE
anchored = TRUE
density = TRUE
throwpass = TRUE //You can throw objects over this, despite its density.
/// You can throw objects over this, despite its density.
throwpass = TRUE
layer = BELOW_OBJ_LAYER
flags_atom = ON_BORDER
var/stack_type //The type of stack the barricade dropped when disassembled if any.
var/stack_amount = 5 //The amount of stack dropped when disassembled at full health
var/destroyed_stack_amount //to specify a non-zero amount of stack to drop when destroyed
/// The type of stack the barricade dropped when disassembled if any.
var/stack_type
/// The amount of stack dropped when disassembled at full health
var/stack_amount = 5
/// to specify a non-zero amount of stack to drop when destroyed
var/destroyed_stack_amount
health = 100 //Pretty tough. Changes sprites at 300 and 150
var/maxhealth = 100 //Basic code functions
var/maxhealth = 100
/// Used for calculating some stuff related to maxhealth as it constantly changes due to e.g. barbed wire. set to 100 to avoid possible divisions by zero
var/starting_maxhealth = 100
var/crusher_resistant = TRUE //Whether a crusher can ram through it.
var/force_level_absorption = 5 //How much force an item needs to even damage it at all.
/// Whether a crusher can ram through it.
var/crusher_resistant = TRUE
/// How much force an item needs to even damage it at all.
var/force_level_absorption = 5
var/barricade_hitsound
var/barricade_type = "barricade" //"metal", "plasteel", etc.
var/wire_icon = 'icons/obj/structures/barricades.dmi' //! Icon file used for the wiring
/// ! Icon file used for the wiring
var/wire_icon = 'icons/obj/structures/barricades.dmi'
var/can_change_dmg_state = TRUE
var/damage_state = BARRICADE_DMG_NONE
var/closed = FALSE
Expand All @@ -35,6 +42,8 @@
var/burn_flame_multiplier = 1
var/repair_materials = list()
var/metallic = TRUE
/// Lower limit of damage beyond which the barricade cannot be fixed by welder. Compared to damage_state. If null it can be repaired at any damage_state.
var/welder_lower_damage_limit = null

/obj/structure/barricade/Initialize(mapload, mob/user)
. = ..()
Expand Down Expand Up @@ -466,3 +475,21 @@
nailgun.in_chamber = null
nailgun.load_into_chamber()
return TRUE

// This proc is to check a bunch of condition to cancel the action that a welder user is trying to do while giving
// a explanation on why...

/obj/structure/barricade/proc/attackby_welder(obj/item/item, mob/user)
if(!HAS_TRAIT(item, TRAIT_TOOL_BLOWTORCH))
to_chat(user, SPAN_WARNING("You need a stronger blowtorch!"))
return FALSE

if(health == maxhealth)
to_chat(user, SPAN_WARNING("[src] doesn't need repairs."))
return FALSE

if(!(isnull(damage_state)) && !(isnull(welder_lower_damage_limit)) && damage_state >= welder_lower_damage_limit)
to_chat(user, SPAN_WARNING("[src] has sustained too much structural damage to be repaired."))
return FALSE

return TRUE
14 changes: 4 additions & 10 deletions code/game/objects/structures/barricade/deployable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,11 @@
/obj/structure/barricade/deployable/attackby(obj/item/item, mob/user)

if(iswelder(item))
if(!HAS_TRAIT(item, TRAIT_TOOL_BLOWTORCH))
to_chat(user, SPAN_WARNING("You need a stronger blowtorch!"))
return
if(user.action_busy)
return
var/obj/item/tool/weldingtool/welder = item
if(health == maxhealth)
to_chat(user, SPAN_WARNING("[src] doesn't need repairs."))
return
if(!attackby_welder(item, user))
return FALSE


weld_cade(welder, user)
weld_cade(item, user)
return

else if(HAS_TRAIT(item, TRAIT_TOOL_CROWBAR))
Expand Down
18 changes: 9 additions & 9 deletions code/game/objects/structures/barricade/handrail.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@
reinforced = !reinforced
update_icon()

/obj/structure/barricade/handrail/attackby(obj/item/W, mob/user)
/obj/structure/barricade/handrail/attackby(obj/item/item, mob/user)
for(var/obj/effect/xenomorph/acid/A in src.loc)
if(A.acid_t == src)
to_chat(user, "You can't get near that, it's melting!")
return

switch(build_state)
if(BARRICADE_BSTATE_SECURED) //Non-reinforced. Wrench to unsecure. Screwdriver to disassemble into metal. 1 metal to reinforce.
if(HAS_TRAIT(W, TRAIT_TOOL_WRENCH)) // Make unsecure
if(HAS_TRAIT(item, TRAIT_TOOL_WRENCH)) // Make unsecure
if(user.action_busy)
return
if(!skillcheck(user, SKILL_CONSTRUCTION, SKILL_CONSTRUCTION_TRAINED))
Expand All @@ -89,15 +89,15 @@
build_state = BARRICADE_BSTATE_UNSECURED
update_icon()
return
if(istype(W, /obj/item/stack/sheet/metal)) // Start reinforcing
if(istype(item, /obj/item/stack/sheet/metal)) // Start reinforcing
if(!can_be_reinforced)
return
if(user.action_busy)
return
if(!skillcheck(user, SKILL_CONSTRUCTION, SKILL_CONSTRUCTION_TRAINED))
to_chat(user, SPAN_WARNING("You are not trained to reinforce [src]..."))
return
var/obj/item/stack/sheet/metal/M = W
var/obj/item/stack/sheet/metal/M = item
playsound(src.loc, 'sound/items/Screwdriver2.ogg', 25, 1)
if(M.amount >= 1 && do_after(user, 30, INTERRUPT_ALL|BEHAVIOR_IMMOBILE, BUSY_ICON_BUILD)) //Shouldnt be possible, but doesnt hurt to check
if(!M.use(1))
Expand All @@ -109,7 +109,7 @@
return

if(BARRICADE_BSTATE_UNSECURED)
if(HAS_TRAIT(W, TRAIT_TOOL_WRENCH)) // Secure again
if(HAS_TRAIT(item, TRAIT_TOOL_WRENCH)) // Secure again
if(user.action_busy)
return
if(!skillcheck(user, SKILL_CONSTRUCTION, SKILL_CONSTRUCTION_TRAINED))
Expand All @@ -123,7 +123,7 @@
build_state = BARRICADE_BSTATE_SECURED
update_icon()
return
if(HAS_TRAIT(W, TRAIT_TOOL_SCREWDRIVER)) // Disassemble into metal
if(HAS_TRAIT(item, TRAIT_TOOL_SCREWDRIVER)) // Disassemble into metal
if(user.action_busy)
return
if(!skillcheck(user, SKILL_CONSTRUCTION, SKILL_CONSTRUCTION_TRAINED))
Expand All @@ -141,7 +141,7 @@

if(BARRICADE_BSTATE_FORTIFIED)
if(reinforced)
if(HAS_TRAIT(W, TRAIT_TOOL_CROWBAR)) // Un-reinforce
if(HAS_TRAIT(item, TRAIT_TOOL_CROWBAR)) // Un-reinforce
if(user.action_busy)
return
if(!skillcheck(user, SKILL_CONSTRUCTION, SKILL_CONSTRUCTION_TRAINED))
Expand All @@ -155,8 +155,8 @@
reinforce()
return
else
if(iswelder(W)) // Finish reinforcing
if(!HAS_TRAIT(W, TRAIT_TOOL_BLOWTORCH))
if(iswelder(item)) // Finish reinforcing
if(!HAS_TRAIT(item, TRAIT_TOOL_BLOWTORCH))
to_chat(user, SPAN_WARNING("You need a stronger blowtorch!"))
return
if(user.action_busy)
Expand Down
22 changes: 8 additions & 14 deletions code/game/objects/structures/barricade/metal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
var/build_state = BARRICADE_BSTATE_SECURED //Look at __game.dm for barricade defines
var/upgrade = null

welder_lower_damage_limit = BARRICADE_DMG_HEAVY

/obj/structure/barricade/metal/update_icon()
. = ..()
if(dir > 2)
Expand All @@ -44,24 +46,16 @@

/obj/structure/barricade/metal/attackby(obj/item/item, mob/user)
if(iswelder(item))
if(!HAS_TRAIT(item, TRAIT_TOOL_BLOWTORCH))
to_chat(user, SPAN_WARNING("You need a stronger blowtorch!"))
return
if(user.action_busy)
return
if(!attackby_welder(item, user))
return FALSE


if(!skillcheck(user, SKILL_ENGINEER, SKILL_ENGINEER_TRAINED))
to_chat(user, SPAN_WARNING("You're not trained to repair [src]..."))
return
var/obj/item/tool/weldingtool/welder = item
if(damage_state == BARRICADE_DMG_HEAVY)
to_chat(user, SPAN_WARNING("[src] has sustained too much structural damage to be repaired."))
return
return FALSE

if(health == maxhealth)
to_chat(user, SPAN_WARNING("[src] doesn't need repairs."))
return
weld_cade(item, user)

weld_cade(welder, user)
return

if(try_nailgun_usage(item, user))
Expand Down
49 changes: 21 additions & 28 deletions code/game/objects/structures/barricade/plasteel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@
repair_materials = list("plasteel" = 0.3)

var/build_state = BARRICADE_BSTATE_SECURED //Look at __game.dm for barricade defines
var/tool_cooldown = 0 //Delay to apply tools to prevent spamming
var/busy = FALSE //Standard busy check
/// Delay to apply tools to prevent spamming
var/tool_cooldown = 0
/// Standard busy check
var/busy = FALSE
var/linked = 0
var/recentlyflipped = FALSE
var/hasconnectionoverlay = TRUE
var/linkable = TRUE
welder_lower_damage_limit = BARRICADE_DMG_HEAVY

/obj/structure/barricade/plasteel/update_icon()
..()
Expand Down Expand Up @@ -57,35 +60,25 @@
if(BARRICADE_BSTATE_MOVABLE)
. += SPAN_INFO("The protection panel has been removed and the anchor bolts loosened. It's ready to be taken apart.")

/obj/structure/barricade/plasteel/weld_cade(obj/item/W, mob/user)
/obj/structure/barricade/plasteel/weld_cade(obj/item/item, mob/user)
busy = TRUE
..()
busy = FALSE

/obj/structure/barricade/plasteel/attackby(obj/item/W, mob/user)
if(iswelder(W))
if(!HAS_TRAIT(W, TRAIT_TOOL_BLOWTORCH))
to_chat(user, SPAN_WARNING("You need a stronger blowtorch!"))
return
if(busy || tool_cooldown > world.time)
return
tool_cooldown = world.time + 10
/obj/structure/barricade/plasteel/attackby(obj/item/item, mob/user)
if(iswelder(item))
if(!attackby_welder(item, user))
return FALSE


if(!skillcheck(user, SKILL_ENGINEER, SKILL_ENGINEER_TRAINED))
to_chat(user, SPAN_WARNING("You're not trained to repair [src]..."))
return
var/obj/item/tool/weldingtool/WT = W
if(damage_state == BARRICADE_DMG_HEAVY)
to_chat(user, SPAN_WARNING("[src] has sustained too much structural damage to be repaired."))
return

if(health == maxhealth)
to_chat(user, SPAN_WARNING("[src] doesn't need repairs."))
return
return FALSE

weld_cade(WT, user)
weld_cade(item, user)
return

if(try_nailgun_usage(W, user))
if(try_nailgun_usage(item, user))
return

for(var/obj/effect/xenomorph/acid/A in src.loc)
Expand All @@ -95,7 +88,7 @@

switch(build_state)
if(2) //Fully constructed step. Use screwdriver to remove the protection panels to reveal the bolts
if(HAS_TRAIT(W, TRAIT_TOOL_SCREWDRIVER))
if(HAS_TRAIT(item, TRAIT_TOOL_SCREWDRIVER))
if(busy || tool_cooldown > world.time)
return
tool_cooldown = world.time + 10
Expand All @@ -113,7 +106,7 @@
playsound(src.loc, 'sound/items/Screwdriver.ogg', 25, 1)
build_state = BARRICADE_BSTATE_UNSECURED
return
if(HAS_TRAIT(W, TRAIT_TOOL_CROWBAR))
if(HAS_TRAIT(item, TRAIT_TOOL_CROWBAR))
if(!skillcheck(user, SKILL_ENGINEER, SKILL_ENGINEER_ENGI))
to_chat(user, SPAN_WARNING("You are not trained to modify [src]..."))
return
Expand All @@ -133,7 +126,7 @@
cade.update_icon()
update_icon()
if(1) //Protection panel removed step. Screwdriver to put the panel back, wrench to unsecure the anchor bolts
if(HAS_TRAIT(W, TRAIT_TOOL_SCREWDRIVER))
if(HAS_TRAIT(item, TRAIT_TOOL_SCREWDRIVER))
if(busy || tool_cooldown > world.time)
return
tool_cooldown = world.time + 10
Expand All @@ -146,7 +139,7 @@
playsound(src.loc, 'sound/items/Screwdriver.ogg', 25, 1)
build_state = BARRICADE_BSTATE_SECURED
return
if(HAS_TRAIT(W, TRAIT_TOOL_WRENCH))
if(HAS_TRAIT(item, TRAIT_TOOL_WRENCH))
if(busy || tool_cooldown > world.time)
return
tool_cooldown = world.time + 10
Expand All @@ -163,7 +156,7 @@
return

if(0) //Anchor bolts loosened step. Apply crowbar to unseat the panel and take apart the whole thing. Apply wrench to rescure anchor bolts
if(HAS_TRAIT(W, TRAIT_TOOL_WRENCH))
if(HAS_TRAIT(item, TRAIT_TOOL_WRENCH))
if(busy || tool_cooldown > world.time)
return
tool_cooldown = world.time + 10
Expand All @@ -182,7 +175,7 @@
build_state = BARRICADE_BSTATE_UNSECURED
update_icon() //unanchored changes layer
return
if(HAS_TRAIT(W, TRAIT_TOOL_CROWBAR))
if(HAS_TRAIT(item, TRAIT_TOOL_CROWBAR))
if(busy || tool_cooldown > world.time)
return
tool_cooldown = world.time + 10
Expand Down

0 comments on commit 8b99bc2

Please sign in to comment.