From 82e12b79c31575cc1915474bb0c357b1d8c2bb85 Mon Sep 17 00:00:00 2001 From: Luc <89928798+lewcc@users.noreply.github.com> Date: Mon, 24 Jul 2023 07:06:02 -0700 Subject: [PATCH] Lets dchat-controlled mobs fire guns (#21572) * Lets dchat-controlled mobs fire guns * Better handling for abstract items, too * better text handling * Update code/modules/mob/living/carbon/human/human_mob.dm Co-authored-by: S34N <12197162+S34NW@users.noreply.github.com> --------- Co-authored-by: S34N <12197162+S34NW@users.noreply.github.com> --- .../mob/living/carbon/human/human_mob.dm | 42 ++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/code/modules/mob/living/carbon/human/human_mob.dm b/code/modules/mob/living/carbon/human/human_mob.dm index edb3423c7b3..6de021ca0f8 100644 --- a/code/modules/mob/living/carbon/human/human_mob.dm +++ b/code/modules/mob/living/carbon/human/human_mob.dm @@ -2119,6 +2119,12 @@ Eyes need to have significantly high darksight to shine unless the mob has the X var/obj/item/in_hand = get_active_hand() if(in_hand) + if(in_hand.flags & NODROP) + visible_message("[src] attempts to drop [in_hand], but it seems to be stuck to [p_their()] hand!") + return + if(in_hand.flags & ABSTRACT) + visible_message("[src] seems to have [p_their()] hands full!") + return visible_message("[src] drops [in_hand] and picks up [thing] instead!") unEquip(in_hand) in_hand.forceMove(old_loc) @@ -2127,8 +2133,8 @@ Eyes need to have significantly high darksight to shine unless the mob has the X put_in_active_hand(thing) /mob/living/carbon/human/proc/dchat_throw() - var/in_hand = get_active_hand() - if(!in_hand) + var/obj/item/in_hand = get_active_hand() + if(!in_hand || in_hand.flags & ABSTRACT) visible_message("[src] makes a throwing motion!") return var/atom/possible_target @@ -2144,9 +2150,11 @@ Eyes need to have significantly high darksight to shine unless the mob has the X break if(!possible_target) - throw_item(cur_turf) - else - throw_item(possible_target) + possible_target = cur_turf + if(in_hand.flags & NODROP) + visible_message("[src] tries to throw [in_hand][isturf(possible_target) ? "" : " towards [possible_target]"], but it won't come off [p_their()] hand!") + return + throw_item(possible_target) /mob/living/carbon/human/proc/dchat_shove() var/turf/ahead = get_turf(get_step(src, dir)) @@ -2156,6 +2164,29 @@ Eyes need to have significantly high darksight to shine unless the mob has the X return dna?.species.disarm(src, H) +/mob/living/carbon/human/proc/dchat_shoot() + + var/atom/possible_target + var/cur_turf = get_turf(src) + for(var/i in 1 to 5) + cur_turf = get_step(cur_turf, dir) + possible_target = locate(/mob/living) in cur_turf + if(possible_target) + break + + if(!possible_target) + possible_target = cur_turf + + var/obj/item/gun/held_gun = get_active_hand() + if(!held_gun) + visible_message("[src] makes fingerguns towards [possible_target]!") + return + if(!istype(held_gun)) + visible_message("[src] points [held_gun] towards [possible_target]!") + return + // for his neutral special, he wields a Gun + held_gun.afterattack(possible_target, src) + visible_message("[src] fires [held_gun][isturf(possible_target) ? "" : " towards [possible_target]!"]") /mob/living/carbon/human/deadchat_plays(mode = DEADCHAT_DEMOCRACY_MODE, cooldown = 7 SECONDS) var/list/inputs = list( @@ -2166,6 +2197,7 @@ Eyes need to have significantly high darksight to shine unless the mob has the X "throw" = CALLBACK(src, PROC_REF(dchat_throw)), "disarm" = CALLBACK(src, PROC_REF(dchat_shove)), "resist" = CALLBACK(src, PROC_REF(dchat_resist)), + "shoot" = CALLBACK(src, PROC_REF(dchat_shoot)), ) AddComponent(/datum/component/deadchat_control/cardinal_movement, mode, inputs, cooldown)