From 2003515939257596fe145b49c5f59aff186d0e67 Mon Sep 17 00:00:00 2001 From: Geeves Date: Sun, 19 Dec 2021 23:10:40 +0200 Subject: [PATCH] Grab Stuff (#12731) Co-authored-by: Werner <1331699+Arrow768@users.noreply.github.com> --- code/__defines/mobs.dm | 3 +- code/game/objects/items.dm | 3 + .../items/weapons/material/twohanded.dm | 5 ++ code/modules/mining/mine_items.dm | 5 ++ code/modules/mob/living/carbon/carbon.dm | 13 +--- .../living/carbon/human/species/species.dm | 5 +- .../station/vaurca/vaurca_subspecies.dm | 3 + code/modules/mob/mob.dm | 35 ----------- code/modules/mob/mob_grab.dm | 63 ++++++++++++------- code/modules/mob/mob_helpers.dm | 15 ----- code/modules/mob/mob_movement.dm | 45 +++---------- code/modules/projectiles/gun.dm | 5 ++ html/changelogs/geeves-bulwark_fireman.yml | 7 +++ 13 files changed, 86 insertions(+), 121 deletions(-) create mode 100644 html/changelogs/geeves-bulwark_fireman.yml diff --git a/code/__defines/mobs.dm b/code/__defines/mobs.dm index 03d7c8129f5..c60d5651e37 100644 --- a/code/__defines/mobs.dm +++ b/code/__defines/mobs.dm @@ -25,7 +25,6 @@ #define INCORPOREAL_SHADE 4 // Shady #define INCORPOREAL_MECH 5 // stripped down bstech -#define MOB_GRAB_NONE 0 #define MOB_GRAB_NORMAL 1 #define MOB_GRAB_FIREMAN 2 @@ -446,4 +445,4 @@ #define ROBOT_PANEL_CELL "cell" #define ROBOT_PANEL_NO_CELL "no cell" -#define BLOOD_REGEN_RATE 0.1 \ No newline at end of file +#define BLOOD_REGEN_RATE 0.1 diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index bc690f42042..308898fc8ca 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -957,3 +957,6 @@ modules/mob/living/carbon/human/life.dm if you die, you will be zoomed out. /obj/item/proc/should_equip() // when you press E with an empty hand, will this item be pulled from suit storage / back slot and put into your hand return FALSE + +/obj/item/proc/can_swap_hands(var/mob/user) + return TRUE diff --git a/code/game/objects/items/weapons/material/twohanded.dm b/code/game/objects/items/weapons/material/twohanded.dm index 1cc90fd7754..ea2bff6179d 100644 --- a/code/game/objects/items/weapons/material/twohanded.dm +++ b/code/game/objects/items/weapons/material/twohanded.dm @@ -76,6 +76,11 @@ return ..() +/obj/item/material/twohanded/can_swap_hands(mob/user) + if(wielded) + return FALSE + return ..() + /obj/item/material/twohanded/dropped(mob/user as mob) //handles unwielding a twohanded weapon when dropped as well as clearing up the offhand if(user) diff --git a/code/modules/mining/mine_items.dm b/code/modules/mining/mine_items.dm index 24ab3716446..7d6eae1c703 100644 --- a/code/modules/mining/mine_items.dm +++ b/code/modules/mining/mine_items.dm @@ -90,6 +90,11 @@ action_button_name = "Wield pick/drill" +/obj/item/pickaxe/can_swap_hands(mob/user) + if(wielded) + return FALSE + return ..() + /obj/item/pickaxe/proc/unwield() wielded = FALSE force = force_unwielded diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index fa654f4850b..985e7bddeb5 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -166,11 +166,9 @@ /mob/living/carbon/swap_hand() var/obj/item/item_in_hand = src.get_active_hand() - if(item_in_hand) //this segment checks if the item in your hand is twohanded. - if(istype(item_in_hand,/obj/item/material/twohanded) || istype(item_in_hand,/obj/item/gun) || istype(item_in_hand,/obj/item/pickaxe) || istype(item_in_hand, /obj/item/grab)) - if(item_in_hand:wielded == 1) - to_chat(usr, SPAN_WARNING("Your other hand is too busy holding the [item_in_hand.name]")) - return + if(item_in_hand && !item_in_hand.can_swap_hands(src)) //this segment checks if the item in your hand is twohanded. + to_chat(src, SPAN_WARNING("Your other hand is too busy holding \the [item_in_hand]!")) + return src.hand = !src.hand if(hud_used.l_hand_hud_object && hud_used.r_hand_hud_object) if(hand) //This being 1 means the left hand is in use @@ -179,11 +177,6 @@ else hud_used.l_hand_hud_object.icon_state = "l_hand_inactive" hud_used.r_hand_hud_object.icon_state = "r_hand_active" - /*if (!( src.hand )) - src.hands.set_dir(NORTH) - else - src.hands.set_dir(SOUTH)*/ - return /mob/living/carbon/proc/activate_hand(var/selhand) //0 or "r" or "right" for right hand; 1 or "l" or "left" for left hand. if(istext(selhand)) diff --git a/code/modules/mob/living/carbon/human/species/species.dm b/code/modules/mob/living/carbon/human/species/species.dm index da7d93e49fc..2fcc522d331 100644 --- a/code/modules/mob/living/carbon/human/species/species.dm +++ b/code/modules/mob/living/carbon/human/species/species.dm @@ -95,7 +95,7 @@ var/break_cuffs = FALSE //used in resist.dm to check if they can break hand/leg cuffs var/natural_climbing = FALSE //If true, the species always succeeds at climbing. var/climb_coeff = 1.25 //The coefficient to the climbing speed of the individual = 60 SECONDS * climb_coeff - + // Death vars. var/respawn_type = CREW var/meat_type = /obj/item/reagent_containers/food/snacks/meat/human @@ -793,3 +793,6 @@ /datum/species/proc/can_hold_s_store(var/obj/item/I) return FALSE + +/datum/species/proc/can_double_fireman_carry() + return FALSE diff --git a/code/modules/mob/living/carbon/human/species/station/vaurca/vaurca_subspecies.dm b/code/modules/mob/living/carbon/human/species/station/vaurca/vaurca_subspecies.dm index fd4a36d9875..fc6f525a8ca 100644 --- a/code/modules/mob/living/carbon/human/species/station/vaurca/vaurca_subspecies.dm +++ b/code/modules/mob/living/carbon/human/species/station/vaurca/vaurca_subspecies.dm @@ -255,3 +255,6 @@ Bulwarks are much larger and have significantly thicker carapaces than most Vaur slot_wrists_str = list("[NORTH]" = list("x" = 15, "y" = 0), "[EAST]" = list("x" = 12, "y" = 0), "[SOUTH]" = list("x" = 4, "y" = 0), "[WEST]" = list("x" = 9, "y" = 0)), slot_shoes_str = list("[NORTH]" = list("x" = 9, "y" = 0), "[EAST]" = list("x" = 8, "y" = 0), "[SOUTH]" = list("x" = 9, "y" = 0), "[WEST]" = list("x" = 8, "y" = 0)) ) + +/datum/species/bug/type_e/can_double_fireman_carry() + return TRUE diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 3a94ce9d4b6..3aa9b56f353 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -348,41 +348,6 @@ face_atom(A) return 1 -/datum/mobl // I have no idea what the fuck this is, but it's better for it to be a datum than an /obj/effect. - var/list/container = list() - var/master - -/mob/proc/ret_grab(datum/mobl/L, flag) - if ((!( istype(l_hand, /obj/item/grab) ) && !( istype(r_hand, /obj/item/grab) ))) - if (!( L )) - return null - else - return L.container - else - if (!( L )) - L = new /datum/mobl - L.container += src - L.master = src - if (istype(l_hand, /obj/item/grab)) - var/obj/item/grab/G = l_hand - if (!(L.container.Find(G.affecting))) - L.container += G.affecting - if (G.affecting) - G.affecting.ret_grab(L, 1) - if (istype(r_hand, /obj/item/grab)) - var/obj/item/grab/G = r_hand - if (!(L.container.Find(G.affecting))) - L.container += G.affecting - if (G.affecting) - G.affecting.ret_grab(L, 1) - if (!( flag )) - if (L.master == src) - var/list/temp = L.container.Copy() - qdel(L) - return temp - else - return L.container - return /mob/verb/mode() set name = "Activate Held Object" diff --git a/code/modules/mob/mob_grab.dm b/code/modules/mob/mob_grab.dm index 59dac40bcd4..4e1b87a64b6 100644 --- a/code/modules/mob/mob_grab.dm +++ b/code/modules/mob/mob_grab.dm @@ -116,15 +116,16 @@ if(state <= GRAB_AGGRESSIVE) allow_upgrade = 1 - //disallow upgrading if we're grabbing more than one person - if((assailant.l_hand && assailant.l_hand != src && istype(assailant.l_hand, /obj/item/grab))) - var/obj/item/grab/G = assailant.l_hand - if(G.affecting != affecting) - allow_upgrade = 0 - if((assailant.r_hand && assailant.r_hand != src && istype(assailant.r_hand, /obj/item/grab))) - var/obj/item/grab/G = assailant.r_hand - if(G.affecting != affecting) - allow_upgrade = 0 + if(!assailant.species.can_double_fireman_carry()) + //disallow upgrading if we're grabbing more than one person + if((assailant.l_hand && assailant.l_hand != src && istype(assailant.l_hand, /obj/item/grab))) + var/obj/item/grab/G = assailant.l_hand + if(G.affecting != affecting) + allow_upgrade = 0 + if((assailant.r_hand && assailant.r_hand != src && istype(assailant.r_hand, /obj/item/grab))) + var/obj/item/grab/G = assailant.r_hand + if(G.affecting != affecting) + allow_upgrade = 0 //disallow upgrading past aggressive if we're being grabbed aggressively for(var/obj/item/grab/G in affecting.grabbed_by) @@ -448,7 +449,7 @@ if(state < GRAB_AGGRESSIVE) to_chat(H, SPAN_WARNING("You need an aggressive grab before you can fireman carry someone!")) return - if(H.get_inactive_hand()) + if(H.get_inactive_hand() && !H.species.can_double_fireman_carry()) to_chat(H, SPAN_WARNING("Your other hand must be empty to fireman carry someone!")) return @@ -460,12 +461,15 @@ if(affecting.buckled_to) return - if(H.get_inactive_hand()) + if(H.get_inactive_hand() && !H.species.can_double_fireman_carry()) to_chat(H, SPAN_WARNING("Your other hand must be empty to fireman carry someone!")) return - var/obj/item/grab/offhand/OH = new /obj/item/grab/offhand(H, H, affecting, src) - H.put_in_hands(OH) + if(H.species.can_double_fireman_carry()) + set_wielding() + else + var/obj/item/grab/offhand/OH = new /obj/item/grab/offhand(H, H, affecting, src) + H.put_in_hands(OH) H.visible_message("[H] lifts \the [affecting] onto their shoulders!", SPAN_NOTICE("You lift \the [affecting] onto your shoulders!")) @@ -474,28 +478,43 @@ adjust_position() moved_event.register(assailant, src, /obj/item/grab/proc/move_affecting) +/obj/item/grab/proc/set_wielding() + wielded = TRUE + state = GRAB_AGGRESSIVE + icon_state = "!reinforce" + hud.icon_state = "!reinforce" + /obj/item/grab/proc/move_affecting() if(affecting && assailant.Adjacent(affecting)) // Only move if it's near us. affecting.forceMove(assailant.loc) +/obj/item/grab/can_swap_hands(mob/user) + if(ishuman(user)) + var/mob/living/carbon/human/H = user + if(H.species.can_double_fireman_carry()) + return TRUE + if(wielded) + return FALSE + return ..() + +/obj/item/grab/proc/get_grab_type() + if(wielded) + return MOB_GRAB_FIREMAN + return MOB_GRAB_NORMAL + /obj/item/grab/offhand icon_state = "!reinforce" /obj/item/grab/offhand/Initialize(mapload, mob/user, mob/victim, var/obj/item/grab/linked) . = ..() + + set_wielding() linked_grab = linked linked.linked_grab = src - linked_grab.wielded = TRUE - - linked_grab.state = GRAB_AGGRESSIVE - - icon_state = "!reinforce" - hud.icon_state = "!reinforce" - linked_grab.icon_state = "!reinforce" - linked_grab.hud.icon_state = "!reinforce" + linked_grab.set_wielding() /obj/item/grab/offhand/process() return /obj/item/grab/offhand/adjust_position() - return \ No newline at end of file + return diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index e61167d7372..e0fd3eed081 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -1244,21 +1244,6 @@ proc/is_blind(A) if(ear && speaker_coverage[ear]) return TRUE -/mob/proc/has_grab() - . = MOB_GRAB_NONE - if(istype(l_hand, /obj/item/grab)) - var/obj/item/grab/l_grab = l_hand - if(l_grab.wielded) - . = max(MOB_GRAB_FIREMAN, .) - else - . = max(MOB_GRAB_NORMAL, .) - if(istype(r_hand, /obj/item/grab)) - var/obj/item/grab/r_grab = r_hand - if(r_grab.wielded) - . = max(MOB_GRAB_FIREMAN, .) - else - . = max(MOB_GRAB_NORMAL, .) - /mob/proc/handle_vision() return diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 8f5c5e3b53d..0e7f6baa567 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -333,43 +333,16 @@ //We are now going to move moving = 1 - //Something with pulling things - var/grab_level = mob.has_grab() - if(grab_level == MOB_GRAB_FIREMAN) - move_delay++ - if (mob_is_human && grab_level == MOB_GRAB_NORMAL) - move_delay = max(move_delay, world.time + 7) - var/list/L = mob.ret_grab() - if(istype(L, /list)) - if(L.len == 2) - L -= mob - var/mob/M = L[1] - if(M) - if ((get_dist(mob, M) <= 1 || M.loc == mob.loc)) - var/turf/T = mob.loc - . = ..() - if (isturf(M.loc)) - var/diag = get_dir(mob, M) - if ((diag - 1) & diag) - else - diag = null - if ((get_dist(mob, M) > 1 || diag)) - step(M, get_dir(M.loc, T)) - else - for(var/mob/M in L) - M.other_mobs = 1 - if(mob != M) - M.animate_movement = 3 - for(var/mob/M in L) - spawn( 0 ) - step(M, direct) - return - spawn( 1 ) - M.other_mobs = null - M.animate_movement = 2 - return + if(mob_is_human) + for(var/obj/item/grab/G in list(mob.l_hand, mob.r_hand)) + switch(G.get_grab_type()) + if(MOB_GRAB_FIREMAN) + move_delay++ + if(MOB_GRAB_NORMAL) + move_delay = max(move_delay, world.time + 7) + step(G.affecting, get_dir(G.affecting.loc, mob.loc)) - else if(mob.confused && prob(25) && mob.m_intent == M_RUN) + if(mob.confused && prob(25) && mob.m_intent == M_RUN) step(mob, pick(cardinal)) else . = mob.SelfMove(n, direct) diff --git a/code/modules/projectiles/gun.dm b/code/modules/projectiles/gun.dm index d6fdcfdb6f3..c3e2c8338ab 100644 --- a/code/modules/projectiles/gun.dm +++ b/code/modules/projectiles/gun.dm @@ -184,6 +184,11 @@ update_held_icon() +/obj/item/gun/can_swap_hands(mob/user) + if(wielded) + return FALSE + return ..() + /obj/item/gun/proc/unique_action(var/mob/user) return diff --git a/html/changelogs/geeves-bulwark_fireman.yml b/html/changelogs/geeves-bulwark_fireman.yml new file mode 100644 index 00000000000..a702b1f37d2 --- /dev/null +++ b/html/changelogs/geeves-bulwark_fireman.yml @@ -0,0 +1,7 @@ +author: Geeves + +delete-after: True + +changes: + - tweak: "Dragging two people at once with a grab will no longer awkwardly move them in the direction you're going." + - rscadd: "Bulwarks can now comfortably hold grabs on two people at once, as well as fireman carrying both."