Skip to content

Commit

Permalink
Merge pull request Civ13#2702 from HaultyAnonie/fetch-the-damn-thing
Browse files Browse the repository at this point in the history
The glory of properly vaulting barriers.
  • Loading branch information
KanohaShinobi authored Apr 14, 2024
2 parents eaa005d + f33fc94 commit 3e860bd
Show file tree
Hide file tree
Showing 7 changed files with 327 additions and 199 deletions.
1 change: 1 addition & 0 deletions code/_onclick/adjacent.dm
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Quick adjacency (to turf):
for (var/turf/T in locs)
if (isnull(T)) continue
if (T.Adjacent(neighbor,src)) return TRUE
//if (istype(T, /obj/structure/window/barrier) && T.dir != T.Adjacent(neighbor, src)) return TRUE
return FALSE

// This is necessary for storage items not on your person.
Expand Down
2 changes: 1 addition & 1 deletion code/game/mob/emote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
if (client)
log_emote("[name]/[key] : [message]")

//Hearing gasp and such every five seconds is not good emotes were not global for a reason.
//Hearing gasp and such every five seconds is not good, emotes were not global for a reason.
// Maybe some people are okay with that.

for (var/mob/M in player_list)
Expand Down
3 changes: 2 additions & 1 deletion code/game/objects/covers_types/covers_buildable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
wall = TRUE
flammable = FALSE
explosion_resistance = 4
buildstack = /obj/item/weapon/barrier

/obj/covers/dirt_wall/blocks/incomplete
name = "dirt blocks wall"
Expand Down Expand Up @@ -44,7 +45,7 @@
return TRUE

/obj/covers/dirt_wall/blocks/incomplete/attackby(obj/item/W as obj, mob/user as mob)
if (istype(W, /obj/item/weapon/barrier))
if (W.type == /obj/item/weapon/barrier)
if (stage == 3)
user << "You start adding dirt to the wall..."
if (do_after(user, 20, src) && W)
Expand Down
144 changes: 87 additions & 57 deletions code/game/objects/structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,37 @@
to_chat(user, SPAN_DANGER("You can't climb there, the way is blocked."))
return FALSE

var/obj/occupied = turf_is_crowded()
var/obj/occupied = turf_is_crowded(user)

if (occupied)
to_chat(user, SPAN_DANGER("There's \a [occupied] in the way."))
return FALSE
return TRUE

/obj/structure/proc/turf_is_crowded()
var/turf/T = get_turf(src)
if (!T || !istype(T))
return FALSE
for (var/obj/O in T.contents)
if (istype(O,/obj/structure))
var/obj/structure/S = O
if (S.climbable) continue
if (O && O.density && !(O.flags & ON_BORDER)) //ON_BORDER structures are handled by the Adjacent() check.
return O
return FALSE
/obj/structure/proc/turf_is_crowded(var/mob/living/user)
var/turf/T = get_step(get_turf(src), dir)
var/turf/TT = get_turf(src)

// Check for climbable objects in the current turf
for (var/obj/O in T.contents)
if (istype(O, /obj/structure))
var/obj/structure/S = O
if (!S) continue // Skip if S is not valid
if (S.climbable) continue // Skip if the object is climbable
if (O && O.density && !(O.flags & ON_BORDER)) //ON_BORDER structures are handled by the Adjacent() check.
return O

// Check for climbable objects in the adjacent turf
for (var/obj/O in TT.contents)
if (istype(O, /obj/structure))
var/obj/structure/S = O
if (!S) continue // Skip if S is not valid
if (S.climbable) continue // Skip if the object is climbable
if (O && O.density && !(O.flags & ON_BORDER)) //ON_BORDER structures are handled by the Adjacent() check.
return O

// If no crowded object is found, return FALSE
return FALSE

/obj/structure/proc/neighbor_turf_passable()
var/turf/T = get_step(src, dir)
Expand All @@ -134,51 +148,67 @@
return TRUE

/obj/structure/proc/do_climb(var/mob/living/user)
if (!can_climb(user))
return

user.face_atom(src)

var/turf/target = null

if (istype(src, /obj/structure/window/barrier))
target = get_step(user, user.dir)
else
target = get_turf(src)

if (!target || target.density || (map && map.check_caribbean_block(user, target)))
return

for (var/obj/structure/S in target)
if (S != src && S.density)
return

usr.visible_message("<span class='warning'>[user] starts climbing onto \the [src]!</span>")
climbers |= user

if (!do_after(user,(issmall(user) ? 20 : 34)))
climbers -= user
return

if (!can_climb(user, post_climb_check=1))
climbers -= user
return

if (!target || target.density)
return

for (var/obj/structure/S in target)
if (S != src && S.density)
return

usr.forceMove(target)

if (get_turf(user) == target)
usr.visible_message("<span class='warning'>[user] climbs onto \the [src]!</span>")
if (istype(src, /obj/structure/table/glass))
var/obj/structure/table/glass/G = src
G.shatter()
climbers -= user
if (!can_climb(user))
return
if (map.check_caribbean_block(user, get_turf(src)))
return

