Skip to content

Commit

Permalink
gym fixes (BeeStation#12053)
Browse files Browse the repository at this point in the history
* gym fixes

fixes not being able to buckle to the weight lifting machines, their animations and the exercised status not giving stamina damage resistance

* fixes a related guillotine problem

fixes the offset not being applied properly

* makes the gym stuff constructable

* forgor about destroy()

* removes the frame since it's a bit overcomplicated
  • Loading branch information
BarteG44 authored Dec 22, 2024
1 parent cad16b2 commit 25c1f78
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 26 deletions.
20 changes: 20 additions & 0 deletions code/datums/components/crafting/crafting_lists/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@
parts = list(/obj/item/camera = 1)
category = CAT_MISC

/datum/crafting_recipe/barbell
name = "Barbell"
result = /obj/item/barbell
time = 2 SECONDS
reqs = list(
/obj/item/stack/sheet/iron = 4,
/obj/item/stack/rods = 2,
)
category = CAT_MISC

/datum/crafting_recipe/chestpress
name = "Chest press handle"
result = /obj/item/barbell/stacklifting
time = 2 SECONDS
reqs = list(
/obj/item/stack/sheet/iron = 4,
/obj/item/stack/rods = 2,
)
category = CAT_MISC

/datum/crafting_recipe/lizardhat
name = "Lizard Cloche Hat"
result = /obj/item/clothing/head/costume/lizard
Expand Down
37 changes: 37 additions & 0 deletions code/datums/components/crafting/crafting_lists/structures.dm
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,40 @@
category = CAT_STRUCTURE
one_per_turf = TRUE

/datum/crafting_recipe/weightmachine
name = "Chest press machine"
result = /obj/structure/weightmachine
time = 6 SECONDS
reqs = list(
/obj/item/stack/sheet/iron = 2,
/obj/item/stack/rods = 6,
/obj/item/barbell/stacklifting = 1,
)
tools = list(TOOL_SCREWDRIVER, TOOL_WRENCH)
category = CAT_STRUCTURE
one_per_turf = TRUE

/datum/crafting_recipe/weightmachine/weightlifter
name = "Inline bench press"
result = /obj/structure/weightmachine/weightlifter
time = 6 SECONDS
reqs = list(
/obj/item/stack/sheet/iron = 2,
/obj/item/stack/rods = 6,
/obj/item/barbell = 1,
)
tools = list(TOOL_SCREWDRIVER, TOOL_WRENCH)
category = CAT_STRUCTURE
one_per_turf = TRUE

/datum/crafting_recipe/punching_bag
name = "Punching bag"
result = /obj/structure/punching_bag
time = 6 SECONDS
reqs = list(
/obj/item/stack/sheet/cotton/cloth = 10,
)
tools = list(TOOL_WIRECUTTER)
category = CAT_STRUCTURE
one_per_turf = TRUE

10 changes: 7 additions & 3 deletions code/game/objects/buckling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
*/
/atom/movable/proc/mouse_buckle_handling(mob/living/M, mob/living/user)
if(can_buckle && istype(M) && istype(user))
return user_buckle_mob(M, user)
return user_buckle_mob(M, user, check_loc = FALSE)

// Mobs have custom behaviour for buckling
/mob/mouse_buckle_handling(mob/living/M, mob/living/user)
Expand All @@ -92,10 +92,14 @@
* force - Set to TRUE to ignore src's can_buckle and M's can_buckle_to
* check_loc - Set to FALSE to allow buckling from adjacent turfs, or TRUE if buckling is only allowed with src and M on the same turf.
*/
/atom/movable/proc/buckle_mob(mob/living/M, force = FALSE, check_loc = TRUE)
/atom/movable/proc/buckle_mob(mob/living/M, force = FALSE, check_loc = TRUE, needs_anchored = FALSE)
if(!buckled_mobs)
buckled_mobs = list()

if(!anchored && needs_anchored)
to_chat(M, "<span class='warning'>Secure [src] first!</span>")
return FALSE

if(!is_buckle_possible(M, force, check_loc))
return FALSE

Expand Down Expand Up @@ -131,7 +135,7 @@
SEND_SIGNAL(src, COMSIG_MOVABLE_BUCKLE, M, force)
return TRUE

/obj/buckle_mob(mob/living/M, force = FALSE, check_loc = TRUE)
/obj/buckle_mob(mob/living/M, force = FALSE, check_loc = TRUE, needs_anchored = FALSE)
. = ..()
if(.)
if(resistance_flags & ON_FIRE) //Sets the mob on fire if you buckle them to a burning atom/movableect
Expand Down
8 changes: 3 additions & 5 deletions code/game/objects/structures/guillotine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
if (istype(S))
H.cut_overlays()
H.update_body_parts_head_only()
H.pixel_y += -GUILLOTINE_HEAD_OFFSET // Offset their body so it looks like they're in the guillotine
H.pixel_y -= GUILLOTINE_HEAD_OFFSET // Offset their body so it looks like they're in the guillotine
H.layer += GUILLOTINE_LAYER_DIFF
else
unbuckle_all_mobs()
Expand All @@ -212,12 +212,10 @@
else
unbuckle_all_mobs()

..()

/obj/structure/guillotine/post_unbuckle_mob(mob/living/M)
M.regenerate_icons()
M.pixel_y -= -GUILLOTINE_HEAD_OFFSET // Move their body back
M.layer -= GUILLOTINE_LAYER_DIFF
M.pixel_y = M.base_pixel_y // Move their body back
M.layer = MOB_LAYER
..()

/obj/structure/guillotine/can_be_unfasten_wrench(mob/user, silent)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/gym/exercise_status.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

/datum/status_effect/exercised/on_creation(mob/living/new_owner, exercise_amount)
src.exercise_amount = exercise_amount * EXERCISE_INCREMENT
update_exercise()
return ..()

/datum/status_effect/exercised/merge(exercise_amount)
Expand Down Expand Up @@ -49,6 +48,7 @@
var/delta = exercise_amount - applied_amount
var/mob/living/carbon/human/human_owner = owner
human_owner.physiology.stun_add -= delta
human_owner.physiology.stamina_mod -= delta
applied_amount = exercise_amount
switch (exercise_amount)
if (0.3 to 0.5)
Expand Down
7 changes: 7 additions & 0 deletions code/game/objects/structures/gym/punching_bag.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@
SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, "exercise", /datum/mood_event/exercise)
user.apply_status_effect(STATUS_EFFECT_EXERCISED, 1)

