dynamic climbing and object heights (#5692)

Co-authored-by: silicons <no@you.cat>
This commit is contained in:
silicons
2023-07-17 22:39:51 +02:00
committed by GitHub
co-authored by silicons
parent 01ae927798
commit 0dee8a0ace
39 changed files with 352 additions and 273 deletions
+3 -120
View File
@@ -5,11 +5,7 @@
// todo: rename to default_unanchor, allow generic structure unanchoring.
var/allow_unanchor = FALSE
var/climbable
var/climb_delay = 3.5 SECONDS
var/breakable
var/list/climbers = list()
var/breakable = FALSE
var/list/connections
var/list/other_connections
@@ -19,9 +15,6 @@
/obj/structure/Initialize(mapload)
. = ..()
if(climbable)
add_obj_verb(src, /obj/structure/proc/climb_on)
if(smoothing_flags & (SMOOTH_CORNERS|SMOOTH_BITMASK))
QUEUE_SMOOTH(src)
QUEUE_SMOOTH_NEIGHBORS(src)
@@ -48,11 +41,6 @@
if(H.species.can_shred(user))
attack_generic(user,1,"slices")
if(climbers.len && !(user in climbers))
user.visible_message("<span class='warning'>[user.name] shakes \the [src].</span>", \
"<span class='notice'>You shake \the [src].</span>")
structure_shaken()
return ..()
/obj/structure/attack_tk()
@@ -70,122 +58,17 @@
if(3.0)
return
/obj/structure/proc/climb_on()
set name = "Climb structure"
set desc = "Climbs onto a structure."
set category = "Object"
set src in oview(1)
do_climb(usr)
/obj/structure/MouseDroppedOnLegacy(mob/target, mob/user)
var/mob/living/H = user
if(istype(H) && can_climb(H) && target == user)
do_climb(target)
else
return ..()
/obj/structure/proc/can_climb(var/mob/living/user, post_climb_check=0)
if (!climbable || !can_touch(user) || (!post_climb_check && (user in climbers)))
return 0
if (!user.Adjacent(src))
to_chat(user, "<span class='danger'>You can't climb there, the way is blocked.</span>")
return 0
var/obj/occupied = turf_is_crowded()
if(occupied)
to_chat(user, "<span class='danger'>There's \a [occupied] in the way.</span>")
return 0
return 1
/obj/structure/proc/turf_is_crowded()
var/turf/T = get_turf(src)
if(!T || !istype(T))
return 0
for(var/obj/O in T.contents)
if(istype(O,/obj/structure))
var/obj/structure/S = O
if(S.climbable) continue
if(O.climb_allowed)
continue
if(O && O.density && !(O.atom_flags & ATOM_BORDER)) //ATOM_BORDER structures are handled by the Adjacent() check.
return O
return 0
// todo: climbable obj-level (to avoid element/signal spam)
/obj/structure/proc/do_climb(var/mob/living/user)
if (!can_climb(user))
return
usr.visible_message("<span class='warning'>[user] starts climbing onto \the [src]!</span>")
climbers |= user
if(!do_after(user, issmall(user) ? climb_delay * 0.6 : climb_delay, src, mobility_flags = MOBILITY_CAN_MOVE | MOBILITY_CAN_USE))
climbers -= user
return
if (!can_climb(user, post_climb_check=1))
climbers -= user
return
var/old = pass_flags & (ATOM_PASS_BUCKLED)
pass_flags |= ATOM_PASS_BUCKLED
usr.locationTransitForceMove(get_turf(src), allow_buckled = TRUE, allow_pulled = FALSE, allow_grabbed = TRUE)
pass_flags = (pass_flags & ~(ATOM_PASS_BUCKLED)) | (old & ATOM_PASS_BUCKLED)
if (get_turf(user) == get_turf(src))
usr.visible_message("<span class='warning'>[user] climbs onto \the [src]!</span>")
climbers -= user
/obj/structure/proc/structure_shaken()
for(var/mob/living/M in climbers)
M.afflict_paralyze(20 * 1)
to_chat(M, "<span class='danger'>You topple as you are shaken off \the [src]!</span>")
climbers.Cut(1,2)
for(var/mob/living/M in get_turf(src))
if(M.lying) return //No spamming this on people.
M.afflict_paralyze(20 * 3)
to_chat(M, "<span class='danger'>You topple as \the [src] moves under you!</span>")
if(prob(25))
var/damage = rand(15,30)
var/mob/living/carbon/human/H = M
if(!istype(H))
to_chat(H, "<span class='danger'>You land heavily!</span>")
M.adjustBruteLoss(damage)
return
var/obj/item/organ/external/affecting
switch(pick(list("ankle","wrist","head","knee","elbow")))
if("ankle")
affecting = H.get_organ(pick(BP_L_FOOT, BP_R_FOOT))
if("knee")
affecting = H.get_organ(pick(BP_L_LEG, BP_R_LEG))
if("wrist")
affecting = H.get_organ(pick(BP_L_HAND, BP_R_HAND))
if("elbow")
affecting = H.get_organ(pick(BP_L_ARM, BP_R_ARM))
if("head")
affecting = H.get_organ(BP_HEAD)
if(affecting)
to_chat(M, "<span class='danger'>You land heavily on your [affecting.name]!</span>")
affecting.take_damage(damage, 0)
if(affecting.parent)
affecting.parent.add_autopsy_data("Misadventure", damage)
else
to_chat(H, "<span class='danger'>You land heavily!</span>")
H.adjustBruteLoss(damage)
H.UpdateDamageIcon()
H.update_health()
return
// todo: remove
/obj/structure/proc/can_touch(var/mob/user)
if (!user)