From 21a2468065ff16a754716ca65b8813c37ee3526b Mon Sep 17 00:00:00 2001 From: Morrow Date: Sat, 28 Oct 2023 04:33:54 -0400 Subject: [PATCH] OK this time for sure --- .../signals/atom/mob/living/signals_xeno.dm | 3 ++ .../xenomorph/abilities/general_powers.dm | 2 ++ .../abilities/lurker/lurker_abilities.dm | 4 --- .../carbon/xenomorph/ai/movement/lurking.dm | 28 +++++++++++++++---- .../mob/living/carbon/xenomorph/ai/xeno_ai.dm | 4 +-- .../living/carbon/xenomorph/castes/Lurker.dm | 6 ---- code/modules/projectiles/projectile.dm | 3 +- 7 files changed, 31 insertions(+), 19 deletions(-) diff --git a/code/__DEFINES/dcs/signals/atom/mob/living/signals_xeno.dm b/code/__DEFINES/dcs/signals/atom/mob/living/signals_xeno.dm index 8cbfb5b9bc..f66c264fde 100644 --- a/code/__DEFINES/dcs/signals/atom/mob/living/signals_xeno.dm +++ b/code/__DEFINES/dcs/signals/atom/mob/living/signals_xeno.dm @@ -66,5 +66,8 @@ /// From /mob/living/carbon/xenomorph/proc/handle_crit() #define COMSIG_XENO_HANDLE_CRIT "xeno_handle_crit" +/// From /datum/action/xeno_action/activable/pounce/use_ability() +#define COMSIG_XENO_USED_POUNCE "xeno_used_pounce" + /// From /mob/living/carbon/xenomorph/proc/handle_ai_shot() #define COMSIG_XENO_HANDLE_AI_SHOT "xeno_handle_ai_shot" diff --git a/code/modules/mob/living/carbon/xenomorph/abilities/general_powers.dm b/code/modules/mob/living/carbon/xenomorph/abilities/general_powers.dm index 7a8151d8aa..15c3b27c13 100644 --- a/code/modules/mob/living/carbon/xenomorph/abilities/general_powers.dm +++ b/code/modules/mob/living/carbon/xenomorph/abilities/general_powers.dm @@ -448,6 +448,8 @@ X.launch_towards(LM) + SEND_SIGNAL(owner, COMSIG_XENO_USED_POUNCE, A) + X.update_icons() additional_effects_always() diff --git a/code/modules/mob/living/carbon/xenomorph/abilities/lurker/lurker_abilities.dm b/code/modules/mob/living/carbon/xenomorph/abilities/lurker/lurker_abilities.dm index 55c2da17fe..a769a75df3 100644 --- a/code/modules/mob/living/carbon/xenomorph/abilities/lurker/lurker_abilities.dm +++ b/code/modules/mob/living/carbon/xenomorph/abilities/lurker/lurker_abilities.dm @@ -30,10 +30,6 @@ if (istype(lurker_invis)) lurker_invis.invisibility_off() - var/datum/xeno_ai_movement/linger/lurking/AI = xeno.ai_movement_handler - if (AI && istype(AI)) - AI.stop_lurking() - /datum/action/xeno_action/activable/pounce/lurker/additional_effects(mob/living/L) var/mob/living/carbon/xenomorph/X = owner if (!istype(X)) diff --git a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm index 61a125eb94..115ae57ca4 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm @@ -27,6 +27,8 @@ RegisterSignal(parent, COMSIG_XENO_HANDLE_AI_SHOT, PROC_REF(stop_lurking)) RegisterSignal(parent, COMSIG_XENO_HANDLE_CRIT, PROC_REF(stop_lurking)) + RegisterSignal(parent, COMSIG_XENO_USED_POUNCE, PROC_REF(stop_lurking)) + addtimer(CALLBACK(src, PROC_REF(check_annoyance)), AI_CHECK_ANNOYANCE_COOLDOWN, TIMER_UNIQUE|TIMER_LOOP|TIMER_DELETE_ME) #undef AI_CHECK_ANNOYANCE_COOLDOWN @@ -176,14 +178,14 @@ #undef LURKER_BAITS_BEFORE_AMBUSH /datum/xeno_ai_movement/linger/lurking/proc/interact_random(mob/living/carbon/xenomorph/X) - for(var/obj/O in orange(1, X)) - if(istype(O, /obj/structure/window_frame)) + for(var/obj/potential_interaction in orange(1, X)) + if(istype(potential_interaction, /obj/structure/window_frame)) continue - if(istype(O, /obj/structure/pipes)) + if(istype(potential_interaction, /obj/structure/pipes)) continue - if(istype(O, /obj/structure/sign)) + if(istype(potential_interaction, /obj/structure/sign)) continue - if(!O.xeno_ai_act(X)) + if(!potential_interaction.xeno_ai_act(X)) continue return TRUE return FALSE @@ -199,6 +201,8 @@ register_turf_signals() ai_lurking = TRUE + RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(lurking_parent_moved)) + var/datum/action/xeno_action/activable/pounce/lurker/LPA = get_xeno_action_by_type(lurking_xeno, /datum/action/xeno_action/activable/pounce/lurker) if(LPA && istype(LPA)) LPA.knockdown = TRUE @@ -215,13 +219,19 @@ unregister_turf_signals() ai_lurking = FALSE + UnregisterSignal(parent, COMSIG_MOVABLE_MOVED) + INVOKE_ASYNC(lurking_xeno, TYPE_PROC_REF(/mob, stop_pulling)) /datum/xeno_ai_movement/linger/lurking/proc/register_turf_signals() - for(var/turf/open/cycled_open_turf in view(5, parent)) + for(var/turf/open/cycled_open_turf in view(world.view, parent)) RegisterSignal(cycled_open_turf, COMSIG_TURF_ENTERED, PROC_REF(set_target)) registered_turfs += cycled_open_turf + var/mob/living/carbon/human/possible_target = locate() in cycled_open_turf + if(possible_target) + parent.current_target = possible_target + /datum/xeno_ai_movement/linger/lurking/proc/unregister_turf_signals() for(var/turf/open/cycled_open_turf in registered_turfs) UnregisterSignal(cycled_open_turf, COMSIG_TURF_ENTERED) @@ -235,3 +245,9 @@ return lurking_xeno.current_target = entering_atom + +/datum/xeno_ai_movement/linger/lurking/proc/lurking_parent_moved(atom/movable/moving_atom, atom/oldloc, direction, Forced) + SIGNAL_HANDLER + + unregister_turf_signals() + register_turf_signals() diff --git a/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm b/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm index 6167aada26..f2d2465258 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm @@ -37,11 +37,11 @@ GLOBAL_LIST_INIT(ai_target_limbs, list( return new /datum/xeno_ai_movement(src) /mob/living/carbon/xenomorph/proc/handle_ai_shot(obj/projectile/P) + SEND_SIGNAL(src, COMSIG_XENO_HANDLE_AI_SHOT, P) + if(current_target || !P.firer) return - SEND_SIGNAL(src, COMSIG_XENO_HANDLE_AI_SHOT, P) - var/distance = get_dist(src, P.firer) if(distance > max_travel_distance) return diff --git a/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm b/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm index ed99c8e719..af525c4e45 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm @@ -77,12 +77,6 @@ /mob/living/carbon/xenomorph/lurker/init_movement_handler() return new /datum/xeno_ai_movement/linger/lurking(src) -/mob/living/carbon/xenomorph/lurker/handle_ai_shot(obj/projectile/P) - if(prob(LURKING_IGNORE_SHOT_CHANCE)) - return - - . = ..() - /mob/living/carbon/xenomorph/lurker/ai_move_target(delta_time) if(throwing) return diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index b01203d0f4..48dc79bfa6 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -1025,7 +1025,8 @@ bullet_message(P) //Message us about the bullet, since damage was inflicted. - + if(mob_flags & AI_CONTROLLED) + handle_ai_shot(P) if(SEND_SIGNAL(src, COMSIG_XENO_BULLET_ACT, damage_result, ammo_flags, P) & COMPONENT_CANCEL_BULLET_ACT) return