From 55ce775acd87da16cbfa2d0c0913cc1ff05e32a4 Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Sun, 22 Oct 2023 04:43:19 +0300 Subject: [PATCH 01/23] scary lurker (wip) --- .../abilities/lurker/lurker_abilities.dm | 4 + .../carbon/xenomorph/ai/movement/lurker.dm | 125 ++++++++++++++++++ .../living/carbon/xenomorph/castes/Lurker.dm | 55 ++++++++ .../carbon/xenomorph/xeno_ai_interaction.dm | 6 + colonialmarines.dme | 1 + 5 files changed, 191 insertions(+) create mode 100644 code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm 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 0c9358119d..6d95f1d172 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,6 +30,10 @@ if (istype(lurker_invis)) lurker_invis.invisibility_off() + var/datum/xeno_ai_movement/linger/lurking/AI = xeno.ai_movement_handler + if (istype(AI)) + AI.stop_lurking(xeno) + /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/lurker.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm new file mode 100644 index 0000000000..af85f41b9b --- /dev/null +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm @@ -0,0 +1,125 @@ +/datum/xeno_ai_movement/linger/lurking + + // Gradually increases the chance of AI to try and bait marines + // Annoyance accumulate when we lurk (stand invisible) and aware of our target + var/annoyance = 0 + + // Total baits this xeno made + var/total_baits = 0 + + // Are we currentlu hiding? + var/ai_lurking = FALSE + +#define ANNOYANCE_INCREASE_COOLDOWN 1 SECONDS + +/datum/xeno_ai_movement/linger/lurking/New(mob/living/carbon/xenomorph/parent) + . = ..() + addtimer(CALLBACK(src, PROC_REF(check_annoyance)), ANNOYANCE_INCREASE_COOLDOWN, TIMER_UNIQUE|TIMER_LOOP|TIMER_DELETE_ME) + +#undef ANNOYANCE_INCREASE_COOLDOWN + +/datum/xeno_ai_movement/linger/lurking/ai_move_idle(delta_time) + var/mob/living/carbon/xenomorph/idle_xeno = parent + if(idle_xeno.throwing) + return + + if(next_home_search < world.time && (!home_turf || get_dist(home_turf, idle_xeno) > max_distance_from_home)) + var/turf/T = get_turf(idle_xeno.loc) + next_home_search = world.time + home_search_delay + var/shortest_distance = INFINITY + for(var/i in RANGE_TURFS(home_locate_range, T)) + var/turf/potential_home = i + if(!potential_home.density && get_dist(idle_xeno, potential_home) < shortest_distance) + home_turf = potential_home + shortest_distance = get_dist(idle_xeno, potential_home) + + if(!home_turf) + return + + if(idle_xeno.move_to_next_turf(home_turf, home_locate_range)) + if(get_dist(home_turf, idle_xeno) <= 0 && !ai_lurking) + start_lurking(idle_xeno) + else + home_turf = null + +/datum/xeno_ai_movement/linger/lurking/ai_move_target(delta_time) + var/mob/living/carbon/xenomorph/moving_xeno = parent + if(moving_xeno.throwing) + return + + if(moving_xeno.current_target.is_mob_incapacitated()) + return ..() + + if(ai_lurking) + return ai_move_idle(delta_time) + + annoyance = 0 + check_for_travelling_turf_change(moving_xeno) + + if(!moving_xeno.move_to_next_turf(travelling_turf)) + travelling_turf = get_turf(moving_xeno.current_target) + return TRUE + +/datum/xeno_ai_movement/linger/lurking/proc/check_annoyance() + var/mob/living/carbon/xenomorph/annoyed_xeno = parent + if(annoyed_xeno.current_target in view(world.view,src)) + return + + annoyance++ + + if(prob(annoyance)) + try_bait() + +#define LURKER_BAIT_TYPES list("Taunt","Emote","Interact") +#define LURKER_BAIT_EMOTES pick("growl","roar","scream","needhelp") +#define LURKER_BAIT_TAUNTS pick("Come here, little host","I won't bite","I see you") +#define LURKER_BAITS_BEFORE_AMBUSH 3 + +/datum/xeno_ai_movement/linger/lurking/proc/try_bait(no_interact) + var/mob/living/carbon/xenomorph/baiting_xeno = parent + if(baiting_xeno.throwing) + return + + if(total_baits >= LURKER_BAITS_BEFORE_AMBUSH) + stop_lurking(baiting_xeno) + return + + var/bait_types = LURKER_BAIT_TYPES + if(no_interact) + bait_types -= "Interact" + + var/bait = pick(bait_types) + switch(bait) + if("Emote") + baiting_xeno.emote(LURKER_BAIT_EMOTES) + if("Taunt") + baiting_xeno.say(LURKER_BAIT_TAUNTS) + if("Interact") + if(!interact_random(baiting_xeno)) + try_bait(no_interact = TRUE) + return + + total_baits++ + annoyance = 0 + +#undef LURKER_BAIT_TYPES +#undef LURKER_BAIT_EMOTES +#undef LURKER_BAIT_TAUNTS +#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)) + continue + if(!O.xeno_ai_act(X)) + continue + return TRUE + return FALSE + +/datum/xeno_ai_movement/linger/lurking/proc/start_lurking(mob/living/carbon/xenomorph/X) + animate(X, alpha = 15, time = 0.5 SECONDS, easing = QUAD_EASING) + ai_lurking = TRUE + +/datum/xeno_ai_movement/linger/lurking/proc/stop_lurking(mob/living/carbon/xenomorph/X) + animate(X, alpha = initial(X.alpha), time = 0.2 SECONDS, easing = QUAD_EASING) + ai_lurking = FALSE diff --git a/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm b/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm index c106eb3078..af525c4e45 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm @@ -59,6 +59,61 @@ icon_xeno = 'icons/mob/xenos/lurker.dmi' icon_xenonid = 'icons/mob/xenonids/lurker.dmi' + var/pull_direction + +/mob/living/carbon/xenomorph/lurker/launch_towards(datum/launch_metadata/LM) + if(!current_target) + return ..() + + pull_direction = turn(get_dir(src, current_target), 180) + + if(!(pull_direction in GLOB.cardinals)) + if(abs(x - current_target.x) < abs(y - current_target.y)) + pull_direction &= (NORTH|SOUTH) + else + pull_direction &= (EAST|WEST) + return ..() + +/mob/living/carbon/xenomorph/lurker/init_movement_handler() + return new /datum/xeno_ai_movement/linger/lurking(src) + +/mob/living/carbon/xenomorph/lurker/ai_move_target(delta_time) + if(throwing) + return + + if(pulling) + if(!current_target || get_dist(src, current_target) > 10) + INVOKE_ASYNC(src, PROC_REF(stop_pulling)) + return ..() + if(can_move_and_apply_move_delay()) + if(!Move(get_step(loc, pull_direction), pull_direction)) + pull_direction = turn(pull_direction, pick(45, -45)) + current_path = null + return + + ..() + + if(get_dist(current_target, src) > 1) + return + + if(!current_target.is_mob_incapacitated()) + return + + if(isxeno(current_target.pulledby)) + return + + if(!DT_PROB(RUNNER_GRAB, delta_time)) + return + + INVOKE_ASYNC(src, PROC_REF(start_pulling), current_target) + swap_hand() + +/mob/living/carbon/xenomorph/lurker/process_ai(delta_time) + if(get_active_hand()) + swap_hand() + zone_selected = pick(GLOB.ai_target_limbs) + return ..() + /datum/behavior_delegate/lurker_base name = "Base Lurker Behavior Delegate" 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 90c0ccf805..587942b41a 100644 --- a/code/modules/mob/living/carbon/xenomorph/xeno_ai_interaction.dm +++ b/code/modules/mob/living/carbon/xenomorph/xeno_ai_interaction.dm @@ -4,6 +4,7 @@ /obj/structure/mineral_door/xeno_ai_act(mob/living/carbon/xenomorph/X) X.do_click(src, "", list()) + return TRUE /obj/structure/mineral_door/resin/xeno_ai_obstacle(mob/living/carbon/xenomorph/xeno) if(xeno.hivenumber != hivenumber) @@ -22,6 +23,7 @@ /obj/structure/machinery/door/xeno_ai_act(mob/living/carbon/xenomorph/X) X.do_click(src, "", list()) + return TRUE // OBJECTS /obj/structure/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction) @@ -38,6 +40,7 @@ do_climb(X) return X.do_click(src, "", list()) + return TRUE // HUMANS @@ -50,6 +53,7 @@ if(status_flags & GODMODE) return ..() X.do_click(src, "", list()) + return TRUE // VEHICLES /obj/vehicle/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction) @@ -57,6 +61,7 @@ /obj/vehicle/xeno_ai_act(mob/living/carbon/xenomorph/X) X.do_click(src, "", list()) + return TRUE // SENTRY /obj/structure/machinery/defenses/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction) @@ -64,6 +69,7 @@ /obj/structure/machinery/defenses/xeno_ai_act(mob/living/carbon/xenomorph/X) X.do_click(src, "", list()) + return TRUE // WINDOW FRAME /obj/structure/window_frame/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction) diff --git a/colonialmarines.dme b/colonialmarines.dme index 781570d77e..02bcb2c6a4 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -1986,6 +1986,7 @@ s// DM Environment file for colonialmarines.dme. #include "code\modules\mob\living\carbon\xenomorph\ai\movement\base_define.dm" #include "code\modules\mob\living\carbon\xenomorph\ai\movement\drone.dm" #include "code\modules\mob\living\carbon\xenomorph\ai\movement\linger.dm" +#include "code\modules\mob\living\carbon\xenomorph\ai\movement\lurker.dm" #include "code\modules\mob\living\carbon\xenomorph\castes\Boiler.dm" #include "code\modules\mob\living\carbon\xenomorph\castes\Burrower.dm" #include "code\modules\mob\living\carbon\xenomorph\castes\Carrier.dm" From 0d85ef18b0dc75f4c5163bfe8ad276271a634fbb Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Sun, 22 Oct 2023 21:26:42 +0300 Subject: [PATCH 02/23] the last thing left to do is signals --- code/__DEFINES/xeno_ai.dm | 2 + code/modules/admin/game_master/game_master.dm | 2 +- .../game_master/game_master_submenu/vents.dm | 2 +- .../abilities/lurker/lurker_abilities.dm | 2 +- .../carbon/xenomorph/ai/movement/lurker.dm | 98 ++++++++++++++++--- .../living/carbon/xenomorph/castes/Lurker.dm | 13 +++ 6 files changed, 103 insertions(+), 16 deletions(-) diff --git a/code/__DEFINES/xeno_ai.dm b/code/__DEFINES/xeno_ai.dm index f67cb3f6dd..a51320a435 100644 --- a/code/__DEFINES/xeno_ai.dm +++ b/code/__DEFINES/xeno_ai.dm @@ -28,6 +28,8 @@ PROBABILITY CALCULATIONS ARE HERE #define RETREAT_AT_PLASMA_LEVEL 0.2 #define RETREAT_AT_HEALTH_LEVEL 0.4 +#define LURKING_IGNORE_SHOT_CHANCE 75 + // Warrior /// How likely should it be that you lunge when off cooldown? diff --git a/code/modules/admin/game_master/game_master.dm b/code/modules/admin/game_master/game_master.dm index d61a7b6921..be98fdf17f 100644 --- a/code/modules/admin/game_master/game_master.dm +++ b/code/modules/admin/game_master/game_master.dm @@ -23,7 +23,7 @@ GLOBAL_LIST_EMPTY(game_master_objectives) // Spawn stuff #define DEFAULT_SPAWN_XENO_STRING XENO_CASTE_DRONE -#define GAME_MASTER_AI_XENOS list(XENO_CASTE_DRONE, XENO_CASTE_RUNNER, XENO_CASTE_CRUSHER) +#define GAME_MASTER_AI_XENOS list(XENO_CASTE_DRONE, XENO_CASTE_RUNNER, XENO_CASTE_LURKER, XENO_CASTE_CRUSHER) #define DEFAULT_XENO_AMOUNT_TO_SPAWN 1 diff --git a/code/modules/admin/game_master/game_master_submenu/vents.dm b/code/modules/admin/game_master/game_master_submenu/vents.dm index 188de1f6f1..d2f56cd810 100644 --- a/code/modules/admin/game_master/game_master_submenu/vents.dm +++ b/code/modules/admin/game_master/game_master_submenu/vents.dm @@ -1,6 +1,6 @@ #define DEFAULT_SPAWN_XENO_STRING XENO_CASTE_DRONE -#define GAME_MASTER_VENT_AI_XENOS list(XENO_CASTE_DRONE, XENO_CASTE_RUNNER) +#define GAME_MASTER_VENT_AI_XENOS list(XENO_CASTE_DRONE, XENO_CASTE_RUNNER, XENO_CASTE_LURKER) #define DEFAULT_XENO_AMOUNT_TO_SPAWN 1 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 6d95f1d172..d7f55279e7 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 @@ -31,7 +31,7 @@ lurker_invis.invisibility_off() var/datum/xeno_ai_movement/linger/lurking/AI = xeno.ai_movement_handler - if (istype(AI)) + if (AI && istype(AI)) AI.stop_lurking(xeno) /datum/action/xeno_action/activable/pounce/lurker/additional_effects(mob/living/L) diff --git a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm index af85f41b9b..3bc6859538 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm @@ -7,16 +7,29 @@ // Total baits this xeno made var/total_baits = 0 + // Distance at which we want to stay from our spotted target + var/lurking_distance = 12 + // Are we currentlu hiding? var/ai_lurking = FALSE -#define ANNOYANCE_INCREASE_COOLDOWN 1 SECONDS + // Let's lower this a little bit cause we do some heavy checks while finding our "home" + home_locate_range = 10 + + max_distance_from_home = 8 + +#define AI_CHECK_ANNOYANCE_COOLDOWN 2.5 SECONDS /datum/xeno_ai_movement/linger/lurking/New(mob/living/carbon/xenomorph/parent) . = ..() - addtimer(CALLBACK(src, PROC_REF(check_annoyance)), ANNOYANCE_INCREASE_COOLDOWN, TIMER_UNIQUE|TIMER_LOOP|TIMER_DELETE_ME) + var/datum/action/xeno_action/activable/pounce/lurker/LPA = get_xeno_action_by_type(parent, /datum/action/xeno_action/activable/pounce/lurker) + if (LPA && istype(LPA)) + LPA.knockdown = TRUE // pounce knocks down + LPA.freeze_self = TRUE -#undef ANNOYANCE_INCREASE_COOLDOWN + addtimer(CALLBACK(src, PROC_REF(check_annoyance)), AI_CHECK_ANNOYANCE_COOLDOWN, TIMER_UNIQUE|TIMER_LOOP|TIMER_DELETE_ME) + +#undef AI_CHECK_ANNOYANCE_COOLDOWN /datum/xeno_ai_movement/linger/lurking/ai_move_idle(delta_time) var/mob/living/carbon/xenomorph/idle_xeno = parent @@ -27,15 +40,54 @@ var/turf/T = get_turf(idle_xeno.loc) next_home_search = world.time + home_search_delay var/shortest_distance = INFINITY - for(var/i in RANGE_TURFS(home_locate_range, T)) + for(var/i in shuffle(RANGE_TURFS(home_locate_range, T))) var/turf/potential_home = i + var/lets_continue + + var/mob/living/carbon/xenomorph/blocking_xeno = locate() in potential_home + if(blocking_xeno && blocking_xeno.stat == CONSCIOUS && blocking_xeno != idle_xeno) + continue + + var/target = idle_xeno.current_target + if(target && potential_home != T && (potential_home in view(world.view, target))) + continue // We prefer standing still when someone can see us + if(!potential_home.density && get_dist(idle_xeno, potential_home) < shortest_distance) - home_turf = potential_home shortest_distance = get_dist(idle_xeno, potential_home) + /// First we try to locate some structures to stand and hide on + for(var/obj/structure/S in potential_home) + if(S && !istype(S, /obj/structure/pipes)) // Don't care if it's dense cause we can break it and hide on remains + home_turf = potential_home + lets_continue = TRUE + break + + if(lets_continue) + continue + + /// If we cannot find any structures, we look for walls around our potential home + for(var/turf/t_around in orange(1, potential_home)) + if(t_around && t_around.density) // Let's find a wall to stick to it + home_turf = potential_home + shortest_distance += 5 // Penalty for no structures, we can do better + lets_continue = TRUE + break + + if(lets_continue) + continue + + /// If we have no structures or walls to stick to (strange), just hide on closest turf + home_turf = potential_home + shortest_distance += 10 // Penalty for empty turfs (we don't wanna hide on them) + if(!home_turf) return + /// Abandon hiding place to stalk our target + if(idle_xeno.current_target && get_dist(home_turf, idle_xeno.current_target) > lurking_distance) + home_turf = null + return + if(idle_xeno.move_to_next_turf(home_turf, home_locate_range)) if(get_dist(home_turf, idle_xeno) <= 0 && !ai_lurking) start_lurking(idle_xeno) @@ -50,19 +102,25 @@ if(moving_xeno.current_target.is_mob_incapacitated()) return ..() + var/turf/target_turf = get_turf(moving_xeno.current_target) if(ai_lurking) + if(get_dist(moving_xeno, target_turf) > lurking_distance) + return moving_xeno.move_to_next_turf(target_turf) return ai_move_idle(delta_time) annoyance = 0 check_for_travelling_turf_change(moving_xeno) if(!moving_xeno.move_to_next_turf(travelling_turf)) - travelling_turf = get_turf(moving_xeno.current_target) + travelling_turf = target_turf return TRUE /datum/xeno_ai_movement/linger/lurking/proc/check_annoyance() var/mob/living/carbon/xenomorph/annoyed_xeno = parent - if(annoyed_xeno.current_target in view(world.view,src)) + if(!annoyed_xeno.current_target || !ai_lurking) + return + + if(annoyed_xeno.current_target in view(world.view, annoyed_xeno)) return annoyance++ @@ -71,9 +129,9 @@ try_bait() #define LURKER_BAIT_TYPES list("Taunt","Emote","Interact") -#define LURKER_BAIT_EMOTES pick("growl","roar","scream","needhelp") -#define LURKER_BAIT_TAUNTS pick("Come here, little host","I won't bite","I see you") -#define LURKER_BAITS_BEFORE_AMBUSH 3 +#define LURKER_BAIT_EMOTES list("growl","roar","scream","needshelp") +#define LURKER_BAIT_TAUNTS list("Come here, little host","I won't bite","I see you") +#define LURKER_BAITS_BEFORE_AMBUSH 4 /datum/xeno_ai_movement/linger/lurking/proc/try_bait(no_interact) var/mob/living/carbon/xenomorph/baiting_xeno = parent @@ -82,6 +140,7 @@ if(total_baits >= LURKER_BAITS_BEFORE_AMBUSH) stop_lurking(baiting_xeno) + total_baits = 0 return var/bait_types = LURKER_BAIT_TYPES @@ -91,9 +150,9 @@ var/bait = pick(bait_types) switch(bait) if("Emote") - baiting_xeno.emote(LURKER_BAIT_EMOTES) + baiting_xeno.emote(pick(LURKER_BAIT_EMOTES)) if("Taunt") - baiting_xeno.say(LURKER_BAIT_TAUNTS) + baiting_xeno.say(pick(LURKER_BAIT_TAUNTS)) if("Interact") if(!interact_random(baiting_xeno)) try_bait(no_interact = TRUE) @@ -111,15 +170,28 @@ for(var/obj/O in orange(1, X)) if(istype(O, /obj/structure/window_frame)) continue + if(istype(O, /obj/structure/pipes)) + continue + if(istype(O, /obj/structure/sign)) + continue if(!O.xeno_ai_act(X)) continue return TRUE return FALSE /datum/xeno_ai_movement/linger/lurking/proc/start_lurking(mob/living/carbon/xenomorph/X) - animate(X, alpha = 15, time = 0.5 SECONDS, easing = QUAD_EASING) + animate(X, alpha = 20, time = 0.5 SECONDS, easing = QUAD_EASING) + X.set_movement_intent(MOVE_INTENT_WALK) ai_lurking = TRUE + var/datum/action/xeno_action/activable/pounce/lurker/LPA = get_xeno_action_by_type(X, /datum/action/xeno_action/activable/pounce/lurker) + if (LPA && istype(LPA)) + LPA.knockdown = TRUE // pounce knocks down again + LPA.freeze_self = TRUE + /datum/xeno_ai_movement/linger/lurking/proc/stop_lurking(mob/living/carbon/xenomorph/X) animate(X, alpha = initial(X.alpha), time = 0.2 SECONDS, easing = QUAD_EASING) + X.set_movement_intent(MOVE_INTENT_RUN) ai_lurking = FALSE + + INVOKE_ASYNC(X, TYPE_PROC_REF(/mob, stop_pulling)) diff --git a/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm b/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm index af525c4e45..4124290454 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm @@ -77,6 +77,19 @@ /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(P.firer) + var/distance = get_dist(src, P.firer) + if(distance > world.view) + if(prob(LURKING_IGNORE_SHOT_CHANCE)) + return + + var/datum/xeno_ai_movement/linger/lurking/lurker_ai = ai_movement_handler + if(lurker_ai && istype(lurker_ai)) + lurker_ai.stop_lurking() + + SSxeno_pathfinding.calculate_path(src, P.firer, distance, src, CALLBACK(src, PROC_REF(set_path)), list(src, P.firer)) + /mob/living/carbon/xenomorph/lurker/ai_move_target(delta_time) if(throwing) return From 3de531d843c435a51a0e77fb6ef7f50dfc2263a7 Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Sun, 22 Oct 2023 23:39:36 +0300 Subject: [PATCH 03/23] alright lurkers ready --- .../abilities/lurker/lurker_abilities.dm | 2 +- .../carbon/xenomorph/ai/movement/lurker.dm | 83 +++++++++++++------ .../mob/living/carbon/xenomorph/ai/xeno_ai.dm | 4 + 3 files changed, 62 insertions(+), 27 deletions(-) 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 d7f55279e7..e8cb84c043 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 @@ -32,7 +32,7 @@ var/datum/xeno_ai_movement/linger/lurking/AI = xeno.ai_movement_handler if (AI && istype(AI)) - AI.stop_lurking(xeno) + AI.stop_lurking() /datum/action/xeno_action/activable/pounce/lurker/additional_effects(mob/living/L) var/mob/living/carbon/xenomorph/X = owner diff --git a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm index 3bc6859538..5e55007802 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm @@ -1,5 +1,8 @@ /datum/xeno_ai_movement/linger/lurking + // Are we currentlu hiding? + var/ai_lurking = FALSE + // Gradually increases the chance of AI to try and bait marines // Annoyance accumulate when we lurk (stand invisible) and aware of our target var/annoyance = 0 @@ -7,11 +10,11 @@ // Total baits this xeno made var/total_baits = 0 - // Distance at which we want to stay from our spotted target - var/lurking_distance = 12 + // List of turfs we see and register while lurking + var/list/registered_turfs = list() - // Are we currentlu hiding? - var/ai_lurking = FALSE + // Distance at which we want to stay from our spotted target +// var/stalking_distance = 12 /// uncomment for stalking // Let's lower this a little bit cause we do some heavy checks while finding our "home" home_locate_range = 10 @@ -27,6 +30,7 @@ LPA.knockdown = TRUE // pounce knocks down LPA.freeze_self = TRUE + RegisterSignal(parent, COMSIG_MOVABLE_MOVED, 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 @@ -48,7 +52,7 @@ if(blocking_xeno && blocking_xeno.stat == CONSCIOUS && blocking_xeno != idle_xeno) continue - var/target = idle_xeno.current_target + var/atom/target = idle_xeno.current_target if(target && potential_home != T && (potential_home in view(world.view, target))) continue // We prefer standing still when someone can see us @@ -84,13 +88,13 @@ return /// Abandon hiding place to stalk our target - if(idle_xeno.current_target && get_dist(home_turf, idle_xeno.current_target) > lurking_distance) - home_turf = null - return +// if(idle_xeno.current_target && get_dist(home_turf, idle_xeno.current_target) > stalking_distance) +// home_turf = null +// return /// uncomment for stalking if(idle_xeno.move_to_next_turf(home_turf, home_locate_range)) if(get_dist(home_turf, idle_xeno) <= 0 && !ai_lurking) - start_lurking(idle_xeno) + start_lurking() else home_turf = null @@ -104,8 +108,8 @@ var/turf/target_turf = get_turf(moving_xeno.current_target) if(ai_lurking) - if(get_dist(moving_xeno, target_turf) > lurking_distance) - return moving_xeno.move_to_next_turf(target_turf) +// if(get_dist(moving_xeno, target_turf) > stalking_distance) +// return moving_xeno.move_to_next_turf(target_turf) /// uncomment for stalking return ai_move_idle(delta_time) annoyance = 0 @@ -128,9 +132,10 @@ if(prob(annoyance)) try_bait() + #define LURKER_BAIT_TYPES list("Taunt","Emote","Interact") #define LURKER_BAIT_EMOTES list("growl","roar","scream","needshelp") -#define LURKER_BAIT_TAUNTS list("Come here, little host","I won't bite","I see you") +#define LURKER_BAIT_TAUNTS list("Come here, little host","I won't bite","I see you","Safe to go, little one") #define LURKER_BAITS_BEFORE_AMBUSH 4 /datum/xeno_ai_movement/linger/lurking/proc/try_bait(no_interact) @@ -139,7 +144,7 @@ return if(total_baits >= LURKER_BAITS_BEFORE_AMBUSH) - stop_lurking(baiting_xeno) + stop_lurking() total_baits = 0 return @@ -179,19 +184,45 @@ return TRUE return FALSE -/datum/xeno_ai_movement/linger/lurking/proc/start_lurking(mob/living/carbon/xenomorph/X) - animate(X, alpha = 20, time = 0.5 SECONDS, easing = QUAD_EASING) - X.set_movement_intent(MOVE_INTENT_WALK) - ai_lurking = TRUE - var/datum/action/xeno_action/activable/pounce/lurker/LPA = get_xeno_action_by_type(X, /datum/action/xeno_action/activable/pounce/lurker) - if (LPA && istype(LPA)) - LPA.knockdown = TRUE // pounce knocks down again - LPA.freeze_self = TRUE +/datum/xeno_ai_movement/linger/lurking/proc/start_lurking() + SIGNAL_HANDLER + if(!ai_lurking) + var/mob/living/carbon/xenomorph/lurking_xeno = parent + animate(lurking_xeno, alpha = 20, time = 0.5 SECONDS, easing = QUAD_EASING) + lurking_xeno.set_movement_intent(MOVE_INTENT_WALK) + register_turf_signals() + ai_lurking = TRUE -/datum/xeno_ai_movement/linger/lurking/proc/stop_lurking(mob/living/carbon/xenomorph/X) - animate(X, alpha = initial(X.alpha), time = 0.2 SECONDS, easing = QUAD_EASING) - X.set_movement_intent(MOVE_INTENT_RUN) - ai_lurking = FALSE + 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 // pounce knocks down again + LPA.freeze_self = TRUE - INVOKE_ASYNC(X, TYPE_PROC_REF(/mob, stop_pulling)) +/datum/xeno_ai_movement/linger/lurking/proc/stop_lurking() + SIGNAL_HANDLER + if(ai_lurking) + var/mob/living/carbon/xenomorph/lurking_xeno = parent + animate(lurking_xeno, alpha = initial(lurking_xeno.alpha), time = 0.2 SECONDS, easing = QUAD_EASING) + lurking_xeno.set_movement_intent(MOVE_INTENT_RUN) + unregister_turf_signals() + ai_lurking = FALSE + + INVOKE_ASYNC(lurking_xeno, TYPE_PROC_REF(/mob, stop_pulling)) + + +/datum/xeno_ai_movement/linger/lurking/proc/register_turf_signals() + for(var/turf/turf in view(world.view, parent)) + RegisterSignal(turf, COMSIG_TURF_ENTERED, PROC_REF(set_target), override = TRUE) + registered_turfs += turf + +/datum/xeno_ai_movement/linger/lurking/proc/unregister_turf_signals() + for(var/turf/turf in view(world.view, parent)) + UnregisterSignal(turf, COMSIG_TURF_ENTERED) + registered_turfs = list() + +/datum/xeno_ai_movement/linger/lurking/proc/set_target(turf/hooked, atom/movable/subject) + SIGNAL_HANDLER + var/mob/living/carbon/xenomorph/lurking_xeno = parent + if(subject in GLOB.alive_human_list) + lurking_xeno.current_target = subject 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 20613e56a2..abe30ee1df 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm @@ -260,6 +260,10 @@ GLOBAL_LIST_INIT(ai_target_limbs, list( SHOULD_CALL_PARENT(TRUE) SSxeno_ai.remove_ai(src) + var/datum/xeno_ai_movement/linger/lurking/AI = ai_movement_handler + if(AI && istype(AI)) + AI.stop_lurking() + GLOBAL_LIST_EMPTY_TYPED(xeno_ai_spawns, /obj/effect/landmark/xeno_ai) /obj/effect/landmark/xeno_ai name = "Xeno AI Spawn" From 2d2ec3c6e16dd4b6bad4a19f8e41e8c423c1d3ec Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Sun, 22 Oct 2023 23:41:13 +0300 Subject: [PATCH 04/23] oopsie garbage code removed --- code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm | 4 ---- 1 file changed, 4 deletions(-) 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 abe30ee1df..20613e56a2 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm @@ -260,10 +260,6 @@ GLOBAL_LIST_INIT(ai_target_limbs, list( SHOULD_CALL_PARENT(TRUE) SSxeno_ai.remove_ai(src) - var/datum/xeno_ai_movement/linger/lurking/AI = ai_movement_handler - if(AI && istype(AI)) - AI.stop_lurking() - GLOBAL_LIST_EMPTY_TYPED(xeno_ai_spawns, /obj/effect/landmark/xeno_ai) /obj/effect/landmark/xeno_ai name = "Xeno AI Spawn" From 348fc7aff07ba6869d59b4f96103955baf9c224b Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Sun, 22 Oct 2023 23:52:14 +0300 Subject: [PATCH 05/23] MINOR SPELLING MISTAKE --- code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm index 5e55007802..45937fe63a 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm @@ -1,6 +1,6 @@ /datum/xeno_ai_movement/linger/lurking - // Are we currentlu hiding? + // Are we currently hiding? var/ai_lurking = FALSE // Gradually increases the chance of AI to try and bait marines From 407189d246c841aad1ddccc4740614c24d81c008 Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Mon, 23 Oct 2023 00:04:08 +0300 Subject: [PATCH 06/23] another rookie mistake ughh sorry --- code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm index 45937fe63a..acbe92c5ba 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm @@ -217,7 +217,7 @@ registered_turfs += turf /datum/xeno_ai_movement/linger/lurking/proc/unregister_turf_signals() - for(var/turf/turf in view(world.view, parent)) + for(var/turf/turf in registered_turfs) UnregisterSignal(turf, COMSIG_TURF_ENTERED) registered_turfs = list() From 714ad2b09b02e24a84e07c569baf49b3b8d411b5 Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Mon, 23 Oct 2023 02:27:36 +0300 Subject: [PATCH 07/23] some minor fixes and lurker pounce knockdown nerf --- .../abilities/lurker/lurker_abilities.dm | 2 +- .../carbon/xenomorph/ai/movement/lurker.dm | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) 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 e8cb84c043..55c2da17fe 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 @@ -8,7 +8,7 @@ // Config options distance = 6 knockdown = FALSE - knockdown_duration = 2.5 + knockdown_duration = 1.5 freeze_self = TRUE freeze_time = 15 can_be_shield_blocked = TRUE diff --git a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm index acbe92c5ba..c65c251b3a 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm @@ -19,7 +19,7 @@ // Let's lower this a little bit cause we do some heavy checks while finding our "home" home_locate_range = 10 - max_distance_from_home = 8 + max_distance_from_home = 10 #define AI_CHECK_ANNOYANCE_COOLDOWN 2.5 SECONDS @@ -107,7 +107,7 @@ return ..() var/turf/target_turf = get_turf(moving_xeno.current_target) - if(ai_lurking) + if(ai_lurking || get_dist(moving_xeno, target_turf) > world.view + 2) // if(get_dist(moving_xeno, target_turf) > stalking_distance) // return moving_xeno.move_to_next_turf(target_turf) /// uncomment for stalking return ai_move_idle(delta_time) @@ -212,14 +212,14 @@ /datum/xeno_ai_movement/linger/lurking/proc/register_turf_signals() - for(var/turf/turf in view(world.view, parent)) - RegisterSignal(turf, COMSIG_TURF_ENTERED, PROC_REF(set_target), override = TRUE) - registered_turfs += turf + for(var/turf/open/OT in view(world.view, parent)) + RegisterSignal(OT, COMSIG_TURF_ENTERED, PROC_REF(set_target), override = TRUE) + registered_turfs += OT /datum/xeno_ai_movement/linger/lurking/proc/unregister_turf_signals() - for(var/turf/turf in registered_turfs) - UnregisterSignal(turf, COMSIG_TURF_ENTERED) - registered_turfs = list() + for(var/turf/open/OT in registered_turfs) + UnregisterSignal(OT, COMSIG_TURF_ENTERED) + registered_turfs.Cut() /datum/xeno_ai_movement/linger/lurking/proc/set_target(turf/hooked, atom/movable/subject) SIGNAL_HANDLER From 39ac21f500f24d24d8d8dbba0b810b46a2ec21cc Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Mon, 23 Oct 2023 03:29:33 +0300 Subject: [PATCH 08/23] stop lurking on crit and small handle_ai_shot refactor --- code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm | 8 +++----- code/modules/mob/living/carbon/xenomorph/life.dm | 4 ++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm b/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm index 4124290454..e090928a3d 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm @@ -79,16 +79,14 @@ /mob/living/carbon/xenomorph/lurker/handle_ai_shot(obj/projectile/P) if(P.firer) - var/distance = get_dist(src, P.firer) - if(distance > world.view) - if(prob(LURKING_IGNORE_SHOT_CHANCE)) - return + if(prob(LURKING_IGNORE_SHOT_CHANCE)) + return var/datum/xeno_ai_movement/linger/lurking/lurker_ai = ai_movement_handler if(lurker_ai && istype(lurker_ai)) lurker_ai.stop_lurking() - SSxeno_pathfinding.calculate_path(src, P.firer, distance, src, CALLBACK(src, PROC_REF(set_path)), list(src, P.firer)) + SSxeno_pathfinding.calculate_path(src, P.firer, ai_range, src, CALLBACK(src, PROC_REF(set_path)), list(src, P.firer)) /mob/living/carbon/xenomorph/lurker/ai_move_target(delta_time) if(throwing) diff --git a/code/modules/mob/living/carbon/xenomorph/life.dm b/code/modules/mob/living/carbon/xenomorph/life.dm index 65839e9c8c..33e53cbd1d 100644 --- a/code/modules/mob/living/carbon/xenomorph/life.dm +++ b/code/modules/mob/living/carbon/xenomorph/life.dm @@ -539,6 +539,10 @@ Make sure their actual health updates immediately.*/ if(!lying) update_canmove() + var/datum/xeno_ai_movement/linger/lurking/AI = ai_movement_handler + if(AI && istype(AI)) + AI.stop_lurking() + /mob/living/carbon/xenomorph/proc/handle_luminosity() var/new_luminosity = 0 if(caste) From 70af3d3b4043c88092f71af30bc3bfa16a6efde5 Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Tue, 24 Oct 2023 17:18:16 +0300 Subject: [PATCH 09/23] added *hiss to bait emotes list --- code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm index c65c251b3a..f158d30080 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm @@ -134,7 +134,7 @@ #define LURKER_BAIT_TYPES list("Taunt","Emote","Interact") -#define LURKER_BAIT_EMOTES list("growl","roar","scream","needshelp") +#define LURKER_BAIT_EMOTES list("growl","roar","hiss","needshelp") #define LURKER_BAIT_TAUNTS list("Come here, little host","I won't bite","I see you","Safe to go, little one") #define LURKER_BAITS_BEFORE_AMBUSH 4 From c8d17230d2f2c9416bb670107c32ac8cfde2889c Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Thu, 26 Oct 2023 04:33:59 +0300 Subject: [PATCH 10/23] made a /var for stalking feature (disabled by default) --- .../carbon/xenomorph/ai/movement/lurker.dm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm index f158d30080..0134ffea8c 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm @@ -3,6 +3,9 @@ // Are we currently hiding? var/ai_lurking = FALSE + // Should we stalk people when they walk too far away? + var/enable_stalking = FALSE + // Gradually increases the chance of AI to try and bait marines // Annoyance accumulate when we lurk (stand invisible) and aware of our target var/annoyance = 0 @@ -10,12 +13,12 @@ // Total baits this xeno made var/total_baits = 0 + // Distance at which we want to stay from our spotted target + var/stalking_distance = 12 + // List of turfs we see and register while lurking var/list/registered_turfs = list() - // Distance at which we want to stay from our spotted target -// var/stalking_distance = 12 /// uncomment for stalking - // Let's lower this a little bit cause we do some heavy checks while finding our "home" home_locate_range = 10 @@ -88,9 +91,9 @@ return /// Abandon hiding place to stalk our target -// if(idle_xeno.current_target && get_dist(home_turf, idle_xeno.current_target) > stalking_distance) -// home_turf = null -// return /// uncomment for stalking + if(idle_xeno.current_target && get_dist(home_turf, idle_xeno.current_target) > stalking_distance && enable_stalking) + home_turf = null + return if(idle_xeno.move_to_next_turf(home_turf, home_locate_range)) if(get_dist(home_turf, idle_xeno) <= 0 && !ai_lurking) @@ -108,8 +111,8 @@ var/turf/target_turf = get_turf(moving_xeno.current_target) if(ai_lurking || get_dist(moving_xeno, target_turf) > world.view + 2) -// if(get_dist(moving_xeno, target_turf) > stalking_distance) -// return moving_xeno.move_to_next_turf(target_turf) /// uncomment for stalking + if(get_dist(moving_xeno, target_turf) > stalking_distance && enable_stalking) + return moving_xeno.move_to_next_turf(target_turf) return ai_move_idle(delta_time) annoyance = 0 From 654dc3e1ac3e20c58bf5260f65225a62839c1290 Mon Sep 17 00:00:00 2001 From: Morrow Date: Fri, 27 Oct 2023 06:14:54 -0400 Subject: [PATCH 11/23] first pass --- .../carbon/xenomorph/ai/movement/lurker.dm | 174 +++++++++--------- 1 file changed, 86 insertions(+), 88 deletions(-) diff --git a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm index 0134ffea8c..11bb9b90be 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm @@ -3,18 +3,14 @@ // Are we currently hiding? var/ai_lurking = FALSE - // Should we stalk people when they walk too far away? - var/enable_stalking = FALSE - - // Gradually increases the chance of AI to try and bait marines - // Annoyance accumulate when we lurk (stand invisible) and aware of our target + // Gradually increases the chance of AI to try and bait marines, annoyance accumulate when we lurk (stand invisible) and aware of our target var/annoyance = 0 - // Total baits this xeno made + // Total baits this xeno has made var/total_baits = 0 // Distance at which we want to stay from our spotted target - var/stalking_distance = 12 + var/stalking_distance = 10 // List of turfs we see and register while lurking var/list/registered_turfs = list() @@ -28,10 +24,6 @@ /datum/xeno_ai_movement/linger/lurking/New(mob/living/carbon/xenomorph/parent) . = ..() - var/datum/action/xeno_action/activable/pounce/lurker/LPA = get_xeno_action_by_type(parent, /datum/action/xeno_action/activable/pounce/lurker) - if (LPA && istype(LPA)) - LPA.knockdown = TRUE // pounce knocks down - LPA.freeze_self = TRUE RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(stop_lurking)) addtimer(CALLBACK(src, PROC_REF(check_annoyance)), AI_CHECK_ANNOYANCE_COOLDOWN, TIMER_UNIQUE|TIMER_LOOP|TIMER_DELETE_ME) @@ -43,63 +35,67 @@ if(idle_xeno.throwing) return - if(next_home_search < world.time && (!home_turf || get_dist(home_turf, idle_xeno) > max_distance_from_home)) - var/turf/T = get_turf(idle_xeno.loc) - next_home_search = world.time + home_search_delay - var/shortest_distance = INFINITY - for(var/i in shuffle(RANGE_TURFS(home_locate_range, T))) - var/turf/potential_home = i - var/lets_continue + if(home_turf) + if(get_dist(home_turf, idle_xeno) <= 0) + start_lurking() + return - var/mob/living/carbon/xenomorph/blocking_xeno = locate() in potential_home - if(blocking_xeno && blocking_xeno.stat == CONSCIOUS && blocking_xeno != idle_xeno) - continue + if(!idle_xeno.move_to_next_turf(home_turf)) + home_turf = null + return - var/atom/target = idle_xeno.current_target - if(target && potential_home != T && (potential_home in view(world.view, target))) - continue // We prefer standing still when someone can see us + return - if(!potential_home.density && get_dist(idle_xeno, potential_home) < shortest_distance) - shortest_distance = get_dist(idle_xeno, potential_home) + if(next_home_search > world.time) + return - /// First we try to locate some structures to stand and hide on - for(var/obj/structure/S in potential_home) - if(S && !istype(S, /obj/structure/pipes)) // Don't care if it's dense cause we can break it and hide on remains - home_turf = potential_home - lets_continue = TRUE - break + var/turf/current_turf = get_turf(idle_xeno) - if(lets_continue) - continue + if(!current_turf) + return - /// If we cannot find any structures, we look for walls around our potential home - for(var/turf/t_around in orange(1, potential_home)) - if(t_around && t_around.density) // Let's find a wall to stick to it - home_turf = potential_home - shortest_distance += 5 // Penalty for no structures, we can do better - lets_continue = TRUE - break + next_home_search = world.time + home_search_delay + var/shortest_distance = INFINITY + var/turf/non_preferred_turf + for(var/turf/potential_home as anything in shuffle(RANGE_TURFS(home_locate_range, current_turf))) - if(lets_continue) - continue + var/blocked = FALSE + for(var/atom/potential_blocker as anything in potential_home) + if(potential_blocker.can_block_movement) + blocked = TRUE + break - /// If we have no structures or walls to stick to (strange), just hide on closest turf - home_turf = potential_home - shortest_distance += 10 // Penalty for empty turfs (we don't wanna hide on them) + if(blocked) + continue - if(!home_turf) - return + var/preferred = FALSE + for(var/turf/closed/touching_turf in orange(1, potential_home)) + preferred = TRUE + break - /// Abandon hiding place to stalk our target - if(idle_xeno.current_target && get_dist(home_turf, idle_xeno.current_target) > stalking_distance && enable_stalking) - home_turf = null - return + if(idle_xeno.current_target) + var/potential_home_dir = get_dir(idle_xeno, potential_home) + var/current_target_dir = get_dir(idle_xeno, idle_xeno.current_target) - if(idle_xeno.move_to_next_turf(home_turf, home_locate_range)) - if(get_dist(home_turf, idle_xeno) <= 0 && !ai_lurking) - start_lurking() - else - home_turf = null + if(current_target_dir != potential_home_dir && current_target_dir != turn(potential_home_dir, 45) && current_target_dir != turn(potential_home_dir, -45)) + continue + + var/xeno_to_potential_home_distance = get_dist(idle_xeno, potential_home) + if(xeno_to_potential_home_distance > shortest_distance) + continue + + if(preferred) + home_turf = potential_home + shortest_distance = xeno_to_potential_home_distance + continue + + if(xeno_to_potential_home_distance < get_dist(idle_xeno, non_preferred_turf)) + non_preferred_turf = potential_home + continue + + if(!home_turf) + home_turf = non_preferred_turf + return /datum/xeno_ai_movement/linger/lurking/ai_move_target(delta_time) var/mob/living/carbon/xenomorph/moving_xeno = parent @@ -111,7 +107,8 @@ var/turf/target_turf = get_turf(moving_xeno.current_target) if(ai_lurking || get_dist(moving_xeno, target_turf) > world.view + 2) - if(get_dist(moving_xeno, target_turf) > stalking_distance && enable_stalking) + if(get_dist(moving_xeno, target_turf) > stalking_distance) + home_turf = null return moving_xeno.move_to_next_turf(target_turf) return ai_move_idle(delta_time) @@ -127,15 +124,11 @@ if(!annoyed_xeno.current_target || !ai_lurking) return - if(annoyed_xeno.current_target in view(world.view, annoyed_xeno)) - return - annoyance++ if(prob(annoyance)) try_bait() - #define LURKER_BAIT_TYPES list("Taunt","Emote","Interact") #define LURKER_BAIT_EMOTES list("growl","roar","hiss","needshelp") #define LURKER_BAIT_TAUNTS list("Come here, little host","I won't bite","I see you","Safe to go, little one") @@ -187,45 +180,50 @@ return TRUE return FALSE - /datum/xeno_ai_movement/linger/lurking/proc/start_lurking() SIGNAL_HANDLER - if(!ai_lurking) - var/mob/living/carbon/xenomorph/lurking_xeno = parent - animate(lurking_xeno, alpha = 20, time = 0.5 SECONDS, easing = QUAD_EASING) - lurking_xeno.set_movement_intent(MOVE_INTENT_WALK) - register_turf_signals() - ai_lurking = TRUE + if(ai_lurking) + return - 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 // pounce knocks down again - LPA.freeze_self = TRUE + var/mob/living/carbon/xenomorph/lurking_xeno = parent + animate(lurking_xeno, alpha = 20, time = 0.5 SECONDS, easing = QUAD_EASING) + lurking_xeno.set_movement_intent(MOVE_INTENT_WALK) + register_turf_signals() + ai_lurking = TRUE + + 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 + LPA.freeze_self = TRUE /datum/xeno_ai_movement/linger/lurking/proc/stop_lurking() SIGNAL_HANDLER - if(ai_lurking) - var/mob/living/carbon/xenomorph/lurking_xeno = parent - animate(lurking_xeno, alpha = initial(lurking_xeno.alpha), time = 0.2 SECONDS, easing = QUAD_EASING) - lurking_xeno.set_movement_intent(MOVE_INTENT_RUN) - unregister_turf_signals() - ai_lurking = FALSE + if(!ai_lurking) + return - INVOKE_ASYNC(lurking_xeno, TYPE_PROC_REF(/mob, stop_pulling)) + var/mob/living/carbon/xenomorph/lurking_xeno = parent + animate(lurking_xeno, alpha = initial(lurking_xeno.alpha), time = 0.2 SECONDS, easing = QUAD_EASING) + lurking_xeno.set_movement_intent(MOVE_INTENT_RUN) + unregister_turf_signals() + ai_lurking = FALSE + INVOKE_ASYNC(lurking_xeno, TYPE_PROC_REF(/mob, stop_pulling)) /datum/xeno_ai_movement/linger/lurking/proc/register_turf_signals() - for(var/turf/open/OT in view(world.view, parent)) - RegisterSignal(OT, COMSIG_TURF_ENTERED, PROC_REF(set_target), override = TRUE) - registered_turfs += OT + for(var/turf/open/cycled_open_turf in view(5, parent)) + RegisterSignal(cycled_open_turf, COMSIG_TURF_ENTERED, PROC_REF(set_target)) + registered_turfs += cycled_open_turf /datum/xeno_ai_movement/linger/lurking/proc/unregister_turf_signals() - for(var/turf/open/OT in registered_turfs) - UnregisterSignal(OT, COMSIG_TURF_ENTERED) + for(var/turf/open/cycled_open_turf in registered_turfs) + UnregisterSignal(cycled_open_turf, COMSIG_TURF_ENTERED) registered_turfs.Cut() -/datum/xeno_ai_movement/linger/lurking/proc/set_target(turf/hooked, atom/movable/subject) +/datum/xeno_ai_movement/linger/lurking/proc/set_target(turf/hooked, atom/movable/entering_atom) SIGNAL_HANDLER var/mob/living/carbon/xenomorph/lurking_xeno = parent - if(subject in GLOB.alive_human_list) - lurking_xeno.current_target = subject + + if(!istype(entering_atom, /mob/living/carbon/human)) + return + + lurking_xeno.current_target = entering_atom From 00f10ff03815c57d46a7ee3e9d3a400aa368142d Mon Sep 17 00:00:00 2001 From: Morrow Date: Fri, 27 Oct 2023 08:03:33 -0400 Subject: [PATCH 12/23] OK changed signs and some values --- .../living/carbon/xenomorph/ai/movement/lurker.dm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm index 11bb9b90be..f80e200a85 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm @@ -10,7 +10,7 @@ var/total_baits = 0 // Distance at which we want to stay from our spotted target - var/stalking_distance = 10 + var/stalking_distance = 12 // List of turfs we see and register while lurking var/list/registered_turfs = list() @@ -25,7 +25,6 @@ /datum/xeno_ai_movement/linger/lurking/New(mob/living/carbon/xenomorph/parent) . = ..() - RegisterSignal(parent, COMSIG_MOVABLE_MOVED, 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 @@ -77,7 +76,7 @@ var/potential_home_dir = get_dir(idle_xeno, potential_home) var/current_target_dir = get_dir(idle_xeno, idle_xeno.current_target) - if(current_target_dir != potential_home_dir && current_target_dir != turn(potential_home_dir, 45) && current_target_dir != turn(potential_home_dir, -45)) + if(current_target_dir == potential_home_dir || current_target_dir == turn(potential_home_dir, 45) || current_target_dir == turn(potential_home_dir, -45)) continue var/xeno_to_potential_home_distance = get_dist(idle_xeno, potential_home) @@ -106,7 +105,7 @@ return ..() var/turf/target_turf = get_turf(moving_xeno.current_target) - if(ai_lurking || get_dist(moving_xeno, target_turf) > world.view + 2) + if(ai_lurking || get_dist(moving_xeno, target_turf) > world.view + 1) if(get_dist(moving_xeno, target_turf) > stalking_distance) home_turf = null return moving_xeno.move_to_next_turf(target_turf) @@ -124,6 +123,11 @@ if(!annoyed_xeno.current_target || !ai_lurking) return + if(get_dist(annoyed_xeno, annoyed_xeno.current_target) > 8) + annoyance = 0 + total_baits = 0 + return + annoyance++ if(prob(annoyance)) From 057691694ebf6bef258eee0ba6ddaecd8a6d9b7f Mon Sep 17 00:00:00 2001 From: Morrow Date: Fri, 27 Oct 2023 08:22:40 -0400 Subject: [PATCH 13/23] some more changes --- .../dcs/signals/atom/mob/living/signals_xeno.dm | 6 ++++++ .../ai/movement/{lurker.dm => lurking.dm} | 9 +++++++-- .../mob/living/carbon/xenomorph/ai/xeno_ai.dm | 14 +++++++++----- .../mob/living/carbon/xenomorph/castes/Lurker.dm | 11 +++-------- code/modules/mob/living/carbon/xenomorph/life.dm | 4 +--- colonialmarines.dme | 2 +- 6 files changed, 27 insertions(+), 19 deletions(-) rename code/modules/mob/living/carbon/xenomorph/ai/movement/{lurker.dm => lurking.dm} (95%) 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 e9862be49d..8cbfb5b9bc 100644 --- a/code/__DEFINES/dcs/signals/atom/mob/living/signals_xeno.dm +++ b/code/__DEFINES/dcs/signals/atom/mob/living/signals_xeno.dm @@ -62,3 +62,9 @@ /// For any additional things that should happen when a xeno's melee_attack_additional_effects_self() proc is called #define COMSIG_XENO_SLASH_ADDITIONAL_EFFECTS_SELF "xeno_slash_additional_effects_self" + +/// From /mob/living/carbon/xenomorph/proc/handle_crit() +#define COMSIG_XENO_HANDLE_CRIT "xeno_handle_crit" + +/// 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/ai/movement/lurker.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm similarity index 95% rename from code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm rename to code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm index f80e200a85..9737c5fb31 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm @@ -25,6 +25,8 @@ /datum/xeno_ai_movement/linger/lurking/New(mob/living/carbon/xenomorph/parent) . = ..() + RegisterSignal(parent, COMSIG_XENO_HANDLE_AI_SHOT, PROC_REF(stop_lurking)) + RegisterSignal(parent, COMSIG_XENO_HANDLE_CRIT, 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 @@ -58,9 +60,12 @@ var/turf/non_preferred_turf for(var/turf/potential_home as anything in shuffle(RANGE_TURFS(home_locate_range, current_turf))) + if(potential_home.density) + continue + var/blocked = FALSE for(var/atom/potential_blocker as anything in potential_home) - if(potential_blocker.can_block_movement) + if(potential_blocker.can_block_movement || potential_blocker.density) blocked = TRUE break @@ -123,7 +128,7 @@ if(!annoyed_xeno.current_target || !ai_lurking) return - if(get_dist(annoyed_xeno, annoyed_xeno.current_target) > 8) + if(get_dist(annoyed_xeno, annoyed_xeno.current_target) > 10) annoyance = 0 total_baits = 0 return 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 20613e56a2..6167aada26 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm @@ -37,12 +37,16 @@ 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) - if(!current_target && P.firer) - var/distance = get_dist(src, P.firer) - if(distance > max_travel_distance) - return + 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 - SSxeno_pathfinding.calculate_path(src, P.firer, distance, src, CALLBACK(src, PROC_REF(set_path)), list(src, P.firer)) + SSxeno_pathfinding.calculate_path(src, P.firer, distance, src, CALLBACK(src, PROC_REF(set_path)), list(src, P.firer)) /mob/living/carbon/xenomorph/proc/register_ai_action(datum/action/xeno_action/XA) if(XA.owner != src) diff --git a/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm b/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm index e090928a3d..ed99c8e719 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm @@ -78,15 +78,10 @@ return new /datum/xeno_ai_movement/linger/lurking(src) /mob/living/carbon/xenomorph/lurker/handle_ai_shot(obj/projectile/P) - if(P.firer) - if(prob(LURKING_IGNORE_SHOT_CHANCE)) - return - - var/datum/xeno_ai_movement/linger/lurking/lurker_ai = ai_movement_handler - if(lurker_ai && istype(lurker_ai)) - lurker_ai.stop_lurking() + if(prob(LURKING_IGNORE_SHOT_CHANCE)) + return - SSxeno_pathfinding.calculate_path(src, P.firer, ai_range, src, CALLBACK(src, PROC_REF(set_path)), list(src, P.firer)) + . = ..() /mob/living/carbon/xenomorph/lurker/ai_move_target(delta_time) if(throwing) diff --git a/code/modules/mob/living/carbon/xenomorph/life.dm b/code/modules/mob/living/carbon/xenomorph/life.dm index 33e53cbd1d..da66c61bfc 100644 --- a/code/modules/mob/living/carbon/xenomorph/life.dm +++ b/code/modules/mob/living/carbon/xenomorph/life.dm @@ -539,9 +539,7 @@ Make sure their actual health updates immediately.*/ if(!lying) update_canmove() - var/datum/xeno_ai_movement/linger/lurking/AI = ai_movement_handler - if(AI && istype(AI)) - AI.stop_lurking() + SEND_SIGNAL(src, COMSIG_XENO_HANDLE_CRIT) /mob/living/carbon/xenomorph/proc/handle_luminosity() var/new_luminosity = 0 diff --git a/colonialmarines.dme b/colonialmarines.dme index c2bc51d894..06048937f9 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -1991,7 +1991,7 @@ #include "code\modules\mob\living\carbon\xenomorph\ai\movement\base_define.dm" #include "code\modules\mob\living\carbon\xenomorph\ai\movement\drone.dm" #include "code\modules\mob\living\carbon\xenomorph\ai\movement\linger.dm" -#include "code\modules\mob\living\carbon\xenomorph\ai\movement\lurker.dm" +#include "code\modules\mob\living\carbon\xenomorph\ai\movement\lurking.dm" #include "code\modules\mob\living\carbon\xenomorph\castes\Boiler.dm" #include "code\modules\mob\living\carbon\xenomorph\castes\Burrower.dm" #include "code\modules\mob\living\carbon\xenomorph\castes\Carrier.dm" From 089b8b683d9e07528624486e617913eafccebc24 Mon Sep 17 00:00:00 2001 From: Morrow Date: Fri, 27 Oct 2023 08:47:20 -0400 Subject: [PATCH 14/23] Blocking yourself moment --- .../modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm | 3 +-- 1 file changed, 1 insertion(+), 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 9737c5fb31..61a125eb94 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm @@ -59,13 +59,12 @@ var/shortest_distance = INFINITY var/turf/non_preferred_turf for(var/turf/potential_home as anything in shuffle(RANGE_TURFS(home_locate_range, current_turf))) - if(potential_home.density) continue var/blocked = FALSE for(var/atom/potential_blocker as anything in potential_home) - if(potential_blocker.can_block_movement || potential_blocker.density) + if(potential_blocker != idle_xeno && (potential_blocker.can_block_movement || potential_blocker.density)) blocked = TRUE break From 21a2468065ff16a754716ca65b8813c37ee3526b Mon Sep 17 00:00:00 2001 From: Morrow Date: Sat, 28 Oct 2023 04:33:54 -0400 Subject: [PATCH 15/23] 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 From 2c21820270fcf914d05d18a233108d988d23579d Mon Sep 17 00:00:00 2001 From: Morrow Date: Sat, 28 Oct 2023 09:03:16 -0400 Subject: [PATCH 16/23] light --- maps/map_files/golden_arrow/golden_arrow.dmm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/maps/map_files/golden_arrow/golden_arrow.dmm b/maps/map_files/golden_arrow/golden_arrow.dmm index 5013a4c3fe..bf87fd46f1 100644 --- a/maps/map_files/golden_arrow/golden_arrow.dmm +++ b/maps/map_files/golden_arrow/golden_arrow.dmm @@ -3770,6 +3770,15 @@ icon_state = "plate" }, /area/almayer/squads/alpha/squad_two) +"xD" = ( +/obj/effect/decal/warning_stripes{ + icon_state = "S" + }, +/obj/structure/machinery/light, +/turf/open/floor/almayer{ + icon_state = "plate" + }, +/area/almayer/hallways/hangar) "xJ" = ( /obj/structure/closet/secure_closet/engineering_welding{ req_one_access = list() @@ -20070,7 +20079,7 @@ Mc bo eu Dc -Rg +xD Nf Jb Cv From 97126a02178576442b7ba78abe285a9a80af6d20 Mon Sep 17 00:00:00 2001 From: Morrow Date: Sat, 28 Oct 2023 09:03:40 -0400 Subject: [PATCH 17/23] Revert "light" This reverts commit 2c21820270fcf914d05d18a233108d988d23579d. --- maps/map_files/golden_arrow/golden_arrow.dmm | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/maps/map_files/golden_arrow/golden_arrow.dmm b/maps/map_files/golden_arrow/golden_arrow.dmm index bf87fd46f1..5013a4c3fe 100644 --- a/maps/map_files/golden_arrow/golden_arrow.dmm +++ b/maps/map_files/golden_arrow/golden_arrow.dmm @@ -3770,15 +3770,6 @@ icon_state = "plate" }, /area/almayer/squads/alpha/squad_two) -"xD" = ( -/obj/effect/decal/warning_stripes{ - icon_state = "S" - }, -/obj/structure/machinery/light, -/turf/open/floor/almayer{ - icon_state = "plate" - }, -/area/almayer/hallways/hangar) "xJ" = ( /obj/structure/closet/secure_closet/engineering_welding{ req_one_access = list() @@ -20079,7 +20070,7 @@ Mc bo eu Dc -xD +Rg Nf Jb Cv From 94fc314f6571be695e2b515c9a8276ddf1823629 Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Sat, 28 Oct 2023 16:25:17 +0300 Subject: [PATCH 18/23] remove invis before pounce --- .../mob/living/carbon/xenomorph/abilities/general_powers.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 15c3b27c13..512a7478be 100644 --- a/code/modules/mob/living/carbon/xenomorph/abilities/general_powers.dm +++ b/code/modules/mob/living/carbon/xenomorph/abilities/general_powers.dm @@ -446,10 +446,10 @@ LM.pass_flags = pounce_pass_flags LM.collision_callbacks = pounce_callbacks - X.launch_towards(LM) - SEND_SIGNAL(owner, COMSIG_XENO_USED_POUNCE, A) + X.launch_towards(LM) + X.update_icons() additional_effects_always() From 4801c118d40f927c0d2986e481723b4867aa7cdd Mon Sep 17 00:00:00 2001 From: Morrow Date: Sat, 28 Oct 2023 12:41:48 -0400 Subject: [PATCH 19/23] Maybe this? --- .../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 115ae57ca4..6321b62b22 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm @@ -229,7 +229,7 @@ registered_turfs += cycled_open_turf var/mob/living/carbon/human/possible_target = locate() in cycled_open_turf - if(possible_target) + if(possible_target && (!parent.current_target || get_dist(parent, possible_target) < get_dist(parent, parent.current_target))) parent.current_target = possible_target /datum/xeno_ai_movement/linger/lurking/proc/unregister_turf_signals() @@ -239,12 +239,12 @@ /datum/xeno_ai_movement/linger/lurking/proc/set_target(turf/hooked, atom/movable/entering_atom) SIGNAL_HANDLER - var/mob/living/carbon/xenomorph/lurking_xeno = parent if(!istype(entering_atom, /mob/living/carbon/human)) return - lurking_xeno.current_target = entering_atom + if(!parent.current_target || get_dist(parent, entering_atom) < get_dist(parent, parent.current_target)) + parent.current_target = entering_atom /datum/xeno_ai_movement/linger/lurking/proc/lurking_parent_moved(atom/movable/moving_atom, atom/oldloc, direction, Forced) SIGNAL_HANDLER From 98a293e4fd6afefbfcc83f408acc40cef0b14ae9 Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Sat, 28 Oct 2023 20:51:14 +0300 Subject: [PATCH 20/23] less baits before push and no lingering corpses in invis --- .../mob/living/carbon/xenomorph/ai/movement/lurking.dm | 4 +++- 1 file changed, 3 insertions(+), 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 6321b62b22..1320b2b9b9 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm @@ -142,7 +142,7 @@ #define LURKER_BAIT_TYPES list("Taunt","Emote","Interact") #define LURKER_BAIT_EMOTES list("growl","roar","hiss","needshelp") #define LURKER_BAIT_TAUNTS list("Come here, little host","I won't bite","I see you","Safe to go, little one") -#define LURKER_BAITS_BEFORE_AMBUSH 4 +#define LURKER_BAITS_BEFORE_AMBUSH 3 /datum/xeno_ai_movement/linger/lurking/proc/try_bait(no_interact) var/mob/living/carbon/xenomorph/baiting_xeno = parent @@ -208,6 +208,8 @@ LPA.knockdown = TRUE LPA.freeze_self = TRUE + INVOKE_ASYNC(lurking_xeno, TYPE_PROC_REF(/mob, stop_pulling)) + /datum/xeno_ai_movement/linger/lurking/proc/stop_lurking() SIGNAL_HANDLER if(!ai_lurking) From e03603292a7f579a7a1220030ee666cbfbe3617c Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Sat, 28 Oct 2023 23:30:02 +0300 Subject: [PATCH 21/23] do not bait while current target is in sight and home locating tweaks --- .../carbon/xenomorph/ai/movement/lurking.dm | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 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 1320b2b9b9..beb832e89a 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm @@ -78,13 +78,17 @@ preferred = TRUE break - if(idle_xeno.current_target) + var/our_target = idle_xeno.current_target + if(our_target) var/potential_home_dir = get_dir(idle_xeno, potential_home) - var/current_target_dir = get_dir(idle_xeno, idle_xeno.current_target) + var/current_target_dir = get_dir(idle_xeno, our_target) if(current_target_dir == potential_home_dir || current_target_dir == turn(potential_home_dir, 45) || current_target_dir == turn(potential_home_dir, -45)) continue + if(get_dist(potential_home, our_target) > stalking_distance) + continue + var/xeno_to_potential_home_distance = get_dist(idle_xeno, potential_home) if(xeno_to_potential_home_distance > shortest_distance) continue @@ -129,7 +133,12 @@ if(!annoyed_xeno.current_target || !ai_lurking) return - if(get_dist(annoyed_xeno, annoyed_xeno.current_target) > 10) + var/target_distance = get_dist(annoyed_xeno, annoyed_xeno.current_target) + + if(target_distance < world.view) + return + + if(target_distance > 10) annoyance = 0 total_baits = 0 return @@ -166,11 +175,11 @@ baiting_xeno.say(pick(LURKER_BAIT_TAUNTS)) if("Interact") if(!interact_random(baiting_xeno)) - try_bait(no_interact = TRUE) - return + return try_bait(no_interact = TRUE) total_baits++ annoyance = 0 + return bait #undef LURKER_BAIT_TYPES #undef LURKER_BAIT_EMOTES From 82c968a46e94b45652a05a24e4dba0404a6d4f89 Mon Sep 17 00:00:00 2001 From: Morrow Date: Sat, 28 Oct 2023 17:01:17 -0400 Subject: [PATCH 22/23] bam --- .../mob/living/carbon/xenomorph/ai/movement/lurking.dm | 7 ++++++- code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm | 7 ++++++- 2 files changed, 12 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 beb832e89a..327ec39a8f 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm @@ -111,7 +111,12 @@ if(moving_xeno.throwing) return - if(moving_xeno.current_target.is_mob_incapacitated()) + var/incapacitated_check = TRUE + if(istype(moving_xeno.current_target, /mob)) + var/mob/current_target_mob = moving_xeno.current_target + incapacitated_check = current_target_mob.is_mob_incapacitated() + + if(incapacitated_check) return ..() var/turf/target_turf = get_turf(moving_xeno.current_target) diff --git a/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm b/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm index af525c4e45..f85a0088fe 100644 --- a/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm +++ b/code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm @@ -96,7 +96,12 @@ if(get_dist(current_target, src) > 1) return - if(!current_target.is_mob_incapacitated()) + if(!istype(current_target, /mob)) + return + + var/mob/current_target_mob = current_target + + if(!current_target_mob.is_mob_incapacitated()) return if(isxeno(current_target.pulledby)) From d4a464c88e5202d6443d0d727ee4975b63316329 Mon Sep 17 00:00:00 2001 From: Morrow Date: Sat, 28 Oct 2023 17:14:22 -0400 Subject: [PATCH 23/23] makes this atom movable because I'm paranoid --- 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 327ec39a8f..2968ffb481 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm @@ -78,7 +78,7 @@ preferred = TRUE break - var/our_target = idle_xeno.current_target + var/atom/movable/our_target = idle_xeno.current_target if(our_target) var/potential_home_dir = get_dir(idle_xeno, potential_home) var/current_target_dir = get_dir(idle_xeno, our_target)