From 498d037b00cebab88f29c0e0643e0937cf547c04 Mon Sep 17 00:00:00 2001 From: Kapu1178 <75460809+Kapu1178@users.noreply.github.com> Date: Mon, 11 Mar 2024 00:41:37 -0400 Subject: [PATCH] Fixes two-handed items and runtimes (#869) * fixx 2h items * make monochrome ghost pref work * buff synaptizine * fix cleanbot getting confused with blood on walls * no more self headbutt * pm fixes --- .../signals/signals_mob/signals_mob_living.dm | 2 +- code/_onclick/hud/rendering/plane_master.dm | 4 -- code/datums/ai/generic/generic_behaviors.dm | 4 +- code/game/objects/items.dm | 13 ++-- code/game/objects/items/grenades/_grenade.dm | 2 +- code/game/objects/items/offhand.dm | 4 +- .../antagonists/highlander/highlander.dm | 3 +- code/modules/cards/cardhand.dm | 6 +- code/modules/cards/deck/deck.dm | 4 +- code/modules/cards/singlecard.dm | 3 +- .../client/preferences/monochrome_ghost.dm | 2 + code/modules/grab/grabs/grab_normal.dm | 2 +- code/modules/mob/dead/observer/observer.dm | 3 +- code/modules/mob/inventory.dm | 63 ++++++++++++++----- code/modules/mob/living/silicon/silicon.dm | 2 +- .../mob/living/simple_animal/bot/cleanbot.dm | 3 +- code/modules/mod/modules/module_kinesis.dm | 4 +- .../chemistry/reagents/medicine_reagents.dm | 2 +- .../reagents/reagent_containers/hypospray.dm | 2 +- .../modules/research/machinery/_production.dm | 2 +- .../code/game/gamemodes/objective.dm | 3 +- 21 files changed, 77 insertions(+), 56 deletions(-) diff --git a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm index e6bdc12855a1..5a1e24edc13f 100644 --- a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm +++ b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm @@ -1,4 +1,4 @@ -///called on /living when attempting to pick up an item, from base of /mob/living/put_in_hand_check(): (obj/item/I) +///called on /living when attempting to pick up an item, from base of /mob/living/can_put_in_hand(): (obj/item/I) #define COMSIG_LIVING_TRY_PUT_IN_HAND "living_try_put_in_hand" /// Can't pick up #define COMPONENT_LIVING_CANT_PUT_IN_HAND (1<<0) diff --git a/code/_onclick/hud/rendering/plane_master.dm b/code/_onclick/hud/rendering/plane_master.dm index 3b8ba4000df0..be78cdbe7fe2 100644 --- a/code/_onclick/hud/rendering/plane_master.dm +++ b/code/_onclick/hud/rendering/plane_master.dm @@ -127,7 +127,6 @@ /atom/movable/screen/plane_master/above_lighting name = "above lighting plane master" plane = ABOVE_LIGHTING_PLANE - appearance_flags = PLANE_MASTER //should use client color blend_mode = BLEND_OVERLAY ///Contains space parallax @@ -144,7 +143,6 @@ /atom/movable/screen/plane_master/pipecrawl name = "pipecrawl plane master" plane = PIPECRAWL_IMAGES_PLANE - appearance_flags = PLANE_MASTER blend_mode = BLEND_OVERLAY /atom/movable/screen/plane_master/pipecrawl/Initialize(mapload) @@ -158,7 +156,6 @@ /atom/movable/screen/plane_master/camera_static name = "camera static plane master" plane = CAMERA_STATIC_PLANE - appearance_flags = PLANE_MASTER blend_mode = BLEND_OVERLAY /atom/movable/screen/plane_master/o_light_visual @@ -172,7 +169,6 @@ /atom/movable/screen/plane_master/runechat name = "runechat plane master" plane = RUNECHAT_PLANE - appearance_flags = PLANE_MASTER blend_mode = BLEND_OVERLAY render_relay_plane = RENDER_PLANE_NON_GAME diff --git a/code/datums/ai/generic/generic_behaviors.dm b/code/datums/ai/generic/generic_behaviors.dm index 83b5fbaecb9b..aa71a26a0ea2 100644 --- a/code/datums/ai/generic/generic_behaviors.dm +++ b/code/datums/ai/generic/generic_behaviors.dm @@ -169,12 +169,10 @@ var/obj/item/target = target_ref.resolve() if(!(target in living_pawn.held_items)) - if(!living_pawn.put_in_hand_check(target)) + if(!living_pawn.put_in_hands(target)) finish_action(controller, FALSE, target, hunger_timer_key) return - living_pawn.put_in_hands(target) - target.melee_attack_chain(living_pawn, living_pawn) if(QDELETED(target) || prob(10)) // Even if we don't finish it all we can randomly decide to be done diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 3cfc70edf795..654e0505e7a1 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -622,12 +622,9 @@ DEFINE_INTERACTABLE(/obj/item) if(!allow_attack_hand_drop(user) || !user.temporarilyRemoveItemFromInventory(src)) return - . = FALSE - pickup(user) - if(!user.put_in_active_hand(src, FALSE, was_in_storage)) - user.dropItemToGround(src) - return TRUE + // Return FALSE if the item is picked up. + return !user.pickup_item(src, ignore_anim = was_in_storage) /obj/item/proc/allow_attack_hand_drop(mob/user) return TRUE @@ -921,9 +918,9 @@ DEFINE_INTERACTABLE(/obj/item) else if(slot) user.update_clothing(slot) - // if the item requires two handed, drop the item on unwield - if(HAS_TRAIT(src, TRAIT_NEEDS_TWO_HANDS)) - user.dropItemToGround(src, force=TRUE) + // if the item requires two handed, drop the item on unwield + if(HAS_TRAIT(src, TRAIT_NEEDS_TWO_HANDS)) + user.dropItemToGround(src, force=TRUE) // Show message if requested if(show_message) diff --git a/code/game/objects/items/grenades/_grenade.dm b/code/game/objects/items/grenades/_grenade.dm index 958358546ce8..0dfb7248bbc1 100644 --- a/code/game/objects/items/grenades/_grenade.dm +++ b/code/game/objects/items/grenades/_grenade.dm @@ -221,7 +221,7 @@ if(damage && attack_type == PROJECTILE_ATTACK && hit_projectile.damage_type != STAMINA && prob(15)) return TRUE -/obj/item/grenade/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", damage = 0, attack_type = MELEE_ATTACK) +/obj/item/grenade/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", damage = 0, attack_type = MELEE_ATTACK, block_success = TRUE) . = ..() if(!.) return diff --git a/code/game/objects/items/offhand.dm b/code/game/objects/items/offhand.dm index 2855094a7ee2..4c65a3ed43da 100644 --- a/code/game/objects/items/offhand.dm +++ b/code/game/objects/items/offhand.dm @@ -36,8 +36,8 @@ /obj/item/offhand/proc/deleteme(datum/source, mob/user) SIGNAL_HANDLER - - qdel(src) + if(!QDELETED(src)) + qdel(src) /obj/item/offhand/proc/try_swap_hands(datum/source, obj/item/held_item) SIGNAL_HANDLER diff --git a/code/modules/antagonists/highlander/highlander.dm b/code/modules/antagonists/highlander/highlander.dm index 27f21456333a..576e649b43e4 100644 --- a/code/modules/antagonists/highlander/highlander.dm +++ b/code/modules/antagonists/highlander/highlander.dm @@ -73,9 +73,8 @@ sword = new(H) if(!GLOB.highlander_controller) sword.flags_1 |= ADMIN_SPAWNED_1 //To prevent announcing - sword.pickup(H) //For the stun shielding - H.put_in_hands(sword) + H.pickup_item(sword) var/obj/item/bloodcrawl/antiwelder = new(H) antiwelder.name = "compulsion of honor" diff --git a/code/modules/cards/cardhand.dm b/code/modules/cards/cardhand.dm index efb18c78346c..38c4f7fb0ef8 100644 --- a/code/modules/cards/cardhand.dm +++ b/code/modules/cards/cardhand.dm @@ -73,14 +73,12 @@ return FALSE var/obj/item/toy/singlecard/selected_card = draw(user, choice) - selected_card.pickup(user) - user.put_in_hands(selected_card) + user.pickup_item(selected_card) if(cards.len == 1) user.temporarilyRemoveItemFromInventory(src, TRUE) var/obj/item/toy/singlecard/last_card = draw(user) - last_card.pickup(user) - user.put_in_hands(last_card) + user.pickup_item(last_card) qdel(src) // cardhand is empty now so delete it /obj/item/toy/cards/cardhand/proc/check_menu(mob/living/user) diff --git a/code/modules/cards/deck/deck.dm b/code/modules/cards/deck/deck.dm index e056fd01d680..ede5146eb0d0 100644 --- a/code/modules/cards/deck/deck.dm +++ b/code/modules/cards/deck/deck.dm @@ -153,8 +153,8 @@ return if(flip_card) card.Flip() - card.pickup(user) - user.put_in_hands(card) + + user.pickup_item(card) user.balloon_alert_to_viewers("draws a card") /obj/item/toy/cards/deck/attack_hand_secondary(mob/living/user, list/modifiers) diff --git a/code/modules/cards/singlecard.dm b/code/modules/cards/singlecard.dm index c927ee8fa8b0..2ad0eff5d33c 100644 --- a/code/modules/cards/singlecard.dm +++ b/code/modules/cards/singlecard.dm @@ -173,8 +173,7 @@ if(!isturf(loc)) // make a cardhand in our active hand user.temporarilyRemoveItemFromInventory(src, TRUE) - new_cardhand.pickup(user) - user.put_in_active_hand(new_cardhand) + user.pickup_item(new_cardhand) return if(istype(item, /obj/item/toy/cards/cardhand)) // insert into cardhand diff --git a/code/modules/client/preferences/monochrome_ghost.dm b/code/modules/client/preferences/monochrome_ghost.dm index 726795c8d791..9bd55927b6d9 100644 --- a/code/modules/client/preferences/monochrome_ghost.dm +++ b/code/modules/client/preferences/monochrome_ghost.dm @@ -11,6 +11,8 @@ return if(value && !M.started_as_observer) + if(locate(/datum/client_colour/ghostmono) in M.client_colours) + return M.add_client_colour(/datum/client_colour/ghostmono) else M.remove_client_colour(/datum/client_colour/ghostmono) diff --git a/code/modules/grab/grabs/grab_normal.dm b/code/modules/grab/grabs/grab_normal.dm index 38089015b06a..84a824b76f02 100644 --- a/code/modules/grab/grabs/grab_normal.dm +++ b/code/modules/grab/grabs/grab_normal.dm @@ -116,7 +116,7 @@ return FALSE /datum/grab/normal/resolve_openhand_attack(obj/item/hand_item/grab/G) - if(!G.assailant.combat_mode) + if(!G.assailant.combat_mode || G.assailant == G.affecting) return FALSE if(G.target_zone == BODY_ZONE_HEAD) if(G.assailant.zone_selected == BODY_ZONE_PRECISE_EYES) diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index 405c70bbcf3d..cdc410f5e061 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -220,7 +220,8 @@ Works together with spawning an observer, noted above. ghost.mind = null if(!admin_ghost) - ghost.add_client_colour(/datum/client_colour/ghostmono) + if(!ghost.client?.prefs || ghost.client.prefs.read_preference(/datum/preference/toggle/monochrome_ghost)) + ghost.add_client_colour(/datum/client_colour/ghostmono) return ghost diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index d985c69a0cf2..5f535020d593 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -143,27 +143,40 @@ //Returns if a certain item can be equipped to a certain slot. -// Currently invalid for two-handed items - call obj/item/mob_can_equip() instead. /mob/proc/can_equip(obj/item/I, slot, disable_warning = FALSE, bypass_equip_delay_self = FALSE) return FALSE -/mob/proc/can_put_in_hand(I, hand_index) - if(hand_index > held_items.len) - return FALSE - if(!put_in_hand_check(I)) - return FALSE - if(!has_hand_for_held_index(hand_index)) - return FALSE - return !held_items[hand_index] +/mob/proc/can_put_in_hand(obj/item/I, hand_index) + return FALSE + +/// A helper for picking up an item. +/mob/proc/pickup_item(obj/item/I, hand_index = active_hand_index, ignore_anim) + if(QDELETED(I)) + return + + if(!can_put_in_hand(I, hand_index)) + return + + I.pickup(src) + . = put_in_hand(I, hand_index, ignore_anim = ignore_anim) + + if(!.) + stack_trace("Somehow, someway, pickup_item failed put_in_hand().") + dropItemToGround(I, silent = TRUE) /mob/proc/put_in_hand(obj/item/I, hand_index, forced = FALSE, ignore_anim = TRUE) - if(hand_index == null || (!forced && !can_put_in_hand(I, hand_index))) + if(hand_index == null) + return FALSE + + if(!forced && !can_put_in_hand(I, hand_index)) return FALSE if(isturf(I.loc) && !ignore_anim) I.do_pickup_animation(src) + if(get_item_for_held_index(hand_index)) dropItemToGround(get_item_for_held_index(hand_index), force = TRUE) + I.forceMove(src) held_items[hand_index] = I I.plane = ABOVE_HUD_PLANE @@ -191,14 +204,30 @@ /mob/proc/put_in_r_hand(obj/item/I) return put_in_hand(I, get_empty_held_index_for_side(RIGHT_HANDS)) -/mob/proc/put_in_hand_check(obj/item/I) - return FALSE //nonliving mobs don't have hands +/mob/living/can_put_in_hand(obj/item/I, hand_index) + if(!istype(I)) + return FALSE -/mob/living/put_in_hand_check(obj/item/I) - if(istype(I) && ((mobility_flags & MOBILITY_PICKUP) || (I.item_flags & ABSTRACT)) \ - && !(SEND_SIGNAL(src, COMSIG_LIVING_TRY_PUT_IN_HAND, I) & COMPONENT_LIVING_CANT_PUT_IN_HAND)) - return TRUE - return FALSE + if(hand_index > held_items.len) + return FALSE + + if(!((mobility_flags & MOBILITY_PICKUP) || (I.item_flags & ABSTRACT))) + return FALSE + + if(SEND_SIGNAL(src, COMSIG_LIVING_TRY_PUT_IN_HAND, I) & COMPONENT_LIVING_CANT_PUT_IN_HAND) + return FALSE + + if(!has_hand_for_held_index(hand_index)) + return FALSE + + return !held_items[hand_index] + +/mob/living/carbon/human/can_put_in_hand(obj/item/I, hand_index) + . = ..() + if(!.) + return + + return dna.species.can_equip(I, ITEM_SLOT_HANDS, TRUE, src) //Puts the item into our active hand if possible. returns TRUE on success. /mob/proc/put_in_active_hand(obj/item/I, forced = FALSE, ignore_animation = TRUE) diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index 302748608082..9f82b39f5fea 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -371,7 +371,7 @@ to_chat(src, span_notice("Automatic announcements [chosen_channel == "None" ? "will not use the radio." : "set to [chosen_channel]."]")) -/mob/living/silicon/put_in_hand_check() // This check is for borgs being able to receive items, not put them in others' hands. +/mob/living/silicon/can_put_in_hand(I, hand_index) return FALSE /mob/living/silicon/assess_threat(judgement_criteria, lasercolor = "", datum/callback/weaponcheck=null) //Secbots won't hunt silicon units diff --git a/code/modules/mob/living/simple_animal/bot/cleanbot.dm b/code/modules/mob/living/simple_animal/bot/cleanbot.dm index 7b6a0dfdd866..c7d64726c42c 100644 --- a/code/modules/mob/living/simple_animal/bot/cleanbot.dm +++ b/code/modules/mob/living/simple_animal/bot/cleanbot.dm @@ -330,7 +330,7 @@ if(HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)) return . = ..() - if(ismopable(attack_target)) + if(ismopable(attack_target) || istype(attack_target, /obj/effect/decal/cleanable/blood)) mode = BOT_CLEANING update_icon_state() var/turf/T = get_turf(attack_target) @@ -346,6 +346,7 @@ playsound(src, 'sound/effects/spray2.ogg', 50, TRUE, -6) attack_target.acid_act(75, 10) target = null + else if(istype(attack_target, /mob/living/basic/cockroach) || ismouse(attack_target)) var/mob/living/living_target = attack_target if(!living_target.stat) diff --git a/code/modules/mod/modules/module_kinesis.dm b/code/modules/mod/modules/module_kinesis.dm index ddd0cdfa4b41..b95d9ec11243 100644 --- a/code/modules/mod/modules/module_kinesis.dm +++ b/code/modules/mod/modules/module_kinesis.dm @@ -95,9 +95,9 @@ if(isitem(grabbed_atom) && (mod.wearer in next_turf)) var/obj/item/grabbed_item = grabbed_atom clear_grab() - grabbed_item.pickup(mod.wearer) - mod.wearer.put_in_hands(grabbed_item) + mod.wearer.pickup_item(grabbed_item) return + var/pixel_x_change = 0 var/pixel_y_change = 0 var/direction = get_dir(grabbed_atom, next_turf) diff --git a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm index 61938dc4904a..d16d90ed73ad 100644 --- a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm @@ -440,7 +440,7 @@ holder.remove_reagent(/datum/reagent/toxin/mindbreaker, 5) - C.adjustToxLoss(5 * removed, updating_health = FALSE) // It used to be incredibly deadly due to an oversight. Not anymore! + C.adjustToxLoss(3 * removed, updating_health = FALSE) // It used to be incredibly deadly due to an oversight. Not anymore! APPLY_CHEM_EFFECT(C, CE_PAINKILLER, 20) APPLY_CHEM_EFFECT(C, CE_STIMULANT, 10) return TRUE diff --git a/code/modules/reagents/reagent_containers/hypospray.dm b/code/modules/reagents/reagent_containers/hypospray.dm index 7240be9f66e3..b47e84a55ba9 100644 --- a/code/modules/reagents/reagent_containers/hypospray.dm +++ b/code/modules/reagents/reagent_containers/hypospray.dm @@ -233,7 +233,7 @@ base_icon_state = "stimpen" volume = 30 amount_per_transfer_from_this = 30 - list_reagents = list(/datum/reagent/medicine/synaptizine = 8, /datum/reagent/medicine/dermaline = 8, /datum/reagent/medicine/meralyne = 8, /datum/reagent/medicine/leporazine = 6) + list_reagents = list(/datum/reagent/medicine/synaptizine = 4, /datum/reagent/medicine/dermaline = 8, /datum/reagent/medicine/meralyne = 8, /datum/reagent/medicine/leporazine = 6) /obj/item/reagent_containers/hypospray/medipen/survival/inject(mob/living/affected_mob, mob/user) if(DOING_INTERACTION(user, DOAFTER_SOURCE_SURVIVALPEN)) diff --git a/code/modules/research/machinery/_production.dm b/code/modules/research/machinery/_production.dm index 370b56a8abab..c7d4aa7f2ed0 100644 --- a/code/modules/research/machinery/_production.dm +++ b/code/modules/research/machinery/_production.dm @@ -244,7 +244,7 @@ DEFINE_INTERACTABLE(/obj/machinery/rnd/production) if(!(D in internal_disk.read(DATA_IDX_DESIGNS))) CRASH("Tried to print a design we don't have! Potential exploit?") - playsound(src, 'goon/sounds/button.ogg') + playsound(src, 'goon/sounds/button.ogg', 100) update_appearance(UPDATE_OVERLAYS) add_to_queue(D, amount, D.dangerous_construction) return TRUE diff --git a/modular_pariah/master_files/code/game/gamemodes/objective.dm b/modular_pariah/master_files/code/game/gamemodes/objective.dm index d8fc0c811023..a9261c473a1e 100644 --- a/modular_pariah/master_files/code/game/gamemodes/objective.dm +++ b/modular_pariah/master_files/code/game/gamemodes/objective.dm @@ -1,7 +1,8 @@ // For modularity, we hook into the update_explanation_text to be sure we have a target to register. /datum/objective/assassinate/update_explanation_text() - RegisterSignal(target, COMSIG_LIVING_DEATH, PROC_REF(register_target_death)) + RegisterSignal(target, COMSIG_LIVING_DEATH, PROC_REF(register_target_death), TRUE) return ..() + /datum/objective/assassinate/proc/register_target_death(mob/living/dead_guy, gibbed) SIGNAL_HANDLER completed = TRUE