Skip to content

Commit

Permalink
removes alot of click-related self registering signals on basic mobs (t…
Browse files Browse the repository at this point in the history
…gstation#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:
  • Loading branch information
Ben10Omintrix authored Oct 15, 2024
1 parent 6e21331 commit 2438ff0
Show file tree
Hide file tree
Showing 18 changed files with 156 additions and 162 deletions.
10 changes: 6 additions & 4 deletions code/modules/mob/living/basic/alien/maid.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions code/modules/mob/living/basic/basic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,19 @@
. += 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)
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)
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
var/result = target.attack_basic_mob(src, modifiers)
SEND_SIGNAL(src, COMSIG_HOSTILE_POST_ATTACKINGTARGET, target, result)
return result
return TRUE

/mob/living/basic/resolve_unarmed_attack(atom/attack_target, list/modifiers)
melee_attack(attack_target, modifiers)
Expand Down
11 changes: 6 additions & 5 deletions code/modules/mob/living/basic/farm_animals/bee/_bee.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions code/modules/mob/living/basic/icemoon/ice_whelp/ice_whelp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
15 changes: 8 additions & 7 deletions code/modules/mob/living/basic/jungle/seedling/seedling.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions code/modules/mob/living/basic/lavaland/mook/mook.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions code/modules/mob/living/basic/lavaland/raptor/_raptor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
13 changes: 7 additions & 6 deletions code/modules/mob/living/basic/minebots/minebot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
. = ..()
Expand Down Expand Up @@ -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)
Expand Down
32 changes: 15 additions & 17 deletions code/modules/mob/living/basic/pets/cat/cat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
if(!is_type_in_list(target, huntable_items) || held_food)
return
target.forceMove(src)
/mob/living/basic/pet/cat/early_melee_attack(atom/target, list/modifiers, ignore_cooldown)
. = ..()
if(!.)
return FALSE

/mob/living/basic/pet/cat/proc/pre_unarmed_attack(mob/living/hitter, atom/target, proximity, modifiers)
SIGNAL_HANDLER
if(istype(target, /obj/machinery/oven/range) && can_interact_with_stove)
target.attack_hand(src)
return FALSE

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
if(!can_hold_item)
return TRUE

if(!is_type_in_list(target, huntable_items) || held_food)
return TRUE
var/atom/movable/movable_target = target
movable_target.forceMove(src)
return FALSE

/mob/living/basic/pet/cat/Exited(atom/movable/gone, direction)
. = ..()
Expand Down
23 changes: 9 additions & 14 deletions code/modules/mob/living/basic/pets/orbie/orbie.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 2438ff0

Please sign in to comment.