var/turf/T = get_turf(src) // Target-Turf
if (src.flags & ON_BORDER)
T = get_step(get_turf(src), dir)
if (user.loc == T)
T = get_turf(src)

var/turf/U = get_turf(user) // Start-Turf
if (!istype(T) || !istype(U))
return FALSE

var/climb_dir = src.dir // Direction of the barrier that the user is trying to climb
var/opposite_dir = reverse_direction(climb_dir) // Reverse the direction to simulate a barrier in the opposite direction facing towards us.

// Check if the user is not directly in front of or behind the barrier
var/turf/next_turf = get_step(T, climb_dir)
if (user.loc != next_turf)
next_turf = get_step(T, opposite_dir)
if (user.loc != next_turf)
to_chat(user, SPAN_WARNING("You can't vault this barrier. You must be directly next to it."))
return

// Check if there's a barrier with opposite direction facing the climbing direction
for (var/obj/I in T)
if (I.dir == opposite_dir && istype(I, /obj/structure/window/barrier))
to_chat(user, SPAN_WARNING("You can't vault this barrier. \A [I.name] is blocking the way."))
return

if (!T || T.density)
return

user.visible_message(SPAN_WARNING("[user] starts climbing onto \the [src]!</span>"), SPAN_WARNING("You start climbing onto \the [src]!"))
user.face_atom(T)
climbers |= user

if (!do_after(user,(issmall(user) ? 20 : 34)))
climbers -= user
climb_dir = null // Reset climb_dir to null
opposite_dir = null // Reset opposite_dir to null
return

if (!can_climb(user, post_climb_check=1))
climb_dir = null // Reset climb_dir to null
opposite_dir = null // Reset opposite_dir to null
climbers -= user
return

user.forceMove(T)

if (get_turf(user) == T)
user.visible_message(SPAN_WARNING("[user] climbs onto \the [src]!"), SPAN_WARNING("You climb onto \the [src]!"))
if (istype(src, /obj/structure/table/glass))
var/obj/structure/table/glass/G = src
G.shatter()
climbers -= user
climb_dir = null // Reset climb_dir to null
opposite_dir = null // Reset opposite_dir to null

/obj/structure/proc/structure_shaken()
for (var/mob/living/M in climbers)
Expand Down
101 changes: 76 additions & 25 deletions code/game/turfs/floor_attackby.dm
Original file line number Diff line number Diff line change
Expand Up @@ -322,18 +322,35 @@
sandbag_time /= H.getStatCoeff("strength")
sandbag_time /= (H.getStatCoeff("crafting") * H.getStatCoeff("crafting"))

if (src == get_step(user, user.dir))
for(var/obj/O in src) // Checking if there's another dense object
if(O.density)
if(O.flags & ON_BORDER)
if(O.dir == user.dir)
to_chat(user, SPAN_WARNING("There is already \a [O.name] in this direction!"))
return
// Store the initial direction of the user
var/initial_direction = user.dir

if (src == get_step(user, initial_direction))
// Adjust direction to cardinal directions if intermediate directions are given
if (initial_direction & EAST)
initial_direction = EAST
else if (initial_direction & WEST)
initial_direction = WEST
// Check for objects in the same direction as the user
for (var/obj/O in src) // Checking if there's another dense object
if (O.density && O.flags & ON_BORDER && O.dir == initial_direction)
to_chat(user, SPAN_WARNING("There is already \a [O.name] in this direction!"))
return
user.visible_message("<span class='danger'>[user] starts constructing the base of a sandbag wall.</span>", "<span class='danger'>You start constructing the base of a sandbag wall.</span>")
if (do_after(user, sandbag_time, user.loc))
var/current_direction = user.dir
if (current_direction & EAST)
current_direction = EAST
else if (current_direction & WEST)
current_direction = WEST
// Recheck user's direction before creating the sandbag/incomplete
for (var/obj/O in src) // Checking user's direction again
if (O.density && O.flags & ON_BORDER && O.dir == current_direction)
to_chat(user, SPAN_WARNING("There is already \a [O.name] in this direction!"))
return
var/progress = bag.sand_amount
qdel(C)
var/obj/structure/window/barrier/sandbag/incomplete/sb = new/obj/structure/window/barrier/sandbag/incomplete(src, user)
var/obj/structure/window/barrier/sandbag/incomplete/sb = new/obj/structure/window/barrier/sandbag/incomplete(src, user, current_direction)
sb.progress = progress
user.visible_message("<span class='danger'>[user] finishes constructing the base of a sandbag wall. Anyone can now add to it.</span>", "<span class='notice'>You finish constructing the base of a sandbag wall. Anyone can now add to it.</span>")
if (ishuman(user))
Expand All @@ -342,27 +359,43 @@
return

else if (istype(C, /obj/item/weapon/barrier))

var/sandbag_time = 50

