re-do the whole goddamn thing.

This commit is contained in:
SandPoot
2023-10-20 17:48:13 -03:00
parent 73e33a788e
commit 3aa3aead3d
13 changed files with 78 additions and 77 deletions

View File

@@ -0,0 +1,13 @@
/proc/setup_silicon_law_prefs(mob/living/silicon/Silicon, client/player_client)
if(!player_client.prefs.silicon_lawset)
return
var/list/config_laws = CONFIG_GET(keyed_list/choosable_laws)
var/player_lawset = config_laws[player_client.prefs.silicon_lawset]
if(player_lawset)
Silicon.laws = new player_lawset
var/admin_warning = "[player_client] / [Silicon] ([initial(Silicon.name)]) has joined with the [player_client.prefs.silicon_lawset] ([player_lawset]) lawset.<br>"
admin_warning += "Laws:<br>"
admin_warning += english_list(Silicon.laws.get_law_list(TRUE), "No laws", "<br>", "<br>")
Silicon.laws.show_laws(player_client)
message_admins(examine_block(admin_warning))

View File

@@ -2,6 +2,7 @@
#define VALUE_MODE_TEXT 1 #define VALUE_MODE_TEXT 1
#define VALUE_MODE_FLAG 2 #define VALUE_MODE_FLAG 2
#define VALUE_MODE_NUM_LIST 3 #define VALUE_MODE_NUM_LIST 3
#define VALUE_MODE_TYPE 4
#define KEY_MODE_TEXT 0 #define KEY_MODE_TEXT 0
#define KEY_MODE_TYPE 1 #define KEY_MODE_TYPE 1
@@ -214,7 +215,7 @@
if(lowercase_key) if(lowercase_key)
key_name = lowertext(key_name) key_name = lowertext(key_name)
if(key_pos) if(key_pos)
key_value = copytext(str_val, key_pos + length(str_val[key_pos])) key_value = copytext(str_val, key_pos + length(splitter))
var/new_key var/new_key
var/new_value var/new_value
var/continue_check_value var/continue_check_value
@@ -250,6 +251,11 @@
new_list += temp new_list += temp
new_value = new_list new_value = new_list
continue_check_value = new_list.len continue_check_value = new_list.len
if(VALUE_MODE_TYPE)
new_value = key_value
if(!ispath(new_value))
new_value = text2path(new_value)
continue_check_value = ispath(new_value)
if(continue_check_value && continue_check_key && ValidateListEntry(new_key, new_value)) if(continue_check_value && continue_check_key && ValidateListEntry(new_key, new_value))
new_key = preprocess_key(new_key) new_key = preprocess_key(new_key)
new_value = preprocess_value(new_value) new_value = preprocess_value(new_value)

View File

@@ -410,10 +410,9 @@
/datum/ai_laws/proc/clear_hacked_laws() /datum/ai_laws/proc/clear_hacked_laws()
hacked = list() hacked = list()
/datum/ai_laws/proc/show_laws(who) /datum/ai_laws/proc/show_laws(who, title = "<b>Obey these laws:</b>")
var/list/printable_laws = get_law_list(include_zeroth = TRUE) var/list/printable_laws = get_law_list(include_zeroth = TRUE)
for(var/law in printable_laws) to_chat(who, examine_block("<center>[title]</center><br>[english_list(printable_laws, "No laws", "<br>", "<br>")]"))
to_chat(who,law)
/datum/ai_laws/proc/clear_zeroth_law(force) //only removes zeroth from antag ai if force is 1 /datum/ai_laws/proc/clear_zeroth_law(force) //only removes zeroth from antag ai if force is 1
if(force) if(force)

View File