/obj/structure/punching_bag/wirecutter_act(mob/living/user, obj/item/I)
to_chat(user, "<span class='notice'>You begin to cut [src] apart...</span>")
if(I.use_tool(src, user, 40, volume=50))
to_chat(user, "<span class='notice'>You cut [src] apart.</span>")
new /obj/item/stack/sheet/cotton/cloth(loc, 10)
qdel(src)
return TRUE
80 changes: 63 additions & 17 deletions code/game/objects/structures/gym/weight_machine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
density = TRUE
anchored = TRUE
blocks_emissive = EMISSIVE_BLOCK_UNIQUE
var/mutable_appearance/overlay
var/weight_type = /obj/item/barbell/stacklifting

///How much we shift the user's pixel y when using the weight machine.
var/pixel_shift_y = -3
Expand Down Expand Up @@ -41,42 +43,61 @@

/obj/structure/weightmachine/Initialize(mapload)
. = ..()

overlay = mutable_appearance(icon, "[base_icon_state]-s")
src.add_overlay(overlay)
weight_action = new(src)
weight_action.weightpress = src

/obj/structure/weightmachine/Destroy()
new /obj/item/stack/sheet/iron(loc, 2)
new /obj/item/stack/rods(loc, 6)
new weight_type(loc)
unbuckle_all_mobs()
QDEL_NULL(weight_action)
qdel(overlay)
return ..()

/obj/structure/weightmachine/buckle_mob(mob/living/buckled, force, check_loc)
/obj/structure/weightmachine/wrench_act(mob/living/user, obj/item/I)
if (default_unfasten_wrench(user, I, 50) == 2 && anchored)
setDir(SOUTH)
unbuckle_all_mobs()
return TRUE

/obj/structure/weightmachine/screwdriver_act(mob/living/user, obj/item/I)
to_chat(user, "<span class='notice'>You begin to take apart [src]...</span>")
if(I.use_tool(src, user, 40, volume=50))
to_chat(user, "<span class='notice'>You deconstruct [src].</span>")
qdel(src)
return TRUE