if (ishuman(user))
var/mob/living/human/H = user
sandbag_time /= H.getStatCoeff("strength")
sandbag_time /= (H.getStatCoeff("crafting") * H.getStatCoeff("crafting"))

if (src == get_step(user, user.dir))
for(var/obj/O in src) // Checking if there's another dense object
if(O.density)
if(O.flags & ON_BORDER)
if(O.dir == user.dir)
to_chat(user, SPAN_WARNING("There is already \a [O.name] in this direction!"))
return
// Store the initial direction of the user
var/initial_direction = user.dir

if (src == get_step(user, initial_direction))
// Adjust direction to cardinal directions if intermediate directions are given
if (initial_direction & EAST)
initial_direction = EAST
else if (initial_direction & WEST)
initial_direction = WEST
// Check for objects in the same direction as the user
for (var/obj/O in src) // Checking if there's another dense object
if (O.density && O.flags & ON_BORDER && O.dir == initial_direction)
to_chat(user, SPAN_WARNING("There is already \a [O.name] in this direction!"))
return
user.visible_message("<span class='danger'>[user] starts constructing the base of a dirt barricade.</span>", "<span class='danger'>You start constructing the base of a dirt barricade.</span>")
if (do_after(user, sandbag_time, user.loc))
// Recheck user's direction before creating the barrier
var/current_direction = user.dir
if (current_direction & EAST)
current_direction = EAST
else if (current_direction & WEST)
current_direction = WEST
for (var/obj/O in src) // Checking user's direction again
if (O.density && O.flags & ON_BORDER && O.dir == current_direction)
to_chat(user, SPAN_WARNING("There is already \a [O.name] in this direction!"))
return
var/obj/item/weapon/barrier/bag = C
var/progress = bag.sand_amount
qdel(C)
var/obj/structure/window/barrier/incomplete/sandbag = new/obj/structure/window/barrier/incomplete(src, user)
var/obj/structure/window/barrier/incomplete/sandbag = new/obj/structure/window/barrier/incomplete(src, user, current_direction)
sandbag.progress = progress
user.visible_message("<span class='danger'>[user] finishes constructing the base of a dirt barricade. Anyone can now add to it.</span>", "<span class='notice'>You finish constructing the base of a dirt barricade. Anyone can now add to it.</span>")
if (ishuman(user))
Expand All @@ -378,25 +411,43 @@
sandbag_time /= H.getStatCoeff("strength")
sandbag_time /= (H.getStatCoeff("crafting") * H.getStatCoeff("crafting"))

if (src == get_step(user, user.dir))
for(var/obj/O in src) // Checking if there's another dense object
if(O.density)
if(O.flags & ON_BORDER)
if(O.dir == user.dir)
to_chat(user, SPAN_WARNING("There is already \a [O.name] in this direction!"))
return
// Store the initial direction of the user
var/initial_direction = user.dir

if (src == get_step(user, initial_direction))
// Adjust direction to cardinal directions if intermediate directions are given
if (initial_direction & EAST)
initial_direction = EAST
else if (initial_direction & WEST)
initial_direction = WEST
// Check for objects in the same direction as the user
for (var/obj/O in src) // Checking if there's another dense object
if (O.density && O.flags & ON_BORDER && O.dir == initial_direction)
to_chat(user, SPAN_WARNING("There is already \a [O.name] in this direction!"))
return
user.visible_message("<span class='danger'>[user] starts constructing the base of a snow barricade.</span>", "<span class='danger'>You start constructing the base of a snow barricade.</span>")
if (do_after(user, sandbag_time, user.loc))
// Recheck user's direction before creating the snowwall
var/current_direction = user.dir
if (current_direction & EAST)
current_direction = EAST
else if (current_direction & WEST)
current_direction = WEST
for (var/obj/O in src) // Checking user's direction again
if (O.density && O.flags & ON_BORDER && O.dir == current_direction)
to_chat(user, SPAN_WARNING("There is already \a [O.name] in this direction!"))
return
var/obj/item/weapon/snowwall/bag = C
var/progress = bag.sand_amount
qdel(C)
var/obj/structure/window/barrier/snowwall/sandbag = new/obj/structure/window/barrier/snowwall/incomplete(src, user)
var/obj/structure/window/barrier/snowwall/sandbag = new/obj/structure/window/barrier/snowwall/incomplete(src, user, current_direction)
sandbag.progress = progress
user.visible_message("<span class='danger'>[user] finishes constructing the base of a snow barricade. Anyone can now add to it.</span>", "<span class='notice'>You finish constructing the base of a snow barricade. Anyone can now add to it.</span>")
if (ishuman(user))
var/mob/living/human/H = user
H.adaptStat("crafting", 3)
return

else if (istype(C, /obj/item/stack/farming/seeds) || istype(C, /obj/item/stack/medical/advanced/herbs))
var/mob/living/human/H = user
var/obj/item/stack/farming/seeds/TS
Expand Down
Loading

0 comments on commit 3e860bd

Please sign in to comment.