From 68fc7a35f382c4750fe3fa460bcbb20724e490a1 Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Mon, 6 Nov 2023 22:42:57 +0300 Subject: [PATCH 1/5] 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 From 72c8bbe27d222345fab24e9877e097ccb843dae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BA=D1=82=D0=BE?= <65656972+xDanilcusx@users.noreply.github.com> Date: Thu, 9 Nov 2023 16:05:34 +0300 Subject: [PATCH 2/5] lower hard target cooldown --- code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 36e1358ee7..17439efadf 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm @@ -21,7 +21,7 @@ max_distance_from_home = 10 #define AI_CHECK_ANNOYANCE_COOLDOWN 2.5 SECONDS -#define AI_NEW_TARGET_COOLDOWN 5 SECONDS +#define AI_NEW_TARGET_COOLDOWN 2 SECONDS /datum/xeno_ai_movement/linger/lurking/New(mob/living/carbon/xenomorph/parent) . = ..() From 1442fe3f12ccb9f6dbc43c7e9e3d22f6b985d52d Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Wed, 15 Nov 2023 00:30:37 +0300 Subject: [PATCH 3/5] doing whats right --- .../mob/living/carbon/xenomorph/ai/movement/lurking.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 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 17439efadf..9d52471ce9 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm @@ -74,12 +74,12 @@ var/blocked = FALSE for(var/obj/structure/potential_blocker in potential_home) - if(potential_blocker.unslashable && (potential_blocker.can_block_movement || potential_blocker.density)) + 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)) + if(potential_blocker != idle_xeno && potential_blocker.can_block_movement && potential_blocker.density) blocked = TRUE break @@ -88,7 +88,7 @@ var/preferred = FALSE for(var/obj/structure/structure in potential_home) - if(structure.unslashable && (structure.can_block_movement || structure.density)) + if(structure.unslashable && structure.can_block_movement && structure.density) continue preferred = TRUE From b10104f6d0e6cc1f11d44c47ed15eb55cfeb9d1d Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Wed, 15 Nov 2023 00:41:02 +0300 Subject: [PATCH 4/5] kill it till it dooms us all --- .../mob/living/carbon/xenomorph/ai/movement/lurking.dm | 6 ------ code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm | 9 ++++++++- .../modules/mob/living/carbon/xenomorph/castes/Lurker.dm | 1 + 3 files changed, 9 insertions(+), 7 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 9d52471ce9..8bab7a25bf 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm @@ -21,7 +21,6 @@ max_distance_from_home = 10 #define AI_CHECK_ANNOYANCE_COOLDOWN 2.5 SECONDS -#define AI_NEW_TARGET_COOLDOWN 2 SECONDS /datum/xeno_ai_movement/linger/lurking/New(mob/living/carbon/xenomorph/parent) . = ..() @@ -31,14 +30,9 @@ 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) 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 80c67976dc..bab8d3bea9 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm @@ -19,6 +19,12 @@ var/datum/xeno_ai_movement/ai_movement_handler + /// The time interval before this xeno should forcefully get a new target + var/forced_retarget_time = (10 SECONDS) + + /// The actual cooldown declaration for forceful retargeting, reference forced_retarget_time for time in between checks + COOLDOWN_DECLARE(forced_retarget_cooldown) + /mob/living/carbon/xenomorph/Destroy() QDEL_NULL(ai_movement_handler) return ..() @@ -68,8 +74,9 @@ var/mob/current_target_mob = current_target stat_check = (current_target_mob.stat != CONSCIOUS) - if(QDELETED(current_target) || stat_check || get_dist(current_target, src) > ai_range) + if(QDELETED(current_target) || stat_check || get_dist(current_target, src) > ai_range || COOLDOWN_FINISHED(src, forced_retarget_cooldown)) current_target = get_target(ai_range) + COOLDOWN_START(src, forced_retarget_cooldown, forced_retarget_time) if(QDELETED(src)) return TRUE diff --git a/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm b/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm index cf1f0f20ce..088fd587e1 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm @@ -59,6 +59,7 @@ icon_xeno = 'icons/mob/xenos/lurker.dmi' icon_xenonid = 'icons/mob/xenonids/lurker.dmi' + forced_retarget_time = (2 SECONDS) var/pull_direction /mob/living/carbon/xenomorph/lurker/launch_towards(datum/launch_metadata/LM) From abe4f0cfb4de27382e289180c0c81bcc78377387 Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Wed, 15 Nov 2023 02:54:52 +0300 Subject: [PATCH 5/5] small tweaks to home search logic --- .../mob/living/carbon/xenomorph/ai/movement/lurking.dm | 5 ++++- .../mob/living/carbon/xenomorph/xeno_ai_interaction.dm | 2 +- 2 files changed, 5 insertions(+), 2 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 8bab7a25bf..eeeb5b9ba8 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm @@ -85,11 +85,14 @@ if(structure.unslashable && structure.can_block_movement && structure.density) continue + if(structure.invisibility == 101) + continue + preferred = TRUE break for(var/turf/closed/touching_turf in orange(1, potential_home)) - if(get_dir(idle_xeno, touching_turf) in diagonals) + if(get_dir(potential_home, touching_turf) in diagonals) continue preferred = TRUE 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 d32474f39c..217f61d56f 100644 --- a/code/modules/mob/living/carbon/xenomorph/xeno_ai_interaction.dm +++ b/code/modules/mob/living/carbon/xenomorph/xeno_ai_interaction.dm @@ -30,7 +30,7 @@ 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 || indestructible) + if(unslashable || indestructible || (climbable && islurker(X))) if(!X.action_busy) do_climb(X) return