diff --git a/code/game/machinery/bank_machine.dm b/code/game/machinery/bank_machine.dm index 313ce43fe50..c9fe85ebc3c 100644 --- a/code/game/machinery/bank_machine.dm +++ b/code/game/machinery/bank_machine.dm @@ -43,27 +43,28 @@ synced_bank_account = null return ..() -/obj/machinery/computer/bank_machine/attackby(obj/item/weapon, mob/user, list/modifiers, list/attack_modifiers) +/obj/machinery/computer/bank_machine/item_interaction(mob/living/user, obj/item/tool, list/modifiers) var/value = 0 - if(istype(weapon, /obj/item/stack/spacecash)) - var/obj/item/stack/spacecash/inserted_cash = weapon + if(istype(tool, /obj/item/stack/spacecash)) + var/obj/item/stack/spacecash/inserted_cash = tool value = inserted_cash.value * inserted_cash.amount - else if(istype(weapon, /obj/item/holochip)) - var/obj/item/holochip/inserted_holochip = weapon + else if(istype(tool, /obj/item/holochip)) + var/obj/item/holochip/inserted_holochip = tool value = inserted_holochip.credits - else if(istype(weapon, /obj/item/coin)) - var/obj/item/coin/inserted_coin = weapon + else if(istype(tool, /obj/item/coin)) + var/obj/item/coin/inserted_coin = tool value = inserted_coin.value - else if(istype(weapon, /obj/item/poker_chip)) - var/obj/item/poker_chip/inserted_chip = weapon + else if(istype(tool, /obj/item/poker_chip)) + var/obj/item/poker_chip/inserted_chip = tool value = inserted_chip.get_item_credit_value() - if(value) - if(synced_bank_account) - synced_bank_account.adjust_money(value) - say("[MONEY_NAME_CAPITALIZED] deposited! The [synced_bank_account.account_holder] is now [synced_bank_account.account_balance] [MONEY_SYMBOL].") - qdel(weapon) - return - return ..() + if(!value) + return NONE + if(synced_bank_account) + synced_bank_account.adjust_money(value) + say("[MONEY_NAME_CAPITALIZED] deposited! The [synced_bank_account.account_holder] is now [synced_bank_account.account_balance] [MONEY_SYMBOL].") + qdel(tool) + return ITEM_INTERACT_SUCCESS + /obj/machinery/computer/bank_machine/process(seconds_per_tick) . = ..() diff --git a/code/game/machinery/barsigns.dm b/code/game/machinery/barsigns.dm index 409d0226bc0..b122355ac70 100644 --- a/code/game/machinery/barsigns.dm +++ b/code/game/machinery/barsigns.dm @@ -152,35 +152,35 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/barsign, 32) deconstruct(disassembled = TRUE) return ITEM_INTERACT_SUCCESS -/obj/machinery/barsign/attackby(obj/item/attacking_item, mob/user) +/obj/machinery/barsign/item_interaction(mob/living/user, obj/item/tool, list/modifiers) - if(istype(attacking_item, /obj/item/blueprints) && !change_area_name) + if(istype(tool, /obj/item/blueprints) && !change_area_name) if(!panel_open) balloon_alert(user, "open the panel first!") - return TRUE + return ITEM_INTERACT_BLOCKING change_area_name = TRUE balloon_alert(user, "sign registered") - return TRUE + return ITEM_INTERACT_SUCCESS - if(istype(attacking_item, /obj/item/stack/cable_coil) && panel_open) - var/obj/item/stack/cable_coil/wire = attacking_item + if(istype(tool, /obj/item/stack/cable_coil) && panel_open) + var/obj/item/stack/cable_coil/wire = tool if(atom_integrity >= max_integrity) balloon_alert(user, "doesn't need repairs!") - return TRUE + return ITEM_INTERACT_BLOCKING if(!wire.use(2)) balloon_alert(user, "need two cables!") - return TRUE + return ITEM_INTERACT_BLOCKING balloon_alert(user, "repaired") atom_integrity = max_integrity set_machine_stat(machine_stat & ~BROKEN) update_appearance() - return TRUE + return ITEM_INTERACT_SUCCESS - return ..() + return NONE /obj/machinery/barsign/emp_act(severity) . = ..() diff --git a/code/game/machinery/big_manipulator/big_manipulator.dm b/code/game/machinery/big_manipulator/big_manipulator.dm index eb78f7708a6..68cb85387f5 100644 --- a/code/game/machinery/big_manipulator/big_manipulator.dm +++ b/code/game/machinery/big_manipulator/big_manipulator.dm @@ -288,6 +288,18 @@ SStgui.update_uis(src) return ITEM_INTERACT_SUCCESS + if(isidcard(tool)) + if(!id_lock) + id_lock = WEAKREF(tool) + balloon_alert(user, "successfully locked") + return ITEM_INTERACT_SUCCESS + if(tool != id_lock.resolve()) + balloon_alert(user, "locked by another id") + return ITEM_INTERACT_BLOCKING + id_lock = null + balloon_alert(user, "successfully unlocked") + return ITEM_INTERACT_SUCCESS + if(!panel_open || !is_wire_tool(tool)) return NONE wires.interact(user) @@ -348,23 +360,6 @@ y_add = 32 + manipulator_arm.calculate_item_offset(FALSE, pixels_to_offset = 16) ) -/obj/machinery/big_manipulator/attackby(obj/item/some_item, mob/user, params) - . = ..() - if(!isidcard(some_item)) - return - - var/obj/item/card/id/clicked_by_this_id = some_item - - if(!id_lock) - id_lock = WEAKREF(clicked_by_this_id) - balloon_alert(user, "successfully locked") - return - var/obj/item/card/id/resolve_id = id_lock.resolve() - if(clicked_by_this_id != resolve_id) - balloon_alert(user, "locked by another id") - return - id_lock = null - balloon_alert(user, "successfully unlocked") /// Attaching the arm effect to the core. /obj/machinery/big_manipulator/proc/create_manipulator_arm() diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm index cf0f1a2b022..6f5cc6abfb8 100644 --- a/code/game/machinery/computer/communications.dm +++ b/code/game/machinery/computer/communications.dm @@ -110,11 +110,11 @@ return TRUE return authenticated -/obj/machinery/computer/communications/attackby(obj/I, mob/user, list/modifiers, list/attack_modifiers) - if(isidcard(I)) - attack_hand(user) - else - return ..() +/obj/machinery/computer/communications/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(!isidcard(tool)) + return NONE + attack_hand(user) + return ITEM_INTERACT_SUCCESS /obj/machinery/computer/communications/emag_act(mob/user, obj/item/card/emag/emag_card) if(istype(emag_card, /obj/item/card/emag/battlecruiser)) diff --git a/code/game/machinery/computer/dna_console.dm b/code/game/machinery/computer/dna_console.dm index 5a212a18503..676559b9d75 100644 --- a/code/game/machinery/computer/dna_console.dm +++ b/code/game/machinery/computer/dna_console.dm @@ -181,53 +181,53 @@ genetic_damage_pulse() return -/obj/machinery/computer/dna_console/attackby(obj/item/item, mob/user, list/modifiers, list/attack_modifiers) +/obj/machinery/computer/dna_console/item_interaction(mob/living/user, obj/item/tool, list/modifiers) // Store chromosomes in the console if there's room - if (istype(item, /obj/item/chromosome)) - item.forceMove(src) - stored_chromosomes += item - to_chat(user, span_notice("You insert [item].")) - return + if (istype(tool, /obj/item/chromosome)) + tool.forceMove(src) + stored_chromosomes += tool + to_chat(user, span_notice("You insert [tool].")) + return ITEM_INTERACT_SUCCESS // Insert data disk if console disk slot is empty // Swap data disk if there is one already a disk in the console - if (istype(item, /obj/item/disk/data)) //INSERT SOME DISKETTES + if (istype(tool, /obj/item/disk/data)) //INSERT SOME DISKETTES // Insert disk into DNA Console - if (!user.transferItemToLoc(item,src)) - return + if (!user.transferItemToLoc(tool,src)) + return ITEM_INTERACT_BLOCKING // If insertion was successful and there's already a diskette in the console, eject the old one. if(diskette) eject_disk(user) // Set the new diskette. - diskette = item - to_chat(user, span_notice("You insert [item].")) - return + diskette = tool + to_chat(user, span_notice("You insert [tool].")) + return ITEM_INTERACT_SUCCESS // Recycle non-activator used injectors // Turn activator used injectors (aka research injectors) to chromosomes - if(istype(item, /obj/item/dnainjector/activator)) - var/obj/item/dnainjector/activator/activator = item - if(activator.used) - if(activator.research && activator.filled) - if(prob(60)) - var/c_typepath = generate_chromosome() - var/obj/item/chromosome/CM = new c_typepath (src) - stored_chromosomes += CM - to_chat(user,span_notice("[capitalize(CM.name)] added to storage.")) - else - to_chat(user, span_notice("There was not enough genetic data to extract a viable chromosome.")) - if(activator.crispr_charge) - crispr_charges++ - to_chat(user, span_notice("CRISPR charge added.")) - qdel(item) - to_chat(user,span_notice("Recycled [item].")) - return - else + if(istype(tool, /obj/item/dnainjector/activator)) + var/obj/item/dnainjector/activator/activator = tool + if(!activator.used) //recycle unused activators - qdel(item) - to_chat(user, span_notice("Recycled unused [item].")) - return - return ..() + qdel(tool) + to_chat(user, span_notice("Recycled unused [tool].")) + return ITEM_INTERACT_SUCCESS + if(activator.research && activator.filled) + if(prob(60)) + var/c_typepath = generate_chromosome() + var/obj/item/chromosome/CM = new c_typepath (src) + stored_chromosomes += CM + to_chat(user,span_notice("[capitalize(CM.name)] added to storage.")) + else + to_chat(user, span_notice("There was not enough genetic data to extract a viable chromosome.")) + if(activator.crispr_charge) + crispr_charges++ + to_chat(user, span_notice("CRISPR charge added.")) + qdel(tool) + to_chat(user,span_notice("Recycled [tool].")) + return ITEM_INTERACT_SUCCESS + + return NONE /obj/machinery/computer/dna_console/multitool_act(mob/living/user, obj/item/multitool/tool) if(!QDELETED(tool.buffer) && istype(tool.buffer, /datum/techweb)) diff --git a/code/game/machinery/computer/orders/order_computer/mining_order.dm b/code/game/machinery/computer/orders/order_computer/mining_order.dm index b7082507a87..1bbb11070ee 100644 --- a/code/game/machinery/computer/orders/order_computer/mining_order.dm +++ b/code/game/machinery/computer/orders/order_computer/mining_order.dm @@ -102,17 +102,17 @@ . = ..() . += span_notice("There's [points] point\s on the card.") -/obj/item/card/mining_point_card/attackby(obj/item/attacking_item, mob/user, list/modifiers, list/attack_modifiers) - if(!isidcard(attacking_item)) - return ..() - var/obj/item/card/id/attacking_id = attacking_item +/obj/item/card/mining_point_card/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(!isidcard(tool)) + return NONE + var/obj/item/card/id/attacking_id = tool balloon_alert(user, "starting transfer") var/point_movement = tgui_alert(user, "To ID (from card) or to card (from ID)?", "Mining Points Transfer", list(TO_USER_ID, TO_POINT_CARD)) if(!point_movement) - return + return ITEM_INTERACT_BLOCKING var/amount = tgui_input_number(user, "How much do you want to transfer? ID Balance: [attacking_id.registered_account.mining_points], Card Balance: [points]", "Transfer Points", min_value = 0, round_value = 1) if(!amount) - return + return ITEM_INTERACT_BLOCKING switch(point_movement) if(TO_USER_ID) if(amount > points) @@ -120,12 +120,15 @@ attacking_id.registered_account.mining_points += amount points -= amount to_chat(user, span_notice("You transfer [amount] mining points from [src] to [attacking_id].")) + return ITEM_INTERACT_SUCCESS if(TO_POINT_CARD) if(amount > attacking_id.registered_account.mining_points) amount = attacking_id.registered_account.mining_points attacking_id.registered_account.mining_points -= amount points += amount to_chat(user, span_notice("You transfer [amount] mining points from [attacking_id] to [src].")) + return ITEM_INTERACT_SUCCESS + return NONE #undef TO_POINT_CARD #undef TO_USER_ID diff --git a/code/game/machinery/computer/prisoner/_prisoner.dm b/code/game/machinery/computer/prisoner/_prisoner.dm index 6ad43ab5b05..7ed7753f5ff 100644 --- a/code/game/machinery/computer/prisoner/_prisoner.dm +++ b/code/game/machinery/computer/prisoner/_prisoner.dm @@ -50,9 +50,8 @@ balloon_alert_to_viewers("id ejected") playsound(src, 'sound/machines/terminal/terminal_insert_disc.ogg', 50, FALSE) -/obj/machinery/computer/prisoner/attackby(obj/item/weapon, mob/user, list/modifiers, list/attack_modifiers) - if(istype(weapon, /obj/item/card/id/advanced/prisoner)) - id_insert(user, weapon) - return TRUE - - return ..() +/obj/machinery/computer/prisoner/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(!istype(tool, /obj/item/card/id/advanced/prisoner)) + return NONE + id_insert(user, tool) + return ITEM_INTERACT_SUCCESS diff --git a/code/game/machinery/defibrillator_mount.dm b/code/game/machinery/defibrillator_mount.dm index 90577c5a757..ba31d4db98f 100644 --- a/code/game/machinery/defibrillator_mount.dm +++ b/code/game/machinery/defibrillator_mount.dm @@ -85,18 +85,18 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/defibrillator_mount, 28) return user.put_in_hands(defib.paddles) -/obj/machinery/defibrillator_mount/attackby(obj/item/item, mob/living/user, list/modifiers, list/attack_modifiers) - if(istype(item, /obj/item/defibrillator)) +/obj/machinery/defibrillator_mount/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(istype(tool, /obj/item/defibrillator)) if(defib) to_chat(user, span_warning("There's already a defibrillator in [src]!")) - return - var/obj/item/defibrillator/new_defib = item + return ITEM_INTERACT_BLOCKING + var/obj/item/defibrillator/new_defib = tool if(!new_defib.get_cell()) to_chat(user, span_warning("Only defibrilators containing a cell can be hooked up to [src]!")) - return + return ITEM_INTERACT_BLOCKING if(HAS_TRAIT(new_defib, TRAIT_NODROP) || !user.transferItemToLoc(new_defib, src)) to_chat(user, span_warning("[new_defib] is stuck to your hand!")) - return + return ITEM_INTERACT_BLOCKING user.visible_message(span_notice("[user] hooks up [new_defib] to [src]!"), \ span_notice("You press [new_defib] into the mount, and it clicks into place.")) playsound(src, 'sound/machines/click.ogg', 50, TRUE) @@ -104,20 +104,27 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/defibrillator_mount, 28) defib = new_defib begin_processing() update_appearance() - return - else if(defib && item == defib.paddles) - defib.paddles.snap_back() - return + return ITEM_INTERACT_SUCCESS - if(!item.GetID() || (!allowed(user) && SSsecurity_level.get_current_level_as_number() < SEC_LEVEL_RED)) //anyone can toggle the clamps in red alert! + if(defib && tool == defib.paddles) + defib.paddles.snap_back() + return ITEM_INTERACT_SUCCESS + + if(!tool.GetID()) + return NONE + + if((!allowed(user) && SSsecurity_level.get_current_level_as_number() < SEC_LEVEL_RED)) //anyone can toggle the clamps in red alert! to_chat(user, span_warning("Insufficient access.")) - return + return ITEM_INTERACT_BLOCKING + if(!defib) to_chat(user, span_warning("You can't engage the clamps on a defibrillator that isn't there.")) - return + return ITEM_INTERACT_BLOCKING + clamps_locked = !clamps_locked to_chat(user, span_notice("Clamps [clamps_locked ? "" : "dis"]engaged.")) update_appearance() + return ITEM_INTERACT_SUCCESS /obj/machinery/defibrillator_mount/multitool_act(mob/living/user, obj/item/multitool) ..() diff --git a/code/game/machinery/doors/airlock.dm b/code/game/machinery/doors/airlock.dm index ca393825664..648285c07bb 100644 --- a/code/game/machinery/doors/airlock.dm +++ b/code/game/machinery/doors/airlock.dm @@ -940,18 +940,17 @@ /obj/machinery/door/airlock/wirecutter_act(mob/living/user, obj/item/tool) if(panel_open && security_level == AIRLOCK_SECURITY_PLASTEEL) - . = ITEM_INTERACT_SUCCESS // everything after this shouldn't result in attackby if(hasPower() && shock(user, 60)) // Protective grille of wiring is electrified - return . + return ITEM_INTERACT_BLOCKING to_chat(user, span_notice("You start cutting through the outer grille.")) if(!tool.use_tool(src, user, 10, volume=100)) - return . + return ITEM_INTERACT_BLOCKING if(!panel_open) // double check it wasn't closed while we were trying to snip - return . + return ITEM_INTERACT_BLOCKING user.visible_message(span_notice("[user] cut through [src]'s outer grille."), span_notice("You cut through [src]'s outer grille.")) security_level = AIRLOCK_SECURITY_PLASTEEL_O - return . + return ITEM_INTERACT_SUCCESS if(note) if(IsReachableBy(user)) user.visible_message(span_notice("[user] cuts down [note] from [src]."), span_notice("You remove [note] from [src].")) @@ -1073,85 +1072,98 @@ return ITEM_INTERACT_SUCCESS /obj/machinery/door/airlock/proc/try_reinforce(mob/user, obj/item/stack/sheet/material, amt_required, new_security_level) + if(!HAS_SILICON_ACCESS(user) && isElectrified() && shock(user, 75)) + return ITEM_INTERACT_BLOCKING if(material.get_amount() < amt_required) to_chat(user, span_warning("You need at least [amt_required] sheets of [material] to reinforce [src].")) - return FALSE + return ITEM_INTERACT_BLOCKING to_chat(user, span_notice("You start reinforcing [src].")) if(!do_after(user, 2 SECONDS, src)) - return FALSE + return ITEM_INTERACT_BLOCKING if(!panel_open || !material.use(amt_required)) - return FALSE + return ITEM_INTERACT_BLOCKING user.visible_message(span_notice("[user] reinforces [src] with [material]."), span_notice("You reinforce [src] with [material].")) security_level = new_security_level update_appearance() - return TRUE + return ITEM_INTERACT_SUCCESS -/obj/machinery/door/airlock/attackby(obj/item/C, mob/user, list/modifiers, list/attack_modifiers) - if(!HAS_SILICON_ACCESS(user)) - if(isElectrified() && (C.obj_flags & CONDUCTS_ELECTRICITY) && shock(user, 75)) - return +/obj/machinery/door/airlock/attacked_by(obj/item/attacking_item, mob/living/user, list/modifiers, list/attack_modifiers) + if(!HAS_SILICON_ACCESS(user) && isElectrified() && (attacking_item.obj_flags & CONDUCTS_ELECTRICITY) && shock(user, 75)) + return ATTACK_FAILED + return ..() + +/obj/machinery/door/airlock/item_interaction(mob/living/user, obj/item/tool, list/modifiers) add_fingerprint(user) - if(is_wire_tool(C) && panel_open) + if(is_wire_tool(tool) && panel_open) attempt_wire_interaction(user) - return - else if(panel_open && security_level == AIRLOCK_SECURITY_NONE && istype(C, /obj/item/stack/sheet)) - if(istype(C, /obj/item/stack/sheet/iron)) - return try_reinforce(user, C, 2, AIRLOCK_SECURITY_IRON) + return ITEM_INTERACT_SUCCESS - else if(istype(C, /obj/item/stack/sheet/plasteel)) - if(!try_reinforce(user, C, 2, AIRLOCK_SECURITY_PLASTEEL)) - return FALSE + if(panel_open && security_level == AIRLOCK_SECURITY_NONE && istype(tool, /obj/item/stack/sheet)) + if(istype(tool, /obj/item/stack/sheet/iron)) + return try_reinforce(user, tool, 2, AIRLOCK_SECURITY_IRON) + + if(istype(tool, /obj/item/stack/sheet/plasteel)) + if(try_reinforce(user, tool, 2, AIRLOCK_SECURITY_PLASTEEL) & ITEM_INTERACT_BLOCKING) + return ITEM_INTERACT_BLOCKING modify_max_integrity(max_integrity * AIRLOCK_INTEGRITY_MULTIPLIER) damage_deflection = AIRLOCK_DAMAGE_DEFLECTION_R update_appearance() - return TRUE + return ITEM_INTERACT_SUCCESS - else if(istype(C, /obj/item/pai_cable)) - var/obj/item/pai_cable/cable = C + return NONE + + if(istype(tool, /obj/item/pai_cable)) + var/obj/item/pai_cable/cable = tool cable.plugin(src, user) - else if(istype(C, /obj/item/airlock_painter)) - change_paintjob(C, user) - else if(istype(C, /obj/item/door_seal)) //adding the seal - var/obj/item/door_seal/airlockseal = C + return ITEM_INTERACT_SUCCESS + + if(istype(tool, /obj/item/airlock_painter)) + change_paintjob(tool, user) + return ITEM_INTERACT_SUCCESS + + if(istype(tool, /obj/item/door_seal)) //adding the seal + var/obj/item/door_seal/airlockseal = tool if(!density) to_chat(user, span_warning("[src] must be closed before you can seal it!")) - return + return ITEM_INTERACT_BLOCKING if(seal) to_chat(user, span_warning("[src] has already been sealed!")) - return + return ITEM_INTERACT_BLOCKING user.visible_message(span_notice("[user] begins sealing [src]."), span_notice("You begin sealing [src].")) playsound(src, 'sound/items/tools/jaws_pry.ogg', 30, TRUE) if(!do_after(user, airlockseal.seal_time, target = src)) - return + return ITEM_INTERACT_BLOCKING if(!density) to_chat(user, span_warning("[src] must be closed before you can seal it!")) - return + return ITEM_INTERACT_BLOCKING if(seal) to_chat(user, span_warning("[src] has already been sealed!")) - return + return ITEM_INTERACT_BLOCKING if(!user.transferItemToLoc(airlockseal, src)) to_chat(user, span_warning("For some reason, you can't attach [airlockseal]!")) - return + return ITEM_INTERACT_BLOCKING playsound(src, 'sound/machines/airlock/airlockforced.ogg', 30, TRUE) user.visible_message(span_notice("[user] finishes sealing [src]."), span_notice("You finish sealing [src].")) seal = airlockseal modify_max_integrity(max_integrity * AIRLOCK_SEAL_MULTIPLIER) update_appearance() + return ITEM_INTERACT_SUCCESS - else if(istype(C, /obj/item/paper) || istype(C, /obj/item/photo)) + if(istype(tool, /obj/item/paper) || istype(tool, /obj/item/photo)) if(note) to_chat(user, span_warning("There's already something pinned to this airlock! Use wirecutters to remove it.")) - return - if(!user.transferItemToLoc(C, src)) - to_chat(user, span_warning("For some reason, you can't attach [C]!")) - return - user.visible_message(span_notice("[user] pins [C] to [src]."), span_notice("You pin [C] to [src].")) - note = C + return ITEM_INTERACT_BLOCKING + if(!user.transferItemToLoc(tool, src)) + to_chat(user, span_warning("For some reason, you can't attach [tool]!")) + return ITEM_INTERACT_BLOCKING + user.visible_message(span_notice("[user] pins [tool] to [src]."), span_notice("You pin [tool] to [src].")) + note = tool update_appearance() - else - return ..() + return ITEM_INTERACT_SUCCESS + + return NONE /obj/machinery/door/airlock/try_to_weld(obj/item/weldingtool/W, mob/living/user) diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index 7d7dc8c268c..121bf7ad051 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -331,13 +331,13 @@ /obj/machinery/door/proc/try_to_activate_door(mob/user, access_bypass = FALSE, bumped = FALSE) add_fingerprint(user) if(operating || (obj_flags & EMAGGED)) - return + return FALSE if(!bumped && !can_open_with_hands) - return + return FALSE if(elevator_mode && elevator_status != LIFT_PLATFORM_UNLOCKED) - return + return FALSE // note: if the ID wire is cut no ID cards are checked at all! (This is intentional!) if(access_bypass || (requiresID() && user_can_activate_door(user))) @@ -347,8 +347,9 @@ close() return TRUE - else if(!operating && density) + if(!operating && density) run_animation(DOOR_DENY_ANIMATION) + return FALSE /// Used in try_to_activate_door /obj/machinery/door/proc/user_can_activate_door(mob/user) @@ -448,20 +449,27 @@ /obj/machinery/door/try_to_crowbar_secondary(obj/item/acting_object, mob/user) try_to_crowbar(null, user, FALSE) -/obj/machinery/door/attackby(obj/item/weapon, mob/living/user, list/modifiers, list/attack_modifiers) - if(istype(weapon, /obj/item/access_key)) - var/obj/item/access_key/key = weapon - return key.attempt_open_door(user, src) - else if(!user.combat_mode && istype(weapon, /obj/item/fireaxe)) - try_to_crowbar(weapon, user, FALSE) - return TRUE - else if(weapon.item_flags & NOBLUDGEON || user.combat_mode) - return ..() - else if(!user.combat_mode && istype(weapon, /obj/item/stack/sheet/mineral/wood)) - return ..() // we need this so our can_barricade element can be called using COMSIG_ATOM_ATTACKBY - else if(try_to_activate_door(user)) - return TRUE - return ..() +/obj/machinery/door/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(istype(tool, /obj/item/access_key)) + var/obj/item/access_key/key = tool + if(!key.attempt_open_door(user, src)) + return ITEM_INTERACT_BLOCKING + return ITEM_INTERACT_SUCCESS + + if(!user.combat_mode && istype(tool, /obj/item/fireaxe)) + try_to_crowbar(tool, user, FALSE) + return ITEM_INTERACT_SUCCESS + + if(tool.item_flags & NOBLUDGEON || user.combat_mode) + return NONE + + if(istype(tool, /obj/item/stack/sheet/mineral/wood)) + return NONE // we need this so our can_barricade element can be called using COMSIG_ATOM_ATTACKBY + + if(try_to_activate_door(user)) + return ITEM_INTERACT_SUCCESS + + return NONE /obj/machinery/door/item_interaction_secondary(mob/living/user, obj/item/tool, list/modifiers) // allows you to crowbar doors while in combat mode diff --git a/code/game/machinery/doors/firedoor.dm b/code/game/machinery/doors/firedoor.dm index ae6a3e002ee..6fa67ce9af5 100644 --- a/code/game/machinery/doors/firedoor.dm +++ b/code/game/machinery/doors/firedoor.dm @@ -836,114 +836,128 @@ icon_state = "[base_icon_state][constructionStep]" return ..() -/obj/structure/firelock_frame/attackby(obj/item/attacking_object, mob/user) +/obj/structure/firelock_frame/item_interaction(mob/living/user, obj/item/tool, list/modifiers) switch(constructionStep) if(CONSTRUCTION_PANEL_OPEN) - if(attacking_object.tool_behaviour == TOOL_CROWBAR) - attacking_object.play_tool_sound(src) - user.visible_message(span_notice("[user] begins removing the circuit board from [src]..."), \ - span_notice("You begin prying out the circuit board from [src]...")) - if(!attacking_object.use_tool(src, user, DEFAULT_STEP_TIME)) - return - if(constructionStep != CONSTRUCTION_PANEL_OPEN) - return - playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, TRUE) - user.visible_message(span_notice("[user] removes [src]'s circuit board."), \ - span_notice("You remove the circuit board from [src].")) - new /obj/item/electronics/firelock(drop_location()) - constructionStep = CONSTRUCTION_NO_CIRCUIT - update_appearance() - return - if(attacking_object.tool_behaviour == TOOL_WRENCH) - if(locate(/obj/machinery/door/firedoor) in get_turf(src)) - to_chat(user, span_warning("There's already a firelock there.")) - return - attacking_object.play_tool_sound(src) - user.visible_message(span_notice("[user] starts bolting down [src]..."), \ - span_notice("You begin bolting [src]...")) - if(!attacking_object.use_tool(src, user, DEFAULT_STEP_TIME)) - return - if(locate(/obj/machinery/door/firedoor) in get_turf(src)) - return - user.visible_message(span_notice("[user] finishes the firelock."), \ - span_notice("You finish the firelock.")) - playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, TRUE) - if(reinforced) - new /obj/machinery/door/firedoor/heavy(get_turf(src)) - else if(directional) - var/obj/machinery/door/firedoor/border_only/new_firedoor = new /obj/machinery/door/firedoor/border_only(get_turf(src)) - new_firedoor.setDir(dir) - new_firedoor.adjust_lights_starting_offset() - else - new /obj/machinery/door/firedoor(get_turf(src)) - qdel(src) - return - if(istype(attacking_object, /obj/item/stack/sheet/plasteel)) - if(directional) - to_chat(user, span_warning("[src] can not be reinforced.")) - return - var/obj/item/stack/sheet/plasteel/plasteel_sheet = attacking_object - if(reinforced) - to_chat(user, span_warning("[src] is already reinforced.")) - return - if(plasteel_sheet.get_amount() < 2) - to_chat(user, span_warning("You need more plasteel to reinforce [src].")) - return - user.visible_message(span_notice("[user] begins reinforcing [src]..."), \ - span_notice("You begin reinforcing [src]...")) - playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, TRUE) - if(do_after(user, DEFAULT_STEP_TIME, target = src)) - if(constructionStep != CONSTRUCTION_PANEL_OPEN || reinforced || plasteel_sheet.get_amount() < 2 || !plasteel_sheet) - return - user.visible_message(span_notice("[user] reinforces [src]."), \ - span_notice("You reinforce [src].")) - playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, TRUE) - plasteel_sheet.use(2) - reinforced = 1 - return + if(!istype(tool, /obj/item/stack/sheet/plasteel)) + return NONE + if(directional) + to_chat(user, span_warning("[src] can not be reinforced.")) + return ITEM_INTERACT_BLOCKING + var/obj/item/stack/sheet/plasteel/plasteel_sheet = tool + if(reinforced) + to_chat(user, span_warning("[src] is already reinforced.")) + return ITEM_INTERACT_BLOCKING + if(plasteel_sheet.get_amount() < 2) + to_chat(user, span_warning("You need more plasteel to reinforce [src].")) + return ITEM_INTERACT_BLOCKING + user.visible_message(span_notice("[user] begins reinforcing [src]..."), \ + span_notice("You begin reinforcing [src]...")) + playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, TRUE) + if(!do_after(user, DEFAULT_STEP_TIME, target = src)) + return ITEM_INTERACT_BLOCKING + if(constructionStep != CONSTRUCTION_PANEL_OPEN || reinforced || plasteel_sheet.get_amount() < 2 || !plasteel_sheet) + return ITEM_INTERACT_BLOCKING + user.visible_message(span_notice("[user] reinforces [src]."), \ + span_notice("You reinforce [src].")) + playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, TRUE) + plasteel_sheet.use(2) + reinforced = 1 + return ITEM_INTERACT_SUCCESS + if(CONSTRUCTION_NO_CIRCUIT) - if(istype(attacking_object, /obj/item/electronics/firelock)) - user.visible_message(span_notice("[user] starts adding [attacking_object] to [src]..."), \ + if(istype(tool, /obj/item/electronics/firelock)) + user.visible_message(span_notice("[user] starts adding [tool] to [src]..."), \ span_notice("You begin adding a circuit board to [src]...")) playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, TRUE) if(!do_after(user, DEFAULT_STEP_TIME, target = src)) - return + return ITEM_INTERACT_BLOCKING if(constructionStep != CONSTRUCTION_NO_CIRCUIT) - return - qdel(attacking_object) + return ITEM_INTERACT_BLOCKING + qdel(tool) user.visible_message(span_notice("[user] adds a circuit to [src]."), \ - span_notice("You insert and secure [attacking_object].")) + span_notice("You insert and secure [tool].")) playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, TRUE) constructionStep = CONSTRUCTION_PANEL_OPEN update_appearance() - return - if(attacking_object.tool_behaviour == TOOL_WELDER) - if(!attacking_object.tool_start_check(user, amount=1)) - return - user.visible_message(span_notice("[user] begins cutting apart [src]'s frame..."), \ - span_notice("You begin slicing [src] apart...")) + return ITEM_INTERACT_SUCCESS - if(attacking_object.use_tool(src, user, DEFAULT_STEP_TIME, volume=50)) - if(constructionStep != CONSTRUCTION_NO_CIRCUIT) - return - user.visible_message(span_notice("[user] cuts apart [src]!"), \ - span_notice("You cut [src] into metal.")) - var/turf/targetloc = get_turf(src) - new /obj/item/stack/sheet/iron(targetloc, directional ? 2 : 3) - if(reinforced) - new /obj/item/stack/sheet/plasteel(targetloc, 2) - qdel(src) - return - if(istype(attacking_object, /obj/item/electroadaptive_pseudocircuit)) - var/obj/item/electroadaptive_pseudocircuit/raspberrypi = attacking_object + if(istype(tool, /obj/item/electroadaptive_pseudocircuit)) + var/obj/item/electroadaptive_pseudocircuit/raspberrypi = tool if(!raspberrypi.adapt_circuit(user, circuit_cost = DEFAULT_STEP_TIME * 0.0005 * STANDARD_CELL_CHARGE)) - return + return ITEM_INTERACT_BLOCKING user.visible_message(span_notice("[user] fabricates a circuit and places it into [src]."), \ span_notice("You adapt a firelock circuit and slot it into the assembly.")) constructionStep = CONSTRUCTION_PANEL_OPEN update_appearance() - return - return ..() + return ITEM_INTERACT_SUCCESS + return NONE + +/obj/structure/firelock_frame/crowbar_act(mob/living/user, obj/item/tool) + if(constructionStep != CONSTRUCTION_PANEL_OPEN) + return NONE + tool.play_tool_sound(src) + user.visible_message(span_notice("[user] begins removing the circuit board from [src]..."), \ + span_notice("You begin prying out the circuit board from [src]...")) + if(!tool.use_tool(src, user, DEFAULT_STEP_TIME)) + return ITEM_INTERACT_BLOCKING + if(constructionStep != CONSTRUCTION_PANEL_OPEN) + return ITEM_INTERACT_BLOCKING + playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, TRUE) + user.visible_message(span_notice("[user] removes [src]'s circuit board."), \ + span_notice("You remove the circuit board from [src].")) + new /obj/item/electronics/firelock(drop_location()) + constructionStep = CONSTRUCTION_NO_CIRCUIT + update_appearance() + return ITEM_INTERACT_SUCCESS + +/obj/structure/firelock_frame/wrench_act(mob/living/user, obj/item/tool) + if(constructionStep != CONSTRUCTION_PANEL_OPEN) + return NONE + if(locate(/obj/machinery/door/firedoor) in get_turf(src)) + to_chat(user, span_warning("There's already a firelock there.")) + return ITEM_INTERACT_BLOCKING + tool.play_tool_sound(src) + user.visible_message(span_notice("[user] starts bolting down [src]..."), \ + span_notice("You begin bolting [src]...")) + if(!tool.use_tool(src, user, DEFAULT_STEP_TIME)) + return ITEM_INTERACT_BLOCKING + if(locate(/obj/machinery/door/firedoor) in get_turf(src)) + return ITEM_INTERACT_BLOCKING + user.visible_message(span_notice("[user] finishes the firelock."), \ + span_notice("You finish the firelock.")) + playsound(get_turf(src), 'sound/items/deconstruct.ogg', 50, TRUE) + if(reinforced) + new /obj/machinery/door/firedoor/heavy(get_turf(src)) + else if(directional) + var/obj/machinery/door/firedoor/border_only/new_firedoor = new /obj/machinery/door/firedoor/border_only(get_turf(src)) + new_firedoor.setDir(dir) + new_firedoor.adjust_lights_starting_offset() + else + new /obj/machinery/door/firedoor(get_turf(src)) + qdel(src) + return ITEM_INTERACT_SUCCESS + +/obj/structure/firelock_frame/welder_act(mob/living/user, obj/item/tool) + if(constructionStep != CONSTRUCTION_NO_CIRCUIT) + return NONE + if(!tool.tool_start_check(user, amount=1)) + return ITEM_INTERACT_BLOCKING + user.visible_message(span_notice("[user] begins cutting apart [src]'s frame..."), \ + span_notice("You begin slicing [src] apart...")) + + if(!tool.use_tool(src, user, DEFAULT_STEP_TIME, volume=50)) + return ITEM_INTERACT_BLOCKING + if(constructionStep != CONSTRUCTION_NO_CIRCUIT) + return ITEM_INTERACT_BLOCKING + user.visible_message(span_notice("[user] cuts apart [src]!"), \ + span_notice("You cut [src] into metal.")) + var/turf/targetloc = get_turf(src) + new /obj/item/stack/sheet/iron(targetloc, directional ? 2 : 3) + if(reinforced) + new /obj/item/stack/sheet/plasteel(targetloc, 2) + qdel(src) + return ITEM_INTERACT_SUCCESS /obj/structure/firelock_frame/rcd_vals(mob/user, obj/item/construction/rcd/the_rcd) if(the_rcd.mode == RCD_DECONSTRUCT) diff --git a/code/game/machinery/flasher.dm b/code/game/machinery/flasher.dm index f08fc004682..98e8edbf25d 100644 --- a/code/game/machinery/flasher.dm +++ b/code/game/machinery/flasher.dm @@ -62,35 +62,45 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/flasher, 26) return ..() //Don't want to render prison breaks impossible -/obj/machinery/flasher/attackby(obj/item/attacking_item, mob/user, list/modifiers, list/attack_modifiers) +/obj/machinery/flasher/item_interaction(mob/living/user, obj/item/tool, list/modifiers) add_fingerprint(user) - if (attacking_item.tool_behaviour == TOOL_WIRECUTTER) - if (bulb) - user.visible_message(span_notice("[user] begins to disconnect [src]'s flashbulb."), span_notice("You begin to disconnect [src]'s flashbulb...")) - if(attacking_item.use_tool(src, user, 30, volume=50) && bulb) - user.visible_message(span_notice("[user] disconnects [src]'s flashbulb!"), span_notice("You disconnect [src]'s flashbulb.")) - bulb.forceMove(loc) - power_change() - else if (istype(attacking_item, /obj/item/assembly/flash/handheld)) - if (!bulb) - if(!user.transferItemToLoc(attacking_item, src)) - return - user.visible_message(span_notice("[user] installs [attacking_item] into [src]."), span_notice("You install [attacking_item] into [src].")) - power_change() - else - to_chat(user, span_warning("A flashbulb is already installed in [src]!")) + if (!istype(tool, /obj/item/assembly/flash/handheld)) + return NONE + if (bulb) + to_chat(user, span_warning("A flashbulb is already installed in [src]!")) + return ITEM_INTERACT_BLOCKING + if(!user.transferItemToLoc(tool, src)) + return ITEM_INTERACT_BLOCKING + user.visible_message(span_notice("[user] installs [tool] into [src]."), \ + span_notice("You install [tool] into [src].")) + power_change() + return ITEM_INTERACT_SUCCESS - else if (attacking_item.tool_behaviour == TOOL_WRENCH) - if(!bulb) - to_chat(user, span_notice("You start unsecuring the flasher frame...")) - if(attacking_item.use_tool(src, user, 40, volume=50)) - to_chat(user, span_notice("You unsecure the flasher frame.")) - deconstruct(TRUE) - else - to_chat(user, span_warning("Remove a flashbulb from [src] first!")) - else - return ..() + +/obj/machinery/flasher/wirecutter_act(mob/living/user, obj/item/tool) + add_fingerprint(user) + if(!bulb) + return NONE + user.visible_message(span_notice("[user] begins to disconnect [src]'s flashbulb."), span_notice("You begin to disconnect [src]'s flashbulb...")) + if(!tool.use_tool(src, user, 30, volume=50) || !bulb) + return ITEM_INTERACT_BLOCKING + user.visible_message(span_notice("[user] disconnects [src]'s flashbulb!"), span_notice("You disconnect [src]'s flashbulb.")) + bulb.forceMove(loc) + power_change() + return ITEM_INTERACT_SUCCESS + +/obj/machinery/flasher/wrench_act(mob/living/user, obj/item/tool) + add_fingerprint(user) + if(bulb) + to_chat(user, span_warning("Remove a flashbulb from [src] first!")) + return ITEM_INTERACT_BLOCKING + to_chat(user, span_notice("You start unsecuring the flasher frame...")) + if(!tool.use_tool(src, user, 40, volume=50)) + return ITEM_INTERACT_BLOCKING + to_chat(user, span_notice("You unsecure the flasher frame.")) + deconstruct(TRUE) + return ITEM_INTERACT_SUCCESS //Let the AI trigger them directly. /obj/machinery/flasher/attack_ai() @@ -189,25 +199,22 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/flasher, 26) if(vname == NAMEOF(src, flash_range)) proximity_monitor?.set_range(flash_range) -/obj/machinery/flasher/portable/attackby(obj/item/attacking_item, mob/user, list/modifiers, list/attack_modifiers) - if (attacking_item.tool_behaviour == TOOL_WRENCH) - attacking_item.play_tool_sound(src, 100) +/obj/machinery/flasher/portable/wrench_act(mob/living/user, obj/item/tool) + tool.play_tool_sound(src, 100) + if (!anchored && !isinspace()) + to_chat(user, span_notice("[src] is now secured.")) + add_overlay("[base_icon_state]-s") + set_anchored(TRUE) + power_change() + proximity_monitor.set_range(flash_range) + return ITEM_INTERACT_SUCCESS - if (!anchored && !isinspace()) - to_chat(user, span_notice("[src] is now secured.")) - add_overlay("[base_icon_state]-s") - set_anchored(TRUE) - power_change() - proximity_monitor.set_range(flash_range) - else - to_chat(user, span_notice("[src] can now be moved.")) - cut_overlays() - set_anchored(FALSE) - power_change() - proximity_monitor.set_range(0) - - else - return ..() + to_chat(user, span_notice("[src] can now be moved.")) + cut_overlays() + set_anchored(FALSE) + power_change() + proximity_monitor.set_range(0) + return ITEM_INTERACT_SUCCESS /obj/item/wallframe/flasher name = "mounted flash frame" diff --git a/code/game/machinery/launch_pad.dm b/code/game/machinery/launch_pad.dm index ed60bd83539..72e8723e40c 100644 --- a/code/game/machinery/launch_pad.dm +++ b/code/game/machinery/launch_pad.dm @@ -320,15 +320,16 @@ closed = TRUE update_indicator() -/obj/machinery/launchpad/briefcase/attackby(obj/item/item, mob/user, list/modifiers, list/attack_modifiers) - if(istype(item, /obj/item/launchpad_remote)) - var/obj/item/launchpad_remote/launch = item - if(IS_WEAKREF_OF(src, launch.pad)) //do not attempt to link when already linked - return ..() - launch.pad = WEAKREF(src) - to_chat(user, span_notice("You link [src] to [launch].")) - else - return ..() +/obj/machinery/launchpad/briefcase/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(!istype(tool, /obj/item/launchpad_remote)) + return NONE + var/obj/item/launchpad_remote/remote = tool + if(IS_WEAKREF_OF(src, remote.pad)) //do not attempt to link when already linked + return ITEM_INTERACT_BLOCKING + remote.pad = WEAKREF(src) + to_chat(user, span_notice("You link [src] to [remote].")) + return ITEM_INTERACT_SUCCESS + /obj/item/launchpad_remote name = "folder" diff --git a/code/game/machinery/modular_shield.dm b/code/game/machinery/modular_shield.dm index 6873c29afb2..e0f10eb7a47 100644 --- a/code/game/machinery/modular_shield.dm +++ b/code/game/machinery/modular_shield.dm @@ -144,13 +144,11 @@ /obj/machinery/modular_shield_generator/crowbar_act(mob/living/user, obj/item/tool) return default_deconstruction_crowbar(user, tool) -/obj/machinery/modular_shield_generator/attackby(obj/item/W, mob/user, list/modifiers) - - if(is_wire_tool(W) && panel_open) - wires.interact(user) - return TRUE - - return ..() +/obj/machinery/modular_shield_generator/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(!panel_open || !is_wire_tool(tool)) + return NONE + wires.interact(user) + return ITEM_INTERACT_SUCCESS /obj/machinery/modular_shield_generator/multitool_act(mob/living/user, obj/item/multitool/multi) multi.set_buffer(src) diff --git a/code/game/machinery/navbeacon.dm b/code/game/machinery/navbeacon.dm index 0350799c6a8..867c98c15ea 100644 --- a/code/game/machinery/navbeacon.dm +++ b/code/game/machinery/navbeacon.dm @@ -119,24 +119,23 @@ . = ..() icon_state = "[base_icon_state][panel_open]" -/obj/machinery/navbeacon/attackby(obj/item/attacking_item, mob/user, list/modifiers, list/attack_modifiers) +/obj/machinery/navbeacon/item_interaction(mob/living/user, obj/item/tool, list/modifiers) var/turf/our_turf = loc if(our_turf.underfloor_accessibility < UNDERFLOOR_INTERACTABLE) - return // prevent intraction when T-scanner revealed + return ITEM_INTERACT_BLOCKING// prevent interaction when T-scanner revealed - if (attacking_item.GetID()) - if(!panel_open) - if (allowed(user)) - controls_locked = !controls_locked - balloon_alert(user, "controls [controls_locked ? "locked" : "unlocked"]") - SStgui.update_uis(src) - else - balloon_alert(user, "access denied") - else - balloon_alert(user, "panel open!") - return - - return ..() + if(!tool.GetID()) + return NONE + if(panel_open) + balloon_alert(user, "panel open!") + return ITEM_INTERACT_BLOCKING + if (!allowed(user)) + balloon_alert(user, "access denied") + return ITEM_INTERACT_BLOCKING + controls_locked = !controls_locked + balloon_alert(user, "controls [controls_locked ? "locked" : "unlocked"]") + SStgui.update_uis(src) + return ITEM_INTERACT_SUCCESS /obj/machinery/navbeacon/attack_ai(mob/user) interact(user) diff --git a/code/game/machinery/requests_console.dm b/code/game/machinery/requests_console.dm index 1bc8c9a4fda..53e3db3f2cf 100644 --- a/code/game/machinery/requests_console.dm +++ b/code/game/machinery/requests_console.dm @@ -517,19 +517,18 @@ GLOBAL_LIST_EMPTY(req_console_ckey_departments) to_chat(user, span_warning("You must open the maintenance panel first!")) return TRUE -/obj/machinery/requests_console/attackby(obj/item/attacking_item, mob/user, list/modifiers, list/attack_modifiers) - var/obj/item/card/id/ID = attacking_item.GetID() - if(ID) - message_verified_by = "[ID.registered_name] ([ID.assignment])" - announcement_authenticated = (ACCESS_RC_ANNOUNCE in ID.access) +/obj/machinery/requests_console/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + var/obj/item/card/id/card = tool.GetID() + if(card) + message_verified_by = "[card.registered_name] ([card.assignment])" + announcement_authenticated = (ACCESS_RC_ANNOUNCE in card.access) SStgui.update_uis(src) - return - if (istype(attacking_item, /obj/item/stamp)) - var/obj/item/stamp/attacking_stamp = attacking_item - message_stamped_by = attacking_stamp.name + return ITEM_INTERACT_SUCCESS + if (istype(tool, /obj/item/stamp)) + message_stamped_by = tool.name SStgui.update_uis(src) - return - return ..() + return ITEM_INTERACT_SUCCESS + return NONE /obj/machinery/requests_console/on_deconstruction(disassembled) new /obj/item/wallframe/requests_console(loc) diff --git a/code/game/machinery/roulette_machine.dm b/code/game/machinery/roulette_machine.dm index 7140e291432..85ab9e2f4ef 100644 --- a/code/game/machinery/roulette_machine.dm +++ b/code/game/machinery/roulette_machine.dm @@ -116,88 +116,90 @@ update_appearance() // Not applicable to all objects. ///Handles setting ownership and the betting itself. -/obj/machinery/roulette/attackby(obj/item/W, mob/user, list/modifiers, list/attack_modifiers) - if(machine_stat & MAINT && is_wire_tool(W)) +/obj/machinery/roulette/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(machine_stat & MAINT && is_wire_tool(tool)) wires.interact(user) - return + return ITEM_INTERACT_SUCCESS if(playing) - return ..() - var/obj/item/card/id/player_card = W.GetID() - if(player_card) - if(isidcard(W)) - playsound(src, 'sound/machines/card_slide.ogg', 50, TRUE) - else - playsound(src, 'sound/machines/terminal/terminal_success.ogg', 50, TRUE) + return NONE + var/obj/item/card/id/player_card = tool.GetID() + if(!player_card) + return NONE + if(isidcard(tool)) + playsound(src, 'sound/machines/card_slide.ogg', 50, TRUE) + else + playsound(src, 'sound/machines/terminal/terminal_success.ogg', 50, TRUE) - if(machine_stat & MAINT || !on || locked) - to_chat(user, span_notice("The machine appears to be disabled.")) - return FALSE + if(machine_stat & MAINT || !on || locked) + to_chat(user, span_notice("The machine appears to be disabled.")) + return ITEM_INTERACT_BLOCKING - if(!player_card.registered_account) - say("You don't have a bank account!") - playsound(src, 'sound/machines/buzz/buzz-two.ogg', 30, TRUE) - return FALSE + if(!player_card.registered_account) + say("You don't have a bank account!") + playsound(src, 'sound/machines/buzz/buzz-two.ogg', 30, TRUE) + return ITEM_INTERACT_BLOCKING - if(my_card) - if(IS_DEPARTMENTAL_CARD(player_card)) // Are they using a department ID - say("You cannot gamble with the department budget!") - playsound(src, 'sound/machines/buzz/buzz-two.ogg', 30, TRUE) - return FALSE - if(player_card.registered_account.account_balance < chosen_bet_amount) //Does the player have enough funds - say("You do not have the funds to play! Lower your bet or get more money.") - playsound(src, 'sound/machines/buzz/buzz-two.ogg', 30, TRUE) - return FALSE - if(!chosen_bet_amount || isnull(chosen_bet_type)) - return FALSE + if(!my_card) + var/msg = tgui_input_text(user, "Name of your roulette wheel", "Roulette Customization", "Roulette Machine", max_length = MAX_NAME_LEN) + if(!msg) + return ITEM_INTERACT_BLOCKING + name = msg + desc = "Owned by [player_card.registered_account.account_holder], draws directly from [user.p_their()] account." + my_card = player_card + RegisterSignal(my_card, COMSIG_QDELETING, PROC_REF(on_my_card_deleted)) + to_chat(user, span_notice("You link the wheel to your account.")) + power_change() + return ITEM_INTERACT_SUCCESS - //double to nothing bets - var/list/doubles = list( - ROULETTE_BET_2TO1_FIRST, - ROULETTE_BET_2TO1_SECOND, - ROULETTE_BET_2TO1_THIRD, - ROULETTE_BET_1TO12, - ROULETTE_BET_13TO24, - ROULETTE_BET_25TO36 - ) - //result of text2num is null if text starts with a character, meaning it's not a singles bet - var/single = !isnull(text2num(chosen_bet_type)) - var/potential_payout_mult - if (single) - potential_payout_mult = ROULETTE_SINGLES_PAYOUT - else - if (chosen_bet_type in doubles) - potential_payout_mult = ROULETTE_DOZ_COL_PAYOUT - else - potential_payout_mult = ROULETTE_SIMPLE_PAYOUT - var/potential_payout = chosen_bet_amount * potential_payout_mult + if(IS_DEPARTMENTAL_CARD(player_card)) // Are they using a department ID + say("You cannot gamble with the department budget!") + playsound(src, 'sound/machines/buzz/buzz-two.ogg', 30, TRUE) + return ITEM_INTERACT_BLOCKING - if(!check_owner_funds(potential_payout)) - return FALSE //owner is too poor + if(player_card.registered_account.account_balance < chosen_bet_amount) //Does the player have enough funds + say("You do not have the funds to play! Lower your bet or get more money.") + playsound(src, 'sound/machines/buzz/buzz-two.ogg', 30, TRUE) + return ITEM_INTERACT_BLOCKING - if(last_anti_spam > world.time) //do not cheat me - return FALSE + if(!chosen_bet_amount || isnull(chosen_bet_type)) + return ITEM_INTERACT_BLOCKING - last_anti_spam = world.time + anti_spam_cooldown + //double to nothing bets + var/list/doubles = list( + ROULETTE_BET_2TO1_FIRST, + ROULETTE_BET_2TO1_SECOND, + ROULETTE_BET_2TO1_THIRD, + ROULETTE_BET_1TO12, + ROULETTE_BET_13TO24, + ROULETTE_BET_25TO36 + ) + //result of text2num is null if text starts with a character, meaning it's not a singles bet + var/single = !isnull(text2num(chosen_bet_type)) + var/potential_payout_mult + if(single) + potential_payout_mult = ROULETTE_SINGLES_PAYOUT + else if(chosen_bet_type in doubles) + potential_payout_mult = ROULETTE_DOZ_COL_PAYOUT + else + potential_payout_mult = ROULETTE_SIMPLE_PAYOUT + var/potential_payout = chosen_bet_amount * potential_payout_mult - icon_state = "rolling" //Prepare the new icon state for rolling before hand. - flick("flick_up", src) - playsound(src, 'sound/machines/piston/piston_raise.ogg', 70) - playsound(src, 'sound/machines/chime.ogg', 50) + if(!check_owner_funds(potential_payout)) + return ITEM_INTERACT_BLOCKING //owner is too poor + + if(last_anti_spam > world.time) //do not cheat me + return ITEM_INTERACT_BLOCKING + + last_anti_spam = world.time + anti_spam_cooldown + + icon_state = "rolling" //Prepare the new icon state for rolling before hand. + flick("flick_up", src) + playsound(src, 'sound/machines/piston/piston_raise.ogg', 70) + playsound(src, 'sound/machines/chime.ogg', 50) + + addtimer(CALLBACK(src, PROC_REF(play), user, player_card, chosen_bet_type, chosen_bet_amount, potential_payout), 4) //Animation first + return ITEM_INTERACT_SUCCESS - addtimer(CALLBACK(src, PROC_REF(play), user, player_card, chosen_bet_type, chosen_bet_amount, potential_payout), 4) //Animation first - return TRUE - else - var/msg = tgui_input_text(user, "Name of your roulette wheel", "Roulette Customization", "Roulette Machine", max_length = MAX_NAME_LEN) - if(!msg) - return - name = msg - desc = "Owned by [player_card.registered_account.account_holder], draws directly from [user.p_their()] account." - my_card = player_card - RegisterSignal(my_card, COMSIG_QDELETING, PROC_REF(on_my_card_deleted)) - to_chat(user, span_notice("You link the wheel to your account.")) - power_change() - return - return ..() ///deletes the my_card ref to prevent harddels /obj/machinery/roulette/proc/on_my_card_deleted(datum/source) diff --git a/code/game/machinery/shieldgen.dm b/code/game/machinery/shieldgen.dm index e3d42f2bfb4..9e44968cbc6 100644 --- a/code/game/machinery/shieldgen.dm +++ b/code/game/machinery/shieldgen.dm @@ -239,33 +239,36 @@ set_anchored(FALSE) -/obj/machinery/shieldgen/attackby(obj/item/W, mob/user, list/modifiers, list/attack_modifiers) - if(istype(W, /obj/item/stack/cable_coil) && (machine_stat & BROKEN) && panel_open) - var/obj/item/stack/cable_coil/coil = W +/obj/machinery/shieldgen/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(istype(tool, /obj/item/stack/cable_coil) && (machine_stat & BROKEN) && panel_open) + var/obj/item/stack/cable_coil/coil = tool if (coil.get_amount() < 1) to_chat(user, span_warning("You need one length of cable to repair [src]!")) - return + return ITEM_INTERACT_BLOCKING to_chat(user, span_notice("You begin to replace the wires...")) - if(do_after(user, 3 SECONDS, target = src)) - if(coil.get_amount() < 1) - return - coil.use(1) - atom_integrity = max_integrity - set_machine_stat(machine_stat & ~BROKEN) - to_chat(user, span_notice("You repair \the [src].")) - update_appearance() + if(!do_after(user, 3 SECONDS, target = src)) + return ITEM_INTERACT_BLOCKING + if(coil.get_amount() < 1) + return ITEM_INTERACT_BLOCKING + coil.use(1) + atom_integrity = max_integrity + set_machine_stat(machine_stat & ~BROKEN) + to_chat(user, span_notice("You repair \the [src].")) + update_appearance() + return ITEM_INTERACT_SUCCESS - else if(W.GetID()) - if(allowed(user) && !(obj_flags & EMAGGED)) - locked = !locked - to_chat(user, span_notice("You [locked ? "lock" : "unlock"] the controls.")) - else if(obj_flags & EMAGGED) + if(tool.GetID()) + if(obj_flags & EMAGGED) to_chat(user, span_danger("Error, access controller damaged!")) - else + return ITEM_INTERACT_BLOCKING + if(!allowed(user)) to_chat(user, span_danger("Access denied.")) + return ITEM_INTERACT_BLOCKING + locked = !locked + to_chat(user, span_notice("You [locked ? "lock" : "unlock"] the controls.")) + return ITEM_INTERACT_SUCCESS - else - return ..() + return NONE /obj/machinery/shieldgen/emag_act(mob/user, obj/item/card/emag/emag_card) if(obj_flags & EMAGGED) @@ -464,22 +467,24 @@ return default_deconstruction_crowbar(user, tool) -/obj/machinery/power/shieldwallgen/attackby(obj/item/W, mob/user, list/modifiers, list/attack_modifiers) - . = ..() - if(W.GetID()) - if(allowed(user) && !(obj_flags & EMAGGED)) - locked = !locked - balloon_alert(user, "[locked ? "locked!" : "unlocked"]") - else if(obj_flags & EMAGGED) +/obj/machinery/power/shieldwallgen/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(tool.GetID()) + if(obj_flags & EMAGGED) balloon_alert(user, "malfunctioning!") - else + return ITEM_INTERACT_BLOCKING + if(!allowed(user)) balloon_alert(user, "no access!") - return + return ITEM_INTERACT_BLOCKING + locked = !locked + balloon_alert(user, "[locked ? "locked!" : "unlocked"]") + return ITEM_INTERACT_SUCCESS add_fingerprint(user) - if(is_wire_tool(W) && panel_open) + if(is_wire_tool(tool) && panel_open) wires.interact(user) - return + return ITEM_INTERACT_SUCCESS + + return NONE /obj/machinery/power/shieldwallgen/interact(mob/user) diff --git a/code/game/machinery/spaceheater.dm b/code/game/machinery/spaceheater.dm index 698b7e3afd3..86731956157 100644 --- a/code/game/machinery/spaceheater.dm +++ b/code/game/machinery/spaceheater.dm @@ -421,36 +421,40 @@ . = TRUE ///Slightly modified to ignore the open_hatch - it's always open, we hacked it. -/obj/machinery/space_heater/improvised_chem_heater/attackby(obj/item/item, mob/user, list/modifiers, list/attack_modifiers) +/obj/machinery/space_heater/improvised_chem_heater/item_interaction(mob/living/user, obj/item/tool, list/modifiers) add_fingerprint(user) - if(default_deconstruction_crowbar(user, item)) - return - if(istype(item, /obj/item/stock_parts/power_store/cell)) + if(istype(tool, /obj/item/stock_parts/power_store/cell)) if(cell) to_chat(user, span_warning("There is already a power cell inside!")) - return - else if(!user.transferItemToLoc(item, src)) - return - cell = item - item.add_fingerprint(usr) + return ITEM_INTERACT_BLOCKING + if(!user.transferItemToLoc(tool, src)) + return ITEM_INTERACT_BLOCKING + cell = tool + tool.add_fingerprint(usr) user.visible_message(span_notice("\The [user] inserts a power cell into \the [src]."), span_notice("You insert the power cell into \the [src].")) SStgui.update_uis(src) + return ITEM_INTERACT_SUCCESS + //reagent containers - if(is_reagent_container(item) && !(item.item_flags & ABSTRACT) && item.is_open_container()) - . = TRUE //no afterattack - var/obj/item/reagent_containers/container = item + if(is_reagent_container(tool) && !(tool.item_flags & ABSTRACT) && tool.is_open_container()) + var/obj/item/reagent_containers/container = tool if(!user.transferItemToLoc(container, src)) - return + return ITEM_INTERACT_BLOCKING replace_beaker(user, container) to_chat(user, span_notice("You add [container] to [src]'s water bath.")) ui_interact(user) - return + return ITEM_INTERACT_SUCCESS + + if(!beaker|| !is_type_in_list(tool, list(/obj/item/reagent_containers/dropper, /obj/item/ph_meter, /obj/item/ph_paper, /obj/item/reagent_containers/syringe))) + return NONE //Dropper tools - if(beaker) - if(is_type_in_list(item, list(/obj/item/reagent_containers/dropper, /obj/item/ph_meter, /obj/item/ph_paper, /obj/item/reagent_containers/syringe))) - item.interact_with_atom(beaker, user) - return + tool.interact_with_atom(beaker, user) + return ITEM_INTERACT_SUCCESS + +/obj/machinery/space_heater/crowbar_act(mob/living/user, obj/item/tool) + add_fingerprint(user) + return default_deconstruction_crowbar(user, tool) /obj/machinery/space_heater/improvised_chem_heater/on_deconstruction(disassembled = TRUE) . = ..() diff --git a/code/game/machinery/syndicatebomb.dm b/code/game/machinery/syndicatebomb.dm index 942344a30d6..2708c67d168 100644 --- a/code/game/machinery/syndicatebomb.dm +++ b/code/game/machinery/syndicatebomb.dm @@ -196,24 +196,28 @@ return TRUE -/obj/machinery/syndicatebomb/attackby(obj/item/I, mob/user, list/modifiers, list/attack_modifiers) - - if(is_wire_tool(I) && open_panel) +/obj/machinery/syndicatebomb/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(is_wire_tool(tool) && open_panel) wires.interact(user) + return ITEM_INTERACT_SUCCESS - else if(istype(I, /obj/item/bombcore)) - if(!payload) - if(!user.transferItemToLoc(I, src)) - return - payload = I - to_chat(user, span_notice("You place [payload] into [src].")) - else + if(istype(tool, /obj/item/bombcore)) + if(payload) to_chat(user, span_warning("[payload] is already loaded into [src]! You'll have to remove it first.")) - else - var/old_integ = atom_integrity - . = ..() - if((old_integ > atom_integrity) && active && (payload in src)) - to_chat(user, span_warning("That seems like a really bad idea...")) + return ITEM_INTERACT_BLOCKING + if(!user.transferItemToLoc(tool, src)) + return ITEM_INTERACT_BLOCKING + payload = tool + to_chat(user, span_notice("You place [payload] into [src].")) + return ITEM_INTERACT_SUCCESS + + return NONE + +/obj/machinery/syndicatebomb/attackby(obj/item/attacking_item, mob/user, list/modifiers, list/attack_modifiers) + var/old_integ = atom_integrity + . = ..() + if((old_integ > atom_integrity) && active && payload) + to_chat(user, span_warning("That seems like a really bad idea...")) /obj/machinery/syndicatebomb/interact(mob/user) wires.interact(user) @@ -554,23 +558,26 @@ playsound(loc, 'sound/effects/bamf.ogg', 75, TRUE, 5) -/obj/item/bombcore/chemical/attackby(obj/item/I, mob/user, list/modifiers, list/attack_modifiers) - if(I.tool_behaviour == TOOL_CROWBAR && beakers.len > 0) - I.play_tool_sound(src) - for (var/obj/item/B in beakers) - B.forceMove(drop_location()) - beakers -= B - return - else if(istype(I, /obj/item/reagent_containers/cup/beaker) || istype(I, /obj/item/reagent_containers/cup/bottle)) - if(beakers.len < max_beakers) - if(!user.transferItemToLoc(I, src)) - return - beakers += I - to_chat(user, span_notice("You load [src] with [I].")) - else - to_chat(user, span_warning("[I] won't fit! \The [src] can only hold up to [max_beakers] containers.")) - return - ..() +/obj/item/bombcore/chemical/item_interaction(mob/living/user, obj/item/tool, list/modifiers) + if(!istype(tool, /obj/item/reagent_containers/cup/beaker) && !istype(tool, /obj/item/reagent_containers/cup/bottle)) + return NONE + if(beakers.len >= max_beakers) + to_chat(user, span_warning("[tool] won't fit! \The [src] can only hold up to [max_beakers] containers.")) + return ITEM_INTERACT_BLOCKING + if(!user.transferItemToLoc(tool, src)) + return ITEM_INTERACT_BLOCKING + beakers += tool + to_chat(user, span_notice("You load [src] with [tool].")) + return ITEM_INTERACT_SUCCESS + +/obj/item/bombcore/chemical/crowbar_act(mob/living/user, obj/item/tool) + if(!beakers.len) + return NONE + tool.play_tool_sound(src) + for (var/obj/item/beaker in beakers) + beaker.forceMove(drop_location()) + beakers -= beaker + return ITEM_INTERACT_SUCCESS /obj/item/bombcore/chemical/on_craft_completion(list/components, datum/crafting_recipe/current_recipe, atom/crafter) // Using different grenade casings, causes the payload to have different properties. diff --git a/code/game/objects/items/tools/janitorial/janitor_key.dm b/code/game/objects/items/tools/janitorial/janitor_key.dm index d18ac7bd20d..294054bc4ce 100644 --- a/code/game/objects/items/tools/janitorial/janitor_key.dm +++ b/code/game/objects/items/tools/janitorial/janitor_key.dm @@ -47,7 +47,7 @@ */ /obj/item/access_key/proc/attempt_open_door(mob/living/user, obj/machinery/door/airlock) if(DOING_INTERACTION_WITH_TARGET(user, airlock)) - return + return FALSE user.balloon_alert_to_viewers("fumbles with keys...", "finding key...") user.playsound_local(src, 'sound/items/rattling_keys.ogg', 25, TRUE) if(!do_after(user, 3 SECONDS, airlock))