Merge pull request #8486 from PsiOmegaDelta/NanoLaws

NanoUI - Silicon law manager
This commit is contained in:
Chinsky
2015-03-17 14:24:30 +03:00
29 changed files with 961 additions and 474 deletions
+2 -19
View File
@@ -80,10 +80,12 @@ var/list/ai_verbs_default = list(
/mob/living/silicon/ai/proc/add_ai_verbs()
src.verbs |= ai_verbs_default
src.verbs |= ai_verbs_subsystems
src.verbs |= silicon_verbs_subsystems
/mob/living/silicon/ai/proc/remove_ai_verbs()
src.verbs -= ai_verbs_default
src.verbs -= ai_verbs_subsystems
src.verbs -= silicon_verbs_subsystems
/mob/living/silicon/ai/New(loc, var/datum/ai_laws/L, var/obj/item/device/mmi/B, var/safety = 0)
announcement = new()
@@ -428,25 +430,6 @@ var/list/ai_verbs_default = list(
else
src << "<span class='notice'>Unable to locate the holopad.</span>"
if (href_list["lawc"]) // Toggling whether or not a law gets stated by the State Laws verb --NeoFite
var/L = text2num(href_list["lawc"])
switch(lawcheck[L+1])
if ("Yes") lawcheck[L+1] = "No"
if ("No") lawcheck[L+1] = "Yes"
// src << text ("Switching Law [L]'s report status to []", lawcheck[L+1])
checklaws()
if (href_list["lawi"]) // Toggling whether or not a law gets stated by the State Laws verb --NeoFite
var/L = text2num(href_list["lawi"])
switch(ioncheck[L])
if ("Yes") ioncheck[L] = "No"
if ("No") ioncheck[L] = "Yes"
// src << text ("Switching Law [L]'s report status to []", lawcheck[L+1])
checklaws()
if (href_list["laws"]) // With how my law selection code works, I changed statelaws from a verb to a proc, and call it through my law selection panel. --NeoFite
statelaws()
if (href_list["track"])
var/mob/target = locate(href_list["track"]) in mob_list
+12 -3
View File
@@ -1,7 +1,7 @@
/mob/living/silicon/ai/examine(mob/user)
if(!..(user))
return
var/msg = ""
if (src.stat == DEAD)
msg += "<span class='deadsay'>It appears to be powered-down.</span>\n"
@@ -23,5 +23,14 @@
msg += "</span>"
msg += "*---------*</span>"
usr << msg
return
user << msg
user.showLaws(src)
return
/mob/proc/showLaws(var/mob/living/silicon/S)
return
/mob/dead/observer/showLaws(var/mob/living/silicon/S)
if(antagHUD || is_admin(src))
S.laws.show_laws(src)
+2 -2
View File
@@ -15,7 +15,7 @@
src.laws_sanity_check()
src.laws.show_laws(who)
/mob/living/silicon/ai/proc/add_ion_law(var/law)
/mob/living/silicon/ai/add_ion_law(var/law)
src.laws_sanity_check()
src.laws.add_ion_law(law)
for(var/mob/living/silicon/robot/R in mob_list)
@@ -25,4 +25,4 @@
/mob/living/silicon/ai/proc/ai_checklaws()
set category = "AI Commands"
set name = "State Laws"
checklaws()
subsystem_law_manager()
@@ -1,12 +1,10 @@
var/list/ai_verbs_subsystems = list(
/mob/living/silicon/ai/proc/subsystem_alarm_monitor,
/mob/living/silicon/ai/proc/subsystem_crew_monitor,
/mob/living/silicon/ai/proc/subsystem_power_monitor,
/mob/living/silicon/ai/proc/subsystem_rcon
)
/mob/living/silicon/ai
var/
var/list/ai_verbs_subsystems = list(
/mob/living/silicon/ai/proc/subsystem_crew_monitor,
/mob/living/silicon/ai/proc/subsystem_power_monitor,
/mob/living/silicon/ai/proc/subsystem_rcon
)
var/obj/nano_module/crew_monitor/crew_monitor
var/obj/nano_module/rcon/rcon
var/obj/nano_module/power_monitor/power_monitor
@@ -19,26 +17,20 @@ var/list/ai_verbs_subsystems = list(
rcon = new(src)
power_monitor = new(src)
/mob/living/silicon/ai/proc/subsystem_alarm_monitor()
set name = "Alarm Monitor"
set category = "AI Subystems"
alarm_monitor.ui_interact(usr)
/mob/living/silicon/ai/proc/subsystem_crew_monitor()
set category = "AI Subystems"
set category = "Subystems"
set name = "Crew Monitor"
crew_monitor.ui_interact(usr)
/mob/living/silicon/ai/proc/subsystem_power_monitor()
set category = "AI Subystems"
set category = "Subystems"
set name = "Power Monitor"
power_monitor.ui_interact(usr)
/mob/living/silicon/ai/proc/subsystem_rcon()
set category = "AI Subystems"
set category = "Subystems"
set name = "RCON"
rcon.ui_interact(usr)
+25 -77
View File
@@ -1,22 +1,30 @@
/mob/living/silicon
var/datum/ai_laws/laws = null
var/list/additional_law_channels = list("State")
/mob/living/silicon/proc/laws_sanity_check()
if (!src.laws)
laws = new base_law_type
/mob/living/silicon/proc/has_zeroth_law()
return laws.zeroth
return laws.zeroth_law != null
/mob/living/silicon/proc/set_zeroth_law(var/law, var/law_borg)
laws_sanity_check()
laws.set_zeroth_law(law, law_borg)
/mob/living/silicon/robot/set_zeroth_law(var/law, var/law_borg)
..()
if(tracking_entities)
src << "<span class='warning'>Internal camera is currently being accessed.</span>"
/mob/living/silicon/proc/add_inherent_law(var/law)
/mob/living/silicon/proc/add_ion_law(var/law)
laws_sanity_check()
laws.add_inherent_law(law)
laws.add_ion_law(law)
/mob/living/silicon/proc/add_inherent_law(var/law, var/state_law = 1)
laws_sanity_check()
laws.add_inherent_law(law, state_law)
/mob/living/silicon/proc/clear_inherent_laws()
laws_sanity_check()
@@ -26,15 +34,15 @@
laws_sanity_check()
laws.clear_ion_laws()
/mob/living/silicon/proc/add_supplied_law(var/number, var/law)
/mob/living/silicon/proc/add_supplied_law(var/number, var/law, var/state_law = 1)
laws_sanity_check()
laws.add_supplied_law(number, law)
laws.add_supplied_law(number, law, state_law)
/mob/living/silicon/proc/clear_supplied_laws()
laws_sanity_check()
laws.clear_supplied_laws()
/mob/living/silicon/proc/statelaws() // -- TLE
/mob/living/silicon/proc/statelaws(var/datum/ai_laws/laws, var/use_statement_order = 1) // -- TLE
var/prefix = ""
switch(lawchannel)
if(MAIN_CHANNEL) prefix = ";"
@@ -42,9 +50,9 @@
else
prefix = get_radio_key_from_channel(lawchannel == "Holopad" ? "department" : lawchannel) + " "
dostatelaws(lawchannel, prefix)
dostatelaws(lawchannel, prefix, laws, use_statement_order)
/mob/living/silicon/proc/dostatelaws(var/method, var/prefix)
/mob/living/silicon/proc/dostatelaws(var/method, var/prefix, var/datum/ai_laws/laws, var/use_statement_order)
if(stating_laws[prefix])
src << "<span class='notice'>[method]: Already stating laws using this communication method.</span>"
return
@@ -53,34 +61,8 @@
var/can_state = statelaw("[prefix]Current Active Laws:")
//src.laws_sanity_check()
//src.laws.show_laws(world)
if (can_state && src.laws.zeroth)
if (src.lawcheck[1] == "Yes") //This line and the similar lines below make sure you don't state a law unless you want to. --NeoFite
can_state = statelaw("[prefix]0. [src.laws.zeroth]")
for (var/index = 1, can_state && index <= src.laws.ion.len, index++)
var/law = src.laws.ion[index]
var/num = ionnum()
if (length(law) > 0)
if (src.ioncheck[index] == "Yes")
can_state = statelaw("[prefix][num]. [law]")
var/number = 1
for (var/index = 1, can_state && index <= src.laws.inherent.len, index++)
var/law = src.laws.inherent[index]
if (length(law) > 0)
if (src.lawcheck[index+1] == "Yes")
can_state = statelaw("[prefix][number]. [law]")
number++
for (var/index = 1, can_state && index <= src.laws.supplied.len, index++)
var/law = src.laws.supplied[index]
if (length(law) > 0)
if(src.lawcheck.len >= number+1)
if (src.lawcheck[number+1] == "Yes")
can_state = statelaw("[prefix][number]. [law]")
number++
for(var/datum/ai_law/law in laws.laws_to_state())
can_state = statelaw("[prefix][law.get_index(use_statement_order)]. [law.law]")
if(!can_state)
src << "<span class='danger'>[method]: Unable to state laws. Communication method unavailable.</span>"
@@ -93,43 +75,9 @@
return 0
/mob/living/silicon/proc/checklaws() //Gives you a link-driven interface for deciding what laws the statelaws() proc will share with the crew. --NeoFite
var/list = "<b>Which laws do you want to include when stating them for the crew?</b><br><br>"
if (src.laws.zeroth)
if (!src.lawcheck[1])
src.lawcheck[1] = "No" //Given Law 0's usual nature, it defaults to NOT getting reported. --NeoFite
list += {"<A href='byond://?src=\ref[src];lawc=0'>[src.lawcheck[1]] 0:</A> [src.laws.zeroth]<BR>"}
for (var/index = 1, index <= src.laws.ion.len, index++)
var/law = src.laws.ion[index]
if (length(law) > 0)
if (!src.ioncheck[index])
src.ioncheck[index] = "Yes"
list += {"<A href='byond://?src=\ref[src];lawi=[index]'>[src.ioncheck[index]] [ionnum()]:</A> [law]<BR>"}
src.ioncheck.len += 1
var/number = 1
for (var/index = 1, index <= src.laws.inherent.len, index++)
var/law = src.laws.inherent[index]
if (length(law) > 0)
src.lawcheck.len += 1
if (!src.lawcheck[number+1])
src.lawcheck[number+1] = "Yes"
list += {"<A href='byond://?src=\ref[src];lawc=[number]'>[src.lawcheck[number+1]] [number]:</A> [law]<BR>"}
number++
for (var/index = 1, index <= src.laws.supplied.len, index++)
var/law = src.laws.supplied[index]
if (length(law) > 0)
src.lawcheck.len += 1
if (!src.lawcheck[number+1])
src.lawcheck[number+1] = "Yes"
list += {"<A href='byond://?src=\ref[src];lawc=[number]'>[src.lawcheck[number+1]] [number]:</A> [law]<BR>"}
number++
list += {"<br><A href='byond://?src=\ref[src];lawr=1'>Channel: [src.lawchannel]</A><br>"}
list += {"<A href='byond://?src=\ref[src];laws=1'>State Laws</A>"}
usr << browse(list, "window=laws")
/mob/living/silicon/proc/law_channels()
var/list/channels = new()
channels += MAIN_CHANNEL
channels += common_radio.channels
channels += additional_law_channels
return channels
@@ -285,7 +285,7 @@
return
/mob/living/silicon/robot/drone/add_robot_verbs()
src.verbs |= robot_verbs_subsystems
src.verbs |= silicon_verbs_subsystems
/mob/living/silicon/robot/drone/remove_robot_verbs()
src.verbs -= robot_verbs_subsystems
src.verbs -= silicon_verbs_subsystems
@@ -39,4 +39,5 @@
msg += "\nIt is [pose]"
user << msg
user.showLaws(src)
return
+3 -31
View File
@@ -41,39 +41,11 @@
/mob/living/silicon/robot/proc/lawsync()
laws_sanity_check()
var/datum/ai_laws/master = connected_ai ? connected_ai.laws : null
var/temp
if (master)
laws.ion.len = master.ion.len
for (var/index = 1, index <= master.ion.len, index++)
temp = master.ion[index]
if (length(temp) > 0)
laws.ion[index] = temp
if (!is_special_character(src) || mind.original != src)
if(master.zeroth_borg) //If the AI has a defined law zero specifically for its borgs, give it that one, otherwise give it the same one. --NEO
temp = master.zeroth_borg
else
temp = master.zeroth
laws.zeroth = temp
laws.inherent.len = master.inherent.len
for (var/index = 1, index <= master.inherent.len, index++)
temp = master.inherent[index]
if (length(temp) > 0)
laws.inherent[index] = temp
laws.supplied.len = master.supplied.len
for (var/index = 1, index <= master.supplied.len, index++)
temp = master.supplied[index]
if (length(temp) > 0)
laws.supplied[index] = temp
master.sync(src)
return
/mob/living/silicon/robot/proc/add_ion_law(var/law)
laws_sanity_check()
laws.add_ion_law(law)
/mob/living/silicon/robot/proc/robot_checklaws() //Gives you a link-driven interface for deciding what laws the statelaws() proc will share with the crew. --NeoFite
/mob/living/silicon/robot/proc/robot_checklaws()
set category = "Robot Commands"
set name = "State Laws"
checklaws()
subsystem_law_manager()
+7 -29
View File
@@ -1,8 +1,3 @@
var/list/robot_verbs_default = list(
/mob/living/silicon/robot/proc/sensor_mode,
/mob/living/silicon/robot/proc/robot_checklaws
)
#define CYBORG_POWER_USAGE_MULTIPLIER 2.5 // Multiplier for amount of power cyborgs use.
/mob/living/silicon/robot
@@ -84,6 +79,11 @@ var/list/robot_verbs_default = list(
var/tracking_entities = 0 //The number of known entities currently accessing the internal camera
var/braintype = "Cyborg"
var/list/robot_verbs_default = list(
/mob/living/silicon/robot/proc/sensor_mode,
/mob/living/silicon/robot/proc/robot_checklaws
)
/mob/living/silicon/robot/syndicate
lawupdate = 0
scrambledcodes = 1
@@ -1063,28 +1063,6 @@ var/list/robot_verbs_default = list(
src << "Module isn't activated"
installed_modules()
return 1
if (href_list["lawc"]) // Toggling whether or not a law gets stated by the State Laws verb --NeoFite
var/L = text2num(href_list["lawc"])
switch(lawcheck[L+1])
if ("Yes") lawcheck[L+1] = "No"
if ("No") lawcheck[L+1] = "Yes"
// src << text ("Switching Law [L]'s report status to []", lawcheck[L+1])
checklaws()
return 1
if (href_list["lawi"]) // Toggling whether or not a law gets stated by the State Laws verb --NeoFite
var/L = text2num(href_list["lawi"])
switch(ioncheck[L])
if ("Yes") ioncheck[L] = "No"
if ("No") ioncheck[L] = "Yes"
// src << text ("Switching Law [L]'s report status to []", lawcheck[L+1])
checklaws()
return 1
if (href_list["laws"]) // With how my law selection code works, I changed statelaws from a verb to a proc, and call it through my law selection panel. --NeoFite
statelaws()
return 1
return
/mob/living/silicon/robot/proc/radio_menu()
@@ -1215,11 +1193,11 @@ var/list/robot_verbs_default = list(
/mob/living/silicon/robot/proc/add_robot_verbs()
src.verbs |= robot_verbs_default
src.verbs |= robot_verbs_subsystems
src.verbs |= silicon_verbs_subsystems
/mob/living/silicon/robot/proc/remove_robot_verbs()
src.verbs -= robot_verbs_default
src.verbs -= robot_verbs_subsystems
src.verbs -= silicon_verbs_subsystems
// Uses power from cyborg's cell. Returns 1 on success or 0 on failure.
// Properly converts using CELLRATE now! Amount is in Joules.
@@ -1,9 +0,0 @@
var/list/robot_verbs_subsystems = list(
/mob/living/silicon/robot/proc/subsystem_alarm_monitor
)
/mob/living/silicon/robot/proc/subsystem_alarm_monitor()
set name = "Alarm Monitor"
set category = "Robot Subystems"
alarm_monitor.ui_interact(usr)
+4 -31
View File
@@ -2,13 +2,9 @@
gender = NEUTER
voice_name = "synthesized voice"
var/syndicate = 0
var/datum/ai_laws/laws = null//Now... THEY ALL CAN ALL HAVE LAWS
var/list/additional_law_channels = list("State")
var/const/MAIN_CHANNEL = "Main Frequency"
var/lawchannel = MAIN_CHANNEL // Default channel on which to state laws
var/list/stating_laws = list()// Channels laws are currently being stated on
var/lawcheck[1]
var/ioncheck[1]
var/obj/item/device/radio/common_radio
var/list/hud_list[10]
@@ -22,9 +18,6 @@
var/obj/item/device/camera/siliconcam/aiCamera = null //photography
var/local_transmit //If set, can only speak to others of the same type within a short range.
// Subsystems
var/obj/nano_module/alarm_monitor = null
var/sensor_mode = 0 //Determines the current HUD.
var/next_alarm_notice
@@ -169,13 +162,12 @@
// This adds the basic clock, shuttle recall timer, and malf_ai info to all silicon lifeforms
/mob/living/silicon/Stat()
..()
statpanel("Status")
if (src.client.statpanel == "Status")
if(statpanel("Status"))
show_station_time()
show_emergency_shuttle_eta()
show_system_integrity()
show_malf_ai()
..()
// this function displays the stations manifest in a separate window
/mob/living/silicon/proc/show_station_manifest()
@@ -255,27 +247,6 @@
/mob/living/silicon/binarycheck()
return 1
/mob/living/silicon/Topic(href, href_list)
if(..())
return 1
if (href_list["lawr"]) // Selects on which channel to state laws
var/list/channels = list(MAIN_CHANNEL)
if(common_radio)
for (var/ch_name in common_radio.channels)
channels += ch_name
channels += additional_law_channels
channels += "Cancel"
var/setchannel = input(usr, "Specify channel.", "Channel selection") in channels
if(setchannel != "Cancel")
lawchannel = setchannel
checklaws()
return 1
return 0
/mob/living/silicon/ex_act(severity)
if(!blinded)
flick("flash", flash)
@@ -299,6 +270,8 @@
/mob/living/silicon/proc/init_subsystems()
alarm_monitor = new/obj/nano_module/alarm_monitor/borg(src)
law_manager = new/obj/nano_module/law_manager(src)
for(var/datum/alarm_handler/AH in alarm_manager.all_handlers)
AH.register(src, /mob/living/silicon/proc/receive_alarm)
queued_alarms[AH] = list() // Makes sure alarms remain listed in consistent order
@@ -0,0 +1,26 @@
/mob/living/silicon
var/list/silicon_verbs_subsystems = list(
/mob/living/silicon/proc/subsystem_alarm_monitor,
/mob/living/silicon/proc/subsystem_law_manager
)
// Subsystems
var/obj/nano_module/alarm_monitor = null
var/obj/nano_module/law_manager = null
/mob/living/silicon/robot/syndicate
silicon_verbs_subsystems = list(
/mob/living/silicon/proc/subsystem_law_manager
)
/mob/living/silicon/proc/subsystem_alarm_monitor()
set name = "Alarm Monitor"
set category = "Subystems"
alarm_monitor.ui_interact(usr)
/mob/living/silicon/proc/subsystem_law_manager()
set name = "Law Manager"
set category = "Subystems"
law_manager.ui_interact(usr)
+17 -7
View File
@@ -75,23 +75,28 @@
return 1
return 0
/proc/isAI(A)
if(istype(A, /mob/living/silicon/ai))
return 1
return 0
/mob/proc/isSilicon()
return 0
/mob/living/silicon/isSilicon()
return 1
/proc/isAI(A)
if(istype(A, /mob/living/silicon/ai))
return 1
return 0
/mob/proc/isAI()
return 0
/mob/living/silicon/ai/isAI()
return 1
/mob/proc/isRobot()
return 0
/mob/living/silicon/robot/isRobot()
return 1
/proc/ispAI(A)
if(istype(A, /mob/living/silicon/pai))
return 1
@@ -149,7 +154,7 @@ proc/hassensorlevel(A, var/level)
var/obj/item/clothing/under/U = H.w_uniform
return U.sensor_mode >= level
return 0
proc/getsensorlevel(A)
var/mob/living/carbon/human/H = A
if(istype(H) && istype(H.w_uniform, /obj/item/clothing/under))
@@ -157,6 +162,11 @@ proc/getsensorlevel(A)
return U.sensor_mode
return SUIT_SENSOR_OFF
/proc/is_admin(var/mob/user)
return check_rights(R_ADMIN, 0, user) != 0
/proc/hsl2rgb(h, s, l)
return //TODO: Implement