diff --git a/code/datums/ai_laws.dm b/code/datums/ai_laws.dm index 5ec9ce8aeb5..bfa4c348e87 100644 --- a/code/datums/ai_laws.dm +++ b/code/datums/ai_laws.dm @@ -26,8 +26,9 @@ var/global/mommi_base_law_type = /datum/ai_laws/keeper // Asimov is OP as fuck o /datum/ai_laws var/name = "Unknown Laws" var/randomly_selectable = 0 + // Zeroth laws var/zeroth = null - var/zeroth_borg = null + var/zeroth_borg = null // wotm8 var/list/inherent = list() var/list/supplied = list() var/list/ion = list() @@ -91,32 +92,60 @@ var/global/mommi_base_law_type = /datum/ai_laws/keeper // Asimov is OP as fuck o number++ /datum/ai_laws/proc/adminLink(var/mob/living/silicon/S,var/law_type,var/index,var/label) - return "[label]" + return "[label] (Remove)" /datum/ai_laws/Topic(href,href_list) - if("set_law" in href_list) - if(usr.client && usr.client.holder) - var/lawtype=text2num(href_list["set_law"]) - var/index=text2num(href_list["index"]) - var/mob/living/silicon/S=locate(href_list["mob"]) - var/oldlaw = get_law(lawtype,index) - var/newlaw = copytext(sanitize(input(usr, "Please enter a new law.", "Freeform Law Entry", oldlaw)),1,MAX_MESSAGE_LEN) - if(newlaw == "") - if(alert(src,"Are you sure you wish to delete this law?","Yes","No") == "No") - return - set_law(lawtype,index,newlaw) + if(!usr.client || !usr.client.holder) + return + if("rm_law" in href_list) + var/lawtype = text2num(href_list["rm_law"]) + var/index=text2num(href_list["index"]) + var/mob/living/silicon/S=locate(href_list["mob"]) - var/lawtype_str="law #[index]" - switch(lawtype) - if(LAW_ZERO) - lawtype_str = "law zero" - if(LAW_IONIC) - lawtype_str = "ionic law #[index]" - if(LAW_INHERENT) - lawtype_str = "core law #[index]" - log_admin("[key_name(usr)] has changed [lawtype_str] on [key_name(S)]: \"[newlaw]\"") - message_admins("[usr.key] changed [lawtype_str] on [key_name(S)]: \"[newlaw]\"") - return 1 + + var/oldlaw = get_law(lawtype,index) + + rm_law(lawtype,index) + + var/lawtype_str="law #[index]" + switch(lawtype) + if(LAW_ZERO) + lawtype_str = "law zero" + if(LAW_IONIC) + lawtype_str = "ionic law #[index]" + if(LAW_INHERENT) + lawtype_str = "core law #[index]" + log_admin("[key_name(usr)] has removed [lawtype_str] on [key_name(S)]: \"[oldlaw]\"") + message_admins("[usr.key] removed [lawtype_str] on [key_name(S)]: \"[oldlaw]\"") + + usr.client.holder.show_player_panel(S) + + return 1 + + if("set_law" in href_list) + var/lawtype=text2num(href_list["set_law"]) + var/index=text2num(href_list["index"]) + var/mob/living/silicon/S=locate(href_list["mob"]) + var/oldlaw = get_law(lawtype,index) + var/newlaw = copytext(sanitize(input(usr, "Please enter a new law.", "Freeform Law Entry", oldlaw)),1,MAX_MESSAGE_LEN) + if(newlaw == "" || newlaw==null) + return + set_law(lawtype,index,newlaw) + + var/lawtype_str="law #[index]" + switch(lawtype) + if(LAW_ZERO) + lawtype_str = "law zero" + if(LAW_IONIC) + lawtype_str = "ionic law #[index]" + if(LAW_INHERENT) + lawtype_str = "core law #[index]" + log_admin("[key_name(usr)] has changed [lawtype_str] on [key_name(S)]: \"[newlaw]\"") + message_admins("[usr.key] changed [lawtype_str] on [key_name(S)]: \"[newlaw]\"") + + usr.client.holder.show_player_panel(S) + + return 1 return 0 /datum/ai_laws/proc/display_admin_tools(var/mob/living/silicon/context) @@ -180,7 +209,17 @@ var/global/mommi_base_law_type = /datum/ai_laws/keeper // Asimov is OP as fuck o else supplied[idx]=law - +// /vg/: Used in the simplified law system. Takes LAW_ constants. +/datum/ai_laws/proc/rm_law(var/law_type,var/idx) + switch(law_type) + if(LAW_IONIC) + ion.Cut(idx,idx+1) + if(LAW_ZERO) + zeroth=null + if(LAW_INHERENT) + inherent.Cut(idx,idx+1) + else + supplied.Cut(idx,idx+1) // Now a modifier /datum/ai_laws/proc/malfunction() diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index bb776ef9478..32dbb346267 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -164,6 +164,7 @@ var/global/floorIsLava = 0 body += L.display_admin_tools(M) body += "
Add Law" body += " | Clear Laws" + body += " | Reset Lawset" body += "
Send Laws - User is not notified of changes until this button pushed!
" body += {"

diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index b1ea872b6e6..df2a8f8c0dd 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -65,6 +65,9 @@ else S << "Your laws are null. Contact a coder immediately." S << "____________________________________" + if(isAI(S)) + var/mob/living/silicon/ai/AI=S + AI.notify_slaved(force_sync=1) else if("add_law" in href_list) var/mob/living/silicon/S = locate(href_list["mob"]) @@ -90,6 +93,28 @@ log_admin("[key_name(usr)] has added a law to [key_name(S)]: \"[newlaw]\"") message_admins("[usr.key] has added a law to [key_name(S)]: \"[newlaw]\"") + else if("reset_laws" in href_list) + var/mob/living/silicon/S = locate(href_list["mob"]) + var/lawtypes = typesof(/datum/ai_laws) - /datum/ai_laws + var/lawtype = input("Select a lawset.","Law Type",1) as null|anything in lawtypes + if(lawtype == null) + return + testing("Lawtype: [lawtype]") + + var/law_zeroth=null + var/law_zeroth_borg=null + if(S.laws.zeroth || S.laws.zeroth_borg) + if(alert(src,"Do you also wish to clear law zero?","Yes","No") == "No") + law_zeroth=S.laws.zeroth + law_zeroth_borg=S.laws.zeroth + + S.laws = new lawtype + S.laws.zeroth=law_zeroth + S.laws.zeroth_borg=law_zeroth_borg + + log_admin("[key_name(usr)] has reset [key_name(S)]: [lawtype]") + message_admins("[usr.key] has reset [key_name(S)]: [lawtype]") + else if("clear_laws" in href_list) var/mob/living/silicon/S = locate(href_list["mob"]) S.laws.clear_inherent_laws() diff --git a/code/modules/mob/living/silicon/ai/laws.dm b/code/modules/mob/living/silicon/ai/laws.dm index 7c072fd1280..32674025add 100755 --- a/code/modules/mob/living/silicon/ai/laws.dm +++ b/code/modules/mob/living/silicon/ai/laws.dm @@ -35,9 +35,14 @@ /mob/living/silicon/ai/proc/add_ion_law(var/law) src.laws_sanity_check() src.laws.add_ion_law(law) + notify_slaved() + +/mob/living/silicon/ai/proc/notify_slaved(var/force_sync=0) for(var/mob/living/silicon/robot/R in mob_list) + if(force_sync) + R.lawsync() if(R.lawupdate && (R.connected_ai == src)) - R << "\red " + law + "\red...LAWS UPDATED" + R << "...LAWS UPDATED" /mob/living/silicon/ai/proc/clear_ion_laws() src.laws_sanity_check() @@ -58,8 +63,6 @@ var/number = 1 sleep(10) - - if (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 src.say("0. [src.laws.zeroth]") @@ -82,7 +85,6 @@ sleep(10) number++ - for (var/index = 1, index <= src.laws.supplied.len, index++) var/law = src.laws.supplied[index] @@ -97,8 +99,6 @@ var/list = "Which laws do you want to include when stating them for the crew?

" - - 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 @@ -106,10 +106,7 @@ 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 += {"[src.ioncheck[index]] [ionnum()]: [law]
"}