After Attack Fixes (#83910)

This commit is contained in:
MrMelbert
2024-06-14 12:25:05 -05:00
committed by GitHub
parent cebfb28b53
commit 4c536fa5e2
9 changed files with 131 additions and 83 deletions

View File

@@ -391,6 +391,10 @@
ui_interact(user)
/obj/item/construction/rcd/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
. = ..()
if(. & ITEM_INTERACT_ANY_BLOCKER)
return .
mode = construction_mode
rcd_create(interacting_with, user)
return ITEM_INTERACT_SUCCESS
@@ -399,7 +403,9 @@
if(!ranged || !range_check(interacting_with, user))
return ITEM_INTERACT_BLOCKING
return interact_with_atom(interacting_with, user, modifiers)
mode = construction_mode
rcd_create(interacting_with, user)
return ITEM_INTERACT_SUCCESS
/obj/item/construction/rcd/interact_with_atom_secondary(atom/interacting_with, mob/living/user, list/modifiers)
mode = RCD_DECONSTRUCT
@@ -410,7 +416,9 @@
if(!ranged || !range_check(interacting_with, user))
return ITEM_INTERACT_BLOCKING
return interact_with_atom_secondary(interacting_with, user, modifiers)
mode = RCD_DECONSTRUCT
rcd_create(interacting_with, user)
return ITEM_INTERACT_SUCCESS
/obj/item/construction/rcd/proc/detonate_pulse()
audible_message("<span class='danger'><b>[src] begins to vibrate and \

View File

@@ -89,20 +89,22 @@
silo_mats = null
return ..()
/obj/item/construction/pre_attack(atom/target, mob/user, params)
if(istype(target, /obj/item/rcd_upgrade))
install_upgrade(target, user)
return TRUE
if(insert_matter(target, user))
return TRUE
/obj/item/construction/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
SHOULD_CALL_PARENT(TRUE)
if(istype(interacting_with, /obj/item/rcd_upgrade))
install_upgrade(interacting_with, user)
return ITEM_INTERACT_SUCCESS
if(insert_matter(interacting_with, user))
return ITEM_INTERACT_SUCCESS
return ..()
/obj/item/construction/attackby(obj/item/item, mob/user, params)
if(istype(item, /obj/item/rcd_upgrade))
install_upgrade(item, user)
return TRUE
if(insert_matter(item, user))
return TRUE
/obj/item/construction/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
SHOULD_CALL_PARENT(TRUE)
if(istype(tool, /obj/item/rcd_upgrade))
install_upgrade(tool, user)
return ITEM_INTERACT_SUCCESS
if(insert_matter(tool, user))
return ITEM_INTERACT_SUCCESS
return ..()
/// Installs an upgrade into the RCD checking if it is already installed, or if it is a banned upgrade

View File

@@ -91,9 +91,16 @@
/obj/item/construction/rld/ranged_interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
if(!range_check(interacting_with, user))
return NONE
return interact_with_atom(interacting_with, user, modifiers)
return try_lighting(interacting_with, user)
/obj/item/construction/rld/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
. = ..()
if(. & ITEM_INTERACT_ANY_BLOCKER)
return .
return try_lighting(interacting_with, user)
/obj/item/construction/rld/proc/try_lighting(atom/interacting_with, mob/user)
var/turf/start = get_turf(src)
switch(mode)
if(REMOVE_MODE)

View File

@@ -242,6 +242,10 @@
return FALSE
/obj/item/construction/plumbing/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
. = ..()
if(. & ITEM_INTERACT_ANY_BLOCKER)
return .
for(var/category_name in plumbing_design_types)
var/list/designs = plumbing_design_types[category_name]

View File

@@ -231,10 +231,16 @@
/obj/item/construction/rtd/ranged_interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
if(!range_check(interacting_with, user))
return NONE
return interact_with_atom(interacting_with, user, modifiers)
return try_tiling(interacting_with, user)
/obj/item/construction/rtd/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
. = ..()
if(. & ITEM_INTERACT_ANY_BLOCKER)
return .
return try_tiling(interacting_with, user)
/obj/item/construction/rtd/proc/try_tiling(atom/interacting_with, mob/living/user)
var/turf/open/floor/floor = interacting_with
if(!istype(floor))
return NONE

View File

@@ -208,7 +208,7 @@
/obj/structure/table/screwdriver_act_secondary(mob/living/user, obj/item/tool)
if(!deconstruction_ready)
return FALSE
return NONE
to_chat(user, span_notice("You start disassembling [src]..."))
if(tool.use_tool(src, user, 2 SECONDS, volume=50))
deconstruct(TRUE)
@@ -216,7 +216,7 @@
/obj/structure/table/wrench_act_secondary(mob/living/user, obj/item/tool)
if(!deconstruction_ready)
return FALSE
return NONE
to_chat(user, span_notice("You start deconstructing [src]..."))
if(tool.use_tool(src, user, 4 SECONDS, volume=50))
playsound(loc, 'sound/items/deconstruct.ogg', 50, TRUE)
@@ -224,33 +224,50 @@
deconstruct(TRUE)
return ITEM_INTERACT_SUCCESS
/obj/structure/table/attackby(obj/item/I, mob/living/user, params)
var/list/modifiers = params2list(params)
/obj/structure/table/item_interaction_secondary(mob/living/user, obj/item/tool, list/modifiers)
if(tool.tool_behaviour == TOOL_SCREWDRIVER || tool.tool_behaviour == TOOL_WRENCH)
// continue to tool act
// ...we need a better way to do this natively.
// maybe flag to call tool acts before item interaction specifically?
return NONE
if(istype(tool, /obj/item/construction/rcd))
return NONE
if(istype(I, /obj/item/storage/bag/tray))
var/obj/item/storage/bag/tray/T = I
if(T.contents.len > 0) // If the tray isn't empty
for(var/x in T.contents)
var/obj/item/item = x
AfterPutItemOnTable(item, user)
I.atom_storage.remove_all(drop_location())
user.visible_message(span_notice("[user] empties [I] on [src]."))
return
if(istype(tool, /obj/item/toy/cards/deck))
var/obj/item/toy/cards/deck/dealer_deck = tool
if(HAS_TRAIT(dealer_deck, TRAIT_WIELDED)) // deal a card faceup on the table
var/obj/item/toy/singlecard/card = dealer_deck.draw(user)
if(card)
card.Flip()
attackby(card, user, list2params(modifiers))
return ITEM_INTERACT_SUCCESS
return item_interaction(user, tool, modifiers)
/obj/structure/table/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if(istype(tool, /obj/item/storage/bag/tray))
var/obj/item/storage/bag/tray/tray = tool
if(tray.contents.len > 0) // If the tray isn't empty
for(var/obj/item/thing in tray.contents)
AfterPutItemOnTable(thing, user)
tool.atom_storage.remove_all(drop_location())
user.visible_message(span_notice("[user] empties [tool] on [src]."))
return ITEM_INTERACT_SUCCESS
// If the tray IS empty, continue on (tray will be placed on the table like other items)
if(istype(I, /obj/item/toy/cards/deck))
var/obj/item/toy/cards/deck/dealer_deck = I
if(istype(tool, /obj/item/toy/cards/deck))
var/obj/item/toy/cards/deck/dealer_deck = tool
if(HAS_TRAIT(dealer_deck, TRAIT_WIELDED)) // deal a card facedown on the table
var/obj/item/toy/singlecard/card = dealer_deck.draw(user)
if(card)
attackby(card, user, params)
return
attackby(card, user, list2params(modifiers))
return ITEM_INTERACT_SUCCESS
if(istype(I, /obj/item/riding_offhand))
var/obj/item/riding_offhand/riding_item = I
if(istype(tool, /obj/item/riding_offhand))
var/obj/item/riding_offhand/riding_item = tool
var/mob/living/carried_mob = riding_item.rider
if(carried_mob == user) //Piggyback user.
return
return NONE
if(user.combat_mode)
user.unbuckle_mob(carried_mob)
tablelimbsmash(user, carried_mob)
@@ -268,32 +285,17 @@
if(do_after(user, tableplace_delay, target = carried_mob))
user.unbuckle_mob(carried_mob)
tableplace(user, carried_mob)
return TRUE
return ITEM_INTERACT_SUCCESS
if(!user.combat_mode && !(I.item_flags & ABSTRACT))
if(user.transferItemToLoc(I, drop_location(), silent = FALSE))
//Center the icon where the user clicked.
if(!LAZYACCESS(modifiers, ICON_X) || !LAZYACCESS(modifiers, ICON_Y))
return
//Clamp it so that the icon never moves more than 16 pixels in either direction (thus leaving the table turf)
I.pixel_x = clamp(text2num(LAZYACCESS(modifiers, ICON_X)) - 16, -(world.icon_size/2), world.icon_size/2)
I.pixel_y = clamp(text2num(LAZYACCESS(modifiers, ICON_Y)) - 16, -(world.icon_size/2), world.icon_size/2)
AfterPutItemOnTable(I, user)
return TRUE
else
return ..()
// Where putting things on tables is handled.
if(!user.combat_mode && !(tool.item_flags & ABSTRACT) && user.transferItemToLoc(tool, drop_location(), silent = FALSE))
//Clamp it so that the icon never moves more than 16 pixels in either direction (thus leaving the table turf)
tool.pixel_x = clamp(text2num(LAZYACCESS(modifiers, ICON_X)) - 16, -(world.icon_size/2), world.icon_size/2)
tool.pixel_y = clamp(text2num(LAZYACCESS(modifiers, ICON_Y)) - 16, -(world.icon_size/2), world.icon_size/2)
AfterPutItemOnTable(tool, user)
return ITEM_INTERACT_SUCCESS
/obj/structure/table/attackby_secondary(obj/item/weapon, mob/user, params)
if(istype(weapon, /obj/item/toy/cards/deck))
var/obj/item/toy/cards/deck/dealer_deck = weapon
if(HAS_TRAIT(dealer_deck, TRAIT_WIELDED)) // deal a card faceup on the table
var/obj/item/toy/singlecard/card = dealer_deck.draw(user)
if(card)
card.Flip()
attackby(card, user, params)
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
..()
return SECONDARY_ATTACK_CONTINUE_CHAIN
return NONE
/obj/structure/table/proc/AfterPutItemOnTable(obj/item/thing, mob/living/user)
return
@@ -642,23 +644,27 @@
else
return span_notice("The top cover is firmly <b>welded</b> on.")
/obj/structure/table/reinforced/attackby_secondary(obj/item/weapon, mob/user, params)
if(weapon.tool_behaviour == TOOL_WELDER)
if(weapon.tool_start_check(user, amount = 0))
if(deconstruction_ready)
to_chat(user, span_notice("You start strengthening the reinforced table..."))
if (weapon.use_tool(src, user, 50, volume = 50))
to_chat(user, span_notice("You strengthen the table."))
deconstruction_ready = FALSE
else
to_chat(user, span_notice("You start weakening the reinforced table..."))
if (weapon.use_tool(src, user, 50, volume = 50))
to_chat(user, span_notice("You weaken the table."))
deconstruction_ready = TRUE
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
/obj/structure/table/reinforced/welder_act_secondary(mob/living/user, obj/item/tool)
if(tool.tool_start_check(user, amount = 0))
if(deconstruction_ready)
to_chat(user, span_notice("You start strengthening the reinforced table..."))
if (tool.use_tool(src, user, 50, volume = 50))
to_chat(user, span_notice("You strengthen the table."))
deconstruction_ready = FALSE
return ITEM_INTERACT_SUCCESS
else
to_chat(user, span_notice("You start weakening the reinforced table..."))
if (tool.use_tool(src, user, 50, volume = 50))
to_chat(user, span_notice("You weaken the table."))
deconstruction_ready = TRUE
return ITEM_INTERACT_SUCCESS
return ITEM_INTERACT_BLOCKING
else
. = ..()
/obj/structure/table/reinforced/item_interaction_secondary(mob/living/user, obj/item/tool, list/modifiers)
if(tool.tool_behaviour == TOOL_WELDER)
return NONE
return ..()
/obj/structure/table/bronze
name = "bronze table"
@@ -858,6 +864,12 @@
deconstruct(TRUE)
return ITEM_INTERACT_SUCCESS
/obj/structure/rack/item_interaction_secondary(mob/living/user, obj/item/tool, list/modifiers)
if(tool.tool_behaviour == TOOL_WRENCH)
return NONE
return item_interaction(user, tool, modifiers)
/obj/structure/rack/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if((tool.item_flags & ABSTRACT) || user.combat_mode)
return NONE

View File

@@ -93,6 +93,10 @@
return TRUE
return .
/obj/item/kinetic_crusher/attack(mob/living/target, mob/living/carbon/user)
target.apply_status_effect(/datum/status_effect/crusher_damage)
return ..()
/obj/item/kinetic_crusher/afterattack(mob/living/target, mob/living/user, clickparams)
if(!isliving(target))
return

View File

@@ -108,6 +108,12 @@
return ITEM_INTERACT_SUCCESS
return NONE
/obj/item/hierophant_club/ranged_interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
if(blink_activated)
blink.teleport(user, interacting_with)
return ITEM_INTERACT_SUCCESS
return NONE
/obj/item/hierophant_club/update_icon_state()
icon_state = inhand_icon_state = "hierophant_club[blink?.current_charges > 0 ? "_ready":""][(!QDELETED(beacon)) ? "":"_beacon"]"
return ..()

View File

@@ -16,19 +16,19 @@
var/datum/storage/tray_storage = test_tray.atom_storage
tray_storage.collection_mode = COLLECT_ONE
test_tray.pre_attack(the_bread, human)
test_tray.melee_attack_chain(human, the_bread)
TEST_ASSERT_EQUAL((the_bread in test_tray.contents), TRUE, "The bread did not get picked up by the serving tray")
test_tray.pre_attack(banana, human)
test_tray.melee_attack_chain(human, banana)
TEST_ASSERT_EQUAL((banana in test_tray.contents), TRUE, "The banana did not get picked up by the serving tray")
the_table.attackby(test_tray, human)
test_tray.melee_attack_chain(human, the_table)
TEST_ASSERT_EQUAL(test_tray.contents.len, 0, "The serving tray did not drop all items on hitting the table")
test_tray.pre_attack(sugarcookie, human)
test_tray.melee_attack_chain(human, sugarcookie)
TEST_ASSERT_EQUAL((sugarcookie in test_tray.contents), TRUE, "The sugarcookie did not get picked up by the serving tray")
@@ -41,7 +41,6 @@
human.equip_to_slot(test_tray, ITEM_SLOT_RPOCKET)
TEST_ASSERT(human.get_item_by_slot(ITEM_SLOT_RPOCKET), "Serving tray failed to fit in the Right Pocket")
test_tray.attack(human, human)
test_tray.melee_attack_chain(human, human)
TEST_ASSERT_EQUAL(test_tray.contents.len, 0, "The serving tray did not drop all items on hitting a human")