[TGUI] Upgrades Bots (#14871)

* secbots, ED209s, cleanbots

* Apply suggestions from AA code review

Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>

* fluid buttons, Restore Safties

* pai rebuild

* deletes all spacing from data list

* katana needs_permit

* lava/storm/boneaxe needs_permit

* check s_store

Co-authored-by: Kyep <Kyep@users.noreply.github.com>
Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
This commit is contained in:
Kyep
2020-11-27 09:56:02 +00:00
committed by GitHub
co-authored by AffectedArc07 Kyep
parent edf4debdeb
commit 4a944658ad
16 changed files with 446 additions and 153 deletions
@@ -1542,7 +1542,10 @@ Eyes need to have significantly high darksight to shine unless the mob has the X
if(judgebot.check_for_weapons(r_hand))
threatcount += 4
if(judgebot.check_for_weapons(belt))
threatcount += 2
threatcount += 4
if(judgebot.check_for_weapons(s_store))
threatcount += 4
//Check for arrest warrant
if(judgebot.check_records)
@@ -871,29 +871,37 @@ Pass a positive integer as an argument to override a bot's default speed.
if("remote")
remote_disabled = !remote_disabled
if("hack")
if(emagged != 2)
emagged = 2
hacked = 1
locked = 1
to_chat(usr, "<span class='warning'>[text_hack]</span>")
show_laws()
bot_reset()
add_attack_logs(usr, src, "Hacked")
else if(!hacked)
to_chat(usr, "<span class='userdanger'>[text_dehack_fail]</span>")
else
emagged = 0
hacked = 0
to_chat(usr, "<span class='notice'>[text_dehack]</span>")
show_laws()
bot_reset()
add_attack_logs(usr, src, "Dehacked")
handle_hacking(usr)
if("ejectpai")
if(paicard && (!locked || issilicon(usr) || usr.can_admin_interact()))
to_chat(usr, "<span class='notice'>You eject [paicard] from [bot_name]</span>")
ejectpai(usr)
update_controls()
/mob/living/simple_animal/bot/proc/canhack(mob/M)
return ((issilicon(M) && !emagged) || M.can_admin_interact())
/mob/living/simple_animal/bot/proc/handle_hacking(mob/M) // refactored out of Topic/ to allow re-use by TGUIs
if(!canhack(M))
return
if(emagged != 2)
emagged = 2
hacked = TRUE
locked = TRUE
to_chat(M, "<span class='warning'>[text_hack]</span>")
show_laws()
bot_reset()
add_attack_logs(M, src, "Hacked")
else if(!hacked)
to_chat(M, "<span class='userdanger'>[text_dehack_fail]</span>")
else
emagged = FALSE
hacked = FALSE
to_chat(M, "<span class='notice'>[text_dehack]</span>")
show_laws()
bot_reset()
add_attack_logs(M, src, "Dehacked")
/mob/living/simple_animal/bot/proc/update_icon()
icon_state = "[initial(icon_state)][on]"
@@ -910,16 +918,17 @@ Pass a positive integer as an argument to override a bot's default speed.
/mob/living/simple_animal/bot/proc/topic_denied(mob/user) //Access check proc for bot topics! Remember to place in a bot's individual Topic if desired.
if(user.can_admin_interact())
return 0
return FALSE
if(user.incapacitated() || !(issilicon(user) || in_range(src, user)))
return 1
// 0 for access, 1 for denied.
return TRUE
if(emagged == 2) //An emagged bot cannot be controlled by humans, silicons can if one hacked it.
if(!hacked) //Manually emagged by a human - access denied to all.
return 1
return TRUE
else if(!issilicon(user)) //Bot is hacked, so only silicons are allowed access.
return 1
return 0
return TRUE
if(locked && !issilicon(user))
return TRUE
return FALSE
/mob/living/simple_animal/bot/proc/hack(mob/user)
var/hack
@@ -190,29 +190,58 @@
req_one_access = list(ACCESS_JANITOR, ACCESS_ROBOTICS)
/mob/living/simple_animal/bot/cleanbot/get_controls(mob/user)
var/dat
dat += hack(user)
dat += showpai(user)
dat += text({"
<TT><B>Cleaner v1.1 controls</B></TT><BR><BR>
Status: []<BR>
Behaviour controls are [locked ? "locked" : "unlocked"]<BR>
Maintenance panel panel is [open ? "opened" : "closed"]"},
text("<A href='?src=[UID()];power=1'>[on ? "On" : "Off"]</A>"))
if(!locked || issilicon(user) || user.can_admin_interact())
dat += text({"<BR>Cleans Blood: []<BR>"}, text("<A href='?src=[UID()];operation=blood'>[blood ? "Yes" : "No"]</A>"))
dat += text({"<BR>Patrol station: []<BR>"}, text("<A href='?src=[UID()];operation=patrol'>[auto_patrol ? "Yes" : "No"]</A>"))
return dat
/mob/living/simple_animal/bot/cleanbot/show_controls(mob/M)
tgui_interact(M)
/mob/living/simple_animal/bot/cleanbot/Topic(href, href_list)
if(..())
return 1
switch(href_list["operation"])
/mob/living/simple_animal/bot/cleanbot/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = TRUE, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "BotClean", name, 500, 500)
ui.open()
/mob/living/simple_animal/bot/cleanbot/tgui_data(mob/user)
var/list/data = list(
"locked" = locked, // controls, locked or not
"noaccess" = topic_denied(user), // does the current user have access? admins, silicons etc can still access bots with locked controls
"maintpanel" = open,
"on" = on,
"autopatrol" = auto_patrol,
"painame" = paicard ? paicard.pai.name : null,
"canhack" = canhack(user),
"emagged" = emagged, // this is an int, NOT a boolean
"remote_disabled" = remote_disabled, // -- STUFF BELOW HERE IS SPECIFIC TO THIS BOT
"cleanblood" = blood
)
return data
/mob/living/simple_animal/bot/cleanbot/tgui_act(action, params)
if (..())
return
if(topic_denied(usr))
to_chat(usr, "<span class='warning'>[src]'s interface is not responding!</span>")
return
add_fingerprint(usr)
. = TRUE
switch(action)
if("power")
if(on)
turn_off()
else
turn_on()
if("autopatrol")
auto_patrol = !auto_patrol
bot_reset()
if("hack")
handle_hacking(usr)
if("disableremote")
remote_disabled = !remote_disabled
if("blood")
blood =!blood
get_targets()
update_controls()
if("ejectpai")
ejectpai()
/mob/living/simple_animal/bot/cleanbot/UnarmedAttack(atom/A)
if(istype(A,/obj/effect/decal/cleanable))
@@ -102,64 +102,77 @@
text_dehack = "You restore [name]'s combat inhibitor."
text_dehack_fail = "[name] ignores your attempts to restrict [p_them()]!"
/mob/living/simple_animal/bot/ed209/get_controls(mob/user)
var/dat
dat += hack(user)
dat += showpai(user)
dat += text({"
<TT><B>Security Unit v2.6 controls</B></TT><BR><BR>
Status: []<BR>
Behaviour controls are [locked ? "locked" : "unlocked"]<BR>
Maintenance panel panel is [open ? "opened" : "closed"]<BR>"},
/mob/living/simple_animal/bot/ed209/show_controls(mob/M)
tgui_interact(M)
"<A href='?src=[UID()];power=1'>[on ? "On" : "Off"]</A>" )
/mob/living/simple_animal/bot/ed209/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = TRUE, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "BotSecurity", name, 500, 500)
ui.open()
if(!locked || issilicon(user) || user.can_admin_interact())
dat += "Auto Patrol <A href='?src=[UID()];operation=patrol'>[auto_patrol ? "On" : "Off"]</A><BR>"
/mob/living/simple_animal/bot/ed209/tgui_data(mob/user)
var/list/data = list(
"locked" = locked, // controls, locked or not
"noaccess" = topic_denied(user), // does the current user have access? admins, silicons etc can still access bots with locked controls
"maintpanel" = open,
"on" = on,
"autopatrol" = auto_patrol,
"painame" = paicard ? paicard.pai.name : null,
"canhack" = canhack(user),
"emagged" = emagged, // this is an int, NOT a boolean
"remote_disabled" = remote_disabled, // -- STUFF BELOW HERE IS SPECIFIC TO THIS BOT
"check_id" = idcheck,
"check_weapons" = weaponscheck,
"check_warrant" = check_records,
"arrest_mode" = arrest_type, // detain or arrest
"arrest_declare" = declare_arrests // announce arrests on radio
)
return data
if(!lasercolor)
dat += text({"<BR>
Arrest Unidentifiable Persons: []<BR>
Arrest for Unauthorized Weapons: []<BR>
Arrest for Warrant: []<BR>
<BR>
Operating Mode: []<BR>
Report Arrests[]<BR>"},
"<A href='?src=[UID()];operation=idcheck'>[idcheck ? "Yes" : "No"]</A>",
"<A href='?src=[UID()];operation=weaponscheck'>[weaponscheck ? "Yes" : "No"]</A>",
"<A href='?src=[UID()];operation=ignorerec'>[check_records ? "Yes" : "No"]</A>",
"<A href='?src=[UID()];operation=switchmode'>[arrest_type ? "Detain" : "Arrest"]</A>",
"<A href='?src=[UID()];operation=declarearrests'>[declare_arrests ? "Yes" : "No"]</A>")
return dat
/mob/living/simple_animal/bot/ed209/Topic(href, href_list)
if(lasercolor && (istype(usr,/mob/living/carbon/human)))
var/mob/living/carbon/human/H = usr
if((lasercolor == "b") && (istype(H.wear_suit, /obj/item/clothing/suit/redtag)))//Opposing team cannot operate it
return
else if((lasercolor == "r") && (istype(H.wear_suit, /obj/item/clothing/suit/bluetag)))
return
if(..())
return 1
switch(href_list["operation"])
if("idcheck")
idcheck = !idcheck
update_controls()
if("weaponscheck")
/mob/living/simple_animal/bot/ed209/tgui_act(action, params)
if (..())
return
if(topic_denied(usr))
to_chat(usr, "<span class='warning'>[src]'s interface is not responding!</span>")
return
add_fingerprint(usr)
. = TRUE
switch(action)
if("power")
if(on)
turn_off()
else
turn_on()
if("autopatrol")
auto_patrol = !auto_patrol
bot_reset()
if("hack")
handle_hacking(usr)
if("disableremote")
remote_disabled = !remote_disabled
if("authweapon")
weaponscheck = !weaponscheck
update_controls()
if("ignorerec")
if("authid")
idcheck = !idcheck
if("authwarrant")
check_records = !check_records
update_controls()
if("switchmode")
if("arrtype")
arrest_type = !arrest_type
update_controls()
if("declarearrests")
if("arrdeclare")
declare_arrests = !declare_arrests
update_controls()
if("ejectpai")
ejectpai()
/mob/living/simple_animal/bot/ed209/topic_denied(mob/user)
if(lasercolor && ishuman(user))
var/mob/living/carbon/human/H = user
if((lasercolor == "b") && (istype(H.wear_suit, /obj/item/clothing/suit/redtag))) //Opposing team cannot operate it
return TRUE
else if((lasercolor == "r") && (istype(H.wear_suit, /obj/item/clothing/suit/bluetag)))
return TRUE
return ..()
/mob/living/simple_animal/bot/ed209/proc/retaliate(mob/living/carbon/human/H)
threatlevel = H.assess_threat(src)
@@ -462,7 +475,6 @@
target = user
mode = BOT_HUNT
/mob/living/simple_animal/bot/ed209/emp_act(severity)
if(severity==2 && prob(70))
@@ -111,61 +111,71 @@
last_found = world.time
/mob/living/simple_animal/bot/secbot/set_custom_texts()
text_hack = "You overload [name]'s target identification system."
text_dehack = "You reboot [name] and restore the target identification."
text_dehack_fail = "[name] refuses to accept your authority!"
/mob/living/simple_animal/bot/secbot/get_controls(mob/user)
var/dat
dat += hack(user)
dat += showpai(user)
dat += text({"
<TT><B>[window_name]</B></TT><BR><BR>
Status: []<BR>
Behaviour controls are [locked ? "locked" : "unlocked"]<BR>
Maintenance panel panel is [open ? "opened" : "closed"]"},
/mob/living/simple_animal/bot/secbot/show_controls(mob/M)
tgui_interact(M)
"<A href='?src=[UID()];power=1'>[on ? "On" : "Off"]</A>" )
/mob/living/simple_animal/bot/secbot/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = TRUE, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "BotSecurity", name, 500, 500)
ui.open()
if(!locked || issilicon(user) || user.can_admin_interact())
dat += text({"<BR>
Arrest Unidentifiable Persons: []<BR>
Arrest for Unauthorized Weapons: []<BR>
Arrest for Warrant: []<BR>
Operating Mode: []<BR>
Report Arrests[]<BR>
Auto Patrol: []"},
/mob/living/simple_animal/bot/secbot/tgui_data(mob/user)
var/list/data = list(
"locked" = locked, // controls, locked or not
"noaccess" = topic_denied(user), // does the current user have access? admins, silicons etc can still access bots with locked controls
"maintpanel" = open,
"on" = on,
"autopatrol" = auto_patrol,
"painame" = paicard ? paicard.pai.name : null,
"canhack" = canhack(user),
"emagged" = emagged, // this is an int, NOT a boolean
"remote_disabled" = remote_disabled, // -- STUFF BELOW HERE IS SPECIFIC TO THIS BOT
"check_id" = idcheck,
"check_weapons" = weaponscheck,
"check_warrant" = check_records,
"arrest_mode" = arrest_type, // detain or arrest
"arrest_declare" = declare_arrests // announce arrests on radio
)
return data
"<A href='?src=[UID()];operation=idcheck'>[idcheck ? "Yes" : "No"]</A>",
"<A href='?src=[UID()];operation=weaponscheck'>[weaponscheck ? "Yes" : "No"]</A>",
"<A href='?src=[UID()];operation=ignorerec'>[check_records ? "Yes" : "No"]</A>",
"<A href='?src=[UID()];operation=switchmode'>[arrest_type ? "Detain" : "Arrest"]</A>",
"<A href='?src=[UID()];operation=declarearrests'>[declare_arrests ? "Yes" : "No"]</A>",
"<A href='?src=[UID()];operation=patrol'>[auto_patrol ? "On" : "Off"]</A>" )
return dat
/mob/living/simple_animal/bot/secbot/Topic(href, href_list)
if(..())
return 1
switch(href_list["operation"])
if("idcheck")
idcheck = !idcheck
update_controls()
if("weaponscheck")
/mob/living/simple_animal/bot/secbot/tgui_act(action, params)
if (..())
return
if(topic_denied(usr))
to_chat(usr, "<span class='warning'>[src]'s interface is not responding!</span>")
return
add_fingerprint(usr)
. = TRUE
switch(action)
if("power")
if(on)
turn_off()
else
turn_on()
if("autopatrol")
auto_patrol = !auto_patrol
bot_reset()
if("hack")
handle_hacking(usr)
if("disableremote")
remote_disabled = !remote_disabled
if("authweapon")
weaponscheck = !weaponscheck
update_controls()
if("ignorerec")
if("authid")
idcheck = !idcheck
if("authwarrant")
check_records = !check_records
update_controls()
if("switchmode")
if("arrtype")
arrest_type = !arrest_type
update_controls()
if("declarearrests")
if("arrdeclare")
declare_arrests = !declare_arrests
update_controls()
if("ejectpai")
ejectpai()
/mob/living/simple_animal/bot/secbot/proc/retaliate(mob/living/carbon/human/H)
threatlevel = H.assess_threat(src)
@@ -47,11 +47,14 @@
..()
update_icon()
/mob/living/simple_animal/bot/ed209/syndicate/get_controls(mob/user)
/mob/living/simple_animal/bot/ed209/syndicate/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = TRUE, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_default_state)
to_chat(user, "<span class='warning'>[src] has no accessible control panel!</span>")
return
/mob/living/simple_animal/bot/ed209/syndicate/show_controls(mob/M)
/mob/living/simple_animal/bot/ed209/syndicate/tgui_data(mob/user)
return
/mob/living/simple_animal/bot/ed209/syndicate/tgui_act(action, params)
return
/mob/living/simple_animal/bot/ed209/syndicate/Topic(href, href_list)