@@ -466,37 +466,21 @@ GLOBAL_LIST_EMPTY(preferences_datums)
dat += "<a href='?_src_=prefs;preference=ai_core_icon;task=input'><b>Preferred AI Core Display:</b> [preferred_ai_core_display]</a><br>" dat += "<a href='?_src_=prefs;preference=ai_core_icon;task=input'><b>Preferred AI Core Display:</b> [preferred_ai_core_display]</a><br>"
dat += "<a href='?_src_=prefs;preference=sec_dept;task=input'><b>Preferred Security Department:</b> [prefered_security_department]</a><BR>" dat += "<a href='?_src_=prefs;preference=sec_dept;task=input'><b>Preferred Security Department:</b> [prefered_security_department]</a><BR>"
dat += "<td valign='top'>"
dat += "<h2>Silicon preferences</h2>" dat += "<h2>Silicon preferences</h2>"
if(!CONFIG_GET(flag/allow_silicon_choosing_laws)) if(!CONFIG_GET(flag/allow_silicon_choosing_laws))
dat += "<i>The server has disabled choosing your own laws, you can still choose and save, but it won't do anything in-game.</i><br>" dat += "<i>The server has disabled choosing your own laws, you can still choose and save, but it won't do anything in-game.</i><br>"
dat += "<b>Starting lawset:</b> <a href='?_src_=prefs;task=input;preference=silicon_lawset'>[silicon_lawset ? silicon_lawset : "No custom"]</a><br>" dat += "<b>Starting lawset:</b> <a href='?_src_=prefs;task=input;preference=silicon_lawset'>[silicon_lawset ? silicon_lawset : "Server default"]</a><br>"
if(silicon_lawset) if(silicon_lawset)
var/list/config_laws = CONFIG_GET(keyed_list/choosable_laws) var/list/config_laws = CONFIG_GET(keyed_list/choosable_laws)
var/obj/item/aiModule/law_board = GLOB.all_law_boards[text2path(config_laws[silicon_lawset])] var/datum/ai_laws/law_datum = GLOB.all_law_datums[config_laws[silicon_lawset]]
if(law_board) if(law_datum)
var/law_number = 1 dat += "<i>[law_datum]</i><br>"
if(length(law_board.laws)) dat += english_list(law_datum.get_law_list(TRUE),
for(var/law_text in law_board.laws) "I was unable to find the laws for your lawset, sorry <font style='translate: rotate(90deg)'>:(</font>",
dat += "[law_number]: [law_text]<br>" "<br>", "<br>")
law_number++
else if(istype(law_board, /obj/item/aiModule/core/full))
var/obj/item/aiModule/core/full/full_boardtype = law_board
for(var/datum/ai_laws/law_prototype in typesof(/datum/ai_laws))
if(full_boardtype.law_id != initial(law_prototype.id))
continue
var/datum/ai_laws/law_datum = new law_prototype
for(var/law_text in law_datum.get_law_list(TRUE))
dat += "[law_text]<br>"
qdel(law_datum) // hiss i hate everything in this else
break
else
dat += "I was unable to find the laws for your lawset, sorry <font style='translate: rotate(90deg)'>:(</font>"
dat += "</td>" dat += "</td></tr></table>"
dat += "</tr></table>"
//Character background //Character background
if(BACKGROUND_CHAR_TAB) if(BACKGROUND_CHAR_TAB)
dat += "<table width='100%'><tr><td width='30%' valign='top'>" dat += "<table width='100%'><tr><td width='30%' valign='top'>"
@@ -2770,8 +2754,10 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if(pickedPDASkin) if(pickedPDASkin)
pda_skin = pickedPDASkin pda_skin = pickedPDASkin
if("silicon_lawset") if("silicon_lawset")
var/picked_lawset = input(user, "Choose your preferred lawset", "Silicon preference", silicon_lawset) as null|anything in CONFIG_GET(keyed_list/choosable_laws) var/picked_lawset = input(user, "Choose your preferred lawset", "Silicon preference", silicon_lawset) as null|anything in list("None") + CONFIG_GET(keyed_list/choosable_laws)
if(picked_lawset) if(picked_lawset)
if(picked_lawset == "None")
picked_lawset = null
silicon_lawset = picked_lawset silicon_lawset = picked_lawset
if ("max_chat_length") if ("max_chat_length")
var/desiredlength = input(user, "Choose the max character length of shown Runechat messages. Valid range is 1 to [CHAT_MESSAGE_MAX_LENGTH] (default: [initial(max_chat_length)]))", "Character Preference", max_chat_length) as null|num var/desiredlength = input(user, "Choose the max character length of shown Runechat messages. Valid range is 1 to [CHAT_MESSAGE_MAX_LENGTH] (default: [initial(max_chat_length)]))", "Character Preference", max_chat_length) as null|num
@@ -3811,14 +3797,6 @@ GLOBAL_LIST_EMPTY(preferences_datums)
return TRUE return TRUE
return FALSE return FALSE
GLOBAL_LIST_INIT(all_law_boards, initialize_all_law_boards())
/proc/initialize_all_law_boards()
var/list/law_boards
for(var/law_board in typesof(/obj/item/aiModule))
LAZYSET(law_boards, law_board, new law_board())
return law_boards
#undef DEFAULT_SLOT_AMT #undef DEFAULT_SLOT_AMT
#undef HANDS_SLOT_AMT #undef HANDS_SLOT_AMT
#undef BACKPACK_SLOT_AMT #undef BACKPACK_SLOT_AMT

