mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-09 16:14:13 +00:00
Law editor for Aurx and friends.
This commit is contained in:
@@ -159,6 +159,60 @@ var/global/const/mommi_base_law_type = /datum/ai_laws/keeper // /datum/ai_laws/a
|
||||
who << "[number]. [law]"
|
||||
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>"
|
||||
|
||||
/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)
|
||||
|
||||
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
|
||||
return 0
|
||||
|
||||
/datum/ai_laws/proc/display_admin_tools(var/mob/living/silicon/context)
|
||||
var/dat=""
|
||||
if (src.zeroth)
|
||||
dat += "<br />0. [adminLink(context,LAW_ZERO,1,zeroth)]"
|
||||
|
||||
for (var/index = 1, index <= src.ion.len, index++)
|
||||
var/law = src.ion[index]
|
||||
var/num = ionnum()
|
||||
dat += "<br />[num]. [adminLink(context,LAW_IONIC,index,law)]"
|
||||
|
||||
var/number = 1
|
||||
for (var/index = 1, index <= src.inherent.len, index++)
|
||||
var/law = src.inherent[index]
|
||||
|
||||
if (length(law) > 0)
|
||||
dat += "<br />[number]. [adminLink(context,LAW_INHERENT,index,law)]"
|
||||
number++
|
||||
|
||||
for (var/index = 1, index <= src.supplied.len, index++)
|
||||
var/law = src.supplied[index]
|
||||
if (length(law) > 0)
|
||||
dat += "<br />[number]. [adminLink(context,1,index,law)]"
|
||||
number++
|
||||
return dat
|
||||
|
||||
// /vg/: Used in the simplified law system. Takes LAW_ constants.
|
||||
/datum/ai_laws/proc/add_law(var/number,var/law)
|
||||
switch(number)
|
||||
@@ -169,4 +223,28 @@ var/global/const/mommi_base_law_type = /datum/ai_laws/keeper // /datum/ai_laws/a
|
||||
if(LAW_INHERENT)
|
||||
add_inherent_law(law)
|
||||
else
|
||||
add_supplied_law(number,law)
|
||||
add_supplied_law(number,law)
|
||||
|
||||
// /vg/: Used in the simplified law system. Takes LAW_ constants.
|
||||
/datum/ai_laws/proc/get_law(var/law_type,var/idx)
|
||||
switch(law_type)
|
||||
if(LAW_IONIC)
|
||||
return ion[idx]
|
||||
if(LAW_ZERO)
|
||||
return zeroth
|
||||
if(LAW_INHERENT)
|
||||
return inherent[idx]
|
||||
else
|
||||
return supplied[idx]
|
||||
|
||||
// /vg/: Used in the simplified law system. Takes LAW_ constants.
|
||||
/datum/ai_laws/proc/set_law(var/law_type,var/idx,var/law)
|
||||
switch(law_type)
|
||||
if(LAW_IONIC)
|
||||
ion[idx]=law
|
||||
if(LAW_ZERO)
|
||||
zeroth=law
|
||||
if(LAW_INHERENT)
|
||||
inherent[idx]=law
|
||||
else
|
||||
inherent[idx]=law
|
||||
@@ -233,3 +233,4 @@
|
||||
else
|
||||
usr << "[src.current.name] selected for law changes."
|
||||
return
|
||||
|
||||
|
||||
@@ -150,6 +150,16 @@ var/global/floorIsLava = 0
|
||||
body+="</td>"
|
||||
body += "</tr></table>"
|
||||
|
||||
// Law Admin Hax
|
||||
if(issilicon(M) && M:laws)
|
||||
body += "<br><br>"
|
||||
body += "<b>Laws:</b><br />"
|
||||
var/datum/ai_laws/L = M:laws
|
||||
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 += "<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>
|
||||
<b>Rudimentary transformation:</b><font size=2><br>These transformations only create a new mob type and copy stuff over. They do not take into account MMIs and similar mob-specific things. The buttons in 'Transformations' are preferred, when possible.</font><br>
|
||||
<A href='?src=\ref[src];simplemake=observer;mob=\ref[M]'>Observer</A> |
|
||||
|
||||
@@ -45,11 +45,60 @@
|
||||
if("10")
|
||||
log_admin("[key_name(usr)] has spawned a death squad.")
|
||||
if(!makeDeathsquad())
|
||||
usr << "\red Unfortunatly there were no candidates available"
|
||||
usr << "\red Unfortunately, there were no candidates available"
|
||||
if("11")
|
||||
log_admin("[key_name(usr)] has spawned vox raiders.")
|
||||
if(!src.makeVoxRaiders())
|
||||
usr << "\red Unfortunately there weren't enough candidates available."
|
||||
usr << "\red Unfortunately, there weren't enough candidates available."
|
||||
|
||||
else if("announce_laws" in href_list)
|
||||
var/mob/living/silicon/S = locate(href_list["mob"])
|
||||
|
||||
log_admin("[key_name(usr)] has notified [key_name(S)] of a change to their laws.")
|
||||
message_admins("[usr.key] has notified [key_name(S)] of a change to their laws.")
|
||||
|
||||
S << "____________________________________"
|
||||
S << "<span style=\"color:red;font-weight:bold;\">LAW CHANGE NOTICE</span>"
|
||||
if(S.laws)
|
||||
S << "<b>Your new laws are as follows:</b>"
|
||||
S.laws.show_laws(S)
|
||||
else
|
||||
S << "<b>Your laws are null.</b> Contact a coder immediately."
|
||||
S << "____________________________________"
|
||||
|
||||
else if("add_law" in href_list)
|
||||
var/mob/living/silicon/S = locate(href_list["mob"])
|
||||
var/lawtypes = list(
|
||||
"Law Zero"= LAW_ZERO,
|
||||
"Ion" = LAW_IONIC,
|
||||
"Core" = LAW_INHERENT,
|
||||
"Standard"= 1
|
||||
)
|
||||
var/lawtype = text2num(input("Select a law type.","Law Type",1) as null|anything in lawtypes)
|
||||
if(lawtype==1)
|
||||
lawtype=text2num(input("Enter desired law priority. (15-50)","Priority", 15) as num)
|
||||
lawtype=Clamp(lawtype,15,50)
|
||||
var/newlaw = copytext(sanitize(input(usr, "Please enter a new law for the AI.", "Freeform Law Entry", "")),1,MAX_MESSAGE_LEN)
|
||||
if(newlaw=="")
|
||||
return
|
||||
S.laws.add_law(lawtype,newlaw)
|
||||
|
||||
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("clear_laws" in href_list)
|
||||
var/mob/living/silicon/S = locate(href_list["mob"])
|
||||
S.laws.clear_inherent_laws()
|
||||
S.laws.clear_supplied_laws()
|
||||
S.laws.clear_ion_laws()
|
||||
|
||||
if(S.laws.zeroth || S.laws.zeroth_borg)
|
||||
if(alert(src,"Do you also wish to clear law zero?","Yes","No") == "Yes")
|
||||
S.laws.set_zeroth_law("","")
|
||||
|
||||
log_admin("[key_name(usr)] has purged [key_name(S)]")
|
||||
message_admins("[usr.key] has purged [key_name(S)]")
|
||||
|
||||
else if(href_list["dbsearchckey"] || href_list["dbsearchadmin"])
|
||||
var/adminckey = href_list["dbsearchadmin"]
|
||||
var/playerckey = href_list["dbsearchckey"]
|
||||
|
||||
Reference in New Issue
Block a user