From 4ff9b181e0b3d7eec8d69d93f69a8b466cf3c006 Mon Sep 17 00:00:00 2001 From: Cerebulon Date: Tue, 24 Aug 2021 20:22:26 +0100 Subject: [PATCH 1/4] Throw Mode QoL Tweaks --- code/_onclick/click.dm | 10 +++---- code/modules/mob/living/carbon/give.dm | 8 ++++-- code/modules/mob/living/living.dm | 40 +++++++++++++++++++------- code/modules/mob/mob.dm | 2 +- 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/code/_onclick/click.dm b/code/_onclick/click.dm index ad0957c024..66eb803ba3 100644 --- a/code/_onclick/click.dm +++ b/code/_onclick/click.dm @@ -84,12 +84,10 @@ RestrainedClickOn(A) return 1 - if(in_throw_mode) - if(isturf(A) || isturf(A.loc)) - throw_item(A) - trigger_aiming(TARGET_CAN_CLICK) - return 1 + if(in_throw_mode && (isturf(A) || isturf(A.loc)) && throw_item(A)) + trigger_aiming(TARGET_CAN_CLICK) throw_mode_off() + return TRUE var/obj/item/W = get_active_hand() @@ -270,7 +268,7 @@ if(T && user.TurfAdjacent(T)) user.ToggleTurfTab(T) return 1 - + /mob/proc/ToggleTurfTab(var/turf/T) if(listed_turf == T) listed_turf = null diff --git a/code/modules/mob/living/carbon/give.dm b/code/modules/mob/living/carbon/give.dm index 09b5fb38cb..d22abca5a7 100644 --- a/code/modules/mob/living/carbon/give.dm +++ b/code/modules/mob/living/carbon/give.dm @@ -1,9 +1,13 @@ -/mob/living/carbon/human/verb/give(var/mob/living/carbon/target in living_mobs(1)) +/mob/living/verb/give(var/mob/living/target in living_mobs(1)) set category = "IC" set name = "Give" + do_give(target) + +/mob/living/proc/do_give(var/mob/living/carbon/human/target) + // TODO : Change to incapacitated() on merge. - if(src.stat || src.lying || src.resting || src.handcuffed) + if(src.incapacitated()) return if(!istype(target) || target.stat || target.lying || target.resting || target.handcuffed || target.client == null) return diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 8ecd3f38c3..354a4e30d3 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -839,9 +839,9 @@ if(lying) density = 0 - if(l_hand) + if(l_hand) unEquip(l_hand) - if(r_hand) + if(r_hand) unEquip(r_hand) for(var/obj/item/weapon/holder/holder in get_mob_riding_slots()) unEquip(holder) @@ -984,14 +984,13 @@ swap_hand() /mob/living/throw_item(atom/target) - src.throw_mode_off() - if(usr.stat || !target) - return - if(target.type == /obj/screen) return + if(stat || !target || istype(target, /obj/screen)) + return FALSE var/atom/movable/item = src.get_active_hand() - if(!item) return + if(!item) + return FALSE var/throw_range = item.throw_range if (istype(item, /obj/item/weapon/grab)) @@ -1011,10 +1010,30 @@ if((N.health + N.halloss) < config.health_threshold_crit || N.stat == DEAD) N.adjustBruteLoss(rand(10,30)) src.drop_from_inventory(G) + return TRUE + else + return FALSE - src.drop_from_inventory(item) - if(!item || !isturf(item.loc)) - return + if(!item) + return FALSE //Grab processing has a chance of returning null + + if(a_intent == I_HELP && Adjacent(target) && isitem(item)) + var/obj/item/I = item + if(ishuman(target)) + var/mob/living/carbon/human/H = target + if(H.in_throw_mode && H.a_intent == I_HELP && unEquip(I)) + H.put_in_hands(I) // If this fails it will just end up on the floor, but that's fitting for things like dionaea. + visible_message("[src] hands \the [H] \a [I].", SPAN_NOTICE("You give \the [target] \a [I].")) + else + to_chat(src, SPAN_NOTICE("You offer \the [I] to \the [target].")) + do_give(H) + return TRUE + remove_from_mob(I) + make_item_drop_sound(I) + I.forceMove(get_turf(target)) + return TRUE + + drop_from_inventory(item) //actually throw it! src.visible_message("[src] has thrown [item].") @@ -1035,6 +1054,7 @@ item.throw_at(target, throw_range, item.throw_speed, src) + return TRUE /mob/living/get_sound_env(var/pressure_factor) if (hallucination) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 7ab2333838..c625ecc4ba 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1111,7 +1111,7 @@ //Throwing stuff /mob/proc/throw_item(atom/target) - return + return FALSE /mob/proc/will_show_tooltip() if(alpha <= EFFECTIVE_INVIS) From 9c1e9559d0d544bba25b86fc18fec75ebb72678c Mon Sep 17 00:00:00 2001 From: Cerebulon Date: Tue, 24 Aug 2021 20:42:56 +0100 Subject: [PATCH 2/4] SPAN_ html + message for initiating give --- code/modules/mob/living/carbon/give.dm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/code/modules/mob/living/carbon/give.dm b/code/modules/mob/living/carbon/give.dm index d22abca5a7..bbf5f4c1fa 100644 --- a/code/modules/mob/living/carbon/give.dm +++ b/code/modules/mob/living/carbon/give.dm @@ -16,31 +16,33 @@ if(!I) I = src.get_inactive_hand() if(!I) - to_chat(src, "You don't have anything in your hands to give to \the [target].") + to_chat(src, SPAN_WARNING("You don't have anything in your hands to give to \the [target].")) return + usr.visible_message(SPAN_NOTICE("\The [usr] holds out \the [I] to \the [target]."), SPAN_NOTICE("You hold out \the [I] to \the [target], waiting for them to accept it.")) + if(alert(target,"[src] wants to give you \a [I]. Will you accept it?",,"No","Yes") == "No") - target.visible_message("\The [src] tried to hand \the [I] to \the [target], \ - but \the [target] didn't want it.") + target.visible_message(SPAN_NOTICE("\The [src] tried to hand \the [I] to \the [target], \ + but \the [target] didn't want it.")) return if(!I) return if(!Adjacent(target)) - to_chat(src, "You need to stay in reaching distance while giving an object.") - to_chat(target, "\The [src] moved too far away.") + to_chat(src, SPAN_WARNING("You need to stay in reaching distance while giving an object")) + to_chat(target, SPAN_WARNING("\The [src] moved too far away.")) return if(I.loc != src || !src.item_is_in_hands(I)) - to_chat(src, "You need to keep the item in your hands.") - to_chat(target, "\The [src] seems to have given up on passing \the [I] to you.") + to_chat(src, SPAN_WARNING("You need to keep the item in your hands.")) + to_chat(target, SPAN_WARNING("\The [src] seems to have given up on passing \the [I] to you.")) return if(target.hands_are_full()) - to_chat(target, "Your hands are full.") - to_chat(src, "Their hands are full.") + to_chat(target, SPAN_WARNING("Your hands are full.")) + to_chat(src, SPAN_WARNING("Their hands are full.")) return if(src.unEquip(I)) target.put_in_hands(I) // If this fails it will just end up on the floor, but that's fitting for things like dionaea. - target.visible_message("\The [src] handed \the [I] to \the [target].") + target.visible_message(SPAN_NOTICE("\The [src] handed \the [I] to \the [target]")) From 34f51f924423a939d607474cee34e2fe1d358444 Mon Sep 17 00:00:00 2001 From: Cerebulon Date: Thu, 26 Aug 2021 18:36:57 +0100 Subject: [PATCH 3/4] Requested changes --- code/modules/mob/living/carbon/give.dm | 3 +-- code/modules/mob/living/living.dm | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/code/modules/mob/living/carbon/give.dm b/code/modules/mob/living/carbon/give.dm index bbf5f4c1fa..4ed2019eb5 100644 --- a/code/modules/mob/living/carbon/give.dm +++ b/code/modules/mob/living/carbon/give.dm @@ -6,10 +6,9 @@ /mob/living/proc/do_give(var/mob/living/carbon/human/target) - // TODO : Change to incapacitated() on merge. if(src.incapacitated()) return - if(!istype(target) || target.stat || target.lying || target.resting || target.handcuffed || target.client == null) + if(!istype(target) || target.incapacitated() || target.client == null) return var/obj/item/I = src.get_active_hand() diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 354a4e30d3..3016f0b1f9 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -984,7 +984,7 @@ swap_hand() /mob/living/throw_item(atom/target) - if(stat || !target || istype(target, /obj/screen)) + if(incapacitated() || !target || istype(target, /obj/screen)) return FALSE var/atom/movable/item = src.get_active_hand() @@ -1028,7 +1028,6 @@ to_chat(src, SPAN_NOTICE("You offer \the [I] to \the [target].")) do_give(H) return TRUE - remove_from_mob(I) make_item_drop_sound(I) I.forceMove(get_turf(target)) return TRUE From 8b9a8d136ff67ff30edbf7c0cf06cf54b65c0c7f Mon Sep 17 00:00:00 2001 From: Cerebulon Date: Wed, 1 Sep 2021 01:54:51 +0100 Subject: [PATCH 4/4] qdel check re-added --- code/modules/mob/living/living.dm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 3016f0b1f9..7213eb2f88 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -1034,6 +1034,9 @@ drop_from_inventory(item) + if(!item || QDELETED(item)) + return TRUE //It may not have thrown, but it sure as hell left your hand successfully. + //actually throw it! src.visible_message("[src] has thrown [item].")