From 2dee69a8d464dbba4fd317b7eae50d06a0f35b44 Mon Sep 17 00:00:00 2001 From: Iajret Creature <122297233+Steals-The-PRs@users.noreply.github.com> Date: Wed, 13 Dec 2023 02:20:53 +0300 Subject: [PATCH] [MIRROR] [no gbp] some few bot fixes [MDB IGNORE] (#1084) * [no gbp] some few bot fixes (#80208) --------- Co-authored-by: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> --- code/datums/station_traits/negative_traits.dm | 2 +- code/modules/mob/living/basic/bots/_bots.dm | 16 +++- code/modules/mob/living/basic/bots/bot_ai.dm | 2 + .../living/basic/bots/cleanbot/cleanbot_ai.dm | 5 +- .../mob/living/basic/bots/medbot/medbot.dm | 6 -- code/modules/mob/living/silicon/ai/ai.dm | 2 +- .../mob/living/silicon/ai/robot_control.dm | 74 ++++++++++++++----- 7 files changed, 72 insertions(+), 35 deletions(-) diff --git a/code/datums/station_traits/negative_traits.dm b/code/datums/station_traits/negative_traits.dm index 425af172e52..5c37fd7ede5 100644 --- a/code/datums/station_traits/negative_traits.dm +++ b/code/datums/station_traits/negative_traits.dm @@ -156,7 +156,7 @@ /datum/station_trait/bot_languages/on_round_start() . = ..() // All bots that exist round start on station Z OR on the escape shuttle have their set language randomized. - for(var/mob/living/simple_animal/bot/found_bot as anything in GLOB.bots_list) + for(var/mob/living/found_bot as anything in GLOB.bots_list) found_bot.randomize_language_if_on_station() /datum/station_trait/revenge_of_pun_pun diff --git a/code/modules/mob/living/basic/bots/_bots.dm b/code/modules/mob/living/basic/bots/_bots.dm index ed2258d6dad..88f61948f8c 100644 --- a/code/modules/mob/living/basic/bots/_bots.dm +++ b/code/modules/mob/living/basic/bots/_bots.dm @@ -91,6 +91,9 @@ GLOBAL_LIST_INIT(command_strings, list( /mob/living/basic/bot/Initialize(mapload) . = ..() + AddElement(/datum/element/relay_attackers) + + RegisterSignal(src, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(after_attacked)) RegisterSignal(src, COMSIG_MOB_TRIED_ACCESS, PROC_REF(attempt_access)) ADD_TRAIT(src, TRAIT_NO_GLIDE, INNATE_TRAIT) GLOB.bots_list += src @@ -181,6 +184,7 @@ GLOBAL_LIST_INIT(command_strings, list( /mob/living/basic/bot/Destroy() GLOB.bots_list -= src + calling_ai_ref = null QDEL_NULL(paicard) QDEL_NULL(pa_system) QDEL_NULL(internal_radio) @@ -521,8 +525,7 @@ GLOBAL_LIST_INIT(command_strings, list( return if(istype(item_to_drop, /obj/item/storage)) - var/obj/item/storage/storage_to_drop = item_to_drop - storage_to_drop.emptyStorage() + item_to_drop.contents = list() return if(!istype(item_to_drop, /obj/item/gun/energy)) @@ -778,11 +781,12 @@ GLOBAL_LIST_INIT(command_strings, list( initial_access = access_card.access.Copy() -/mob/living/basic/bot/proc/summon_bot(atom/caller, user_access = list(), grant_all_access = FALSE) +/mob/living/basic/bot/proc/summon_bot(atom/caller, turf/turf_destination, user_access = list(), grant_all_access = FALSE) if(isAI(caller) && !set_ai_caller(caller)) return FALSE bot_reset(bypass_ai_reset = isAI(caller)) - ai_controller?.set_blackboard_key(BB_BOT_SUMMON_TARGET, get_turf(caller)) + var/turf/destination = turf_destination ? turf_destination : get_turf(caller) + ai_controller?.set_blackboard_key(BB_BOT_SUMMON_TARGET, destination) var/list/access_to_grant = grant_all_access ? REGION_ACCESS_ALL_STATION : user_access + initial_access access_card.set_access(access_to_grant) speak("Responding.", radio_channel) @@ -801,3 +805,7 @@ GLOBAL_LIST_INIT(command_strings, list( update_appearance() if(update_hud) diag_hud_set_botmode() + +/mob/living/basic/bot/proc/after_attacked(datum/source, atom/attacker, attack_flags) + if(attack_flags & ATTACKER_DAMAGING_ATTACK) + do_sparks(number = 5, cardinal_only = TRUE, source = src) diff --git a/code/modules/mob/living/basic/bots/bot_ai.dm b/code/modules/mob/living/basic/bots/bot_ai.dm index 5fe2678dfb7..39c4875b15f 100644 --- a/code/modules/mob/living/basic/bots/bot_ai.dm +++ b/code/modules/mob/living/basic/bots/bot_ai.dm @@ -58,6 +58,8 @@ /datum/ai_controller/basic_controller/bot/proc/can_reach_target(target, distance = 10) if(!isdatum(target)) //we dont need to check if its not a datum! return TRUE + if(get_turf(pawn) == get_turf(target)) + return TRUE var/list/path = get_path_to(pawn, target, max_distance = distance, access = get_access()) if(!length(path)) return FALSE diff --git a/code/modules/mob/living/basic/bots/cleanbot/cleanbot_ai.dm b/code/modules/mob/living/basic/bots/cleanbot/cleanbot_ai.dm index a5daba20367..5ca7cdae3a6 100644 --- a/code/modules/mob/living/basic/bots/cleanbot/cleanbot_ai.dm +++ b/code/modules/mob/living/basic/bots/cleanbot/cleanbot_ai.dm @@ -77,9 +77,8 @@ var/list/ignore_list = controller.blackboard[BB_TEMPORARY_IGNORE_LIST] for(var/atom/found_item in found) if(LAZYACCESS(ignore_list, found_item)) - found -= found_item - if(length(found)) - return pick(found) + continue + return found_item /datum/ai_planning_subtree/acid_spray diff --git a/code/modules/mob/living/basic/bots/medbot/medbot.dm b/code/modules/mob/living/basic/bots/medbot/medbot.dm index 44b6ae11b21..278a69d154b 100644 --- a/code/modules/mob/living/basic/bots/medbot/medbot.dm +++ b/code/modules/mob/living/basic/bots/medbot/medbot.dm @@ -254,12 +254,6 @@ playsound(src, SFX_SPARKS, 75, TRUE, SHORT_RANGE_SOUND_EXTRARANGE) return TRUE -/mob/living/basic/bot/medbot/explode() - var/atom/our_loc = drop_location() - drop_part(medkit_type, our_loc) - drop_part(health_analyzer, our_loc) - return ..() - /mob/living/basic/bot/medbot/examine() . = ..() if(!(medical_mode_flags & MEDBOT_TIPPED_MODE)) diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index 1264e7c884d..f2f815df0e2 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -607,7 +607,7 @@ var/summon_success if(isbasicbot(bot)) var/mob/living/basic/bot/basic_bot = bot - summon_success = basic_bot.summon_bot(src, grant_all_access = TRUE) + summon_success = basic_bot.summon_bot(src, waypoint, grant_all_access = TRUE) else var/mob/living/simple_animal/bot/simple_bot = bot call_bot_cooldown = world.time + CALL_BOT_COOLDOWN diff --git a/code/modules/mob/living/silicon/ai/robot_control.dm b/code/modules/mob/living/silicon/ai/robot_control.dm index f349f6b1b7f..c4cc256244c 100644 --- a/code/modules/mob/living/silicon/ai/robot_control.dm +++ b/code/modules/mob/living/silicon/ai/robot_control.dm @@ -35,11 +35,29 @@ var/turf/ai_current_turf = get_turf(owner) data["robots"] = list() - for(var/mob/living/simple_animal/bot/simple_bot as anything in GLOB.bots_list) - //Only non-emagged bots on a valid Z-level are detected! - if(!is_valid_z_level(ai_current_turf, get_turf(simple_bot)) || !(simple_bot.bot_mode_flags & BOT_MODE_REMOTE_ENABLED)) + for(var/mob/living/our_bot as anything in GLOB.bots_list) + if(!isbot(our_bot) || !is_valid_z_level(ai_current_turf, get_turf(our_bot))) continue - var/list/robot_data = list( + + if(isbasicbot(our_bot)) + var/mob/living/basic/bot/basic_bot = our_bot + if(!(basic_bot.bot_mode_flags & BOT_MODE_REMOTE_ENABLED)) + continue + var/list/basic_bot_data = list( + name = basic_bot.name, + model = basic_bot.bot_type, + mode = basic_bot.mode, + hacked = !!(basic_bot.bot_access_flags & BOT_COVER_HACKED), + location = get_area_name(basic_bot, TRUE), + ref = REF(basic_bot), + ) + data["robots"] += list(basic_bot_data) + continue + + var/mob/living/simple_animal/bot/simple_bot = our_bot + if(!(simple_bot.bot_mode_flags & BOT_MODE_REMOTE_ENABLED)) + continue + var/list/simple_bot_data = list( name = simple_bot.name, model = simple_bot.bot_type, mode = simple_bot.get_mode(), @@ -47,34 +65,50 @@ location = get_area_name(simple_bot, TRUE), ref = REF(simple_bot), ) - data["robots"] += list(robot_data) + data["robots"] += list(simple_bot_data) return data -/datum/robot_control/ui_act(action, params) +/datum/robot_control/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) . = ..() - if(.) + if(. || !isliving(ui.user)) + return + var/mob/living/our_user = ui.user + if(!is_interactable(our_user)) + return + if(owner.control_disabled) return - if(!is_interactable(usr)) + var/mob/living/bot = locate(params["ref"]) in GLOB.bots_list + if(isnull(bot)) return - var/mob/living/simple_animal/bot/bot switch(action) if("callbot") //Command a bot to move to a selected location. if(owner.call_bot_cooldown > world.time) - to_chat(usr, span_danger("Error: Your last call bot command is still processing, please wait for the bot to finish calculating a route.")) + to_chat(our_user, span_danger("Error: Your last call bot command is still processing, please wait for the bot to finish calculating a route.")) return - bot = locate(params["ref"]) in GLOB.bots_list + if(isbasicbot(bot)) + var/mob/living/basic/bot/basic_bot = bot + if(!(basic_bot.bot_mode_flags & BOT_MODE_REMOTE_ENABLED)) + return + else + var/mob/living/simple_animal/bot/simple_bot = bot + if(!(simple_bot.bot_mode_flags & BOT_MODE_REMOTE_ENABLED)) + return + owner.bot_ref = WEAKREF(bot) - if(!bot || !(bot.bot_mode_flags & BOT_MODE_REMOTE_ENABLED) || owner.control_disabled) - return owner.waypoint_mode = TRUE - to_chat(usr, span_notice("Set your waypoint by clicking on a valid location free of obstructions.")) - . = TRUE + to_chat(our_user, span_notice("Set your waypoint by clicking on a valid location free of obstructions.")) if("interface") //Remotely connect to a bot! - bot = locate(params["ref"]) in GLOB.bots_list owner.bot_ref = WEAKREF(bot) - if(!bot || !(bot.bot_mode_flags & BOT_MODE_REMOTE_ENABLED) || owner.control_disabled) - return - bot.attack_ai(usr) - . = TRUE + if(isbasicbot(bot)) + var/mob/living/basic/bot/basic_bot = bot + if(!(basic_bot.bot_mode_flags & BOT_MODE_REMOTE_ENABLED)) + return + else + var/mob/living/basic/bot/simple_bot = bot + if(!(simple_bot.bot_mode_flags & BOT_MODE_REMOTE_ENABLED)) + return + bot.attack_ai(our_user) + + return TRUE