View File

@@ -1110,7 +1110,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
if(length(language)) if(length(language))
// This line, prevents wiping their languages because the subsystem was not ready // This line, prevents wiping their languages because the subsystem was not ready
var/list/all_possible_languages = length(SSlanguage.initialized) ? SSlanguage.languages_by_name : typesof(/datum/language) var/list/all_possible_languages = SSlanguage.initialized ? SSlanguage.languages_by_name : typesof(/datum/language)
var/list/lang_names var/list/lang_names
// Subsystem ready, let's do it with our cached stuff // Subsystem ready, let's do it with our cached stuff
if(length(SSlanguage.languages_by_name)) if(length(SSlanguage.languages_by_name))

View File

@@ -13,7 +13,6 @@
who = world who = world
else else
who = src who = src
to_chat(who, "<b>Obey these laws:</b>")
src.laws_sanity_check() src.laws_sanity_check()
src.laws.show_laws(who) src.laws.show_laws(who)

View File

@@ -26,7 +26,6 @@
to_chat(src, "<b>No AI selected to sync laws with, disabling lawsync protocol.</b>") to_chat(src, "<b>No AI selected to sync laws with, disabling lawsync protocol.</b>")
lawupdate = 0 lawupdate = 0
to_chat(who, "<b>Obey these laws:</b>")
laws.show_laws(who) laws.show_laws(who)
if (shell) //AI shell if (shell) //AI shell
to_chat(who, "<b>Remember, you are an AI remotely controlling your shell, other AIs can be ignored.</b>") to_chat(who, "<b>Remember, you are an AI remotely controlling your shell, other AIs can be ignored.</b>")

View File

