forked from DaedalusDock/daedalusdock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathai.dm
210 lines (169 loc) · 5.22 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*
AI ClickOn()
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(atom/A, params)
if(control_disabled || incapacitated())
return
if(ismob(A))
ai_actual_track(A)
else
A.move_camera_by_click()
/mob/living/silicon/ai/ClickOn(atom/A, params)
if(world.time <= next_click)
return
next_click = world.time + 1
if(!can_interact_with(A))
return
if(multicam_on)
var/turf/T = get_turf(A)
if(T)
for(var/atom/movable/screen/movable/pic_in_pic/ai/P in T.vis_locs)
if(P.ai == src)
P.Click(params)
break
if(check_click_intercept(params,A))
return
if(control_disabled || incapacitated())
return
var/turf/pixel_turf = get_turf_pixel(A)
if(isnull(pixel_turf))
return
if(!can_see(A))
if(isturf(A)) //On unmodified clients clicking the static overlay clicks the turf underneath
return //So there's no point messaging admins
message_admins("[ADMIN_LOOKUPFLW(src)] might be running a modified client! (failed can_see on AI click of [A] (Turf Loc: [ADMIN_VERBOSEJMP(pixel_turf)]))")
var/message = "[key_name(src)] might be running a modified client! (failed can_see on AI click of [A] (Turf Loc: [AREACOORD(pixel_turf)]))"
log_admin(message)
if(REALTIMEOFDAY >= chnotify + 9000)
chnotify = REALTIMEOFDAY
send2tgs_adminless_only("NOCHEAT", message)
return
var/list/modifiers = params2list(params)
if(LAZYACCESS(modifiers, SHIFT_CLICK))
if(LAZYACCESS(modifiers, CTRL_CLICK))
CtrlShiftClickOn(A)
return
ShiftClickOn(A)
return
if(LAZYACCESS(modifiers, ALT_CLICK)) // alt and alt-gr (rightalt)
AltClickOn(A)
return
if(LAZYACCESS(modifiers, CTRL_CLICK))
CtrlClickOn(A)
return
if(LAZYACCESS(modifiers, MIDDLE_CLICK))
MiddleClickOn(A, params)
return
if(LAZYACCESS(modifiers, RIGHT_CLICK))
var/secondary_result = A.attack_ai_secondary(src, modifiers)
if(secondary_result == SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN || secondary_result == SECONDARY_ATTACK_CONTINUE_CHAIN)
return
else if(secondary_result != SECONDARY_ATTACK_CALL_NORMAL)
CRASH("attack_ai_secondary did not return a SECONDARY_ATTACK_* define.")
if(world.time <= next_move)
return
if(waypoint_mode)
waypoint_mode = 0
set_waypoint(A)
return
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, proximity_flag, list/modifiers)
A.attack_ai(src)
/mob/living/silicon/ai/RangedAttack(atom/A)
A.attack_ai(src)
/atom/proc/attack_ai(mob/user)
return
/**
* What happens when the AI holds right-click on an item. Returns a SECONDARY_ATTACK_* value.
*
* Arguments:
* * user The mob holding the right click
* * modifiers The list of the custom click modifiers
*/
/atom/proc/attack_ai_secondary(mob/user, list/modifiers)
return SECONDARY_ATTACK_CALL_NORMAL
/*
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/CtrlShiftClickOn(atom/A)
A.AICtrlShiftClick(src)
/mob/living/silicon/ai/ShiftClickOn(atom/A)
if(A.AIShiftClick(src))
return
return ..()
/mob/living/silicon/ai/CtrlClickOn(atom/A, list/params)
A.AICtrlClick(src)
/mob/living/silicon/ai/AltClickOn(atom/A)
A.AIAltClick(src)
/*
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.
*/
/* Questions: Instead of an Emag check on every function, can we not add to airlocks onclick if emag return? */
/* Atom Procs */
/atom/proc/AICtrlClick()
return FALSE
/atom/proc/AIAltClick(mob/living/silicon/ai/user)
AltClick(user)
return
/atom/proc/AIShiftClick()
return
/atom/proc/AICtrlShiftClick()
return
/* Airlocks */
/obj/machinery/door/airlock/AICtrlClick() // Bolts doors
if(obj_flags & EMAGGED)
return
toggle_bolt(usr)
log_touch(usr)
/obj/machinery/door/airlock/AIAltClick() // Eletrifies doors.
if(obj_flags & EMAGGED)
return
if(!secondsElectrified)
shock_perm(usr)
else
shock_restore(usr)
/obj/machinery/door/airlock/AIShiftClick() // Opens and closes doors!
if(obj_flags & EMAGGED)
return FALSE
user_toggle_open(usr)
log_touch(usr)
return TRUE
/obj/machinery/door/airlock/AICtrlShiftClick() // Sets/Unsets Emergency Access Override
if(obj_flags & EMAGGED)
return
toggle_emergency(usr)
log_touch(usr)
/* APC */
/obj/machinery/power/apc/AICtrlClick() // turns off/on APCs.
if(can_use(usr, 1))
toggle_breaker(usr)
/* AI Turrets */
/obj/machinery/turretid/AIAltClick() //toggles lethal on turrets
if(ailock)
return
toggle_lethal(usr)
/obj/machinery/turretid/AICtrlClick() //turns off/on Turrets
if(ailock)
return
toggle_on(usr)
/* Holopads */
/obj/machinery/holopad/AIAltClick(mob/living/silicon/ai/user)
hangup_all_calls()
log_touch(usr)
//
// Override TurfAdjacent for AltClicking
//
/mob/living/silicon/ai/TurfAdjacent(turf/T)
return (GLOB.cameranet && GLOB.cameranet.checkTurfVis(T))