mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-20 11:35:19 +01:00
Robot code clean up and fixes.
Fixes runtime when a borg is reset. Fixes issue where /proc/select_active_ai_with_fewest_borgs() would not always return the intended AI. Fixes issues with new borgs spamming the master AI with creation messages under some circumstances.
This commit is contained in:
@@ -54,8 +54,6 @@
|
||||
|
||||
/mob/living/silicon/robot/drone/init()
|
||||
laws = new /datum/ai_laws/drone()
|
||||
connected_ai = null
|
||||
|
||||
aiCamera = new/obj/item/device/camera/siliconcam/drone_camera(src)
|
||||
playsound(src.loc, 'sound/machines/twobeep.ogg', 50, 0)
|
||||
|
||||
|
||||
@@ -226,9 +226,7 @@
|
||||
if(tra.current)
|
||||
var/I = image('icons/mob/mob.dmi', loc = tra.current, icon_state = "traitor")
|
||||
src.client.images += I
|
||||
if(src.connected_ai)
|
||||
src.connected_ai.connected_robots -= src
|
||||
src.connected_ai = null
|
||||
src.disconnect_from_ai()
|
||||
if(src.mind)
|
||||
if(!src.mind.special_role)
|
||||
src.mind.special_role = "traitor"
|
||||
|
||||
@@ -164,11 +164,10 @@ var/list/robot_verbs_default = list(
|
||||
aiCamera = new/obj/item/device/camera/siliconcam/robot_camera(src)
|
||||
laws = new /datum/ai_laws/nanotrasen()
|
||||
additional_law_channels += "Binary"
|
||||
connected_ai = select_active_ai_with_fewest_borgs()
|
||||
if(connected_ai)
|
||||
connected_ai.connected_robots += src
|
||||
var/new_ai = select_active_ai_with_fewest_borgs()
|
||||
if(new_ai)
|
||||
lawupdate = 1
|
||||
sync()
|
||||
connect_to_ai(new_ai)
|
||||
else
|
||||
lawupdate = 0
|
||||
|
||||
@@ -365,7 +364,7 @@ var/list/robot_verbs_default = list(
|
||||
|
||||
choose_icon(6,module_sprites)
|
||||
radio.config(module.channels)
|
||||
notify_ai(2)
|
||||
notify_ai(ROBOT_NOTIFICATION_NEW_MODULE, module.name)
|
||||
|
||||
/mob/living/silicon/robot/proc/updatename(var/prefix as text)
|
||||
if(prefix)
|
||||
@@ -385,7 +384,7 @@ var/list/robot_verbs_default = list(
|
||||
else
|
||||
changed_name = "[modtype] [braintype]-[num2text(ident)]"
|
||||
|
||||
notify_ai(3, real_name, changed_name)
|
||||
notify_ai(ROBOT_NOTIFICATION_NEW_NAME, real_name, changed_name)
|
||||
real_name = changed_name
|
||||
name = real_name
|
||||
|
||||
@@ -802,7 +801,7 @@ var/list/robot_verbs_default = list(
|
||||
if(prob(50))
|
||||
emagged = 1
|
||||
lawupdate = 0
|
||||
connected_ai = null
|
||||
disconnect_from_ai()
|
||||
user << "You emag [src]'s interface."
|
||||
message_admins("[key_name_admin(user)] emagged cyborg [key_name_admin(src)]. Laws overridden.")
|
||||
log_game("[key_name(user)] emagged cyborg [key_name(src)]. Laws overridden.")
|
||||
@@ -1134,8 +1133,7 @@ var/list/robot_verbs_default = list(
|
||||
return
|
||||
|
||||
/mob/living/silicon/robot/proc/UnlinkSelf()
|
||||
if (src.connected_ai)
|
||||
src.connected_ai = null
|
||||
disconnect_from_ai()
|
||||
lawupdate = 0
|
||||
lockcharge = 0
|
||||
canmove = 1
|
||||
@@ -1245,14 +1243,29 @@ var/list/robot_verbs_default = list(
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/mob/living/silicon/robot/proc/notify_ai(var/notifytype, var/oldname, var/newname)
|
||||
/mob/living/silicon/robot/proc/notify_ai(var/notifytype, var/first_arg, var/second_arg)
|
||||
if(!connected_ai)
|
||||
return
|
||||
switch(notifytype)
|
||||
if(1) //New Robot
|
||||
if(ROBOT_NOTIFICATION_NEW_UNIT) //New Robot
|
||||
connected_ai << "<br><br><span class='notice'>NOTICE - New [lowertext(braintype)] connection detected: <a href='byond://?src=\ref[connected_ai];track2=\ref[connected_ai];track=\ref[src]'>[name]</a></span><br>"
|
||||
if(2) //New Module
|
||||
connected_ai << "<br><br><span class='notice'>NOTICE - [braintype] module change detected: [name] has loaded the [module.name].</span><br>"
|
||||
if(3) //New Name
|
||||
if(oldname != newname)
|
||||
connected_ai << "<br><br><span class='notice'>NOTICE - [braintype] reclassification detected: [oldname] is now designated as [newname].</span><br>"
|
||||
if(ROBOT_NOTIFICATION_NEW_MODULE) //New Module
|
||||
connected_ai << "<br><br><span class='notice'>NOTICE - [braintype] module change detected: [name] has loaded the [first_arg].</span><br>"
|
||||
if(ROBOT_NOTIFICATION_MODULE_RESET)
|
||||
connected_ai << "<br><br><span class='notice'>NOTICE - [braintype] module reset detected: [name] has unladed the [first_arg].</span><br>"
|
||||
if(ROBOT_NOTIFICATION_NEW_NAME) //New Name
|
||||
if(first_arg != second_arg)
|
||||
connected_ai << "<br><br><span class='notice'>NOTICE - [braintype] reclassification detected: [first_arg] is now designated as [second_arg].</span><br>"
|
||||
|
||||
/mob/living/silicon/robot/proc/disconnect_from_ai()
|
||||
if(connected_ai)
|
||||
connected_ai.connected_robots -= src
|
||||
connected_ai = null
|
||||
|
||||
/mob/living/silicon/robot/proc/connect_to_ai(var/mob/living/silicon/ai/AI)
|
||||
if(AI && AI != connected_ai)
|
||||
disconnect_from_ai()
|
||||
connected_ai = AI
|
||||
connected_ai.connected_robots |= src
|
||||
notify_ai(ROBOT_NOTIFICATION_NEW_UNIT)
|
||||
sync()
|
||||
|
||||
@@ -168,7 +168,6 @@
|
||||
O.mmi.transfer_identity(src)
|
||||
|
||||
callHook("borgify", list(O))
|
||||
O.notify_ai(1)
|
||||
O.Namepick()
|
||||
|
||||
spawn(0)//To prevent the proc from returning null.
|
||||
|
||||
Reference in New Issue
Block a user