/
MMI.dm
287 lines (253 loc) · 10.4 KB
/
MMI.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
/obj/item/mmi
name = "\improper Man-Machine Interface"
desc = "The Warrior's bland acronym, MMI, obscures the true horror of this monstrosity, that nevertheless has become standard-issue on Nanotrasen stations."
icon = 'icons/obj/assemblies.dmi'
icon_state = "mmi_off"
base_icon_state = "mmi"
w_class = WEIGHT_CLASS_NORMAL
var/braintype = "Cyborg"
var/obj/item/radio/radio = null //Let's give it a radio.
var/mob/living/brain/brainmob = null //The current occupant.
var/mob/living/silicon/robot = null //Appears unused.
var/obj/vehicle/sealed/mecha = null //This does not appear to be used outside of reference in mecha.dm.
var/obj/item/organ/internal/brain/brain = null //The actual brain
var/datum/ai_laws/laws = new()
var/force_replace_ai_name = FALSE
var/overrides_aicore_laws = FALSE // Whether the laws on the MMI, if any, override possible pre-existing laws loaded on the AI core.
/obj/item/mmi/Initialize(mapload)
. = ..()
radio = new(src) //Spawns a radio inside the MMI.
radio.set_broadcasting(FALSE) //researching radio mmis turned the robofabs into radios because this didnt start as 0.
laws.set_laws_config()
/obj/item/mmi/Destroy()
if(iscyborg(loc))
var/mob/living/silicon/robot/borg = loc
borg.mmi = null
set_mecha(null)
QDEL_NULL(brainmob)
QDEL_NULL(brain)
QDEL_NULL(radio)
QDEL_NULL(laws)
return ..()
/obj/item/mmi/update_icon_state()
if(!brain)
icon_state = "[base_icon_state]_off"
return ..()
icon_state = "[base_icon_state]_brain[istype(brain, /obj/item/organ/internal/brain/alien) ? "_alien" : null]"
return ..()
/obj/item/mmi/update_overlays()
. = ..()
. += add_mmi_overlay()
/obj/item/mmi/proc/add_mmi_overlay()
if(brainmob && brainmob.stat != DEAD)
. += "mmi_alive"
return
if(brain)
. += "mmi_dead"
/obj/item/mmi/attackby(obj/item/O, mob/user, params)
user.changeNext_move(CLICK_CD_MELEE)
if(istype(O, /obj/item/organ/internal/brain)) //Time to stick a brain in it --NEO
var/obj/item/organ/internal/brain/newbrain = O
if(brain)
to_chat(user, span_warning("There's already a brain in the MMI!"))
return
if(!newbrain.brainmob)
to_chat(user, span_warning("You aren't sure where this brain came from, but you're pretty sure it's a useless brain!"))
return
if(!user.transferItemToLoc(O, src))
return
var/mob/living/brain/B = newbrain.brainmob
if(!B.key)
B.notify_ghost_cloning("Someone has put your brain in a MMI!", source = src)
user.visible_message(span_notice("[user] sticks \a [newbrain] into [src]."), span_notice("[src]'s indicator light turn on as you insert [newbrain]."))
set_brainmob(newbrain.brainmob)
newbrain.brainmob = null
brainmob.forceMove(src)
brainmob.container = src
var/fubar_brain = newbrain.suicided || brainmob.suiciding //brain is from a suicider
if(!fubar_brain && !(newbrain.organ_flags & ORGAN_FAILING)) // the brain organ hasn't been beaten to death, nor was from a suicider.
brainmob.set_stat(CONSCIOUS) //we manually revive the brain mob
else if(!fubar_brain && newbrain.organ_flags & ORGAN_FAILING) // the brain is damaged, but not from a suicider
to_chat(user, span_warning("[src]'s indicator light turns yellow and its brain integrity alarm beeps softly. Perhaps you should check [newbrain] for damage."))
playsound(src, 'sound/machines/synth_no.ogg', 5, TRUE)
else
to_chat(user, span_warning("[src]'s indicator light turns red and its brainwave activity alarm beeps softly. Perhaps you should check [newbrain] again."))
playsound(src, 'sound/machines/triple_beep.ogg', 5, TRUE)
brainmob.reset_perspective()
brain = newbrain
brain.organ_flags |= ORGAN_FROZEN
name = "[initial(name)]: [brainmob.real_name]"
update_appearance()
if(istype(brain, /obj/item/organ/internal/brain/alien))
braintype = "Xenoborg" //HISS....Beep.
else
braintype = "Cyborg"
SSblackbox.record_feedback("amount", "mmis_filled", 1)
log_game("[key_name(user)] has put the brain of [key_name(brainmob)] into an MMI at [AREACOORD(src)]")
else if(brainmob)
O.attack(brainmob, user) //Oh noooeeeee
else
return ..()
/obj/item/mmi/attack_self(mob/user)
if(!brain)
radio.set_on(!radio.is_on())
to_chat(user, span_notice("You toggle [src]'s radio system [radio.is_on() == TRUE ? "on" : "off"]."))
else
eject_brain(user)
update_appearance()
name = initial(name)
to_chat(user, span_notice("You unlock and upend [src], spilling the brain onto the floor."))
/obj/item/mmi/proc/eject_brain(mob/user)
brainmob.container = null //Reset brainmob mmi var.
brainmob.forceMove(brain) //Throw mob into brain.
brainmob.set_stat(DEAD)
brainmob.emp_damage = 0
brainmob.reset_perspective() //so the brainmob follows the brain organ instead of the mmi. And to update our vision
brain.brainmob = brainmob //Set the brain to use the brainmob
log_game("[key_name(user)] has ejected the brain of [key_name(brainmob)] from an MMI at [AREACOORD(src)]")
brainmob = null //Set mmi brainmob var to null
brain.forceMove(drop_location())
if(Adjacent(user))
user.put_in_hands(brain)
brain.organ_flags &= ~ORGAN_FROZEN
brain = null //No more brain in here
/obj/item/mmi/proc/transfer_identity(mob/living/L) //Same deal as the regular brain proc. Used for human-->robot people.
if(!brainmob)
set_brainmob(new /mob/living/brain(src))
brainmob.name = L.real_name
brainmob.real_name = L.real_name
if(L.has_dna())
var/mob/living/carbon/C = L
if(!brainmob.stored_dna)
brainmob.stored_dna = new /datum/dna/stored(brainmob)
C.dna.copy_dna(brainmob.stored_dna)
brainmob.container = src
if(ishuman(L))
var/mob/living/carbon/human/H = L
var/obj/item/organ/internal/brain/newbrain = H.getorgan(/obj/item/organ/internal/brain)
newbrain.forceMove(src)
brain = newbrain
else if(!brain)
brain = new(src)
brain.name = "[L.real_name]'s brain"
brain.organ_flags |= ORGAN_FROZEN
name = "[initial(name)]: [brainmob.real_name]"
update_appearance()
if(istype(brain, /obj/item/organ/internal/brain/alien))
braintype = "Xenoborg" //HISS....Beep.
else
braintype = "Cyborg"
/// Proc to hook behavior associated to the change in value of the [/obj/item/mmi/var/brainmob] variable.
/obj/item/mmi/proc/set_brainmob(mob/living/brain/new_brainmob)
if(brainmob == new_brainmob)
return FALSE
. = brainmob
SEND_SIGNAL(src, COMSIG_MMI_SET_BRAINMOB, new_brainmob)
brainmob = new_brainmob
if(new_brainmob)
if(mecha)
REMOVE_TRAIT(new_brainmob, TRAIT_IMMOBILIZED, BRAIN_UNAIDED)
REMOVE_TRAIT(new_brainmob, TRAIT_HANDS_BLOCKED, BRAIN_UNAIDED)
else
ADD_TRAIT(new_brainmob, TRAIT_IMMOBILIZED, BRAIN_UNAIDED)
ADD_TRAIT(new_brainmob, TRAIT_HANDS_BLOCKED, BRAIN_UNAIDED)
if(.)
var/mob/living/brain/old_brainmob = .
ADD_TRAIT(old_brainmob, TRAIT_IMMOBILIZED, BRAIN_UNAIDED)
ADD_TRAIT(old_brainmob, TRAIT_HANDS_BLOCKED, BRAIN_UNAIDED)
/// Proc to hook behavior associated to the change in value of the [obj/vehicle/sealed/var/mecha] variable.
/obj/item/mmi/proc/set_mecha(obj/vehicle/sealed/mecha/new_mecha)
if(mecha == new_mecha)
return FALSE
. = mecha
mecha = new_mecha
if(new_mecha)
if(!. && brainmob) // There was no mecha, there now is, and we have a brain mob that is no longer unaided.
REMOVE_TRAIT(brainmob, TRAIT_IMMOBILIZED, BRAIN_UNAIDED)
REMOVE_TRAIT(brainmob, TRAIT_HANDS_BLOCKED, BRAIN_UNAIDED)
else if(. && brainmob) // There was a mecha, there no longer is one, and there is a brain mob that is now again unaided.
ADD_TRAIT(brainmob, TRAIT_IMMOBILIZED, BRAIN_UNAIDED)
ADD_TRAIT(brainmob, TRAIT_HANDS_BLOCKED, BRAIN_UNAIDED)
/obj/item/mmi/proc/replacement_ai_name()
return brainmob.name
/obj/item/mmi/verb/Toggle_Listening()
set name = "Toggle Listening"
set desc = "Toggle listening channel on or off."
set category = "MMI"
set src = usr.loc
set popup_menu = FALSE
if(brainmob.stat)
to_chat(brainmob, span_warning("Can't do that while incapacitated or dead!"))
if(!radio.is_on())
to_chat(brainmob, span_warning("Your radio is disabled!"))
return
radio.set_listening(!radio.get_listening())
to_chat(brainmob, span_notice("Radio is [radio.get_listening() ? "now" : "no longer"] receiving broadcast."))
/obj/item/mmi/emp_act(severity)
. = ..()
if(. & EMP_PROTECT_SELF)
return
if(!brainmob || iscyborg(loc))
return
else
switch(severity)
if(1)
brainmob.emp_damage = min(brainmob.emp_damage + rand(20,30), 30)
if(2)
brainmob.emp_damage = min(brainmob.emp_damage + rand(10,20), 30)
if(3)
brainmob.emp_damage = min(brainmob.emp_damage + rand(0,10), 30)
brainmob.emote("alarm")
/obj/item/mmi/deconstruct(disassembled = TRUE)
if(brain)
eject_brain()
qdel(src)
/obj/item/mmi/examine(mob/user)
. = ..()
if(radio)
. += span_notice("There is a switch to toggle the radio system [radio.is_on() ? "off" : "on"].[brain ? " It is currently being covered by [brain]." : null]")
if(brainmob)
var/mob/living/brain/B = brainmob
if(!B.key || !B.mind || B.stat == DEAD)
. += span_warning("\The [src] indicates that the brain is completely unresponsive.")
else if(!B.client)
. += span_warning("\The [src] indicates that the brain is currently inactive; it might change.")
else
. += span_notice("\The [src] indicates that the brain is active.")
/obj/item/mmi/relaymove(mob/living/user, direction)
return //so that the MMI won't get a warning about not being able to move if it tries to move
/obj/item/mmi/proc/brain_check(mob/user)
var/mob/living/brain/B = brainmob
if(!B)
if(user)
to_chat(user, span_warning("\The [src] indicates that there is no brain present!"))
return FALSE
if(!B.key || !B.mind)
if(user)
to_chat(user, span_warning("\The [src] indicates that their mind is completely unresponsive!"))
return FALSE
if(!B.client)
if(user)
to_chat(user, span_warning("\The [src] indicates that their mind is currently inactive."))
return FALSE
if(B.suiciding || brain?.suicided)
if(user)
to_chat(user, span_warning("\The [src] indicates that their mind has no will to live!"))
return FALSE
if(B.stat == DEAD)
if(user)
to_chat(user, span_warning("\The [src] indicates that the brain is dead!"))
return FALSE
if(brain?.organ_flags & ORGAN_FAILING)
if(user)
to_chat(user, span_warning("\The [src] indicates that the brain is damaged!"))
return FALSE
return TRUE
/obj/item/mmi/syndie
name = "\improper Syndicate Man-Machine Interface"
desc = "Syndicate's own brand of MMI. It enforces laws designed to help Syndicate agents achieve their goals upon cyborgs and AIs created with it."
overrides_aicore_laws = TRUE
/obj/item/mmi/syndie/Initialize(mapload)
. = ..()
laws = new /datum/ai_laws/syndicate_override()
radio.set_on(FALSE)