Skip to content

Commit

Permalink
Equip Delay (#3854)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
It now takes a moment to remove or equip clothing, triggering a do_after
that places the item in the appropriate slot once completed.

Base times are as follows:

![image](https://github.com/user-attachments/assets/962a8ebd-df09-4fb8-88de-2d65b443c055)

You can move while equipping some lighter items, but it slows you down.

Please thank @Kapu1178 for writing the better code in this pr, their
work can also be found in [This
PR](DaedalusDock/daedalusdock#1093)

Comes with functionality for more sound effects being plugged in for
different types of items.

KNOWN ISSUES:

- [x] Equip noises can be spammed by repeatedly clicking during the
do_after

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game
My immersion
More importance in picking the right gear for different situations. You
can no longer hotswap in and out of stuff like spacesuits instantly,
think a little more carefully about when to put them on.
<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding. -->

## Changelog

:cl: Kapu1178
add: There is now a customizable delay for equipping and unequipping
items from clothing slots.
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
Sun-Soaked authored Jan 6, 2025
1 parent 032c07d commit c954d22
Show file tree
Hide file tree
Showing 63 changed files with 572 additions and 54 deletions.
50 changes: 50 additions & 0 deletions code/__DEFINES/clothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,53 @@
/// How much integrity does a shirt lose every time we bite it?
#define MOTH_EATING_CLOTHING_DAMAGE 15
*/

// Base equipment delays
/// Delay base for full-body coverage suit slot items. (hardsuits, spacesuits, radsuits, etc.)
#define EQUIP_DELAY_OVERSUIT (6 SECONDS)

/// Delay base for suit slot items
#define EQUIP_DELAY_SUIT (4 SECONDS)

/// Delay base for hard-body shoes and boots.
#define EQUIP_DELAY_BOOTS (2 SECONDS)
/// Delay base for hard-body, strapped, or otherwise head-covering hats.
#define EQUIP_DELAY_HELMET (2 SECONDS)
/// Delay base for shoes.
#define EQUIP_DELAY_SHOES (2 SECONDS)
/// Delay base for suit and cloak slot items that are trivially removed or put on. (Coats, Jackets, Ponchos, etc.)
#define EQUIP_DELAY_COAT (2 SECONDS)
/// Delay base for Undersuits.
#define EQUIP_DELAY_UNDERSUIT (2 SECONDS)

/// Delay base for masks.
#define EQUIP_DELAY_MASK (1 SECONDS)
/// Delay base for back-worn objects.
#define EQUIP_DELAY_BACK (1 SECONDS)
/// Delay base for belts.
#define EQUIP_DELAY_BELT (1 SECONDS)
/// Delay base for hats.
#define EQUIP_DELAY_HAT (1 SECONDS)
/// Delay base for gloves.
#define EQUIP_DELAY_GLOVES (1 SECONDS)
/// Delay base for glasses.
#define EQUIP_DELAY_EYEWEAR (1 SECONDS)

// Flags for self equipping items
/// Allow movement during equip/unequip
#define EQUIP_ALLOW_MOVEMENT (1<<0)
/// Apply a slowdown when equipping or unequipping.
#define EQUIP_SLOWDOWN (1<<1)

//sound defines for equipping and unequipping
#define EQUIP_SOUND_VFAST_GENERIC 'sound/items/equip/equipping_vfast_generic.ogg'
#define UNEQUIP_SOUND_VFAST_GENERIC 'sound/items/equip/unequipping_vfast_generic.ogg'

#define EQUIP_SOUND_SHORT_GENERIC 'sound/items/equip/equipping_short_generic.ogg'
#define UNEQUIP_SOUND_SHORT_GENERIC 'sound/items/equip/unequipping_short_generic.ogg'

#define EQUIP_SOUND_MED_GENERIC 'sound/items/equip/equipping_med_generic.ogg'
#define UNEQUIP_SOUND_MED_GENERIC 'sound/items/equip/unequipping_med_generic.ogg'

#define EQUIP_SOUND_LONG_GENERIC 'sound/items/equip/equipping_long_generic.ogg'
#define UNEQUIP_SOUND_LONG_GENERIC 'sound/items/equip/unequipping_long_generic.ogg'
2 changes: 2 additions & 0 deletions code/__DEFINES/timed_action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
#define IGNORE_HELD_ITEM (1<<2)
/// Can do the action even if the mob is incapacitated
#define IGNORE_INCAPACITATED (1<<3)
/// Can do the action even if the mob changes active hand
#define IGNORE_HAND_CHANGE (1<<4)
3 changes: 3 additions & 0 deletions code/__DEFINES/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_WIELDED "wielded" //The item is currently being wielded
#define TRAIT_FORCE_SUIT_STORAGE "force_suit_storage" // the item can be worn in suit storage without an outerclothing

/// Equipping or unequipping an item
#define TRAIT_EQUIPPING_OR_UNEQUIPPING "equipping_or_unequipping"

//quirk traits
#define TRAIT_ALCOHOL_TOLERANCE "alcohol_tolerance"
#define TRAIT_AGEUSIA "ageusia"
Expand Down
2 changes: 2 additions & 0 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ GLOBAL_LIST_EMPTY(species_list)
drifting = TRUE

var/holding = user.get_active_held_item()
var/whichhand = user.active_hand_index

delay *= user.do_after_coefficent()

Expand Down Expand Up @@ -337,6 +338,7 @@ GLOBAL_LIST_EMPTY(species_list)
// Check flags
if(QDELETED(user) \
|| (!(timed_action_flags & IGNORE_USER_LOC_CHANGE) && !drifting && user.loc != user_loc) \
|| (!(timed_action_flags & IGNORE_HAND_CHANGE) && user.active_hand_index != whichhand) \
|| (!(timed_action_flags & IGNORE_HELD_ITEM) && user.get_active_held_item() != holding) \
|| (!(timed_action_flags & IGNORE_INCAPACITATED) && HAS_TRAIT(user, TRAIT_INCAPACITATED)) \
|| (extra_checks && !extra_checks.Invoke()))
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
var/image/item_overlay = image(holding)
item_overlay.alpha = 92

if(!user.can_equip(holding, slot_id, TRUE))
if(!user.can_equip(holding, slot_id, TRUE, TRUE))
item_overlay.color = "#FF0000"
else
item_overlay.color = "#00ff00"
Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/storage/storage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@
playsound(A, "rustle", 50, TRUE, -5)
if(istype(over_object, /atom/movable/screen/inventory/hand))
var/atom/movable/screen/inventory/hand/H = over_object
M.putItemFromInventoryInHandIfPossible(A, H.held_index)
M.putItemFromInventoryInHandIfPossible(A, H.held_index, FALSE, TRUE)
return
A.add_fingerprint(M)

Expand Down
12 changes: 10 additions & 2 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,20 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb
var/usesound
///Used when yate into a mob
var/mob_throw_hit_sound
///Sound used when equipping the item into a valid slot
///Sound used when an item has been equipped into a valid slot
var/equip_sound
///Sound uses when picking the item up (into your hands)
var/pickup_sound
///Sound uses when dropping the item, or when its thrown.
var/drop_sound
///Sound used when an item is being equipped with equip_delay
var/equipping_sound
///Sound used when an item is being unequipped with equip_delay
var/unequipping_sound

///flags used for equip_delay
var/equip_self_flags = NONE

///Whether or not we use stealthy audio levels for this item's attack sounds
var/stealthy_audio = FALSE

Expand Down Expand Up @@ -462,7 +470,7 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb
if(throwing)
throwing.finalize(FALSE)
if(loc == user)
if(!allow_attack_hand_drop(user) || !user.temporarilyRemoveItemFromInventory(src))
if(!allow_attack_hand_drop(user) || !user.temporarilyRemoveItemFromInventory(src, use_unequip_delay = TRUE))
return

remove_outline()
Expand Down
9 changes: 8 additions & 1 deletion code/game/objects/items/gear_packs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
var/obj/item/gear_handle/gear_handle_type = /obj/item/gear_handle
var/obj/item/gear_handle/gear_handle

equipping_sound = EQUIP_SOUND_SHORT_GENERIC
unequipping_sound = UNEQUIP_SOUND_SHORT_GENERIC
equip_delay_self = EQUIP_DELAY_BACK
equip_delay_other = EQUIP_DELAY_BACK * 1.5
strip_delay = EQUIP_DELAY_BACK * 1.5
equip_self_flags = EQUIP_ALLOW_MOVEMENT

/obj/item/gear_pack/get_cell()
return cell

Expand Down Expand Up @@ -106,7 +113,7 @@
var/mob/M = loc
if(!M.incapacitated() && istype(over_object, /atom/movable/screen/inventory/hand))
var/atom/movable/screen/inventory/hand/H = over_object
M.putItemFromInventoryInHandIfPossible(src, H.held_index)
M.putItemFromInventoryInHandIfPossible(src, H.held_index, FALSE, TRUE)

/obj/item/gear_pack/attackby(obj/item/W, mob/user, params)
if(W == gear_handle)
Expand Down
18 changes: 13 additions & 5 deletions code/game/objects/items/storage/backpack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
supports_variations = VOX_VARIATION | KEPORI_VARIATION
kepori_override_icon = 'icons/mob/clothing/back/backpacks_kepori.dmi'

equipping_sound = EQUIP_SOUND_VFAST_GENERIC
unequipping_sound = UNEQUIP_SOUND_VFAST_GENERIC
equip_delay_self = EQUIP_DELAY_BACK
equip_delay_other = EQUIP_DELAY_BACK * 1.5
strip_delay = EQUIP_DELAY_BACK * 1.5
equip_self_flags = EQUIP_ALLOW_MOVEMENT | EQUIP_SLOWDOWN

/obj/item/storage/backpack/ComponentInitialize()
. = ..()
var/datum/component/storage/STR = GetComponent(/datum/component/storage)
Expand All @@ -44,11 +51,6 @@
* Backpack Types
*/

/obj/item/storage/backpack/old/ComponentInitialize()
. = ..()
var/datum/component/storage/STR = GetComponent(/datum/component/storage)
STR.max_combined_w_class = 12

/obj/item/storage/backpack/holding
name = "bag of holding"
desc = "A backpack that opens into a localized pocket of bluespace."
Expand Down Expand Up @@ -181,6 +183,12 @@
greyscale_icon_state = "satchel"
greyscale_colors = list(list(11, 12), list(17, 18), list(10, 11))

equipping_sound = null
unequipping_sound = null
equip_delay_self = null
equip_delay_other = EQUIP_DELAY_BACK
strip_delay = EQUIP_DELAY_BACK

/obj/item/storage/backpack/satchel/ComponentInitialize()
. = ..()
var/datum/component/storage/STR = GetComponent(/datum/component/storage)
Expand Down
7 changes: 7 additions & 0 deletions code/game/objects/items/storage/belt.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
greyscale_icon_state = "belt"
greyscale_colors = list(list(16, 12), list(15, 11), list(13, 12))

equipping_sound = EQUIP_SOUND_VFAST_GENERIC
unequipping_sound = UNEQUIP_SOUND_VFAST_GENERIC
equip_delay_self = EQUIP_DELAY_BELT
equip_delay_other = EQUIP_DELAY_BELT * 1.5
strip_delay = EQUIP_DELAY_BELT * 1.5
equip_self_flags = EQUIP_ALLOW_MOVEMENT

/obj/item/storage/belt/update_overlays()
. = ..()
if(!content_overlays)
Expand Down
10 changes: 8 additions & 2 deletions code/modules/clothing/clothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
resistance_flags = FLAMMABLE
max_integrity = 200
integrity_failure = 0.4

equip_sound = 'sound/items/equip/cloth_equip.ogg'
equipping_sound = EQUIP_SOUND_SHORT_GENERIC
unequipping_sound = UNEQUIP_SOUND_SHORT_GENERIC

var/damaged_clothes = 0 //similar to machine's BROKEN stat and structure's broken var
///What level of bright light protection item has.
var/flash_protect = FLASH_PROTECTION_NONE
Expand All @@ -11,7 +16,8 @@
var/visor_flags = 0 //flags that are added/removed when an item is adjusted up/down
var/visor_flags_inv = 0 //same as visor_flags, but for flags_inv
var/visor_flags_cover = 0 //same as above, but for flags_cover
//what to toggle when toggled with weldingvisortoggle()

//what to toggle when toggled with weldingvisortoggle()
var/visor_vars_to_toggle = VISOR_FLASHPROTECT | VISOR_TINT | VISOR_VISIONFLAGS | VISOR_DARKNESSVIEW | VISOR_INVISVIEW
lefthand_file = 'icons/mob/inhands/clothing_lefthand.dmi'
righthand_file = 'icons/mob/inhands/clothing_righthand.dmi'
Expand Down Expand Up @@ -67,7 +73,7 @@

if(!M.incapacitated() && loc == M && istype(over_object, /atom/movable/screen/inventory/hand))
var/atom/movable/screen/inventory/hand/H = over_object
if(M.putItemFromInventoryInHandIfPossible(src, H.held_index))
if(M.putItemFromInventoryInHandIfPossible(src, H.held_index, FALSE, TRUE))
add_fingerprint(usr)

/obj/item/reagent_containers/food/snacks/clothing
Expand Down
11 changes: 9 additions & 2 deletions code/modules/clothing/glasses/_glasses.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@
w_class = WEIGHT_CLASS_SMALL
flags_cover = GLASSESCOVERSEYES
slot_flags = ITEM_SLOT_EYES
strip_delay = 20
equip_delay_other = 25
resistance_flags = NONE
custom_materials = list(/datum/material/glass = 250)
supports_variations = VOX_VARIATION
greyscale_colors = list(list(14, 26), list(17, 26))
greyscale_icon_state = "glasses"

equip_sound = 'sound/items/equip/straps_equip.ogg'
equipping_sound = EQUIP_SOUND_VFAST_GENERIC
unequipping_sound = UNEQUIP_SOUND_VFAST_GENERIC
equip_delay_self = EQUIP_DELAY_EYEWEAR
equip_delay_other = EQUIP_DELAY_EYEWEAR * 1.5
strip_delay = EQUIP_DELAY_EYEWEAR * 1.5
equip_self_flags = EQUIP_ALLOW_MOVEMENT

var/vision_flags = 0
var/darkness_view = 2//Base human is 2
var/invis_view = SEE_INVISIBLE_LIVING //admin only for now
Expand Down
10 changes: 8 additions & 2 deletions code/modules/clothing/gloves/_gloves.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@
slot_flags = ITEM_SLOT_GLOVES
attack_verb = list("challenged")
var/transfer_prints = FALSE
strip_delay = 20
equip_delay_other = 40

equipping_sound = EQUIP_SOUND_VFAST_GENERIC
unequipping_sound = UNEQUIP_SOUND_VFAST_GENERIC
equip_delay_self = EQUIP_DELAY_GLOVES
equip_delay_other = EQUIP_DELAY_GLOVES + (3 SECONDS)
strip_delay = EQUIP_DELAY_GLOVES + (3 SECONDS)
equip_self_flags = EQUIP_ALLOW_MOVEMENT

cuttable = TRUE
clothamnt = 2
greyscale_colors = list(list(10, 13), list(11, 14), list(9, 12))
Expand Down
9 changes: 8 additions & 1 deletion code/modules/clothing/head/_head.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
supports_variations = VOX_VARIATION
blood_overlay_type = "helmet"

equipping_sound = EQUIP_SOUND_VFAST_GENERIC
unequipping_sound = UNEQUIP_SOUND_VFAST_GENERIC
equip_delay_self = EQUIP_DELAY_HAT
equip_delay_other = EQUIP_DELAY_HAT * 1.5
strip_delay = EQUIP_DELAY_HAT * 1.5
equip_self_flags = EQUIP_ALLOW_MOVEMENT

///Special throw_impact for hats to frisbee hats at people to place them on their heads/attempt to de-hat them.
/obj/item/clothing/head/throw_impact(atom/hit_atom, datum/thrownthing/thrownthing)
. = ..()
Expand Down Expand Up @@ -44,7 +51,7 @@
///if the hat manages to knock something off
if(H.dropItemToGround(WH))
H.visible_message("<span class='warning'>[src] knocks [WH] off [H]'s head!</span>", "<span class='warning'>[WH] is suddenly knocked off your head by [src]!</span>")
if(H.equip_to_slot_if_possible(src, ITEM_SLOT_HEAD, 0, 1, 1))
if(H.equip_to_slot_if_possible(src, ITEM_SLOT_HEAD, 0, 1, 1, TRUE))
H.visible_message("<span class='notice'>[src] lands neatly on [H]'s head!</span>", "<span class='notice'>[src] lands perfectly onto your head!</span>")
return
if(iscyborg(hit_atom))
Expand Down
14 changes: 14 additions & 0 deletions code/modules/clothing/head/hardhat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
clothing_flags = SNUG_FIT
resistance_flags = FIRE_PROOF

equip_sound = 'sound/items/equip/armor_equip.ogg'
equipping_sound = EQUIP_SOUND_SHORT_GENERIC
unequipping_sound = UNEQUIP_SOUND_SHORT_GENERIC
equip_delay_self = EQUIP_DELAY_HELMET
equip_delay_other = EQUIP_DELAY_HELMET * 1.5
strip_delay = EQUIP_DELAY_HELMET * 1.5

/obj/item/clothing/head/hardhat
name = "hard hat"
desc = "A piece of headgear used in dangerous working conditions to protect the head. Comes with a built-in flashlight."
Expand All @@ -24,6 +31,13 @@
light_on = FALSE
dog_fashion = /datum/dog_fashion/head

equip_sound = 'sound/items/equip/armor_equip.ogg'
equipping_sound = EQUIP_SOUND_SHORT_GENERIC
unequipping_sound = UNEQUIP_SOUND_SHORT_GENERIC
equip_delay_self = EQUIP_DELAY_HELMET
equip_delay_other = EQUIP_DELAY_HELMET * 1.5
strip_delay = EQUIP_DELAY_HELMET * 1.5

///Determines used sprites: hardhat[on]_[hat_type] and hardhat[on]_[hat_type]2 (lying down sprite)
var/hat_type = "yellow"
///Whether the headlamp is on or off.
Expand Down
7 changes: 7 additions & 0 deletions code/modules/clothing/head/helmet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
flags_cover = HEADCOVERSEYES
//flags_inv = HIDEHAIR // nah

equip_sound = 'sound/items/equip/armor_equip.ogg'
equipping_sound = EQUIP_SOUND_SHORT_GENERIC
unequipping_sound = UNEQUIP_SOUND_SHORT_GENERIC
equip_delay_self = EQUIP_DELAY_HELMET
equip_delay_other = EQUIP_DELAY_HELMET * 1.5
strip_delay = EQUIP_DELAY_HELMET * 1.5

dog_fashion = /datum/dog_fashion/head/helmet

//if a flashlight can be mounted. if it has a flashlight and this is false, it is permanently attached.
Expand Down
7 changes: 7 additions & 0 deletions code/modules/clothing/head/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
clothing_flags = SNUG_FIT
flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDEFACIALHAIR

equip_sound = 'sound/items/equip/armor_equip.ogg'
equipping_sound = EQUIP_SOUND_SHORT_GENERIC
unequipping_sound = UNEQUIP_SOUND_SHORT_GENERIC
equip_delay_self = EQUIP_DELAY_HELMET
equip_delay_other = EQUIP_DELAY_HELMET * 1.5
strip_delay = EQUIP_DELAY_HELMET * 1.5

/obj/item/clothing/head/snowman
name = "Snowman Head"
desc = "A ball of white styrofoam. So festive."
Expand Down
7 changes: 7 additions & 0 deletions code/modules/clothing/head/misc_special.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
resistance_flags = FIRE_PROOF
clothing_flags = SNUG_FIT

equip_sound = 'sound/items/equip/armor_equip.ogg'
equipping_sound = EQUIP_SOUND_SHORT_GENERIC
unequipping_sound = UNEQUIP_SOUND_SHORT_GENERIC
equip_delay_self = EQUIP_DELAY_HELMET
equip_delay_other = EQUIP_DELAY_HELMET * 1.5
strip_delay = EQUIP_DELAY_HELMET * 1.5

/obj/item/clothing/head/welding/attack_self(mob/user)
weldingvisortoggle(user)

Expand Down
Loading

0 comments on commit c954d22

Please sign in to comment.