-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathaifixer.dm
127 lines (114 loc) · 4.15 KB
/
aifixer.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
/obj/machinery/computer/aifixer
name = "\improper AI system integrity restorer"
desc = "Used with intelliCards containing nonfunctional AIs to restore them to working order."
req_access = list(ACCESS_CAPTAIN, ACCESS_ROBO_CONTROL, ACCESS_COMMAND)
circuit = /obj/item/circuitboard/computer/aifixer
icon_keyboard = "tech_key"
icon_screen = "ai-fixer"
light_color = LIGHT_COLOR_PINK
/// Variable containing transferred AI
var/mob/living/silicon/ai/occupier
/// Variable dictating if we are in the process of restoring the occupier AI
var/restoring = FALSE
/obj/machinery/computer/aifixer/screwdriver_act(mob/living/user, obj/item/I)
if(occupier)
if(stat & (NOPOWER|BROKEN))
to_chat(user, span_warning("The screws on [name]'s screen won't budge."))
else
to_chat(user, span_warning("The screws on [name]'s screen won't budge and it emits a warning beep."))
else
return ..()
/obj/machinery/computer/aifixer/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "AiRestorer", name)
ui.open()
/obj/machinery/computer/aifixer/ui_data(mob/user)
var/list/data = list()
data["ejectable"] = FALSE
data["AI_present"] = FALSE
data["error"] = null
if(!occupier)
data["error"] = "Please transfer an AI unit."
else
data["AI_present"] = TRUE
data["name"] = occupier.name
data["restoring"] = restoring
data["health"] = (occupier.health + 100) / 2
data["isDead"] = occupier.stat == DEAD
data["laws"] = occupier.laws.get_law_list(include_zeroth = 1)
return data
/obj/machinery/computer/aifixer/ui_act(action, params)
if(..())
return
if(!occupier)
restoring = FALSE
switch(action)
if("PRG_beginReconstruction")
if(occupier?.health < 100)
to_chat(usr, span_notice("Reconstruction in progress. This will take several minutes."))
playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 25, FALSE)
restoring = TRUE
occupier.notify_ghost_cloning("Your core files are being restored!", source = src)
. = TRUE
/obj/machinery/computer/aifixer/proc/Fix()
use_power(1000)
occupier.adjustOxyLoss(-5, FALSE)
occupier.adjustFireLoss(-5, FALSE)
occupier.adjustBruteLoss(-5, FALSE)
occupier.updatehealth()
if(occupier.health >= 0 && occupier.stat == DEAD)
occupier.revive()
return occupier.health < 100
/obj/machinery/computer/aifixer/process()
if(..())
if(restoring)
var/oldstat = occupier.stat
restoring = Fix()
if(oldstat != occupier.stat)
update_appearance(UPDATE_ICON)
/obj/machinery/computer/aifixer/update_overlays()
. = ..()
if(stat & (NOPOWER|BROKEN))
return
if(restoring)
. += "ai-fixer-on"
if(!occupier)
. += "ai-fixer-empty"
return
switch(occupier.stat)
if(0)
. += "ai-fixer-full"
if(2)
. += "ai-fixer-404"
/obj/machinery/computer/aifixer/transfer_ai(interaction, mob/user, mob/living/silicon/ai/AI, obj/item/aicard/card)
if(!..())
return
//Downloading AI from card to terminal.
if(interaction == AI_TRANS_FROM_CARD)
if(stat & (NOPOWER|BROKEN))
to_chat(user, "[src] is offline and cannot take an AI at this time!")
return
AI.forceMove(src)
occupier = AI
AI.control_disabled = TRUE
AI.radio_enabled = FALSE
to_chat(AI, "You have been uploaded to a stationary terminal. Sadly, there is no remote access from here.")
to_chat(user, "[span_boldnotice("Transfer successful")]: [AI.name] ([rand(1000,9999)].exe) installed and executed successfully. Local copy has been removed.")
card.AI = null
update_appearance()
else //Uploading AI from terminal to card
if(occupier && !restoring)
to_chat(occupier, span_notice("You have been downloaded to a mobile storage device. Still no remote access."))
to_chat(user, "[span_notice("Transfer successful")]: [occupier.name] ([rand(1000,9999)].exe) removed from host terminal and stored within local memory.")
occupier.forceMove(card)
card.AI = occupier
occupier = null
update_appearance(UPDATE_ICON)
else if (restoring)
to_chat(user, span_alert("ERROR: Reconstruction in progress."))
else if (!occupier)
to_chat(user, "[span_boldannounce("ERROR")]: Unable to locate artificial intelligence.")
/obj/machinery/computer/aifixer/on_deconstruction()
if(occupier)
QDEL_NULL(occupier)