From 9ec8e2d6ec4e0ac868abbb57a7b29aebac6231e4 Mon Sep 17 00:00:00 2001 From: xDanilcusx Date: Mon, 30 Oct 2023 19:52:01 +0300 Subject: [PATCH] now in ai_behavior_override! --- code/__DEFINES/dcs/flags.dm | 3 + .../kidnap_override_behavior.dm | 55 +++++++++++-------- code/modules/admin/admin_verbs.dm | 2 - .../admin/game_master/hive_landmark.dm | 5 ++ .../game_master/toggle_xeno_kidnapping.dm | 13 ----- .../mob/living/carbon/xenomorph/XenoProcs.dm | 1 + .../xenomorph/ai/movement/base_define.dm | 6 +- .../mob/living/carbon/xenomorph/ai/xeno_ai.dm | 12 +++- colonialmarines.dme | 1 - 9 files changed, 54 insertions(+), 44 deletions(-) delete mode 100644 code/modules/admin/game_master/toggle_xeno_kidnapping.dm diff --git a/code/__DEFINES/dcs/flags.dm b/code/__DEFINES/dcs/flags.dm index 59d13ef35b..4d9571c087 100644 --- a/code/__DEFINES/dcs/flags.dm +++ b/code/__DEFINES/dcs/flags.dm @@ -5,6 +5,9 @@ /// Returned in PostTransfer to prevent transfer, similar to `COMPONENT_INCOMPATIBLE` #define COMPONENT_NOTRANSFER 2 +/// Returned in case we want to qdel our ai_behavior_override on /check_behavior_validity() +#define OVERRIDE_BEHAVIOR_QDEL 2 + /// Return value to cancel attaching #define ELEMENT_INCOMPATIBLE 1 diff --git a/code/datums/components/xeno/ai_behavior_overrides/kidnap_override_behavior.dm b/code/datums/components/xeno/ai_behavior_overrides/kidnap_override_behavior.dm index 28cf660bd3..a420074758 100644 --- a/code/datums/components/xeno/ai_behavior_overrides/kidnap_override_behavior.dm +++ b/code/datums/components/xeno/ai_behavior_overrides/kidnap_override_behavior.dm @@ -1,16 +1,32 @@ /datum/component/ai_behavior_override/kidnap +// behavior_icon_state = "capture order" /datum/component/ai_behavior_override/kidnap/Initialize(...) . = ..() - if(!istype(parent, /mob)) + if(!istype(parent, /mob) || isxeno(parent)) return COMPONENT_INCOMPATIBLE /datum/component/ai_behavior_override/kidnap/check_behavior_validity(mob/living/carbon/xenomorph/checked_xeno, distance) . = ..() - if(distance > 10) // Probably want checks like if(!target) and not already pulling someone and such + var/stat = parent?:stat + var/mob/pulledby = parent?:pulledby + + if(stat == DEAD) + return OVERRIDE_BEHAVIOR_QDEL + + if(HAS_TRAIT(parent, TRAIT_NESTED)) + return OVERRIDE_BEHAVIOR_QDEL + + if(distance > 10) + return FALSE + + if(stat == CONSCIOUS) + return FALSE + + if(isxeno(pulledby) && pulledby != checked_xeno) return FALSE return TRUE @@ -18,30 +34,25 @@ /datum/component/ai_behavior_override/kidnap/process_override_behavior(mob/living/carbon/xenomorph/processing_xeno, delta_time) . = ..() -/* - if(get_active_hand()) - swap_hand() - - if(stat_check && GLOB.xeno_kidnapping) - if(pulling) - if(ai_move_hive(delta_time)) - return TRUE - - if(isxeno(current_target.pulledby) || HAS_TRAIT(current_target, TRAIT_NESTED)) - current_target = null - ai_move_idle(delta_time) - return TRUE + processing_xeno.current_target = parent + processing_xeno.resting = FALSE - if(get_dist(current_target, src) <= 1) - INVOKE_ASYNC(src, PROC_REF(start_pulling), current_target) - face_atom(current_target) - swap_hand() + if(processing_xeno.get_active_hand()) + processing_xeno.swap_hand() - ai_move_target(delta_time) + var/datum/xeno_ai_movement/AI = processing_xeno.ai_movement_handler + if(processing_xeno.pulling == parent) + AI.ai_move_hive(delta_time) return TRUE - return FALSE -*/ + var/atom/movable/target = processing_xeno.current_target + if(get_dist(processing_xeno, target) <= 1) + INVOKE_ASYNC(processing_xeno, TYPE_PROC_REF(/mob, start_pulling), target) + processing_xeno.face_atom(target) + processing_xeno.swap_hand() + + processing_xeno.ai_move_target(delta_time) + return TRUE /* This is where we do our target setting and such, instead of moving in here:. diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 082731cc1c..06499ba0af 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -325,7 +325,6 @@ var/list/roundstart_mod_verbs = list( add_verb(src, /client/proc/cmd_mentor_say) add_verb(src, /datum/admins/proc/imaginary_friend) if(CLIENT_HAS_RIGHTS(src, R_BUILDMODE)) - add_verb(src, /client/proc/toggle_xeno_kidnapping) add_verb(src, /client/proc/togglebuildmodeself) add_verb(src, /client/proc/toggle_game_master) add_verb(src, /client/proc/toggle_join_xeno) @@ -357,7 +356,6 @@ var/list/roundstart_mod_verbs = list( /client/proc/remove_admin_verbs() remove_verb(src, list( admin_verbs_default, - /client/proc/toggle_xeno_kidnapping, /client/proc/togglebuildmodeself, /client/proc/toggle_game_master, /client/proc/toggle_join_xeno, diff --git a/code/modules/admin/game_master/hive_landmark.dm b/code/modules/admin/game_master/hive_landmark.dm index 2fc2c40eb4..8d711b2342 100644 --- a/code/modules/admin/game_master/hive_landmark.dm +++ b/code/modules/admin/game_master/hive_landmark.dm @@ -1,3 +1,8 @@ /obj/effect/landmark/ai_hive name = "Hive Landmark" var/hive_radius = 7 + +/obj/effect/landmark/ai_hive/New() + . = ..() + + new /obj/effect/alien/weeds/node(loc) diff --git a/code/modules/admin/game_master/toggle_xeno_kidnapping.dm b/code/modules/admin/game_master/toggle_xeno_kidnapping.dm deleted file mode 100644 index a60f1bac49..0000000000 --- a/code/modules/admin/game_master/toggle_xeno_kidnapping.dm +++ /dev/null @@ -1,13 +0,0 @@ - -/// As long as this toggled xenos will try and steal crit marines to nest them on nearest ai_hive landmark. This can be toggled by game masters. -/client/proc/toggle_xeno_kidnapping() - set name = "Toggle Xeno Kidnapping" - set category = "Game Master" - - if(!admin_holder || !check_rights(R_MOD, FALSE)) - return - - GLOB.xeno_kidnapping = !GLOB.xeno_kidnapping - message_admins("[src] has [GLOB.xeno_kidnapping ? "enabled" : "disabled"] AI kidnapping feature.") - -GLOBAL_VAR(xeno_kidnapping) diff --git a/code/modules/mob/living/carbon/xenomorph/XenoProcs.dm b/code/modules/mob/living/carbon/xenomorph/XenoProcs.dm index 02b460f02b..d791f1409d 100644 --- a/code/modules/mob/living/carbon/xenomorph/XenoProcs.dm +++ b/code/modules/mob/living/carbon/xenomorph/XenoProcs.dm @@ -756,6 +756,7 @@ for(var/obj/structure/bed/nest/preexisting_nest in get_turf(host_to_nest)) if(preexisting_nest.dir == dir_to_nest) to_chat(src, SPAN_XENONOTICE("There is already a host nested here!")) + step_to(host_to_nest, src) return var/obj/structure/bed/nest/applicable_nest = new(get_turf(host_to_nest)) diff --git a/code/modules/mob/living/carbon/xenomorph/ai/movement/base_define.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/base_define.dm index a77e21b5ae..00f66fc3dd 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/base_define.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/base_define.dm @@ -135,13 +135,13 @@ if(!potential_weeded_wall) continue - var/xeno_to_potential_nest_distance = get_dist(capping_xeno, potential_nest) - if(xeno_to_potential_nest_distance > shortest_distance) + var/hive_to_potential_nest_distance = get_dist(hive_landmark, potential_nest) + if(hive_to_potential_nest_distance > shortest_distance) continue nest_turf = potential_nest weeded_wall = potential_weeded_wall - shortest_distance = xeno_to_potential_nest_distance + shortest_distance = hive_to_potential_nest_distance if(!nest_turf) 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 a6e264a11c..0acc7b2438 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm @@ -77,7 +77,7 @@ GLOBAL_LIST_INIT(ai_target_limbs, list( var/mob/current_target_mob = current_target stat_check = (current_target_mob.stat != CONSCIOUS) - if(QDELETED(current_target) || (stat_check && !GLOB.xeno_kidnapping) || get_dist(current_target, src) > ai_range) + if(QDELETED(current_target) || stat_check|| get_dist(current_target, src) > ai_range) current_target = get_target(ai_range) if(QDELETED(src)) return TRUE @@ -222,7 +222,13 @@ GLOBAL_LIST_INIT(ai_target_limbs, list( var/datum/component/ai_behavior_override/closest_valid_override for(var/datum/component/ai_behavior_override/cycled_override in GLOB.all_ai_behavior_overrides) var/distance = get_dist(src, cycled_override.parent) - if(cycled_override.check_behavior_validity(src, distance) && distance < shortest_distance) + var/validity = cycled_override.check_behavior_validity(src, distance) + + if(validity == OVERRIDE_BEHAVIOR_QDEL) + qdel(cycled_override) + continue + + if(validity && distance < shortest_distance) shortest_distance = distance closest_valid_override = cycled_override @@ -324,7 +330,7 @@ GLOBAL_LIST_INIT(ai_target_limbs, list( if(FACTION_XENOMORPH in checked_human.faction_group) return FALSE - if(checked_human.stat != CONSCIOUS && !GLOB.xeno_kidnapping) + if(checked_human.stat != CONSCIOUS) return FALSE return TRUE diff --git a/colonialmarines.dme b/colonialmarines.dme index 38429bff9f..4798010799 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -1374,7 +1374,6 @@ #include "code\modules\admin\game_master\game_master_submenu.dm" #include "code\modules\admin\game_master\hive_landmark.dm" #include "code\modules\admin\game_master\toggle_join_xeno.dm" -#include "code\modules\admin\game_master\toggle_xeno_kidnapping.dm" #include "code\modules\admin\game_master\game_master_submenu\vents.dm" #include "code\modules\admin\medal_panel\medals_panel.dm" #include "code\modules\admin\medal_panel\medals_panel_tgui.dm"