Skip to content

Commit 3e7b639

Browse files
authored
improvements to equipment slowdown (#1095)
1 parent 41356d7 commit 3e7b639

File tree

17 files changed

+72
-3
lines changed

17 files changed

+72
-3
lines changed

code/__DEFINES/inventory.dm

+8
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ GLOBAL_LIST_INIT(security_wintercoat_allowed, typecacheof(list(
240240
#define EQUIP_DELAY_OVERSUIT (7 SECONDS)
241241
/// Delay base for things like coats that are trivially removed or put on.
242242
#define EQUIP_DELAY_COAT (2 SECONDS)
243+
/// Delay base for masks
244+
#define EQUIP_DELAY_MASK (1 SECONDS)
243245
/// Delay base for back-worn objects.
244246
#define EQUIP_DELAY_BACK (2 SECONDS)
245247
/// Delay base for belts.
@@ -248,3 +250,9 @@ GLOBAL_LIST_INIT(security_wintercoat_allowed, typecacheof(list(
248250
#define EQUIP_DELAY_GLOVES (1 SECONDS)
249251
/// Delay base for shoes.
250252
#define EQUIP_DELAY_SHOES (1 SECONDS)
253+
254+
// Flags for self equipping items
255+
/// Allow movement during equip/unequip
256+
#define EQUIP_ALLOW_MOVEMENT (1<<0)
257+
/// Apply a slowdown when equipping or unequipping.
258+
#define EQUIP_SLOWDOWN (1<<1)

code/__DEFINES/traits.dm

+3
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
447447
*/
448448
#define TRAIT_DONUT_LOVER "donut_lover"
449449

450+
/// Equipping or unequipping an item
451+
#define TRAIT_EQUIPPING_OR_UNEQUIPPING "equipping_or_unequipping"
452+
450453
/// `do_teleport` will not allow this atom to teleport
451454
#define TRAIT_NO_TELEPORT "no-teleport"
452455

code/game/objects/items.dm

+2
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ DEFINE_INTERACTABLE(/obj/item)
158158
var/weak_against_armor = null
159159
///What objects the suit storage can store
160160
var/list/allowed = null
161+
/// Flags for equipping/unequipping items, only applies to self manipulation.
162+
var/equip_self_flags = EQUIP_ALLOW_MOVEMENT | EQUIP_SLOWDOWN
161163
///In deciseconds, how long an item takes to equip; counts only for normal clothing slots, not pockets etc.
162164
var/equip_delay_self = 0
163165
///In deciseconds, how long an item takes to put on another person

code/game/objects/items/food/deepfried.dm

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
desc = fried.desc
3434
w_class = fried.w_class
3535
slowdown = fried.slowdown
36+
equip_self_flags = fried.equip_self_flags
3637
equip_delay_self = fried.equip_delay_self
3738
equip_delay_other = fried.equip_delay_other
3839
strip_delay = fried.strip_delay

code/modules/clothing/gloves/_gloves.dm

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
attack_verb_continuous = list("challenges")
1313
attack_verb_simple = list("challenge")
1414

15+
equip_delay_self = EQUIP_ALLOW_MOVEMENT
1516
equip_delay_self = EQUIP_DELAY_GLOVES
1617
equip_delay_other = EQUIP_DELAY_GLOVES + (3 SECONDS)
1718
strip_delay = EQUIP_DELAY_GLOVES + (3 SECONDS)

code/modules/clothing/masks/_masks.dm

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
equip_delay_other = 40
88
supports_variations_flags = CLOTHING_SNOUTED_VARIATION | CLOTHING_VOX_VARIATION
99

10+
equip_delay_self = EQUIP_DELAY_MASK
11+
equip_delay_other = EQUIP_DELAY_MASK * 1.5
12+
strip_delay = EQUIP_DELAY_MASK * 1.5
13+
1014
var/modifies_speech = FALSE
1115
var/mask_adjusted = FALSE
1216
var/adjusted_flags = null

code/modules/clothing/shoes/_shoes.dm

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
permeability_coefficient = 0.5
1515
slowdown = 0
1616

17+
equip_self_flags = NONE
1718
equip_delay_self = EQUIP_DELAY_SHOES
1819
equip_delay_other = EQUIP_DELAY_SHOES * 1.5
1920
strip_delay = EQUIP_DELAY_SHOES // In stripping code, if the mob is standing, it adds additional time.

code/modules/clothing/suits/_suits.dm

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
drop_sound = 'sound/items/handling/cloth_drop.ogg'
1212
pickup_sound = 'sound/items/handling/cloth_pickup.ogg'
1313

14+
equip_self_flags = NONE
1415
equip_delay_self = EQUIP_DELAY_OVERSUIT
1516
equip_delay_other = EQUIP_DELAY_OVERSUIT * 1.5
1617
strip_delay = EQUIP_DELAY_OVERSUIT * 1.5

code/modules/clothing/suits/chaplainsuits.dm

+2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
/obj/item/clothing/suit/chaplainsuit
44
allowed = list(/obj/item/storage/book/bible, /obj/item/nullrod, /obj/item/reagent_containers/food/drinks/bottle/holywater, /obj/item/storage/fancy/candle_box, /obj/item/candle, /obj/item/tank/internals/emergency_oxygen, /obj/item/tank/internals/plasmaman)
55

6+
equip_self_flags = EQUIP_ALLOW_MOVEMENT | EQUIP_SLOWDOWN
67
equip_delay_self = EQUIP_DELAY_COAT
78
equip_delay_other = EQUIP_DELAY_COAT * 1.5
89
strip_delay = EQUIP_DELAY_COAT * 1.5
910

1011
/obj/item/clothing/suit/hooded/chaplainsuit
1112
allowed = list(/obj/item/storage/book/bible, /obj/item/nullrod, /obj/item/reagent_containers/food/drinks/bottle/holywater, /obj/item/storage/fancy/candle_box, /obj/item/candle, /obj/item/tank/internals/emergency_oxygen, /obj/item/tank/internals/plasmaman)
1213

14+
equip_self_flags = EQUIP_ALLOW_MOVEMENT | EQUIP_SLOWDOWN
1315
equip_delay_self = EQUIP_DELAY_COAT
1416
equip_delay_other = EQUIP_DELAY_COAT * 1.5
1517
strip_delay = EQUIP_DELAY_COAT * 1.5

code/modules/clothing/suits/cloaks.dm

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
body_parts_covered = CHEST|GROIN|LEGS|ARMS
1313
flags_inv = HIDESUITSTORAGE
1414

15+
equip_self_flags = EQUIP_ALLOW_MOVEMENT | EQUIP_SLOWDOWN
1516
equip_delay_self = EQUIP_DELAY_COAT
1617
equip_delay_other = EQUIP_DELAY_COAT * 1.5
1718
strip_delay = EQUIP_DELAY_COAT * 1.5

code/modules/clothing/suits/jacket.dm

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
supports_variations_flags = CLOTHING_DIGITIGRADE_VARIATION | CLOTHING_TESHARI_VARIATION | CLOTHING_VOX_VARIATION
1212

13+
equip_self_flags = EQUIP_ALLOW_MOVEMENT | EQUIP_SLOWDOWN
1314
equip_delay_self = EQUIP_DELAY_COAT
1415
equip_delay_other = EQUIP_DELAY_COAT * 1.5
1516
strip_delay = EQUIP_DELAY_COAT * 1.5

code/modules/clothing/suits/jobs.dm

+6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454

5555
supports_variations_flags = CLOTHING_DIGITIGRADE_VARIATION | CLOTHING_TESHARI_VARIATION | CLOTHING_VOX_VARIATION
5656

57+
equip_self_flags = EQUIP_ALLOW_MOVEMENT | EQUIP_SLOWDOWN
5758
equip_delay_self = EQUIP_DELAY_COAT
5859
equip_delay_other = EQUIP_DELAY_COAT * 1.5
5960
strip_delay = EQUIP_DELAY_COAT * 1.5
@@ -80,6 +81,7 @@
8081
heat_protection = CHEST|GROIN|LEGS|ARMS
8182
supports_variations_flags = CLOTHING_DIGITIGRADE_VARIATION | CLOTHING_TESHARI_VARIATION | CLOTHING_VOX_VARIATION
8283

84+
equip_self_flags = EQUIP_ALLOW_MOVEMENT | EQUIP_SLOWDOWN
8385
equip_delay_self = EQUIP_DELAY_COAT
8486
equip_delay_other = EQUIP_DELAY_COAT * 1.5
8587
strip_delay = EQUIP_DELAY_COAT * 1.5
@@ -115,6 +117,7 @@
115117

116118
supports_variations_flags = CLOTHING_DIGITIGRADE_VARIATION_NO_NEW_ICON | CLOTHING_TESHARI_VARIATION | CLOTHING_VOX_VARIATION
117119

120+
equip_self_flags = EQUIP_ALLOW_MOVEMENT | EQUIP_SLOWDOWN
118121
equip_delay_self = EQUIP_DELAY_COAT
119122
equip_delay_other = EQUIP_DELAY_COAT * 1.5
120123
strip_delay = EQUIP_DELAY_COAT * 1.5
@@ -133,6 +136,7 @@
133136
blood_overlay_type = "coat"
134137
body_parts_covered = CHEST|ARMS
135138

139+
equip_self_flags = EQUIP_ALLOW_MOVEMENT | EQUIP_SLOWDOWN
136140
equip_delay_self = EQUIP_DELAY_COAT
137141
equip_delay_other = EQUIP_DELAY_COAT * 1.5
138142
strip_delay = EQUIP_DELAY_COAT * 1.5
@@ -239,6 +243,7 @@
239243
cold_protection = CHEST|ARMS
240244
heat_protection = CHEST|ARMS
241245

246+
equip_self_flags = EQUIP_ALLOW_MOVEMENT | EQUIP_SLOWDOWN
242247
equip_delay_self = EQUIP_DELAY_COAT
243248
equip_delay_other = EQUIP_DELAY_COAT * 1.5
244249
strip_delay = EQUIP_DELAY_COAT * 1.5
@@ -284,6 +289,7 @@
284289
armor = list(BLUNT = 0, PUNCTURE = 0, SLASH = 0, LASER = 0, ENERGY = 0, BOMB = 0, BIO = 50, FIRE = 50, ACID = 50)
285290
supports_variations_flags = CLOTHING_TESHARI_VARIATION
286291

292+
equip_self_flags = EQUIP_ALLOW_MOVEMENT | EQUIP_SLOWDOWN
287293
equip_delay_self = EQUIP_DELAY_COAT
288294
equip_delay_other = EQUIP_DELAY_COAT * 1.5
289295
strip_delay = EQUIP_DELAY_COAT * 1.5

code/modules/clothing/suits/labcoat.dm

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
supports_variations_flags = CLOTHING_DIGITIGRADE_VARIATION_NO_NEW_ICON | CLOTHING_TESHARI_VARIATION | CLOTHING_VOX_VARIATION
3030

31+
equip_self_flags = EQUIP_ALLOW_MOVEMENT | EQUIP_SLOWDOWN
3132
equip_delay_self = EQUIP_DELAY_COAT
3233
equip_delay_other = EQUIP_DELAY_COAT * 1.5
3334
strip_delay = EQUIP_DELAY_COAT * 1.5

code/modules/clothing/suits/toggles.dm

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/obj/item/clothing/suit/hooded
44
actions_types = list(/datum/action/item_action/toggle_hood)
55

6+
equip_self_flags = EQUIP_ALLOW_MOVEMENT | EQUIP_SLOWDOWN
67
equip_delay_self = EQUIP_DELAY_COAT
78
equip_delay_other = EQUIP_DELAY_COAT * 1.5
89
strip_delay = EQUIP_DELAY_COAT * 1.5

code/modules/clothing/under/_under.dm

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
drop_sound = 'sound/items/handling/cloth_drop.ogg'
1616
pickup_sound = 'sound/items/handling/cloth_pickup.ogg'
1717

18+
equip_self_flags = NONE
1819
equip_delay_self = EQUIP_DELAY_UNDERSUIT
1920
equip_delay_other = EQUIP_DELAY_UNDERSUIT * 1.5
2021
strip_delay = EQUIP_DELAY_UNDERSUIT * 1.5

code/modules/mob/inventory.dm

+35-3
Original file line numberDiff line numberDiff line change
@@ -660,14 +660,46 @@
660660
span_notice("[src] starts to put on [I]..."),
661661
span_notice("You start to put on [I]...")
662662
)
663-
return do_after(src, src, I.equip_delay_self, DO_PUBLIC, display = I)
663+
664+
. = I.do_equip_wait(src)
665+
666+
if(.)
667+
visible_message(
668+
span_notice("[src] puts on [I]."),
669+
span_notice("You put on [I].")
670+
)
664671

665672
/mob/living/carbon/human/unequip_delay_self_check(obj/item/I)
666673
if(!I.equip_delay_self || is_holding(I))
667674
return TRUE
668675

669676
visible_message(
670677
span_notice("[src] starts to take off [I]..."),
671-
span_notice("You start to take off [I]...")
678+
span_notice("You start to take off [I]..."),
672679
)
673-
return do_after(src, src, I.equip_delay_self, DO_PUBLIC, display = I)
680+
681+
. = I.do_equip_wait(src)
682+
683+
if(.)
684+
visible_message(
685+
span_notice("[src] takes off [I]."),
686+
span_notice("You takes off [I].")
687+
)
688+
689+
/// Called by equip_delay_self and unequip_delay_self.
690+
/obj/item/proc/do_equip_wait(mob/living/L)
691+
var/flags = DO_PUBLIC
692+
if(equip_self_flags & EQUIP_ALLOW_MOVEMENT)
693+
flags |= IGNORE_USER_LOC_CHANGE | IGNORE_TARGET_LOC_CHANGE
694+
695+
if(equip_self_flags & EQUIP_SLOWDOWN)
696+
L.add_movespeed_modifier(/datum/movespeed_modifier/equipping)
697+
698+
ADD_TRAIT(L, TRAIT_EQUIPPING_OR_UNEQUIPPING, ref(src))
699+
700+
. = do_after(L, L, equip_delay_self, flags, display = src)
701+
702+
REMOVE_TRAIT(L, TRAIT_EQUIPPING_OR_UNEQUIPPING, ref(src))
703+
704+
if(!HAS_TRAIT(L, TRAIT_EQUIPPING_OR_UNEQUIPPING))
705+
L.remove_movespeed_modifier(/datum/movespeed_modifier/equipping)

code/modules/movespeed/modifiers/items.dm

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616

1717
/datum/movespeed_modifier/sphere
1818
slowdown = -0.5
19+
20+
/datum/movespeed_modifier/equipping
21+
slowdown = 1.5

0 commit comments

Comments
 (0)