/
silicon_laws.dm
154 lines (128 loc) · 4.7 KB
/
silicon_laws.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#define BASE_LAW_TYPE /datum/ai_laws/nanotrasen
/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_law != null
/mob/living/silicon/proc/set_zeroth_law(law, law_borg)
throw_alert("newlaw", /atom/movable/screen/alert/newlaw)
laws_sanity_check()
laws.set_zeroth_law(law, law_borg)
if(!isnull(usr) && law)
log_and_message_admins("has given [src] the zeroth laws: [law]/[law_borg ? law_borg : "N/A"]")
/mob/living/silicon/robot/set_zeroth_law(law, law_borg)
..()
if(tracking_entities)
to_chat(src, "<span class='warning'>Internal camera is currently being accessed.</span>")
/mob/living/silicon/proc/add_ion_law(law)
throw_alert("newlaw", /atom/movable/screen/alert/newlaw)
laws_sanity_check()
laws.add_ion_law(law)
if(!isnull(usr) && law)
log_and_message_admins("has given [src] the ion law: [law]")
/mob/living/silicon/proc/add_inherent_law(law)
throw_alert("newlaw", /atom/movable/screen/alert/newlaw)
laws_sanity_check()
laws.add_inherent_law(law)
if(!isnull(usr) && law)
log_and_message_admins("has given [src] the inherent law: [law]")
/mob/living/silicon/proc/add_supplied_law(number, law)
throw_alert("newlaw", /atom/movable/screen/alert/newlaw)
laws_sanity_check()
laws.add_supplied_law(number, law)
if(!isnull(usr) && law)
log_and_message_admins("has given [src] the supplied law: [law]")
/mob/living/silicon/proc/delete_law(datum/ai_law/law)
throw_alert("newlaw", /atom/movable/screen/alert/newlaw)
laws_sanity_check()
laws.delete_law(law)
if(!isnull(usr) && law)
log_and_message_admins("has deleted a law belonging to [src]: [law.law]")
/mob/living/silicon/proc/clear_inherent_laws(silent = 0)
throw_alert("newlaw", /atom/movable/screen/alert/newlaw)
laws_sanity_check()
laws.clear_inherent_laws()
if(!silent && !isnull(usr))
log_and_message_admins("cleared the inherent laws of [src]")
/mob/living/silicon/proc/clear_ion_laws(silent = 0)
throw_alert("newlaw", /atom/movable/screen/alert/newlaw)
laws_sanity_check()
laws.clear_ion_laws()
if(!silent && !isnull(usr))
log_and_message_admins("cleared the ion laws of [src]")
/mob/living/silicon/proc/clear_supplied_laws(silent = 0)
throw_alert("newlaw", /atom/movable/screen/alert/newlaw)
laws_sanity_check()
laws.clear_supplied_laws()
if(!silent && !isnull(usr))
log_and_message_admins("cleared the supplied laws of [src]")
/mob/living/silicon/proc/clear_zeroth_law(silent = FALSE)
throw_alert("newlaw", /atom/movable/screen/alert/newlaw)
laws_sanity_check()
laws.clear_zeroth_laws()
if(!silent && !isnull(usr))
log_and_message_admins("cleared the zeroth law of [src]")
/mob/living/silicon/proc/statelaws(datum/ai_laws/laws)
var/prefix = ""
if(MAIN_CHANNEL == lawchannel)
prefix = ";"
else if(lawchannel in additional_law_channels)
prefix = additional_law_channels[lawchannel]
else
prefix = get_radio_key_from_channel(lawchannel)
dostatelaws(lawchannel, prefix, laws)
/mob/living/silicon/proc/dostatelaws(method, prefix, datum/ai_laws/laws)
if(stating_laws[prefix])
to_chat(src, "<span class='notice'>[method]: Already stating laws using this communication method.</span>")
return
stating_laws[prefix] = 1
var/can_state = statelaw("[prefix]Current Active Laws:")
for(var/datum/ai_law/law in laws.laws_to_state())
can_state = statelaw("[prefix][law.get_index()]. [law.law]")
if(!can_state)
break
if(!can_state)
to_chat(src, "<span class='danger'>[method]: Unable to state laws. Communication method unavailable.</span>")
stating_laws[prefix] = 0
/mob/living/silicon/proc/statelaw(law)
if(src.say(law))
sleep(10)
return 1
return 0
/mob/living/silicon/proc/law_channels()
var/list/channels = new()
channels += MAIN_CHANNEL
var/obj/item/radio/radio = get_radio()
channels += radio.channels
channels += additional_law_channels
return channels
/mob/living/silicon/proc/lawsync()
laws_sanity_check()
laws.sort_laws()
/mob/living/silicon/proc/make_laws()
if(HAS_TRAIT(SSstation, STATION_TRAIT_UNIQUE_AI))
laws = pick_unique_lawset()
else if(GLOB.configuration.general.random_ai_lawset)
laws = get_random_lawset()
else
laws = new /datum/ai_laws/crewsimov()
/mob/living/silicon/proc/get_random_lawset()
var/list/law_options[0]
var/paths = subtypesof(/datum/ai_laws)
for(var/law in paths)
var/datum/ai_laws/L = new law
if(!L.default)
continue
law_options += L
return pick(law_options)
///returns a random non starting / kill crew lawset if the station has a unique ai lawset
/proc/pick_unique_lawset()
var/list/law_options = list()
var/paths = subtypesof(/datum/ai_laws)
for(var/law in paths)
var/datum/ai_laws/L = new law
if(!L.unique_ai)
continue
law_options += L
return pick(law_options)
#undef BASE_LAW_TYPE