/obj/structure/weightmachine/buckle_mob(mob/living/buckled, force, check_loc, needs_anchored = TRUE)
. = ..()
weight_action.Grant(buckled)

// /obj/structure/weightmachine/post_buckle_mob(mob/living/buckled)
// add_overlay("[base_icon_state]-e")
// layer = ABOVE_MOB_LAYER
/obj/structure/weightmachine/post_buckle_mob(mob/living/buckled)
weight_action.Grant(buckled)
buckled.add_overlay(overlay)
src.cut_overlay(overlay)

/obj/structure/weightmachine/unbuckle_mob(mob/living/buckled_mob, force, can_fall)
. = ..()
src.add_overlay(overlay)
buckled_mob.cut_overlay(overlay)
weight_action.Remove(buckled_mob)

// /obj/structure/weightmachine/post_unbuckle_mob(mob/living/buckled)
// cut_overlays()

/obj/structure/weightmachine/proc/perform_workout(mob/living/user)
user.balloon_alert_to_viewers("[pick(more_weight)]")
START_PROCESSING(SSobj, src)
if(do_after(user, 8 SECONDS, src) && user.has_gravity())
user.Stun(2 SECONDS)
user.Stun(0.5 SECONDS)
if(issilicon(user) || isipc(user)) //IPCs don't have muscle mass... i think
user.balloon_alert(user, pick(finished_silicon_message))
else
user.balloon_alert(user, pick(finished_message))
if (user.client)
user.client.give_award(/datum/award/achievement/misc/weights, user)
SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, "exercise", /datum/mood_event/exercise)
user.apply_status_effect(STATUS_EFFECT_EXERCISED, 10)
if(ishuman(user))
SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, "exercise", /datum/mood_event/exercise)
user.apply_status_effect(STATUS_EFFECT_EXERCISED, 40)
end_workout()

/obj/structure/weightmachine/proc/end_workout()
Expand All @@ -88,12 +109,8 @@
if(!has_buckled_mobs())
end_workout()
return FALSE
var/image/workout = image(icon, "[base_icon_state]-o", layer = ABOVE_MOB_LAYER)
workout.plane = GAME_PLANE //I hate the plane cube
workout.layer = FLY_LAYER
flick_overlay_view(workout,0.8 SECONDS)
flick("[base_icon_state]-u", src)
var/mob/living/user = buckled_mobs[1]
flick("[base_icon_state]-u", src)
animate(user, pixel_y = pixel_shift_y, time = 4, SINE_EASING)
playsound(user, 'sound/machines/creak.ogg', 60, TRUE)
animate(pixel_y = user.base_pixel_y, time = 4, SINE_EASING)
Expand All @@ -109,3 +126,32 @@
icon_state = "benchpress"
base_icon_state = "benchpress"
pixel_shift_y = 5
weight_type = /obj/item/barbell

/obj/item/barbell
name = "barbell"
desc = "A long bar with some huge weights on the ends. Very impressive."
icon = 'icons/obj/fitness.dmi'
icon_state = "barbell"
lefthand_file = 'icons/mob/inhands/equipment/weightlifting.dmi'
righthand_file = 'icons/mob/inhands/equipment/weightlifting.dmi'
flags_1 = CONDUCT_1
force = 16
throwforce = 16
block_flags = BLOCKING_ACTIVE | BLOCKING_NASTY
attack_weight = 2
w_class = WEIGHT_CLASS_HUGE
item_flags = SLOWS_WHILE_IN_HAND
custom_materials = list(/datum/material/iron=10000)
throw_speed = 1
throw_range = 2
slowdown = 2

/obj/item/barbell/ComponentInitialize()
. = ..()
AddComponent(/datum/component/two_handed, require_twohands=TRUE, block_power_unwielded=block_power, block_power_wielded=block_power)

/obj/item/barbell/stacklifting
name = "chest press handle"
desc = "A handle that attaches to some heavy weights. Looks complicated."
icon_state = "chestpress"
Binary file added icons/mob/inhands/equipment/weightlifting.dmi
Binary file not shown.
Binary file modified icons/obj/fitness.dmi
Binary file not shown.

0 comments on commit 25c1f78

Please sign in to comment.