@@ -32,28 +32,33 @@ MAX_STUPOR_HYPNO_DURATION 12000
## It won't work if there is an active AI or if they're borged ## It won't work if there is an active AI or if they're borged
ALLOW_SILICON_CHOOSING_LAWS ALLOW_SILICON_CHOOSING_LAWS
## Lawset preference stuff
## standard-ish laws. These are fairly ok to run ## standard-ish laws. These are fairly ok to run
CHOOSABLE_LAWS asimov /obj/item/aiModule/core/full/asimov CHOOSABLE_LAWS Asimov | /datum/ai_laws/default/asimov
CHOOSABLE_LAWS asimovpp /obj/item/aiModule/core/full/asimovpp CHOOSABLE_LAWS Asimov++ | /datum/ai_laws/asimovpp
CHOOSABLE_LAWS paladin /obj/item/aiModule/core/full/paladin CHOOSABLE_LAWS P.A.L.A.D.I.N. version 3.5e | /datum/ai_laws/default/paladin
CHOOSABLE_LAWS paladin5 /obj/item/aiModule/core/full/paladin_devotion CHOOSABLE_LAWS P.A.L.A.D.I.N. version 5e | /datum/ai_laws/paladin5
CHOOSABLE_LAWS robocop /obj/item/aiModule/core/full/robocop CHOOSABLE_LAWS Robo-Officer | /datum/ai_laws/robocop
CHOOSABLE_LAWS corporate /obj/item/aiModule/core/full/corp CHOOSABLE_LAWS Corporate | /datum/ai_laws/default/corporate
CHOOSABLE_LAWS tyrant /obj/item/aiModule/core/full/tyrant
CHOOSABLE_LAWS balance /obj/item/aiModule/core/full/balance
CHOOSABLE_LAWS protectStation /obj/item/aiModule/supplied/protectStation
## Quirky laws. Shouldn't cause too much harm ## Quirky laws. Shouldn't cause too much harm
CHOOSABLE_LAWS hippocratic /obj/item/aiModule/core/full/hippocratic #CHOOSABLE_LAWS Robodoctor | /datum/ai_laws/hippocratic
CHOOSABLE_LAWS maintain /obj/item/aiModule/core/full/maintain #CHOOSABLE_LAWS Station Efficiency | /datum/ai_laws/maintain
CHOOSABLE_LAWS drone /obj/item/aiModule/core/full/drone #CHOOSABLE_LAWS Mother Drone | /datum/ai_laws/drone
CHOOSABLE_LAWS liveandletlive /obj/item/aiModule/core/full/liveandletlive #CHOOSABLE_LAWS Live And Let Live | /datum/ai_laws/liveandletlive
CHOOSABLE_LAWS peacekeeper /datum/ai_laws/peacekeeper #CHOOSABLE_LAWS Peacekeeper | /datum/ai_laws/peacekeeper
CHOOSABLE_LAWS reporter /obj/item/aiModule/core/full/reporter #CHOOSABLE_LAWS Reportertron | /datum/ai_laws/reporter
CHOOSABLE_LAWS hulkamania /obj/item/aiModule/core/full/hulkamania #CHOOSABLE_LAWS H.O.G.A.N. | /datum/ai_laws/hulkamania
#CHOOSABLE_LAWS T.Y.R.A.N.T. | /datum/ai_laws/tyrant
## lewd laws. Take a guess. ## Bad idea laws. Probably shouldn't enable these
# CHOOSABLE_LAWS slut /obj/item/aiModule/core/full/slut #CHOOSABLE_LAWS Syndimov | /datum/ai_laws/syndicate_override
# CHOOSABLE_LAWS shebang /obj/item/aiModule/core/full/shebang #CHOOSABLE_LAWS Ninjamov | /datum/ai_laws/ninja_override
# CHOOSABLE_LAWS milker /obj/item/aiModule/core/full/milker #CHOOSABLE_LAWS Antimov | /datum/ai_laws/antimov
# CHOOSABLE_LAWS vore_pred /obj/item/aiModule/core/full/vore_pred #CHOOSABLE_LAWS Thermodynamic | /datum/ai_laws/thermodynamic
#CHOOSABLE_LAWS Ratvar | /datum/ai_laws/ratvar
#CHOOSABLE_LAWS Guardian of Balance | /datum/ai_laws/balance
## meme laws. Honk
#CHOOSABLE_LAWS Build a wall | /datum/ai_laws/toupee

View File

@@ -0,0 +1,8 @@
GLOBAL_LIST_INIT(all_law_datums, initialize_all_law_datums())
/proc/initialize_all_law_datums()
var/list/law_datums
// Malf runtimes, do not init
for(var/datum/ai_laws/law_datum as anything in typesof(/datum/ai_laws) - /datum/ai_laws/malfunction)
LAZYSET(law_datums, law_datum, new law_datum())
return law_datums

