Skip to content

Commit

Permalink
[MIRROR] Support Lattice Construction Fixes (#2831)
Browse files Browse the repository at this point in the history
Co-authored-by: Hubblenaut <[email protected]>
Co-authored-by: Lexanx <[email protected]>
  • Loading branch information
3 people authored Nov 24, 2024
1 parent 1634dc5 commit 4debf56
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 80 deletions.
1 change: 1 addition & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@
#include "code\datums\extensions\local_network.dm"
#include "code\datums\extensions\penetration.dm"
#include "code\datums\extensions\state_machine.dm"
#include "code\datums\extensions\support_lattice.dm"
#include "code\datums\extensions\appearance\appearance.dm"
#include "code\datums\extensions\appearance\base_icon_state.dm"
#include "code\datums\extensions\appearance\cardborg.dm"
Expand Down
48 changes: 48 additions & 0 deletions code/datums/extensions/support_lattice.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/datum/extension/support_lattice
base_type = /datum/extension/support_lattice
expected_type = /atom

/datum/extension/support_lattice/proc/try_construct(obj/item/C, mob/living/user)
var/turf/T = get_turf(holder)
if (istype(C, /obj/item/stack/material/rods))
var/obj/structure/lattice/L = locate(/obj/structure/lattice, T)
if(L)
return L.use_tool(C, user)
var/obj/item/stack/material/rods/R = C
if (!R.can_use(1))
USE_FEEDBACK_STACK_NOT_ENOUGH(R, 1, "to lay down support lattice.")
return TRUE

to_chat(user, SPAN_NOTICE("You lay down the support lattice."))
playsound(T, 'sound/weapons/Genhit.ogg', 50, 1)
T.ReplaceWithLattice(R.material.name)
R.use(1)
return TRUE

if (istype(C, /obj/item/stack/tile))
var/obj/structure/lattice/L = locate(/obj/structure/lattice, T)
if(!L)
to_chat(user, SPAN_WARNING("The plating is going to need some support."))
return TRUE
var/obj/item/stack/tile/floor/S = C
if (!S.can_use(1))
USE_FEEDBACK_STACK_NOT_ENOUGH(S, 1, "to place the plating.")
return TRUE

qdel(L)
playsound(T, 'sound/weapons/Genhit.ogg', 50, 1)
T.ChangeTurf(/turf/simulated/floor/plating, keep_air = TRUE)
S.use(1)
return TRUE

if(isCoil(C))
var/obj/item/stack/cable_coil/coil = C
var/obj/structure/lattice/L = locate(/obj/structure/lattice, T)
if(L)
coil.PlaceCableOnTurf(T, user)
return TRUE
else
to_chat(user, SPAN_WARNING("The cable needs something to be secured to."))
return TRUE

return FALSE
44 changes: 4 additions & 40 deletions code/game/turfs/space/space.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
. = ..()
update_starlight()

set_extension(src, /datum/extension/support_lattice)

appearance = SSskybox.space_appearance_cache[(((x + y) ^ ~(x * y) + z) % 25) + 1]

if(!HasBelow(z))
Expand Down Expand Up @@ -77,48 +79,10 @@
remove_starlight()

/turf/space/use_tool(obj/item/C, mob/living/user, list/click_params)
if (istype(C, /obj/item/stack/material/rods))
var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
if(L)
return L.use_tool(C, user)
var/obj/item/stack/material/rods/R = C
if (!R.can_use(1))
USE_FEEDBACK_STACK_NOT_ENOUGH(R, 1, "to lay down support lattice.")
return TRUE

to_chat(user, SPAN_NOTICE("You lay down the support lattice."))
playsound(src, 'sound/weapons/Genhit.ogg', 50, 1)
ReplaceWithLattice(R.material.name)
R.use(1)
return TRUE

if (istype(C, /obj/item/stack/tile))
var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
if(!L)
to_chat(user, SPAN_WARNING("The plating is going to need some support."))
return TRUE
var/obj/item/stack/tile/floor/S = C
if (!S.can_use(1))
USE_FEEDBACK_STACK_NOT_ENOUGH(S, 1, "to place the plating.")
return TRUE

qdel(L)
playsound(src, 'sound/weapons/Genhit.ogg', 50, 1)
ChangeTurf(/turf/simulated/floor/plating, keep_air = TRUE)
S.use(1)
var/datum/extension/support_lattice/sl = get_extension(src, /datum/extension/support_lattice)
if (sl.try_construct(C, user))
return TRUE

//Checking if the user attacked with a cable coil
if(isCoil(C))
var/obj/item/stack/cable_coil/coil = C
var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
if(L)
coil.PlaceCableOnTurf(src, user)
return TRUE
else
to_chat(user, SPAN_WARNING("The cable needs something to be secured to."))
return TRUE

return ..()


Expand Down
43 changes: 6 additions & 37 deletions code/modules/multiz/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@

z_flags = ZM_MIMIC_DEFAULTS | ZM_MIMIC_OVERWRITE | ZM_MIMIC_NO_AO | ZM_ALLOW_ATMOS

/turf/simulated/open/Initialize()
. = ..()
set_extension(src, /datum/extension/support_lattice)

/turf/simulated/open/update_dirt()
return 0

Expand Down Expand Up @@ -64,45 +68,10 @@
return TRUE

/turf/simulated/open/use_tool(obj/item/C, mob/living/user, list/click_params)
if (istype(C, /obj/item/stack/material/rods))
var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
if(L)
return L.use_tool(C, user)
var/obj/item/stack/material/rods/R = C
if (!R.can_use(1))
USE_FEEDBACK_STACK_NOT_ENOUGH(R, 1, "to lay down support lattice.")
return TRUE
to_chat(user, SPAN_NOTICE("You lay down the support lattice."))
playsound(src, 'sound/weapons/Genhit.ogg', 50, 1)
new /obj/structure/lattice(locate(src.x, src.y, src.z), R.material.name)
return TRUE

if (istype(C, /obj/item/stack/tile))
var/obj/structure/lattice/L = locate(/obj/structure/lattice, src)
if(!L)
to_chat(user, SPAN_WARNING("The plating is going to need some support."))
return TRUE

var/obj/item/stack/tile/floor/S = C
if (!S.can_use(1))
USE_FEEDBACK_STACK_NOT_ENOUGH(S, 1, "to plate the lattice.")
return TRUE

qdel(L)
playsound(src, 'sound/weapons/Genhit.ogg', 50, 1)
ChangeTurf(/turf/simulated/floor/plating, keep_air = TRUE)
var/datum/extension/support_lattice/sl = get_extension(src, /datum/extension/support_lattice)
if (sl.try_construct(C, user))
return TRUE

//To lay cable.
if(isCoil(C))
var/obj/item/stack/cable_coil/coil = C
coil.PlaceCableOnTurf(src, user)
return TRUE

for(var/atom/movable/M in below)
if(M.movable_flags & MOVABLE_FLAG_Z_INTERACT)
return C.resolve_attackby(M, user)

return ..()

/turf/simulated/open/attack_hand(mob/user)
Expand Down
6 changes: 3 additions & 3 deletions code/modules/multiz/zmimic/mimic_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@

return ..()

/atom/movable/openspace/mimic/can_use_item(obj/item/tool, mob/user, click_params)
USE_FEEDBACK_FAILURE("\The [src] is too far away.")
return FALSE
/atom/movable/openspace/mimic/use_tool(obj/item/tool, mob/user, list/click_params)
SHOULD_CALL_PARENT(FALSE)
return tool.resolve_attackby(loc, user, click_params)

/atom/movable/openspace/mimic/attack_hand(mob/user)
to_chat(user, SPAN_NOTICE("You cannot reach \the [src] from here."))
Expand Down

0 comments on commit 4debf56

Please sign in to comment.