This repository has been archived by the owner on Sep 12, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
airestorer.dm
122 lines (102 loc) · 3.2 KB
/
airestorer.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
/datum/computer_file/program/aidiag
filename = "aidiag"
filedesc = "NT FRK"
program_icon_state = "generic"
extended_desc = "Firmware Restoration Kit, capable of reconstructing damaged AI systems. Requires direct AI connection via intellicard slot."
size = 12
requires_ntnet = FALSE
usage_flags = PROGRAM_CONSOLE | PROGRAM_LAPTOP
transfer_access = ACCESS_HEADS
available_on_ntnet = TRUE
tgui_id = "NtosAiRestorer"
program_icon = "laptop-code"
/// Variable dictating if we are in the process of restoring the AI in the inserted intellicard
var/restoring = FALSE
/datum/computer_file/program/aidiag/proc/get_ai(cardcheck)
var/obj/item/computer_hardware/ai_slot/ai_slot
if(computer)
ai_slot = computer.all_components[MC_AI]
if(computer && ai_slot && ai_slot.check_functionality())
if(cardcheck == 1)
return ai_slot
if(ai_slot.enabled && ai_slot.stored_card)
if(cardcheck == 2)
return ai_slot.stored_card
if(ai_slot.stored_card.AI)
return ai_slot.stored_card.AI
return
/datum/computer_file/program/aidiag/ui_act(action, params)
. = ..()
if(.)
return
var/mob/living/silicon/ai/A = get_ai()
if(!A)
restoring = FALSE
switch(action)
if("PRG_beginReconstruction")
if(A && A.health < 100)
restoring = TRUE
A.notify_ghost_cloning("Your core files are being restored!", source = computer)
return TRUE
if("PRG_eject")
if(computer.all_components[MC_AI])
var/obj/item/computer_hardware/ai_slot/ai_slot = computer.all_components[MC_AI]
if(ai_slot && ai_slot.stored_card)
ai_slot.try_eject(0,usr)
return TRUE
/datum/computer_file/program/aidiag/process_tick()
. = ..()
if(!restoring) //Put the check here so we don't check for an ai all the time
return
var/obj/item/aicard/cardhold = get_ai(2)
var/obj/item/computer_hardware/ai_slot/ai_slot = get_ai(1)
var/mob/living/silicon/ai/A = get_ai()
if(!A || !cardhold)
restoring = FALSE // If the AI was removed, stop the restoration sequence.
if(ai_slot)
ai_slot.locked = FALSE
return
if(cardhold.flush)
ai_slot.locked = FALSE
restoring = FALSE
return
ai_slot.locked =TRUE
A.adjustOxyLoss(-5, 0)
A.adjustFireLoss(-5, 0)
A.adjustToxLoss(-5, 0)
A.adjustBruteLoss(-5, 0)
A.updatehealth()
if(A.health >= 0 && A.stat == DEAD)
A.revive(full_heal = FALSE, admin_revive = FALSE)
// Finished restoring
if(A.health >= 100)
ai_slot.locked = FALSE
restoring = FALSE
return TRUE
/datum/computer_file/program/aidiag/ui_data(mob/user)
var/list/data = get_header_data()
var/mob/living/silicon/ai/AI = get_ai()
var/obj/item/aicard/aicard = get_ai(2)
data["ejectable"] = TRUE
data["AI_present"] = FALSE
data["error"] = null
if(!aicard)
data["error"] = "Please insert an intelliCard."
else
if(!AI)
data["error"] = "No AI located"
else
var/obj/item/aicard/cardhold = AI.loc
if(cardhold.flush)
data["error"] = "Flush in progress"
else
data["AI_present"] = TRUE
data["name"] = AI.name
data["restoring"] = restoring
data["health"] = (AI.health + 100) / 2
data["isDead"] = AI.stat == DEAD
data["laws"] = AI.laws.get_law_list(include_zeroth = TRUE, render_html = FALSE)
return data
/datum/computer_file/program/aidiag/kill_program(forced)
restoring = FALSE
return ..()