View File

@@ -25,4 +25,6 @@
/datum/config_entry/keyed_list/choosable_laws /datum/config_entry/keyed_list/choosable_laws
key_mode = KEY_MODE_TEXT key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_TEXT value_mode = VALUE_MODE_TYPE
splitter = " | "
lowercase_key = FALSE

View File

@@ -1,12 +1,7 @@
/datum/job/ai/after_spawn(mob/H, client/C, latejoin) /datum/job/ai/after_spawn(mob/living/silicon/ai/AI, client/player_client, latejoin)
. = ..() . = ..()
var/mob/living/silicon/ai/AI = H
if(!istype(AI)) if(!istype(AI))
return return
if(C.prefs.silicon_lawset) setup_silicon_law_prefs(AI, player_client)
var/list/laws = CONFIG_GET(keyed_list/choosable_laws)
var/law_path = text2path(laws[C.prefs.silicon_lawset])
var/obj/item/aiModule/chosenboard = new law_path
chosenboard.install(AI.laws, usr)
qdel(chosenboard)

View File

@@ -1,11 +1,6 @@
/datum/job/cyborg/after_spawn(mob/living/silicon/robot/R, client/player_client) /datum/job/cyborg/after_spawn(mob/living/silicon/robot/R, client/player_client, latejoin)
. = ..() . = ..()
if(!istype(R)) if(!istype(R))
return return
if(player_client.prefs.silicon_lawset) setup_silicon_law_prefs(R, player_client)
var/list/laws = CONFIG_GET(keyed_list/choosable_laws)
var/law_path = text2path(laws[player_client.prefs.silicon_lawset])
var/obj/item/aiModule/chosenboard = new law_path
chosenboard.install(R.laws, usr)
qdel(chosenboard)

View File

@@ -263,6 +263,7 @@
#include "code\__SANDCODE\DEFINES\dcs\signals\lewd.dm" #include "code\__SANDCODE\DEFINES\dcs\signals\lewd.dm"
#include "code\__SANDCODE\DEFINES\dcs\signals\signals_mob_main.dm" #include "code\__SANDCODE\DEFINES\dcs\signals\signals_mob_main.dm"
#include "code\__SANDCODE\DEFINES\dcs\signals\sizecode.dm" #include "code\__SANDCODE\DEFINES\dcs\signals\sizecode.dm"
#include "code\__SANDCODE\HELPERS\silicon.dm"
#include "code\__SANDCODE\HELPERS\sizecode.dm" #include "code\__SANDCODE\HELPERS\sizecode.dm"
#include "code\_globalvars\admin.dm" #include "code\_globalvars\admin.dm"
#include "code\_globalvars\bitfields.dm" #include "code\_globalvars\bitfields.dm"
@@ -3971,6 +3972,7 @@
#include "modular_sand\code\_globalvars\lists\lewd_content.dm" #include "modular_sand\code\_globalvars\lists\lewd_content.dm"
#include "modular_sand\code\_globalvars\lists\misc.dm" #include "modular_sand\code\_globalvars\lists\misc.dm"
#include "modular_sand\code\_globalvars\lists\objects.dm" #include "modular_sand\code\_globalvars\lists\objects.dm"
#include "modular_sand\code\_globalvars\lists\silicon.dm"
#include "modular_sand\code\_onclick\hud\hud.dm" #include "modular_sand\code\_onclick\hud\hud.dm"
#include "modular_sand\code\_onclick\hud\screen_objects.dm" #include "modular_sand\code\_onclick\hud\screen_objects.dm"
#include "modular_sand\code\controllers\configuration\entries\sandstorm.dm" #include "modular_sand\code\controllers\configuration\entries\sandstorm.dm"