From 68fc7a35f382c4750fe3fa460bcbb20724e490a1 Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Mon, 6 Nov 2023 22:42:57 +0300 Subject: [PATCH] hard target switch cooldown and hiding on structures --- .../carbon/xenomorph/ai/movement/lurking.dm | 37 ++++++++++++++++--- .../living/carbon/xenomorph/attack_alien.dm | 5 +++ .../carbon/xenomorph/xeno_ai_interaction.dm | 8 +++- 3 files changed, 44 insertions(+), 6 deletions(-) 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 e9413bc4a4..36e1358ee7 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm @@ -21,6 +21,7 @@ max_distance_from_home = 10 #define AI_CHECK_ANNOYANCE_COOLDOWN 2.5 SECONDS +#define AI_NEW_TARGET_COOLDOWN 5 SECONDS /datum/xeno_ai_movement/linger/lurking/New(mob/living/carbon/xenomorph/parent) . = ..() @@ -30,9 +31,14 @@ 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) + addtimer(CALLBACK(src, PROC_REF(get_new_target), parent), AI_NEW_TARGET_COOLDOWN, TIMER_UNIQUE|TIMER_LOOP|TIMER_DELETE_ME) start_lurking() +/datum/xeno_ai_movement/linger/lurking/proc/get_new_target(mob/living/carbon/xenomorph/parent) + parent.current_target = parent.get_target(parent.ai_range) + +#undef AI_NEW_TARGET_COOLDOWN #undef AI_CHECK_ANNOYANCE_COOLDOWN /datum/xeno_ai_movement/linger/lurking/ai_move_idle(delta_time) @@ -67,7 +73,12 @@ continue var/blocked = FALSE - for(var/atom/potential_blocker as anything in potential_home) + for(var/obj/structure/potential_blocker in potential_home) + if(potential_blocker.unslashable && (potential_blocker.can_block_movement || potential_blocker.density)) + blocked = TRUE + break + + for(var/mob/potential_blocker in potential_home) if(potential_blocker != idle_xeno && (potential_blocker.can_block_movement || potential_blocker.density)) blocked = TRUE break @@ -76,7 +87,21 @@ continue var/preferred = FALSE + for(var/obj/structure/structure in potential_home) + if(structure.unslashable && (structure.can_block_movement || structure.density)) + continue + + preferred = TRUE + break + for(var/turf/closed/touching_turf in orange(1, potential_home)) + if(get_dir(idle_xeno, touching_turf) in diagonals) + continue + + preferred = TRUE + break + + for(var/obj/item/stack/sheet/sheet in potential_home) preferred = TRUE break @@ -194,12 +219,14 @@ #undef LURKER_BAITS_BEFORE_AMBUSH /datum/xeno_ai_movement/linger/lurking/proc/interact_random(mob/living/carbon/xenomorph/X) - for(var/obj/potential_interaction in orange(1, X)) - if(istype(potential_interaction, /obj/structure/window_frame)) + for(var/atom/potential_interaction in orange(1, X)) + if(istype(potential_interaction, /obj/structure/shuttle)) + continue + if(istype(potential_interaction, /turf/closed/shuttle)) continue - if(istype(potential_interaction, /obj/structure/pipes)) + if(istype(potential_interaction, /obj/effect)) continue - if(istype(potential_interaction, /obj/structure/sign)) + if(istype(potential_interaction, /turf/open)) continue if(!potential_interaction.xeno_ai_act(X)) continue diff --git a/code/modules/mob/living/carbon/xenomorph/attack_alien.dm b/code/modules/mob/living/carbon/xenomorph/attack_alien.dm index c331324770..32d94dd1c6 100644 --- a/code/modules/mob/living/carbon/xenomorph/attack_alien.dm +++ b/code/modules/mob/living/carbon/xenomorph/attack_alien.dm @@ -520,6 +520,10 @@ . = XENO_NO_DELAY_ACTION + if(M.action_busy) + to_chat(M, SPAN_WARNING("You are already doing something!")) + return + if(M.claw_type >= CLAW_TYPE_SHARP) M.animation_attack_on(src) playsound(src, 'sound/effects/metalhit.ogg', 25, 1) @@ -933,6 +937,7 @@ M.visible_message(SPAN_DANGER("[M] smashes [src] beyond recognition!"), \ SPAN_DANGER("You enter a frenzy and smash [src] apart!"), null, 5, CHAT_TYPE_XENO_COMBAT) malfunction() + tip_over() else M.visible_message(SPAN_DANGER("[M] [M.slashes_verb] [src]!"), \ SPAN_DANGER("You [M.slash_verb] [src]!"), null, 5, CHAT_TYPE_XENO_COMBAT) diff --git a/code/modules/mob/living/carbon/xenomorph/xeno_ai_interaction.dm b/code/modules/mob/living/carbon/xenomorph/xeno_ai_interaction.dm index 9f4ce3df0e..d32474f39c 100644 --- a/code/modules/mob/living/carbon/xenomorph/xeno_ai_interaction.dm +++ b/code/modules/mob/living/carbon/xenomorph/xeno_ai_interaction.dm @@ -30,13 +30,19 @@ At bare minimum, make sure the relevant checks from parent types gets copied in return OBJECT_PENALTY /obj/structure/xeno_ai_act(mob/living/carbon/xenomorph/X) - if(unslashable) + if(unslashable || indestructible) if(!X.action_busy) do_climb(X) return return ..() +/obj/structure/machinery/xeno_ai_act(mob/living/carbon/xenomorph/X) + if(stat & TIPPED_OVER) + return + + return ..() + // MINERAL DOOR /obj/structure/mineral_door/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target) return DOOR_PENALTY