From 2438ff02132120ddaa673237e40c10f1124042db Mon Sep 17 00:00:00 2001 From: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Date: Tue, 15 Oct 2024 22:58:20 +0300 Subject: [PATCH] removes alot of click-related self registering signals on basic mobs (#87220) ## About The Pull Request there was no real benefit of using signals over proc overrides for many of these cases. ## Why It's Good For The Game registering signals on self when we can just override the proc is un-necessary, im responsible for most of these so im just confronting the sins of my past ## Changelog :cl: /:cl: --- code/modules/mob/living/basic/alien/maid.dm | 10 +++--- code/modules/mob/living/basic/basic.dm | 15 +++++--- .../mob/living/basic/farm_animals/bee/_bee.dm | 11 +++--- .../basic/icemoon/ice_whelp/ice_whelp.dm | 22 ++++++------ .../living/basic/jungle/seedling/seedling.dm | 15 ++++---- .../basic/lavaland/gutlunchers/gutlunchers.dm | 14 ++++---- .../mob/living/basic/lavaland/mook/mook.dm | 14 ++++---- .../living/basic/lavaland/raptor/_raptor.dm | 14 ++++---- .../mob/living/basic/minebots/minebot.dm | 13 +++---- code/modules/mob/living/basic/pets/cat/cat.dm | 34 +++++++++---------- .../mob/living/basic/pets/orbie/orbie.dm | 23 +++++-------- .../mob/living/basic/pets/parrot/_parrot.dm | 24 ++++++------- .../basic/space_fauna/eyeball/_eyeball.dm | 20 +++++------ .../basic/space_fauna/hivebot/_hivebot.dm | 11 +++--- .../mob/living/basic/space_fauna/morph.dm | 28 ++++++++------- .../mob/living/basic/space_fauna/mushroom.dm | 22 +++++------- .../basic/space_fauna/regal_rat/regal_rat.dm | 20 +++++------ .../basic/space_fauna/supermatter_spider.dm | 12 +++---- 18 files changed, 158 insertions(+), 164 deletions(-) diff --git a/code/modules/mob/living/basic/alien/maid.dm b/code/modules/mob/living/basic/alien/maid.dm index decfe5736ce..cf6499884e9 100644 --- a/code/modules/mob/living/basic/alien/maid.dm +++ b/code/modules/mob/living/basic/alien/maid.dm @@ -15,17 +15,19 @@ /mob/living/basic/alien/maid/Initialize(mapload) . = ..() AddElement(/datum/element/cleaning) - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack)) ///Handles the maid attacking other players, cancelling the attack to clean up instead. -/mob/living/basic/alien/maid/proc/pre_attack(mob/living/puncher, atom/target) - SIGNAL_HANDLER +/mob/living/basic/alien/maid/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) + return FALSE + target.wash(CLEAN_SCRUB) if(istype(target, /obj/effect/decal/cleanable)) visible_message(span_notice("[src] cleans up \the [target].")) else visible_message(span_notice("[src] polishes \the [target].")) - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE /** * Barmaid special type diff --git a/code/modules/mob/living/basic/basic.dm b/code/modules/mob/living/basic/basic.dm index 9501c4e21d3..22a20064370 100644 --- a/code/modules/mob/living/basic/basic.dm +++ b/code/modules/mob/living/basic/basic.dm @@ -216,15 +216,20 @@ . += span_deadsay("Upon closer examination, [p_they()] appear[p_s()] to be [HAS_MIND_TRAIT(user, TRAIT_NAIVE) ? "asleep" : "dead"].") /mob/living/basic/proc/melee_attack(atom/target, list/modifiers, ignore_cooldown = FALSE) - face_atom(target) - if (!ignore_cooldown) - changeNext_move(melee_attack_cooldown) - if(SEND_SIGNAL(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, target, Adjacent(target), modifiers) & COMPONENT_HOSTILE_NO_ATTACK) - return FALSE //but more importantly return before attack_animal called + if(!early_melee_attack(target, modifiers, ignore_cooldown)) + return FALSE var/result = target.attack_basic_mob(src, modifiers) SEND_SIGNAL(src, COMSIG_HOSTILE_POST_ATTACKINGTARGET, target, result) return result +/mob/living/basic/proc/early_melee_attack(atom/target, list/modifiers, ignore_cooldown = FALSE) + face_atom(target) + if(!ignore_cooldown) + changeNext_move(melee_attack_cooldown) + if(SEND_SIGNAL(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, target, Adjacent(target), modifiers) & COMPONENT_HOSTILE_NO_ATTACK) + return FALSE //but more importantly return before attack_animal called + return TRUE + /mob/living/basic/resolve_unarmed_attack(atom/attack_target, list/modifiers) melee_attack(attack_target, modifiers) diff --git a/code/modules/mob/living/basic/farm_animals/bee/_bee.dm b/code/modules/mob/living/basic/farm_animals/bee/_bee.dm index 53f9c618c63..2eae8731059 100644 --- a/code/modules/mob/living/basic/farm_animals/bee/_bee.dm +++ b/code/modules/mob/living/basic/farm_animals/bee/_bee.dm @@ -70,7 +70,6 @@ AddComponent(/datum/component/swarming) AddComponent(/datum/component/obeys_commands, pet_commands) AddElement(/datum/element/swabable, CELL_LINE_TABLE_QUEEN_BEE, CELL_VIRUS_TABLE_GENERIC_MOB, 1, 5) - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack)) /mob/living/basic/bee/mob_pickup(mob/living/picker) if(flags_1 & HOLOGRAM_1) @@ -108,18 +107,20 @@ /mob/living/basic/bee/proc/spawn_corpse() new /obj/item/trash/bee(loc, src) -/mob/living/basic/bee/proc/pre_attack(mob/living/puncher, atom/target) - SIGNAL_HANDLER +/mob/living/basic/bee/early_melee_attack(atom/target, list/modifiers) + . = ..() + if(!.) + return FALSE if(istype(target, /obj/machinery/hydroponics)) var/obj/machinery/hydroponics/hydro = target pollinate(hydro) - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE if(istype(target, /obj/structure/beebox)) var/obj/structure/beebox/hive = target handle_habitation(hive) - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE /mob/living/basic/bee/proc/handle_habitation(obj/structure/beebox/hive) if(hive == beehome) //if its our home, we enter or exit it diff --git a/code/modules/mob/living/basic/icemoon/ice_whelp/ice_whelp.dm b/code/modules/mob/living/basic/icemoon/ice_whelp/ice_whelp.dm index 43f8c61d0c8..cc6bd1c900e 100644 --- a/code/modules/mob/living/basic/icemoon/ice_whelp/ice_whelp.dm +++ b/code/modules/mob/living/basic/icemoon/ice_whelp/ice_whelp.dm @@ -45,8 +45,6 @@ AddComponent(/datum/component/basic_mob_ability_telegraph) AddComponent(/datum/component/basic_mob_attack_telegraph, telegraph_duration = 0.6 SECONDS) - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack)) - var/static/list/innate_actions = list( /datum/action/cooldown/mob_cooldown/fire_breath/ice = BB_WHELP_STRAIGHTLINE_FIRE, /datum/action/cooldown/mob_cooldown/fire_breath/ice/cross = BB_WHELP_WIDESPREAD_FIRE, @@ -55,22 +53,24 @@ grant_actions_by_list(innate_actions) -/mob/living/basic/mining/ice_whelp/proc/pre_attack(mob/living/sculptor, atom/target) - SIGNAL_HANDLER +/mob/living/basic/mining/ice_whelp/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) + return FALSE if(istype(target, /obj/structure/flora/rock/icy)) - INVOKE_ASYNC(src, PROC_REF(create_sculpture), target) - return COMPONENT_HOSTILE_NO_ATTACK + create_sculpture(target) + return FALSE - if(!istype(target, src.type)) - return + if(!istype(target, type)) + return TRUE var/mob/living/victim = target if(victim.stat != DEAD) - return + return TRUE - INVOKE_ASYNC(src, PROC_REF(cannibalize_victim), victim) - return COMPONENT_HOSTILE_NO_ATTACK + cannibalize_victim(victim) + return FALSE /// Carve a stone into a beautiful self-portrait /mob/living/basic/mining/ice_whelp/proc/create_sculpture(atom/target) diff --git a/code/modules/mob/living/basic/jungle/seedling/seedling.dm b/code/modules/mob/living/basic/jungle/seedling/seedling.dm index 00db708bc32..3af0675a7f8 100644 --- a/code/modules/mob/living/basic/jungle/seedling/seedling.dm +++ b/code/modules/mob/living/basic/jungle/seedling/seedling.dm @@ -80,23 +80,24 @@ AddElement(/datum/element/wall_tearer, allow_reinforced = FALSE) AddComponent(/datum/component/obeys_commands, seedling_commands) - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack)) RegisterSignal(src, COMSIG_KB_MOB_DROPITEM_DOWN, PROC_REF(drop_can)) update_appearance() -/mob/living/basic/seedling/proc/pre_attack(mob/living/puncher, atom/target) - SIGNAL_HANDLER +/mob/living/basic/seedling/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) + return FALSE if(istype(target, /obj/machinery/hydroponics)) treat_hydro_tray(target) - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE if(isnull(held_can)) - return + return TRUE if(istype(target, /obj/structure/sink) || istype(target, /obj/structure/reagent_dispensers)) - INVOKE_ASYNC(held_can, TYPE_PROC_REF(/obj/item, melee_attack_chain), src, target) - return COMPONENT_HOSTILE_NO_ATTACK + held_can.melee_attack_chain(src, target) + return FALSE ///seedlings can water trays, remove weeds, or remove dead plants diff --git a/code/modules/mob/living/basic/lavaland/gutlunchers/gutlunchers.dm b/code/modules/mob/living/basic/lavaland/gutlunchers/gutlunchers.dm index 6b822d490de..e447255c867 100644 --- a/code/modules/mob/living/basic/lavaland/gutlunchers/gutlunchers.dm +++ b/code/modules/mob/living/basic/lavaland/gutlunchers/gutlunchers.dm @@ -34,7 +34,6 @@ /mob/living/basic/mining/gutlunch/Initialize(mapload) . = ..() GLOB.gutlunch_count++ - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack)) if(greyscale_config) set_greyscale(colors = list(pick(possible_colors))) AddElement(/datum/element/ai_retaliate) @@ -52,19 +51,18 @@ GLOB.gutlunch_count-- return ..() -/mob/living/basic/mining/gutlunch/proc/pre_attack(mob/living/puncher, atom/target) - SIGNAL_HANDLER - - if(!istype(target, /obj/structure/ore_container/food_trough/gutlunch_trough)) +/mob/living/basic/mining/gutlunch/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) return - + if(!istype(target, /obj/structure/ore_container/food_trough/gutlunch_trough)) + return TRUE var/obj/ore_food = locate(/obj/item/stack/ore) in target - if(isnull(ore_food)) balloon_alert(src, "no food!") else melee_attack(ore_food) - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE /mob/living/basic/mining/gutlunch/proc/after_birth(mob/living/basic/mining/gutlunch/grub/baby, mob/living/partner) var/our_color = LAZYACCESS(atom_colours, FIXED_COLOUR_PRIORITY) || COLOR_GRAY diff --git a/code/modules/mob/living/basic/lavaland/mook/mook.dm b/code/modules/mob/living/basic/lavaland/mook/mook.dm index 88802389739..f492c83e74b 100644 --- a/code/modules/mob/living/basic/lavaland/mook/mook.dm +++ b/code/modules/mob/living/basic/lavaland/mook/mook.dm @@ -58,7 +58,6 @@ AddComponent(/datum/component/ai_listen_to_weather) AddElement(/datum/element/wall_tearer, allow_reinforced = FALSE) - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack)) RegisterSignal(src, COMSIG_KB_MOB_DROPITEM_DOWN, PROC_REF(drop_ore)) if(is_healer) @@ -96,27 +95,28 @@ held_ore = null update_appearance(UPDATE_OVERLAYS) -/mob/living/basic/mining/mook/proc/pre_attack(mob/living/attacker, atom/target) - SIGNAL_HANDLER - +/mob/living/basic/mining/mook/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) + return FALSE return attack_sequence(target) /mob/living/basic/mining/mook/proc/attack_sequence(atom/target) if(istype(target, /obj/item/stack/ore) && isnull(held_ore)) var/obj/item/ore_target = target ore_target.forceMove(src) - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE if(istype(target, /obj/structure/ore_container/material_stand)) if(held_ore) held_ore.forceMove(target) - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE if(istype(target, /obj/structure/bonfire)) var/obj/structure/bonfire/fire_target = target if(!fire_target.burning) fire_target.start_burning() - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE /mob/living/basic/mining/mook/proc/change_combatant_state(state) attack_state = state diff --git a/code/modules/mob/living/basic/lavaland/raptor/_raptor.dm b/code/modules/mob/living/basic/lavaland/raptor/_raptor.dm index 2cb9384b06b..917c9c3c438 100644 --- a/code/modules/mob/living/basic/lavaland/raptor/_raptor.dm +++ b/code/modules/mob/living/basic/lavaland/raptor/_raptor.dm @@ -97,7 +97,6 @@ GLOBAL_LIST_EMPTY(raptor_population) ai_controller.set_blackboard_key(BB_BASIC_MOB_SPEAK_LINES, display_emote) inherited_stats = new inherit_properties() - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack)) var/static/list/my_food = list(/obj/item/stack/ore) AddElement(/datum/element/basic_eating, food_types = my_food) AddElement(/datum/element/ai_retaliate) @@ -147,19 +146,20 @@ GLOBAL_LIST_EMPTY(raptor_population) pixel_y = (direction & NORTH) ? -5 : 0 -/mob/living/basic/raptor/proc/pre_attack(mob/living/puncher, atom/target) - SIGNAL_HANDLER - +/mob/living/basic/raptor/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) + return FALSE if(!istype(target, /obj/structure/ore_container/food_trough/raptor_trough)) - return + return TRUE var/obj/ore_food = locate(/obj/item/stack/ore) in target if(isnull(ore_food)) balloon_alert(src, "no food!") else - INVOKE_ASYNC(src, PROC_REF(melee_attack), ore_food) - return COMPONENT_HOSTILE_NO_ATTACK + melee_attack(ore_food) + return TRUE /mob/living/basic/raptor/melee_attack(mob/living/target, list/modifiers, ignore_cooldown) if(!combat_mode && istype(target, /mob/living/basic/raptor/baby_raptor)) diff --git a/code/modules/mob/living/basic/minebots/minebot.dm b/code/modules/mob/living/basic/minebots/minebot.dm index bcf8071d7c2..c9edfb0471f 100644 --- a/code/modules/mob/living/basic/minebots/minebot.dm +++ b/code/modules/mob/living/basic/minebots/minebot.dm @@ -85,7 +85,6 @@ /datum/id_trim/job/shaft_miner, ) AddElement(/datum/element/mob_access, accesses) - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack)) /mob/living/basic/mining_drone/set_combat_mode(new_mode, silent = TRUE) . = ..() @@ -250,13 +249,15 @@ QDEL_NULL(stored_gun) return ..() -/mob/living/basic/mining_drone/proc/pre_attack(datum/source, atom/target) - SIGNAL_HANDLER +/mob/living/basic/mining_drone/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) + return FALSE if(!istype(target, /mob/living/basic/node_drone)) - return NONE - INVOKE_ASYNC(src, PROC_REF(repair_node_drone), target) - return COMPONENT_HOSTILE_NO_ATTACK + return TRUE + repair_node_drone(target) + return FALSE /mob/living/basic/mining_drone/proc/repair_node_drone(mob/living/my_target) do_sparks(5, FALSE, source = my_target) diff --git a/code/modules/mob/living/basic/pets/cat/cat.dm b/code/modules/mob/living/basic/pets/cat/cat.dm index 68821731ee4..3c2ab3f7c9f 100644 --- a/code/modules/mob/living/basic/pets/cat/cat.dm +++ b/code/modules/mob/living/basic/pets/cat/cat.dm @@ -94,29 +94,27 @@ ai_controller.set_blackboard_key(BB_HUNTABLE_PREY, typecacheof(huntable_items)) if(can_breed) add_breeding_component() - if(can_hold_item) - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack)) - if(can_interact_with_stove) - RegisterSignal(src, COMSIG_LIVING_EARLY_UNARMED_ATTACK, PROC_REF(pre_unarmed_attack)) /mob/living/basic/pet/cat/proc/add_cell_sample() AddElement(/datum/element/swabable, CELL_LINE_TABLE_CAT, CELL_VIRUS_TABLE_GENERIC_MOB, 1, 5) -/mob/living/basic/pet/cat/proc/pre_attack(mob/living/source, atom/movable/target) - SIGNAL_HANDLER +/mob/living/basic/pet/cat/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) + return FALSE + + if(istype(target, /obj/machinery/oven/range) && can_interact_with_stove) + target.attack_hand(src) + return FALSE + + if(!can_hold_item) + return TRUE + if(!is_type_in_list(target, huntable_items) || held_food) - return - target.forceMove(src) - -/mob/living/basic/pet/cat/proc/pre_unarmed_attack(mob/living/hitter, atom/target, proximity, modifiers) - SIGNAL_HANDLER - - if(!proximity || !can_unarmed_attack()) - return NONE - if(!istype(target, /obj/machinery/oven/range)) - return NONE - target.attack_hand(src) - return COMPONENT_CANCEL_ATTACK_CHAIN + return TRUE + var/atom/movable/movable_target = target + movable_target.forceMove(src) + return FALSE /mob/living/basic/pet/cat/Exited(atom/movable/gone, direction) . = ..() diff --git a/code/modules/mob/living/basic/pets/orbie/orbie.dm b/code/modules/mob/living/basic/pets/orbie/orbie.dm index a0fbba899e3..85d82e92515 100644 --- a/code/modules/mob/living/basic/pets/orbie/orbie.dm +++ b/code/modules/mob/living/basic/pets/orbie/orbie.dm @@ -36,7 +36,7 @@ ///overlay for our happy eyes var/static/mutable_appearance/happy_eyes_overlay = mutable_appearance('icons/mob/simple/pets.dmi', "orbie_happy_eye_overlay") ///commands we can give orbie - var/list/pet_commands = list( + var/static/list/pet_commands = list( /datum/pet_command/idle, /datum/pet_command/free, /datum/pet_command/untargeted_ability/pet_lights, @@ -52,24 +52,21 @@ AddElement(/datum/element/basic_eating, food_types = food_types) ADD_TRAIT(src, TRAIT_SILICON_EMOTES_ALLOWED, INNATE_TRAIT) - RegisterSignal(src, COMSIG_ATOM_CAN_BE_PULLED, PROC_REF(on_pulled)) RegisterSignal(src, COMSIG_VIRTUAL_PET_LEVEL_UP, PROC_REF(on_level_up)) - RegisterSignal(src, COMSIG_MOB_CLICKON, PROC_REF(on_click)) RegisterSignal(src, COMSIG_ATOM_UPDATE_LIGHT_ON, PROC_REF(on_lights)) ai_controller.set_blackboard_key(BB_BASIC_FOODS, typecacheof(food_types)) update_appearance() -/mob/living/basic/orbie/proc/on_click(mob/living/basic/source, atom/target, params) - SIGNAL_HANDLER - - if(!CanReach(target)) - return - +/mob/living/basic/orbie/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) + return FALSE if(src == target || happy_state || !istype(target)) - return + return TRUE toggle_happy_state() addtimer(CALLBACK(src, PROC_REF(toggle_happy_state)), 30 SECONDS) + return FALSE /mob/living/basic/orbie/proc/on_lights(datum/source) SIGNAL_HANDLER @@ -80,10 +77,8 @@ happy_state = !happy_state update_appearance() -/mob/living/basic/orbie/proc/on_pulled(datum/source) //i need move resist at 0, but i also dont want him to be pulled - SIGNAL_HANDLER - - return COMSIG_ATOM_CANT_PULL +/mob/living/basic/orbie/can_be_pulled(user, grab_state, force) + return FALSE /mob/living/basic/orbie/proc/on_level_up(datum/source, new_level) SIGNAL_HANDLER diff --git a/code/modules/mob/living/basic/pets/parrot/_parrot.dm b/code/modules/mob/living/basic/pets/parrot/_parrot.dm index e22948848eb..e76b9a5e83e 100644 --- a/code/modules/mob/living/basic/pets/parrot/_parrot.dm +++ b/code/modules/mob/living/basic/pets/parrot/_parrot.dm @@ -100,8 +100,6 @@ GLOBAL_LIST_INIT(strippable_parrot_items, create_strippable_list(list( AddComponent(/datum/component/listen_and_repeat, desired_phrases = get_static_list_of_phrases(), blackboard_key = BB_PARROT_REPEAT_STRING) AddComponent(/datum/component/tameable, food_types = edibles, tame_chance = 100, bonus_tame_chance = 0) AddComponent(/datum/component/obeys_commands, pet_commands) - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attacking)) - RegisterSignal(src, COMSIG_MOB_CLICKON, PROC_REF(on_click)) RegisterSignal(src, COMSIG_ATOM_ATTACKBY_SECONDARY, PROC_REF(on_attacked)) // this means we could have a peaceful interaction, like getting a cracker RegisterSignal(src, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_injured)) // this means we got hurt and it's go time RegisterSignal(src, COMSIG_ANIMAL_PET, PROC_REF(on_pet)) @@ -186,12 +184,12 @@ GLOBAL_LIST_INIT(strippable_parrot_items, create_strippable_list(list( icon_state = HAS_TRAIT(src, TRAIT_PARROT_PERCHED) ? icon_sit : icon_living /// Proc that we just use to see if we're rightclicking something for perch behavior or dropping the item we currently ahve -/mob/living/basic/parrot/proc/on_click(mob/living/basic/source, atom/target, params) - SIGNAL_HANDLER - if(!LAZYACCESS(params, RIGHT_CLICK) || !CanReach(target)) - return - if(start_perching(target) && !isnull(held_item)) +/mob/living/basic/parrot/resolve_right_click_attack(atom/target, list/modifiers) + if(!start_perching(target)) + return SECONDARY_ATTACK_CALL_NORMAL + if(!isnull(held_item)) drop_held_item(gently = TRUE) + return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN /// Proc that handles sending the signal and returning a valid phrase to say. Will not do anything if we don't have a stat or if we're cliented. /// Will return either a string or null. @@ -275,16 +273,16 @@ GLOBAL_LIST_INIT(strippable_parrot_items, create_strippable_list(list( /// Master proc which will determine the intent of OUR attacks on an object and summon the relevant procs accordingly. /// This is pretty much meant for players, AI will use the task-specific procs instead. -/mob/living/basic/parrot/proc/pre_attacking(mob/living/basic/source, atom/target) - SIGNAL_HANDLER - if(stat != CONSCIOUS) - return +/mob/living/basic/parrot/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) + return FALSE if(isitem(target) && steal_from_ground(target)) - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE if(iscarbon(target) && steal_from_mob(target)) - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE /// Picks up an item from the ground and puts it in our claws. Returns TRUE if we picked it up, FALSE otherwise. /mob/living/basic/parrot/proc/steal_from_ground(obj/item/target) diff --git a/code/modules/mob/living/basic/space_fauna/eyeball/_eyeball.dm b/code/modules/mob/living/basic/space_fauna/eyeball/_eyeball.dm index c036fe46169..e735067b3ed 100644 --- a/code/modules/mob/living/basic/space_fauna/eyeball/_eyeball.dm +++ b/code/modules/mob/living/basic/space_fauna/eyeball/_eyeball.dm @@ -60,7 +60,6 @@ AddElement(/datum/element/simple_flying) AddComponent(/datum/component/tameable, food_types = list(/obj/item/food/grown/carrot), tame_chance = 100) ADD_TRAIT(src, TRAIT_SPACEWALK, INNATE_TRAIT) - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack)) on_hit_overlay = mutable_appearance(icon, "[icon_state]_crying") /mob/living/basic/eyeball/UnarmedAttack(atom/attack_target, proximity_flag, list/modifiers) @@ -94,21 +93,18 @@ cut_overlay(on_hit_overlay) -/mob/living/basic/eyeball/proc/pre_attack(mob/living/eyeball, atom/target) - SIGNAL_HANDLER - +/mob/living/basic/eyeball/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) + return FALSE if(!ishuman(target)) - return - + return TRUE var/mob/living/carbon/human_target = target var/obj/item/organ/internal/eyes/eyes = human_target.get_organ_slot(ORGAN_SLOT_EYES) - if(!eyes) - return - if(eyes.damage < 10) - return + if(isnull(eyes) || eyes.damage < 10) + return TRUE heal_eye_damage(human_target, eyes) - return COMPONENT_HOSTILE_NO_ATTACK - + return FALSE /mob/living/basic/eyeball/proc/heal_eye_damage(mob/living/target, obj/item/organ/internal/eyes/eyes) if(!COOLDOWN_FINISHED(src, eye_healing)) diff --git a/code/modules/mob/living/basic/space_fauna/hivebot/_hivebot.dm b/code/modules/mob/living/basic/space_fauna/hivebot/_hivebot.dm index 6b72f1f0975..b29718f8810 100644 --- a/code/modules/mob/living/basic/space_fauna/hivebot/_hivebot.dm +++ b/code/modules/mob/living/basic/space_fauna/hivebot/_hivebot.dm @@ -96,18 +96,19 @@ /mob/living/basic/hivebot/mechanic/Initialize(mapload) . = ..() GRANT_ACTION(/datum/action/cooldown/spell/conjure/foam_wall) - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack)) -/mob/living/basic/hivebot/mechanic/proc/pre_attack(mob/living/fixer, atom/target) - SIGNAL_HANDLER +/mob/living/basic/hivebot/mechanic/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) + return FALSE if(ismachinery(target)) repair_machine(target) - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE if(istype(target, /mob/living/basic/hivebot)) repair_hivebot(target) - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE /mob/living/basic/hivebot/mechanic/proc/repair_machine(obj/machinery/fixable) if(fixable.get_integrity() >= fixable.max_integrity) diff --git a/code/modules/mob/living/basic/space_fauna/morph.dm b/code/modules/mob/living/basic/space_fauna/morph.dm index f1f568a261b..f205474af81 100644 --- a/code/modules/mob/living/basic/space_fauna/morph.dm +++ b/code/modules/mob/living/basic/space_fauna/morph.dm @@ -51,7 +51,6 @@ /mob/living/basic/morph/Initialize(mapload) . = ..() ADD_TRAIT(src, TRAIT_VENTCRAWLER_ALWAYS, INNATE_TRAIT) - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack)) RegisterSignal(src, COMSIG_CLICK_SHIFT, PROC_REF(trigger_ability)) RegisterSignal(src, COMSIG_ACTION_DISGUISED_APPEARANCE, PROC_REF(on_disguise)) RegisterSignal(src, SIGNAL_REMOVETRAIT(TRAIT_DISGUISED), PROC_REF(on_undisguise)) @@ -150,28 +149,31 @@ return COMSIG_MOB_CANCEL_CLICKON /// Handles the logic for attacking anything. -/mob/living/basic/morph/proc/pre_attack(mob/living/basic/source, atom/target) - SIGNAL_HANDLER +/mob/living/basic/morph/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) + return FALSE if(HAS_TRAIT(src, TRAIT_DISGUISED) && (melee_damage_disguised <= 0)) balloon_alert(src, "can't attack while disguised!") - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE if(isliving(target)) //Eat Corpses to regen health var/mob/living/living_target = target if(living_target.stat != DEAD) - return + return TRUE - INVOKE_ASYNC(source, PROC_REF(eat), eatable = living_target, delay = 3 SECONDS, update_health = -50) - return COMPONENT_HOSTILE_NO_ATTACK + eat(eatable = living_target, delay = 3 SECONDS, update_health = -50) + return FALSE - if(isitem(target)) //Eat items just to be annoying - var/obj/item/item_target = target - if(item_target.anchored) - return + if(!isitem(target)) //Eat items just to be annoying + return TRUE - INVOKE_ASYNC(source, PROC_REF(eat), eatable = item_target, delay = 2 SECONDS) - return COMPONENT_HOSTILE_NO_ATTACK + var/obj/item/item_target = target + if(item_target.anchored) + return TRUE + eat(eatable = item_target, delay = 2 SECONDS) + return FALSE /// Eat stuff. Delicious. Return TRUE if we ate something, FALSE otherwise. /// Required: `eatable` is the thing (item or mob) that we are going to eat. diff --git a/code/modules/mob/living/basic/space_fauna/mushroom.dm b/code/modules/mob/living/basic/space_fauna/mushroom.dm index de501eaea2e..28f8fa46013 100644 --- a/code/modules/mob/living/basic/space_fauna/mushroom.dm +++ b/code/modules/mob/living/basic/space_fauna/mushroom.dm @@ -53,7 +53,6 @@ health = maxHealth AddElement(/datum/element/swabable, CELL_LINE_TABLE_WALKING_MUSHROOM, CELL_VIRUS_TABLE_GENERIC_MOB, 1, 5) ADD_TRAIT(src, TRAIT_VENTCRAWLER_ALWAYS, INNATE_TRAIT) - RegisterSignal(src, COMSIG_HOSTILE_POST_ATTACKINGTARGET, PROC_REF(on_attacked_target)) /datum/ai_controller/basic_controller/mushroom blackboard = list( @@ -94,20 +93,17 @@ recover(attack_target) return TRUE -/mob/living/basic/mushroom/proc/on_attacked_target(mob/living/basic/attacker, atom/target) - SIGNAL_HANDLER - - if(!istype(target, /mob/living/basic/mushroom)) +/mob/living/basic/mushroom/melee_attack(mob/living/basic/mushroom/target, list/modifiers, ignore_cooldown = FALSE) + . = ..() + if(!.) + return FALSE + if(!istype(target) || target.stat != DEAD) return - var/mob/living/basic/mushroom/victim = target - if(victim.stat != DEAD) + if(target.faint_ticker >= 3) + consume_mushroom(target) return - if(victim.faint_ticker >= 3) - consume_mushroom(victim) - return - - victim.faint_ticker++ - visible_message(span_notice("[src] chews a bit on [victim].")) + target.faint_ticker++ + visible_message(span_notice("[src] chews a bit on [target].")) /mob/living/basic/mushroom/proc/consume_mushroom(mob/living/basic/mushroom/consumed) visible_message(span_warning("[src] devours [consumed]!")) diff --git a/code/modules/mob/living/basic/space_fauna/regal_rat/regal_rat.dm b/code/modules/mob/living/basic/space_fauna/regal_rat/regal_rat.dm index 9f9598b11ae..eae137787ed 100644 --- a/code/modules/mob/living/basic/space_fauna/regal_rat/regal_rat.dm +++ b/code/modules/mob/living/basic/space_fauna/regal_rat/regal_rat.dm @@ -49,7 +49,6 @@ . = ..() ADD_TRAIT(src, TRAIT_VENTCRAWLER_ALWAYS, INNATE_TRAIT) - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(pre_attack)) RegisterSignal(src, COMSIG_MOB_LOGIN, PROC_REF(on_login)) AddElementTrait(TRAIT_WADDLING, INNATE_TRAIT, /datum/element/waddling) @@ -169,21 +168,22 @@ special_moniker = "You better not screw with [p_their()] [selected_kingdom]... How do you become a [selected_title] of that anyways?" /// Checks if we are able to attack this object, as well as send out the signal to see if we get any special regal rat interactions. -/mob/living/basic/regal_rat/proc/pre_attack(mob/living/source, atom/target) - SIGNAL_HANDLER +/mob/living/basic/regal_rat/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) + return FALSE if(DOING_INTERACTION(src, REGALRAT_INTERACTION) || !allowed_to_attack(target)) - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE if(SEND_SIGNAL(target, COMSIG_RAT_INTERACT, src) & COMPONENT_RAT_INTERACTED) - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE - if(isnull(mind)) - return + if(isnull(mind) || !combat_mode) + return TRUE - if(!combat_mode) - INVOKE_ASYNC(src, PROC_REF(poison_target), target) - return COMPONENT_HOSTILE_NO_ATTACK + poison_target(target) + return TRUE /// Checks if we are allowed to attack this mob. Will return TRUE if we are potentially allowed to attack, but if we end up in a case where we should NOT attack, return FALSE. /mob/living/basic/regal_rat/proc/allowed_to_attack(atom/the_target) diff --git a/code/modules/mob/living/basic/space_fauna/supermatter_spider.dm b/code/modules/mob/living/basic/space_fauna/supermatter_spider.dm index a094e20ec35..8c879045a36 100644 --- a/code/modules/mob/living/basic/space_fauna/supermatter_spider.dm +++ b/code/modules/mob/living/basic/space_fauna/supermatter_spider.dm @@ -44,11 +44,11 @@ AddElement(/datum/element/ai_retaliate) AddElement(/datum/element/footstep, FOOTSTEP_MOB_CLAW) - RegisterSignal(src, COMSIG_HOSTILE_PRE_ATTACKINGTARGET, PROC_REF(on_attack)) - /// Proc that we call on attacking something to dust 'em. -/mob/living/basic/supermatter_spider/proc/on_attack(mob/living/basic/source, atom/target) - SIGNAL_HANDLER +/mob/living/basic/supermatter_spider/early_melee_attack(atom/target, list/modifiers, ignore_cooldown) + . = ..() + if(!.) + return FALSE if(isliving(target)) var/mob/living/victim = target @@ -57,14 +57,14 @@ victim.dust() if(single_use) death() - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE if(!isturf(target)) dust_feedback(target) qdel(target) if(single_use) death() - return COMPONENT_HOSTILE_NO_ATTACK + return FALSE /// Simple proc that plays the supermatter dusting sound and sends a visible message. /mob/living/basic/supermatter_spider/proc/dust_feedback(atom/target)