mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
Admin law panel fixes and enhancements
This resolves some deficiencies in the PP law toolkit for silicons. - Added remove button for each law (tested) - Removed buggy blank law behavior. Blank laws are now ignored. - Added button to reset lawset to a standard one (e.g. asimov) (tested) - Cyborgs slaved to AI are notified of law change when Send Laws is used, and are also forced to sync. - Law changes refresh PP.
This commit is contained in:
@@ -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,18 +92,43 @@ 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 "<a href=\"?src=\ref[src];set_law=[law_type];index=[index];mob=\ref[S]\">[label]</a>"
|
||||
return "<a href=\"?src=\ref[src];set_law=[law_type];index=[index];mob=\ref[S]\">[label]</a> (<a href=\"?src=\ref[src];rm_law=[law_type];index=[index];mob=\ref[S]\" style=\"color:red\">Remove</a>)"
|
||||
|
||||
/datum/ai_laws/Topic(href,href_list)
|
||||
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/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)
|
||||
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")
|
||||
if(newlaw == "" || newlaw==null)
|
||||
return
|
||||
set_law(lawtype,index,newlaw)
|
||||
|
||||
@@ -116,6 +142,9 @@ var/global/mommi_base_law_type = /datum/ai_laws/keeper // Asimov is OP as fuck o
|
||||
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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -164,6 +164,7 @@ var/global/floorIsLava = 0
|
||||
body += L.display_admin_tools(M)
|
||||
body += "<br /><a href='?src=\ref[src];mob=\ref[M];add_law=1'>Add Law</a>"
|
||||
body += " | <a href='?src=\ref[src];mob=\ref[M];clear_laws=1'>Clear Laws</a>"
|
||||
body += " | <a href='?src=\ref[src];mob=\ref[M];reset_laws=1'>Reset Lawset</a>"
|
||||
body += "<br /><a href='?src=\ref[src];mob=\ref[M];announce_laws=1'><b>Send Laws</b></a> - User is not notified of changes until this button pushed!<br />"
|
||||
|
||||
body += {"<br><br>
|
||||
|
||||
@@ -65,6 +65,9 @@
|
||||
else
|
||||
S << "<b>Your laws are null.</b> 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()
|
||||
|
||||
@@ -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 << "<span class='danger'>...LAWS UPDATED</span>"
|
||||
|
||||
/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 = "<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
|
||||
@@ -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 += {"<A href='byond://?src=\ref[src];lawi=[index]'>[src.ioncheck[index]] [ionnum()]:</A> [law]<BR>"}
|
||||
|
||||
Reference in New Issue
Block a user