Skip to content

Commit

Permalink
[MIRROR] [no gbp] some few bot fixes [MDB IGNORE] (#1084)
Browse files Browse the repository at this point in the history
* [no gbp] some few bot fixes (#80208)

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: Ben10Omintrix <[email protected]>
  • Loading branch information
3 people authored Dec 12, 2023
1 parent 6a0be67 commit 2dee69a
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 35 deletions.
2 changes: 1 addition & 1 deletion code/datums/station_traits/negative_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions code/modules/mob/living/basic/bots/_bots.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand All @@ -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)
2 changes: 2 additions & 0 deletions code/modules/mob/living/basic/bots/bot_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions code/modules/mob/living/basic/bots/cleanbot/cleanbot_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 0 additions & 6 deletions code/modules/mob/living/basic/bots/medbot/medbot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/silicon/ai/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
74 changes: 54 additions & 20 deletions code/modules/mob/living/silicon/ai/robot_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,46 +35,80 @@
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(),
hacked = !!(simple_bot.bot_cover_flags & BOT_COVER_HACKED),
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

0 comments on commit 2dee69a

Please sign in to comment.