Skip to content

Commit

Permalink
bugfix: walking on tables (#4508)
Browse files Browse the repository at this point in the history
* bugfix: walking on tables

* bugfix: walking on tables

* bugfix: walking on tables

* bugfix: walking on tables

* add: climbing animation

Added climbing animation when climbing onto a structures.

* bugfix: climbing in clown shoes

Fixed animation of clown boots when on structures

* add: fall animation

Added fall animation if the mob was above the surface.

* add: hopping animation

Added hopping animation when a mob climbs over a fence and small bugfix.

* add: hopping animation

Added hopping animation when a mob climbs over a railing and small bugfix.

* bugfix: disables climb animation

Disables the climbing animation on fences with a medium hole.
The time of climbing through the hole is increased by 3 times (values taken from define).

* bugfix: walking on tables

Fixed the possibility of walking on tables.
Added the feature of climbing on the skeleton bar.
Now the table can be accessed from any structures that can be climbed.

* Update structures.dm

* Update tables_racks.dm

* bugfix: walking on tables

* bugfix: walking on tables

* bugfix: walking on tables

* bugfix: disables climb animation

* add: hopping animation

* bugfix: walking on tables

* bugfix: walking on tables

Fix drop doll on pulling action and destroy action.

* bugfix: move stuctures with mob

* refactor: changed 'usr' to 'user'

* refactor: changed 'usr' to 'user'

* refactor: changed 'usr' to 'user'

* refactor: changed 'usr' to 'user'

* bugfix: moving a tray table with something on it

* bugfix: table drop damage for anthropomorphs only

Животные теперь не умирают сидя на столе.

* bugfix: multi-person fall

Co-authored-by: Rerik007 <[email protected]>

* refactor: change <span> to proc

* bugfix: Oops!

* refactor: usr to user

* refactor: standardization

Co-authored-by: BeebBeebBoob <[email protected]>

---------

Co-authored-by: Rerik007 <[email protected]>
Co-authored-by: BeebBeebBoob <[email protected]>
  • Loading branch information
3 people authored Mar 14, 2024
1 parent 5b8943b commit 28dc080
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 63 deletions.
7 changes: 4 additions & 3 deletions code/datums/elements/waddling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
Waddle(target)

/datum/element/waddling/proc/Waddle(atom/movable/target)
animate(target, pixel_z = 4, time = 0)
var/current_pixel_z = target.pixel_z
animate(target, pixel_z = target.pixel_z + 4, time = 0)
var/prev_trans = matrix(target.transform)
animate(pixel_z = 0, transform = turn(target.transform, pick(-12, 0, 12)), time = 2)
animate(pixel_z = 0, transform = prev_trans, time = 0)
animate(pixel_z = target.pixel_z - 4, transform = turn(target.transform, pick(-12, 0, 12)), time = 2)
animate(pixel_z = current_pixel_z, transform = prev_trans, time = 0)
2 changes: 2 additions & 0 deletions code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@
if(isspaceturf(get_turf(user))) // Can't fall onto nothing.
return

user.pixel_z = initial(user.pixel_z)

if(user.m_intent == MOVE_INTENT_RUN)
user.Weaken(10 SECONDS)
else
Expand Down
155 changes: 106 additions & 49 deletions code/game/objects/structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
return ..()

/obj/structure/Destroy()
if(climbable)
structure_gone(src)
if(SSticker)
GLOB.cameranet.updateVisibility(src)
if(smooth)
Expand All @@ -49,14 +51,16 @@
if(!..())
return FALSE

if(climbable)
structure_gone(old)

if(creates_cover)
if(isturf(old))
REMOVE_TRAIT(old, TRAIT_TURF_COVERED, UNIQUE_TRAIT_SOURCE(src))
if(isturf(loc))
ADD_TRAIT(loc, TRAIT_TURF_COVERED, UNIQUE_TRAIT_SOURCE(src))
return TRUE


/obj/structure/has_prints()
return TRUE

Expand All @@ -79,6 +83,32 @@

do_climb(usr)

/obj/structure/proc/animate_jumping_off(mob/living/user)
if(!user.flying && user.mob_has_gravity())
var/delay = user.movement_delay()/4
sleep(delay)
animate(user, pixel_z = initial(user.pixel_z), time = 3, easing = BACK_EASING|EASE_IN)

/obj/structure/proc/animate_climb(mob/living/user)
if(!istype(user))
return
if(!user.checkpass(PASSTABLE) && !user.flying && user.mob_size > MOB_SIZE_SMALL)
var/delay = user.movement_delay()/2
sleep(delay)
animate(user, pixel_z = 16, time = 1, easing = LINEAR_EASING)
if(user.floating)
user.float(TRUE)

/obj/structure/Uncrossed(atom/movable/mover)
. = ..()
if(!istype(mover, /mob/living))
return
if(climbable)
var/turf/T = get_turf(mover)
var/obj/structure/other_structure = locate(/obj/structure) in T
if(!other_structure?.climbable)
animate_jumping_off(mover)

/obj/structure/MouseDrop_T(atom/movable/dropping, mob/user, params)
. = ..()
if(!. && dropping == user)
Expand All @@ -94,18 +124,28 @@
return T
return null

/obj/structure/proc/do_climb(var/mob/living/user)
/obj/structure/proc/climb_check(mob/living/user)
if(user.mob_size == MOB_SIZE_SMALL)
return FALSE
if(user.flying)
return FALSE
if(!can_touch(user) || !climbable)
return FALSE
var/blocking_object = density_check()
if(blocking_object)
to_chat(user, "<span class='warning'>You cannot climb [src], as it is blocked by \a [blocking_object]!</span>")
to_chat(user, span_warning("You cannot climb [src], as it is blocked by \a [blocking_object]!"))
return FALSE

var/turf/T = src.loc
if(!T || !istype(T)) return FALSE
if(!T || !istype(T))
return FALSE

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

/obj/structure/proc/do_climb(mob/living/user)
if(!climb_check(user))
return FALSE

user.visible_message(span_warning("[user] starts climbing onto \the [src]!"))
climber = user
if(!do_after(user, 50, target = src))
climber = null
Expand All @@ -115,12 +155,13 @@
climber = null
return FALSE

usr.loc = get_turf(src)
user.loc = get_turf(src)
animate_climb(user)

if(get_turf(user) == get_turf(src))
usr.visible_message("<span class='warning'>[user] climbs onto \the [src]!</span>")
user.visible_message(span_warning("[user] climbs onto \the [src]!"))

clumse_stuff(climber)

climber = null

return TRUE
Expand Down Expand Up @@ -165,49 +206,65 @@
AM.force /= force_mult
AM.throwforce /= force_mult

/obj/structure/proc/get_fall_damage(mob/living/L)
if(prob(25))

var/damage = rand(15,30)
var/mob/living/carbon/human/H = L
if(!istype(H))
to_chat(H, span_warning("You land heavily!"))
L.adjustBruteLoss(damage)
return

var/obj/item/organ/external/affecting

switch(pick(list("ankle","wrist","head","knee","elbow")))
if("ankle")
affecting = H.get_organ(pick(BODY_ZONE_PRECISE_L_FOOT, BODY_ZONE_PRECISE_R_FOOT))
if("knee")
affecting = H.get_organ(pick(BODY_ZONE_L_LEG, BODY_ZONE_R_LEG))
if("wrist")
affecting = H.get_organ(pick(BODY_ZONE_PRECISE_L_HAND, BODY_ZONE_PRECISE_R_HAND))
if("elbow")
affecting = H.get_organ(pick(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM))
if("head")
affecting = H.get_organ(BODY_ZONE_HEAD)

if(affecting)
to_chat(L, span_warning("You land heavily on your [affecting.name]!"))
affecting.receive_damage(damage, 0)
if(affecting.parent)
affecting.parent.add_autopsy_data("Misadventure", damage)
else
to_chat(H, span_warning("You land heavily!"))
H.adjustBruteLoss(damage)

H.UpdateDamageIcon()

/obj/structure/proc/structure_gone(atom/location)
for(var/mob/living/carbon/human/H in get_turf(location))
H.pixel_z = initial(H.pixel_z)
if(H.lying || H.mob_size <= MOB_SIZE_SMALL)
continue
to_chat(H, span_warning("You stop feeling \the [src] beneath your feet."))
if(H.m_intent == MOVE_INTENT_WALK)
H.Weaken(3 SECONDS)
if(H.m_intent == MOVE_INTENT_RUN)
H.Weaken(10 SECONDS)
get_fall_damage(H)

/obj/structure/proc/structure_shaken()

for(var/mob/living/M in get_turf(src))

if(M.lying) return //No spamming this on people.
if(M.lying)
continue //No spamming this on people.

M.Weaken(10 SECONDS)
to_chat(M, "<span class='warning'>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='warning'>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(BODY_ZONE_PRECISE_L_FOOT, BODY_ZONE_PRECISE_R_FOOT))
if("knee")
affecting = H.get_organ(pick(BODY_ZONE_L_LEG, BODY_ZONE_R_LEG))
if("wrist")
affecting = H.get_organ(pick(BODY_ZONE_PRECISE_L_HAND, BODY_ZONE_PRECISE_R_HAND))
if("elbow")
affecting = H.get_organ(pick(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM))
if("head")
affecting = H.get_organ(BODY_ZONE_HEAD)

if(affecting)
to_chat(M, "<span class='warning'>You land heavily on your [affecting.name]!</span>")
affecting.receive_damage(damage, 0)
if(affecting.parent)
affecting.parent.add_autopsy_data("Misadventure", damage)
else
to_chat(H, "<span class='warning'>You land heavily!</span>")
H.adjustBruteLoss(damage)

H.UpdateDamageIcon()
to_chat(M, span_warning("You topple as \the [src] moves under you!"))

get_fall_damage(M)

return

/obj/structure/proc/can_touch(mob/living/user)
Expand All @@ -229,14 +286,14 @@
. = ..()
if(!(resistance_flags & INDESTRUCTIBLE))
if(resistance_flags & ON_FIRE)
. += "<span class='warning'>It's on fire!</span>"
. += span_warning("It's on fire!")
if(broken)
. += "<span class='notice'>It appears to be broken.</span>"
. += span_notice("It appears to be broken.")
var/examine_status = examine_status(user)
if(examine_status)
. += examine_status
if(climbable)
. += "<span class='info'>You can <b>Click-Drag</b> someone to [src] to put them on the table after a short delay.</span>"
. += span_info("You can <b>Click-Drag</b> someone to [src] to put them on the structure after a short delay.")

/obj/structure/proc/examine_status(mob/user) //An overridable proc, mostly for falsewalls.
var/healthpercent = (obj_integrity/max_integrity) * 100
Expand All @@ -247,7 +304,7 @@
. += "It appears heavily damaged."
if(0 to 25)
if(!broken)
. += "<span class='warning'>It's falling apart!</span>"
. += span_warning("It's falling apart!")

/obj/structure/proc/prevents_buckled_mobs_attacking()
return FALSE
Expand Down
25 changes: 25 additions & 0 deletions code/game/objects/structures/fence.dm
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,31 @@
return TRUE
return FALSE

/obj/structure/fence/do_climb(mob/living/user)
if(!climb_check(user))
return FALSE

user.visible_message("<span class='warning'>[user] starts climbing onto \the [src]!</span>")
climber = user
if(!do_after(user, CLIMB_TIME, target = src))
climber = null
return FALSE

if(!can_touch(user) || !climbable)
climber = null
return FALSE

user.loc = get_turf(src)

if(get_turf(user) == get_turf(src))
user.visible_message("<span class='warning'>[user] climbs onto \the [src]!</span>")

clumse_stuff(climber)

climber = null

return TRUE

/*
Shock user with probability prb (if all connections & power are working)
Returns TRUE if shocked, FALSE otherwise
Expand Down
51 changes: 44 additions & 7 deletions code/game/objects/structures/railings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,53 @@
return TRUE
return FALSE

/obj/structure/railing/proc/hopping(mob/living/user)
if(!istype(user))
return
var/delay = user.movement_delay()/2
sleep(delay)
animate(user, pixel_z = 10, time = 3, easing = CIRCULAR_EASING|EASE_OUT)
delay = user.movement_delay()/4
sleep(delay)
animate(user, pixel_z = initial(user.pixel_z), time = 3, easing = CIRCULAR_EASING|EASE_OUT)
if(user.floating)
user.float(TRUE)

/obj/structure/railing/do_climb(mob/living/user)
if(!climb_check(user))
return FALSE

var/initial_mob_loc = get_turf(user)
. = ..()
if(.)
currently_climbed = TRUE
if(initial_mob_loc != get_turf(src)) // If we are on the railing, we want to move in the same dir as the railing. Otherwise we get put on the railing
currently_climbed = FALSE
return
user.Move(get_step(user, dir), TRUE)

user.visible_message("<span class='warning'>[user] starts climbing onto \the [src]!</span>")
climber = user
if(!do_after(user, 50, target = src))
climber = null
return FALSE

if(!can_touch(user) || !climbable)
climber = null
return FALSE

user.loc = get_turf(src)
hopping(user)

if(get_turf(user) == get_turf(src))
user.visible_message("<span class='warning'>[user] climbs onto \the [src]!</span>")

clumse_stuff(climber)

climber = null

currently_climbed = TRUE

if(initial_mob_loc != get_turf(src)) // If we are on the railing, we want to move in the same dir as the railing. Otherwise we get put on the railing
currently_climbed = FALSE
return TRUE
user.loc = get_step(user, dir)
currently_climbed = FALSE

return TRUE

/obj/structure/railing/proc/can_be_rotated(mob/user)
if(anchored)
Expand Down
Loading

0 comments on commit 28dc080

Please sign in to comment.