mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-20 03:25:49 +01:00
Slightly refactors storage item insertion (#24429)
* everything is on fire * silent trait check * how did it even become CRLF * minor formatting * fix icon updating and adds silent insertion to global trait list * adds the new parameter to documentation - whoops! * pain * contra review * contra review again, reduces amount of checks for user in the loops --------- Co-authored-by: cybercapitalism <98280110+cybercapitalism@users.noreply.github.com>
This commit is contained in:
@@ -249,6 +249,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
|
||||
#define TRAIT_FORCES_OPEN_DOORS_ITEM "forces_open_doors_item_varient"
|
||||
/// Makes the item no longer spit out a visible message when thrown
|
||||
#define TRAIT_NO_THROWN_MESSAGE "no_message_when_thrown"
|
||||
/// Makes the item not display a message on storage insertion
|
||||
#define TRAIT_SILENT_INSERTION "silent_insertion"
|
||||
|
||||
/// A surgical tool; when in hand in help intent (and with a surgery in progress) won't attack the user
|
||||
#define TRAIT_SURGICAL "surgical_tool"
|
||||
|
||||
@@ -107,7 +107,8 @@ GLOBAL_LIST_INIT(traits_by_type, list(
|
||||
"TRAIT_FORCES_OPEN_DOORS" = TRAIT_FORCES_OPEN_DOORS_ITEM,
|
||||
"TRAIT_OBSCURED_WIRES" = TRAIT_OBSCURED_WIRES,
|
||||
"TRAIT_XENO_INTERACTABLE" = TRAIT_XENO_INTERACTABLE,
|
||||
"TRAIT_NO_THROWN_MESSAGE" = TRAIT_NO_THROWN_MESSAGE
|
||||
"TRAIT_NO_THROWN_MESSAGE" = TRAIT_NO_THROWN_MESSAGE,
|
||||
"TRAIT_SILENT_INSERTION" = TRAIT_SILENT_INSERTION
|
||||
),
|
||||
/turf = list(
|
||||
"bluespace_speed_trait" = TRAIT_BLUESPACE_SPEED
|
||||
|
||||
@@ -397,7 +397,7 @@
|
||||
else if(B.rating <= A.rating)
|
||||
continue
|
||||
W.remove_from_storage(B, src)
|
||||
W.handle_item_insertion(A, 1)
|
||||
W.handle_item_insertion(A, user, TRUE)
|
||||
component_parts -= A
|
||||
component_parts += B
|
||||
B.loc = null
|
||||
|
||||
@@ -368,7 +368,7 @@ GLOBAL_DATUM_INIT(welding_sparks, /mutable_appearance, mutable_appearance('icons
|
||||
failure = 1
|
||||
continue
|
||||
success = 1
|
||||
S.handle_item_insertion(IT, 1) //The 1 stops the "You put the [src] into [S]" insertion message from being displayed.
|
||||
S.handle_item_insertion(IT, user, TRUE) //The TRUE stops the "You put the [src] into [S]" insertion message from being displayed.
|
||||
if(success && !failure)
|
||||
to_chat(user, "<span class='notice'>You put everything in [S].</span>")
|
||||
else if(success)
|
||||
@@ -377,7 +377,7 @@ GLOBAL_DATUM_INIT(welding_sparks, /mutable_appearance, mutable_appearance('icons
|
||||
to_chat(user, "<span class='notice'>You fail to pick anything up with [S].</span>")
|
||||
|
||||
else if(S.can_be_inserted(src))
|
||||
S.handle_item_insertion(src)
|
||||
S.handle_item_insertion(src, user)
|
||||
else if(istype(I, /obj/item/stack/tape_roll))
|
||||
if(isstorage(src)) //Don't tape the bag if we can put the duct tape inside it instead
|
||||
var/obj/item/storage/bag = src
|
||||
|
||||
@@ -454,7 +454,7 @@
|
||||
|
||||
// The following three procs handle refusing access to contents if the duffel is zipped
|
||||
|
||||
/obj/item/storage/backpack/duffel/handle_item_insertion(obj/item/I, prevent_warning, bypass_zip = FALSE)
|
||||
/obj/item/storage/backpack/duffel/handle_item_insertion(obj/item/I, mob/user, prevent_warning, bypass_zip = FALSE)
|
||||
if(bypass_zip)
|
||||
return ..()
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
. = ..()
|
||||
update_weight()
|
||||
|
||||
/obj/item/storage/bag/trash/handle_item_insertion(obj/item/I, prevent_warning)
|
||||
/obj/item/storage/bag/trash/handle_item_insertion(obj/item/I, mob/user, prevent_warning)
|
||||
. = ..()
|
||||
update_weight()
|
||||
|
||||
@@ -273,7 +273,7 @@
|
||||
|
||||
|
||||
// Modified handle_item_insertion. Would prefer not to, but...
|
||||
/obj/item/storage/bag/sheetsnatcher/handle_item_insertion(obj/item/W as obj, prevent_warning = 0)
|
||||
/obj/item/storage/bag/sheetsnatcher/handle_item_insertion(obj/item/W as obj, mob/user, prevent_warning = FALSE)
|
||||
var/obj/item/stack/sheet/S = W
|
||||
if(!istype(S)) return 0
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
belt_image.color = I.color
|
||||
. += belt_image
|
||||
|
||||
/obj/item/storage/belt/handle_item_insertion(obj/item/I, prevent_warning)
|
||||
/obj/item/storage/belt/handle_item_insertion(obj/item/I, mob/user, prevent_warning)
|
||||
. = ..()
|
||||
update_weight()
|
||||
|
||||
@@ -754,7 +754,7 @@
|
||||
else
|
||||
to_chat(user, "<span class='warning'>[src] is empty!</span>")
|
||||
|
||||
/obj/item/storage/belt/rapier/handle_item_insertion(obj/item/W, prevent_warning)
|
||||
/obj/item/storage/belt/rapier/handle_item_insertion(obj/item/W, mob/user, prevent_warning)
|
||||
if(!..())
|
||||
return
|
||||
playsound(src, 'sound/weapons/blade_sheath.ogg', 20)
|
||||
|
||||
@@ -423,20 +423,21 @@
|
||||
* This doesn't perform any checks of whether an item can be inserted. That's done by [/obj/item/storage/proc/can_be_inserted]
|
||||
* Arguments:
|
||||
* * obj/item/I - The item to be inserted
|
||||
* * mob/user - The mob performing the insertion
|
||||
* * prevent_warning - Stop the insertion message being displayed. Intended for cases when you are inserting multiple items at once.
|
||||
*/
|
||||
/obj/item/storage/proc/handle_item_insertion(obj/item/I, prevent_warning = FALSE)
|
||||
/obj/item/storage/proc/handle_item_insertion(obj/item/I, mob/user, prevent_warning = FALSE)
|
||||
if(!istype(I))
|
||||
return FALSE
|
||||
if(usr)
|
||||
if(!Adjacent(usr) && !isnewplayer(usr))
|
||||
if(user)
|
||||
if(!Adjacent(user) && !isnewplayer(user))
|
||||
return FALSE
|
||||
if(!usr.unEquip(I, silent = TRUE))
|
||||
if(!user.unEquip(I, silent = TRUE))
|
||||
return FALSE
|
||||
usr.update_icons() //update our overlays
|
||||
user.update_icons() //update our overlays
|
||||
if(QDELING(I))
|
||||
return FALSE
|
||||
if(silent)
|
||||
if(silent || HAS_TRAIT(I, TRAIT_SILENT_INSERTION))
|
||||
prevent_warning = TRUE
|
||||
I.forceMove(src)
|
||||
if(QDELING(I))
|
||||
@@ -447,25 +448,34 @@
|
||||
var/mob/M = _M
|
||||
if((M.s_active == src) && M.client)
|
||||
M.client.screen += I
|
||||
if(user)
|
||||
if(user.client && user.s_active != src)
|
||||
user.client.screen -= I
|
||||
I.dropped(user, TRUE)
|
||||
add_fingerprint(user)
|
||||
|
||||
if(usr)
|
||||
if(usr.client && usr.s_active != src)
|
||||
usr.client.screen -= I
|
||||
I.dropped(usr, TRUE)
|
||||
add_fingerprint(usr)
|
||||
if(!prevent_warning)
|
||||
// all mobs with clients attached, sans the item's user
|
||||
var/viewer_list = GLOB.player_list - user
|
||||
|
||||
if(!prevent_warning && !istype(I, /obj/item/gun/energy/kinetic_accelerator/crossbow))
|
||||
for(var/mob/M in viewers(usr, null))
|
||||
if(M == usr)
|
||||
to_chat(usr, "<span class='notice'>You put [I] into [src].</span>")
|
||||
else if(M in range(1)) //If someone is standing close enough, they can tell what it is...
|
||||
M.show_message("<span class='notice'>[usr] puts [I] into [src].</span>")
|
||||
else if(I && I.w_class >= WEIGHT_CLASS_NORMAL) //Otherwise they can only see large or normal items from a distance...
|
||||
M.show_message("<span class='notice'>[usr] puts [I] into [src].</span>")
|
||||
// the item's user will always get a notification
|
||||
to_chat(user, "<span class='notice'>You put [I] into [src].</span>")
|
||||
|
||||
// if the item less than normal sized, only people within 1 tile get the message, otherwise, everybody in view gets it
|
||||
if(I.w_class < WEIGHT_CLASS_NORMAL)
|
||||
for(var/mob/M in viewer_list)
|
||||
if(in_range(M, user))
|
||||
M.show_message("<span class='notice'>[user] puts [I] into [src].</span>")
|
||||
else
|
||||
// restrict player list to include only those in view
|
||||
viewer_list = viewer_list & viewers(world.view, user)
|
||||
for(var/mob/M in viewer_list)
|
||||
M.show_message("<span class='notice'>[user] puts [I] into [src].</span>")
|
||||
|
||||
orient2hud(user)
|
||||
if(user.s_active)
|
||||
user.s_active.show_to(user)
|
||||
|
||||
orient2hud(usr)
|
||||
if(usr.s_active)
|
||||
usr.s_active.show_to(usr)
|
||||
I.mouse_opacity = MOUSE_OPACITY_OPAQUE //So you can click on the area around the item to equip it, instead of having to pixel hunt
|
||||
I.in_inventory = TRUE
|
||||
update_icon()
|
||||
@@ -545,7 +555,7 @@
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
handle_item_insertion(I)
|
||||
handle_item_insertion(I, user)
|
||||
|
||||
/obj/item/storage/attack_hand(mob/user)
|
||||
if(ishuman(user))
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
if(. && istype(I, /obj/item/card/id))
|
||||
refresh_ID()
|
||||
|
||||
/obj/item/storage/wallet/handle_item_insertion(obj/item/I, prevent_warning = FALSE)
|
||||
/obj/item/storage/wallet/handle_item_insertion(obj/item/I, mob/user, prevent_warning = FALSE)
|
||||
. = ..()
|
||||
if(. && istype(I, /obj/item/card/id))
|
||||
refresh_ID()
|
||||
|
||||
@@ -928,7 +928,7 @@
|
||||
var/obj/item/storage/bag/trash/bag = jani_vehicle?.mybag || jani_cart?.mybag
|
||||
var/obj/trashed_into
|
||||
if(bag?.can_be_inserted(garbage, TRUE))
|
||||
bag.handle_item_insertion(garbage, TRUE)
|
||||
bag.handle_item_insertion(garbage, user, TRUE)
|
||||
trashed_into = bag
|
||||
else if(target_bin)
|
||||
move_into_storage(user, target_bin, garbage)
|
||||
|
||||
@@ -296,7 +296,7 @@
|
||||
if(egg != /obj/item/fish_eggs) // Don't harvest duds
|
||||
egg = new egg(get_turf(user)) //Spawn the egg at the user's feet
|
||||
if(fish_bag?.can_be_inserted(egg))
|
||||
fish_bag.handle_item_insertion(egg)
|
||||
fish_bag.handle_item_insertion(egg, user)
|
||||
else
|
||||
duds++
|
||||
egg_list.Remove(egg) //Remove the egg from the egg_list
|
||||
@@ -350,7 +350,7 @@
|
||||
if(fish_item)
|
||||
var/obj/item/I = new fish_item(get_turf(user))
|
||||
if(fish_bag?.can_be_inserted(I))
|
||||
fish_bag.handle_item_insertion(I)
|
||||
fish_bag.handle_item_insertion(I, user)
|
||||
user.visible_message("[user.name] scoops \a [fish_name] from [src].", "You scoop \a [fish_name] out of [src].")
|
||||
kill_fish(fish_to_scoop) //Kill the caught fish from the tank
|
||||
|
||||
|
||||
@@ -828,7 +828,7 @@
|
||||
for(var/obj/item/food/snacks/grown/G in locate(user.x,user.y,user.z))
|
||||
if(!S.can_be_inserted(G))
|
||||
return
|
||||
S.handle_item_insertion(G, 1)
|
||||
S.handle_item_insertion(G, user, TRUE)
|
||||
|
||||
else if(istype(O, /obj/item/shovel/spade))
|
||||
if(!myseed && !weedlevel)
|
||||
|
||||
@@ -243,50 +243,50 @@
|
||||
/obj/item/proc/equip_to_best_slot(mob/M)
|
||||
if(src != M.get_active_hand())
|
||||
to_chat(M, "<span class='warning'>You are not holding anything to equip!</span>")
|
||||
return 0
|
||||
return FALSE
|
||||
|
||||
if(M.equip_to_appropriate_slot(src))
|
||||
if(M.hand)
|
||||
M.update_inv_l_hand()
|
||||
else
|
||||
M.update_inv_r_hand()
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
if(M.s_active && M.s_active.can_be_inserted(src, 1)) //if storage active insert there
|
||||
M.s_active.handle_item_insertion(src)
|
||||
return 1
|
||||
if(M.s_active && M.s_active.can_be_inserted(src, TRUE)) //if storage active insert there
|
||||
M.s_active.handle_item_insertion(src, M)
|
||||
return TRUE
|
||||
|
||||
var/obj/item/storage/S = M.get_inactive_hand()
|
||||
if(istype(S) && S.can_be_inserted(src, 1)) //see if we have box in other hand
|
||||
S.handle_item_insertion(src)
|
||||
return 1
|
||||
if(istype(S) && S.can_be_inserted(src, M, TRUE)) //see if we have box in other hand
|
||||
S.handle_item_insertion(src, M)
|
||||
return TRUE
|
||||
|
||||
S = M.get_item_by_slot(SLOT_HUD_WEAR_ID)
|
||||
if(istype(S) && S.can_be_inserted(src, 1)) //else we put in a wallet
|
||||
S.handle_item_insertion(src)
|
||||
return 1
|
||||
if(istype(S) && S.can_be_inserted(src, TRUE)) //else we put in a wallet
|
||||
S.handle_item_insertion(src, M)
|
||||
return TRUE
|
||||
|
||||
S = M.get_item_by_slot(SLOT_HUD_BELT)
|
||||
if(istype(S) && S.can_be_inserted(src, 1)) //else we put in belt
|
||||
S.handle_item_insertion(src)
|
||||
return 1
|
||||
if(istype(S) && S.can_be_inserted(src, TRUE)) //else we put in belt
|
||||
S.handle_item_insertion(src, M)
|
||||
return TRUE
|
||||
|
||||
var/obj/item/O = M.get_item_by_slot(SLOT_HUD_BACK) //else we put in backpack
|
||||
if(istype(O, /obj/item/storage))
|
||||
S = O
|
||||
if(S.can_be_inserted(src, 1))
|
||||
S.handle_item_insertion(src)
|
||||
if(S.can_be_inserted(src, TRUE))
|
||||
S.handle_item_insertion(src, M)
|
||||
playsound(loc, "rustle", 50, TRUE, -5)
|
||||
return 1
|
||||
return TRUE
|
||||
if(ismodcontrol(O))
|
||||
var/obj/item/mod/control/C = O
|
||||
if(C.can_be_inserted(src, 1))
|
||||
C.handle_item_insertion(src)
|
||||
if(C.can_be_inserted(src, TRUE))
|
||||
C.handle_item_insertion(src, M)
|
||||
playsound(loc, "rustle", 50, TRUE, -5)
|
||||
return 1
|
||||
return TRUE
|
||||
|
||||
to_chat(M, "<span class='warning'>You are unable to equip that!</span>")
|
||||
return 0
|
||||
return FALSE
|
||||
|
||||
/mob/proc/get_all_slots()
|
||||
return list(wear_mask, back, l_hand, r_hand)
|
||||
|
||||
@@ -446,12 +446,12 @@
|
||||
return
|
||||
if(ismodcontrol(equipped_item)) // Check if the item is a MODsuit
|
||||
if(thing && equipped_item.can_be_inserted(thing)) // Check if the item can be inserted into the MODsuit
|
||||
equipped_item.handle_item_insertion(thing) // Insert the item into the MODsuit
|
||||
equipped_item.handle_item_insertion(thing, src) // Insert the item into the MODsuit
|
||||
playsound(loc, "rustle", 50, TRUE, -5)
|
||||
return
|
||||
if(!istype(equipped_item)) // We also let you equip things like this
|
||||
equip_to_slot_if_possible(thing, slot_item)
|
||||
return
|
||||
if(thing && equipped_item.can_be_inserted(thing)) // put thing in belt or bag
|
||||
equipped_item.handle_item_insertion(thing)
|
||||
equipped_item.handle_item_insertion(thing, src)
|
||||
playsound(loc, "rustle", 50, 1, -5)
|
||||
|
||||
@@ -272,7 +272,7 @@
|
||||
// Convinience proc. Collects crap that fails to equip either onto the mob's back, or drops it.
|
||||
// Used in job equipping so shit doesn't pile up at the start loc.
|
||||
/mob/living/carbon/human/proc/equip_or_collect(obj/item/W, slot, initial = FALSE)
|
||||
if(W.mob_can_equip(src, slot, 1))
|
||||
if(W.mob_can_equip(src, slot, TRUE))
|
||||
//Mob can equip. Equip it.
|
||||
equip_to_slot_or_del(W, slot, initial)
|
||||
else
|
||||
@@ -280,12 +280,12 @@
|
||||
if(isstorage(back))
|
||||
var/obj/item/storage/S = back
|
||||
//Now, S represents a container we can insert W into.
|
||||
S.handle_item_insertion(W, TRUE, TRUE)
|
||||
S.handle_item_insertion(W, src, TRUE, TRUE)
|
||||
return S
|
||||
if(ismodcontrol(back))
|
||||
var/obj/item/mod/control/C = back
|
||||
if(C.bag)
|
||||
C.bag.handle_item_insertion(W, TRUE, TRUE)
|
||||
C.bag.handle_item_insertion(W, src, TRUE, TRUE)
|
||||
return C.bag
|
||||
|
||||
var/turf/T = get_turf(src)
|
||||
|
||||
@@ -427,9 +427,9 @@
|
||||
return bag.can_be_inserted(I, stop_messages)
|
||||
return FALSE
|
||||
|
||||
/obj/item/mod/control/proc/handle_item_insertion(I, prevent_warning)
|
||||
/obj/item/mod/control/proc/handle_item_insertion(I, mob/user, prevent_warning)
|
||||
if(bag)
|
||||
bag.handle_item_insertion(I, prevent_warning)
|
||||
bag.handle_item_insertion(I, user, prevent_warning)
|
||||
|
||||
/obj/item/mod/control/get_cell()
|
||||
if(!open)
|
||||
|
||||
@@ -80,13 +80,13 @@
|
||||
var/obj/item/I = new item_to_summon(src)
|
||||
if(H.back && isstorage(H.back))
|
||||
var/obj/item/storage/S = H.back
|
||||
S.handle_item_insertion(I, TRUE) //We don't check if it can be inserted because it's magic, GET IN THERE!
|
||||
S.handle_item_insertion(I, H, TRUE) //We don't check if it can be inserted because it's magic, GET IN THERE!
|
||||
H.visible_message("<span class='chaosgood'>[H]'s [S.name] glows bright!</span>", "<span class='chaosverygood'>\A [I] suddenly appears in your glowing [S.name]!</span>")
|
||||
return
|
||||
if(H.back && ismodcontrol(H.back))
|
||||
var/obj/item/mod/control/C = H.back
|
||||
if(C.bag)
|
||||
C.handle_item_insertion(I, TRUE)
|
||||
C.handle_item_insertion(I, H, TRUE)
|
||||
H.visible_message("<span class='chaosgood'>[H]'s [C] glows bright!</span>", "<span class='chaosverygood'>\A [I] suddenly appears in your glowing [C.name]!</span>")
|
||||
return
|
||||
I.forceMove(get_turf(H))
|
||||
|
||||
@@ -125,6 +125,10 @@
|
||||
empty_state = "crossbow_empty"
|
||||
can_holster = TRUE
|
||||
|
||||
/obj/item/gun/energy/kinetic_accelerator/crossbow/Initialize(mapload)
|
||||
. = ..()
|
||||
ADD_TRAIT(src, TRAIT_SILENT_INSERTION, ROUNDSTART_TRAIT)
|
||||
|
||||
/obj/item/gun/energy/kinetic_accelerator/crossbow/large
|
||||
name = "energy crossbow"
|
||||
desc = "A reverse engineered weapon using syndicate technology."
|
||||
|
||||
Reference in New Issue
Block a user