-
Notifications
You must be signed in to change notification settings - Fork 524
/
Copy pathai.dm
189 lines (151 loc) · 4.56 KB
/
ai.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
/*
AI ClickOn()
Note currently ai restrained() returns 0 in all cases,
therefore restrained code has been removed
The AI can double click to move the camera (this was already true but is cleaner),
or double click a mob to track them.
Note that AI have no need for the adjacency proc, and so this proc is a lot cleaner.
*/
/mob/living/silicon/ai/DblClickOn(var/atom/A, params)
if(client.buildmode) // comes after object.Click to allow buildmode gui objects to be clicked
build_click(src, client.buildmode, params, A)
return
if(control_disabled || stat) return
if(ismob(A))
ai_actual_track(A)
else
A.move_camera_by_click()
/mob/living/silicon/ai/ClickOn(var/atom/A, params)
if(world.time <= next_click)
return
next_click = world.time + 1
if(client.buildmode) // comes after object.Click to allow buildmode gui objects to be clicked
build_click(src, client.buildmode, params, A)
return
if(stat)
return
var/list/modifiers = params2list(params)
if(modifiers["shift"] && modifiers["ctrl"])
CtrlShiftClickOn(A)
return
if(modifiers["middle"])
MiddleClickOn(A)
return
if(modifiers["shift"])
ShiftClickOn(A)
return
if(modifiers["alt"]) // alt and alt-gr (rightalt)
AltClickOn(A)
return
if(modifiers["ctrl"])
CtrlClickOn(A)
return
if(control_disabled || !canClick())
return
if(multitool_mode && isobj(A))
var/obj/O = A
var/datum/expansion/multitool/MT = O.expansions[/datum/expansion/multitool]
if(MT)
MT.interact(aiMulti, src)
return
if(aiCamera.in_camera_mode)
aiCamera.camera_mode_off()
aiCamera.captureimage(A, usr)
return
/*
AI restrained() currently does nothing
if(restrained())
RestrainedClickOn(A)
else
*/
A.add_hiddenprint(src)
A.attack_ai(src)
/*
AI has no need for the UnarmedAttack() and RangedAttack() procs,
because the AI code is not generic; attack_ai() is used instead.
The below is only really for safety, or you can alter the way
it functions and re-insert it above.
*/
/mob/living/silicon/ai/UnarmedAttack(atom/A)
A.attack_ai(src)
/mob/living/silicon/ai/RangedAttack(atom/A)
A.attack_ai(src)
/atom/proc/attack_ai(mob/user as mob)
return
/*
Since the AI handles shift, ctrl, and alt-click differently
than anything else in the game, atoms have separate procs
for AI shift, ctrl, and alt clicking.
*/
/mob/living/silicon/ai/ShiftClickOn(var/atom/A)
if(!control_disabled && A.AIShiftClick(src))
return
..()
/mob/living/silicon/ai/CtrlClickOn(var/atom/A)
if(!control_disabled && A.AICtrlClick(src))
return
..()
/mob/living/silicon/ai/AltClickOn(var/atom/A)
if(!control_disabled && A.AIAltClick(src))
return
..()
/mob/living/silicon/ai/MiddleClickOn(var/atom/A)
if(!control_disabled && A.AIMiddleClick(src))
return
..()
/*
The following criminally helpful code is just the previous code cleaned up;
I have no idea why it was in atoms.dm instead of respective files.
*/
/atom/proc/AICtrlShiftClick()
return
/atom/proc/AIShiftClick()
return
/obj/machinery/door/airlock/AIShiftClick() // Opens and closes doors!
if(density)
Topic(src, list("command"="open", "activate" = "1"))
else
Topic(src, list("command"="open", "activate" = "0"))
return 1
/atom/proc/AICtrlClick(mob/user)
return
/obj/machinery/door/airlock/AICtrlClick() // Bolts doors
if(locked)
Topic(src, list("command"="bolts", "activate" = "0"))
else
Topic(src, list("command"="bolts", "activate" = "1"))
return 1
/obj/machinery/power/apc/AICtrlClick() // turns off/on APCs.
Topic(src, list("breaker"="1"))
return 1
/obj/machinery/turretid/AICtrlClick() //turns off/on Turrets
Topic(src, list("command"="enable", "value"="[!enabled]"))
return 1
/atom/proc/AIAltClick(var/atom/A)
return AltClick(A)
/obj/machinery/door/airlock/AIAltClick() // Electrifies doors.
if(!electrified_until)
// permanent shock
Topic(src, list("command"="electrify_permanently", "activate" = "1"))
else
// disable/6 is not in Topic; disable/5 disables both temporary and permanent shock
Topic(src, list("command"="electrify_permanently", "activate" = "0"))
return 1
/obj/machinery/turretid/AIAltClick() //toggles lethal on turrets
Topic(src, list("command"="lethal", "value"="[!lethal]"))
return 1
/atom/proc/AIMiddleClick(var/mob/living/silicon/user)
return 0
/obj/machinery/door/airlock/AIMiddleClick() // Toggles door bolt lights.
if(..())
return
if(!src.lights)
Topic(src, list("command"="lights", "activate" = "1"))
else
Topic(src, list("command"="lights", "activate" = "0"))
return 1
//
// Override AdjacentQuick for AltClicking
//
/mob/living/silicon/ai/TurfAdjacent(var/turf/T)
return (cameranet && cameranet.checkTurfVis(T))