From defc627a8290c60df25d59f27d8b87b0dc500c31 Mon Sep 17 00:00:00 2001 From: Morrow Date: Wed, 1 Nov 2023 03:29:03 -0400 Subject: [PATCH] max assigned to behavior --- .../attack_override_behavior.dm | 4 ++++ .../base_override_behavior.dm | 20 ++++++++++++++++--- .../capture_override_behavior.dm | 6 ++++++ .../hive_override_behavior.dm | 14 +++++++++++-- code/game/area/areas_event.dm | 2 +- code/modules/admin/game_master/game_master.dm | 6 +++--- .../xenomorph/ai/movement/base_define.dm | 2 +- .../carbon/xenomorph/ai/movement/drone.dm | 2 ++ .../mob/living/carbon/xenomorph/ai/xeno_ai.dm | 2 +- 9 files changed, 47 insertions(+), 11 deletions(-) diff --git a/code/datums/components/xeno/ai_behavior_overrides/attack_override_behavior.dm b/code/datums/components/xeno/ai_behavior_overrides/attack_override_behavior.dm index a86fd14c79..30ec893db3 100644 --- a/code/datums/components/xeno/ai_behavior_overrides/attack_override_behavior.dm +++ b/code/datums/components/xeno/ai_behavior_overrides/attack_override_behavior.dm @@ -4,6 +4,8 @@ /datum/component/ai_behavior_override/attack/check_behavior_validity(mob/living/carbon/xenomorph/checked_xeno, distance) . = ..() + if(!.) + return if(distance > 10) return FALSE @@ -12,6 +14,8 @@ /datum/component/ai_behavior_override/attack/process_override_behavior(mob/living/carbon/xenomorph/processing_xeno, delta_time) . = ..() + if(!.) + return if(processing_xeno.current_target == parent) return FALSE diff --git a/code/datums/components/xeno/ai_behavior_overrides/base_override_behavior.dm b/code/datums/components/xeno/ai_behavior_overrides/base_override_behavior.dm index 4258d4b418..a5bb0728de 100644 --- a/code/datums/components/xeno/ai_behavior_overrides/base_override_behavior.dm +++ b/code/datums/components/xeno/ai_behavior_overrides/base_override_behavior.dm @@ -11,6 +11,12 @@ GLOBAL_LIST_EMPTY(all_ai_behavior_overrides) /// The actual image holder that sits on parent for game masters var/image/behavior_image + /// The xenos currently handling this task + var/currently_assigned + + /// How many xenos we want assigned to this task at max + var/max_assigned = 3 + /datum/component/ai_behavior_override/Initialize(...) . = ..() @@ -19,7 +25,9 @@ GLOBAL_LIST_EMPTY(all_ai_behavior_overrides) behavior_image = new(behavior_icon, parent, behavior_icon_state, layer = ABOVE_FLY_LAYER) for(var/client/game_master in GLOB.game_masters) - game_master.images += behavior_image + game_master.images |= behavior_image + + currently_assigned = list() /datum/component/ai_behavior_override/Destroy(force, silent, ...) GLOB.all_ai_behavior_overrides -= src @@ -28,15 +36,21 @@ GLOBAL_LIST_EMPTY(all_ai_behavior_overrides) game_master.images -= behavior_image QDEL_NULL(behavior_image) + currently_assigned = null . = ..() /// Override this to check if we want our behavior to be valid for the checked_xeno, passes the common factor of "distance" which is the distance between the checked_xeno and src parent /datum/component/ai_behavior_override/proc/check_behavior_validity(mob/living/carbon/xenomorph/checked_xeno, distance) - return FALSE + if(length(currently_assigned) >= max_assigned && !(checked_xeno in currently_assigned)) + return FALSE + + return TRUE /// Processes what we want this behavior to do, return FALSE if we want to continue in the process_ai() proc or TRUE if we want to handle everything and have process_ai() return /datum/component/ai_behavior_override/proc/process_override_behavior(mob/living/carbon/xenomorph/processing_xeno, delta_time) SHOULD_NOT_SLEEP(TRUE) - return FALSE + currently_assigned |= processing_xeno + + return TRUE diff --git a/code/datums/components/xeno/ai_behavior_overrides/capture_override_behavior.dm b/code/datums/components/xeno/ai_behavior_overrides/capture_override_behavior.dm index 3d9a2576cd..3651ca25ed 100644 --- a/code/datums/components/xeno/ai_behavior_overrides/capture_override_behavior.dm +++ b/code/datums/components/xeno/ai_behavior_overrides/capture_override_behavior.dm @@ -2,6 +2,8 @@ /datum/component/ai_behavior_override/capture behavior_icon_state = "capture_order" + max_assigned = 1 + /datum/component/ai_behavior_override/capture/Initialize(...) . = ..() @@ -13,6 +15,8 @@ /datum/component/ai_behavior_override/capture/check_behavior_validity(mob/living/carbon/xenomorph/checked_xeno, distance) . = ..() + if(!.) + return var/mob/parent_mob = parent @@ -47,6 +51,8 @@ /datum/component/ai_behavior_override/capture/process_override_behavior(mob/living/carbon/xenomorph/processing_xeno, delta_time) . = ..() + if(!.) + return processing_xeno.current_target = parent processing_xeno.resting = FALSE diff --git a/code/datums/components/xeno/ai_behavior_overrides/hive_override_behavior.dm b/code/datums/components/xeno/ai_behavior_overrides/hive_override_behavior.dm index 0ef1dd71bb..3fb5923a71 100644 --- a/code/datums/components/xeno/ai_behavior_overrides/hive_override_behavior.dm +++ b/code/datums/components/xeno/ai_behavior_overrides/hive_override_behavior.dm @@ -7,18 +7,28 @@ GLOBAL_LIST_EMPTY(ai_hives) /datum/component/ai_behavior_override/hive behavior_icon_state = "core" + max_assigned = 0 + var/hive_radius = 7 /datum/component/ai_behavior_override/hive/Initialize(...) . = ..() - if(!istype(parent, /turf/open)) + if(!istype(parent, /turf/open) && !istype(parent, /obj/effect/alien)) return COMPONENT_INCOMPATIBLE GLOB.ai_hives += src - new /obj/effect/alien/weeds/node(get_turf(parent)) + + if(!istype(parent, /obj/effect/alien)) + new /obj/effect/alien/weeds/node(get_turf(parent)) /datum/component/ai_behavior_override/hive/Destroy(force, silent, ...) GLOB.ai_hives -= src . = ..() + +/datum/component/ai_behavior_override/hive/check_behavior_validity(mob/living/carbon/xenomorph/checked_xeno, distance) + return FALSE + +/datum/component/ai_behavior_override/hive/process_override_behavior(mob/living/carbon/xenomorph/processing_xeno, delta_time) + return FALSE diff --git a/code/game/area/areas_event.dm b/code/game/area/areas_event.dm index c43dae3a65..8fc66afd4d 100644 --- a/code/game/area/areas_event.dm +++ b/code/game/area/areas_event.dm @@ -42,7 +42,7 @@ structure: icon_state = "event" //no bioscan and no tunnels allowed - flags_area = AREA_AVOID_BIOSCAN|AREA_NOTUNNEL + flags_area = AREA_AVOID_BIOSCAN //events are not part of regular gameplay, therefore, no statistics statistic_exempt = TRUE diff --git a/code/modules/admin/game_master/game_master.dm b/code/modules/admin/game_master/game_master.dm index 7b92a06252..aed0016429 100644 --- a/code/modules/admin/game_master/game_master.dm +++ b/code/modules/admin/game_master/game_master.dm @@ -118,7 +118,7 @@ GLOBAL_VAR_INIT(radio_communication_clarity, 100) for(var/datum/component/ai_behavior_override/override in GLOB.all_ai_behavior_overrides) game_master_client.images += override.behavior_image - GLOB.game_masters += game_master_client + GLOB.game_masters |= game_master_client /datum/game_master/Destroy(force, ...) . = ..() @@ -289,7 +289,7 @@ GLOBAL_VAR_INIT(radio_communication_clarity, 100) user.client?.click_intercept = src for(var/datum/component/ai_behavior_override/override in GLOB.all_ai_behavior_overrides) - game_master_client.images += override.behavior_image + game_master_client.images |= override.behavior_image /datum/game_master/proc/InterceptClickOn(mob/user, params, atom/object) @@ -319,7 +319,7 @@ GLOBAL_VAR_INIT(radio_communication_clarity, 100) var/behavior_type = SELECTABLE_XENO_BEHAVIORS_ASSOC[selected_behavior] if(LAZYACCESS(modifiers, MIDDLE_CLICK)) - if(object.datum_components[behavior_type]) + if(object.datum_components?[behavior_type]) var/component_to_remove = object.datum_components[behavior_type] qdel(component_to_remove) return TRUE 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 da19db3d7c..7e36e89260 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 @@ -114,7 +114,7 @@ var/turf/weeded_wall var/shortest_distance = INFINITY - for(var/turf/potential_nest as anything in RANGE_TURFS(hive_radius, closest_hive)) + for(var/turf/potential_nest as anything in shuffle(RANGE_TURFS(hive_radius, closest_hive))) if(potential_nest.density) continue diff --git a/code/modules/mob/living/carbon/xenomorph/ai/movement/drone.dm b/code/modules/mob/living/carbon/xenomorph/ai/movement/drone.dm index 5682062cea..086000bed4 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/movement/drone.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/movement/drone.dm @@ -54,6 +54,8 @@ idle_xeno.lay_down() return + idle_xeno.resting = FALSE + if(home_turf == last_home_turf) blacklisted_turfs += home_turf addtimer(CALLBACK(src, PROC_REF(unblacklist_turf), home_turf), BLACKLIST_TURF_TIMEOUT) 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 517c54ed71..08684b2cd9 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|| 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