Manual pull 83910 (#28201)

After Attack Fixes (#83910)

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
This commit is contained in:
Gandalf
2024-06-15 18:47:27 +01:00
committed by GitHub
parent 135c84aba9
commit ffe5ae7172
9 changed files with 131 additions and 83 deletions

View File

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

View File

@@ -89,20 +89,22 @@
silo_mats = null silo_mats = null
return ..() return ..()
/obj/item/construction/pre_attack(atom/target, mob/user, params) /obj/item/construction/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
if(istype(target, /obj/item/rcd_upgrade)) SHOULD_CALL_PARENT(TRUE)
install_upgrade(target, user) if(istype(interacting_with, /obj/item/rcd_upgrade))
return TRUE install_upgrade(interacting_with, user)
if(insert_matter(target, user)) return ITEM_INTERACT_SUCCESS
return TRUE if(insert_matter(interacting_with, user))
return ITEM_INTERACT_SUCCESS
return ..() return ..()
/obj/item/construction/attackby(obj/item/item, mob/user, params) /obj/item/construction/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if(istype(item, /obj/item/rcd_upgrade)) SHOULD_CALL_PARENT(TRUE)
install_upgrade(item, user) if(istype(tool, /obj/item/rcd_upgrade))
return TRUE install_upgrade(tool, user)
if(insert_matter(item, user)) return ITEM_INTERACT_SUCCESS
return TRUE if(insert_matter(tool, user))
return ITEM_INTERACT_SUCCESS
return ..() return ..()
/// Installs an upgrade into the RCD checking if it is already installed, or if it is a banned upgrade /// 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) /obj/item/construction/rld/ranged_interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
if(!range_check(interacting_with, user)) if(!range_check(interacting_with, user))
return NONE 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) /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) var/turf/start = get_turf(src)
switch(mode) switch(mode)
if(REMOVE_MODE) if(REMOVE_MODE)

View File

@@ -249,6 +249,10 @@
return FALSE return FALSE
/obj/item/construction/plumbing/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers) /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) for(var/category_name in plumbing_design_types)
var/list/designs = plumbing_design_types[category_name] 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) /obj/item/construction/rtd/ranged_interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
if(!range_check(interacting_with, user)) if(!range_check(interacting_with, user))
return NONE 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) /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 var/turf/open/floor/floor = interacting_with
if(!istype(floor)) if(!istype(floor))
return NONE return NONE

View File

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

View File

@@ -94,6 +94,10 @@
return TRUE return TRUE
return . 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) /obj/item/kinetic_crusher/afterattack(mob/living/target, mob/living/user, clickparams)
if(!isliving(target)) if(!isliving(target))
return return

View File

@@ -108,6 +108,12 @@
return ITEM_INTERACT_SUCCESS return ITEM_INTERACT_SUCCESS
return NONE 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() /obj/item/hierophant_club/update_icon_state()
icon_state = inhand_icon_state = "hierophant_club[blink?.current_charges > 0 ? "_ready":""][(!QDELETED(beacon)) ? "":"_beacon"]" icon_state = inhand_icon_state = "hierophant_club[blink?.current_charges > 0 ? "_ready":""][(!QDELETED(beacon)) ? "":"_beacon"]"
return ..() return ..()

View File

@@ -16,19 +16,19 @@
var/datum/storage/tray_storage = test_tray.atom_storage var/datum/storage/tray_storage = test_tray.atom_storage
tray_storage.collection_mode = COLLECT_ONE 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_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") 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_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") 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) 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_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") TEST_ASSERT_EQUAL(test_tray.contents.len, 0, "The serving tray did not drop all items on hitting a human")