-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathcyborg.dm
187 lines (152 loc) · 5.49 KB
/
cyborg.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
/*
Cyborg ClickOn()
Cyborgs have no range restriction on attack_robot(), because it is basically an AI click.
However, they do have a range restriction on item use, so they cannot do without the
adjacency code.
*/
/mob/living/silicon/robot/ClickOn(atom/A, params)
if(world.time <= next_click)
return
next_click = world.time + 1
if(check_click_intercept(params,A))
return
if(stat || (lockcharge) || IsParalyzed() || IsStun())
return
var/list/modifiers = params2list(params)
if(LAZYACCESS(modifiers, SHIFT_CLICK))
if(LAZYACCESS(modifiers, CTRL_CLICK))
CtrlShiftClickOn(A)
return
if(LAZYACCESS(modifiers, MIDDLE_CLICK))
ShiftMiddleClickOn(A)
return
ShiftClickOn(A)
return
if(LAZYACCESS(modifiers, MIDDLE_CLICK))
MiddleClickOn(A, params)
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, RIGHT_CLICK) && !module_active)
var/secondary_result = A.attack_robot_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_robot_secondary did not return a SECONDARY_ATTACK_* define.")
if(next_move >= world.time)
return
face_atom(A) // change direction to face what you clicked on
var/obj/item/W = get_active_held_item()
if(!W && get_dist(src,A) <= interaction_range)
A.attack_robot(src)
return
if(W)
if(incapacitated())
return
//while buckled, you can still connect to and control things like doors, but you can't use your modules
if(buckled)
to_chat(src, span_warning("You can't use modules while buckled to [buckled]!"))
return
//if your "hands" are blocked you shouldn't be able to use modules
if(HAS_TRAIT(src, TRAIT_HANDS_BLOCKED))
return
if(W == A)
W.attack_self(src)
return
// cyborgs are prohibited from using storage items so we can I think safely remove (A.loc in contents)
if(A == loc || (A in loc) || (A in contents))
W.melee_attack_chain(src, A, params)
return
if(!isturf(loc))
return
// cyborgs are prohibited from using storage items so we can I think safely remove (A.loc && isturf(A.loc.loc))
if(isturf(A) || isturf(A.loc))
if(A.Adjacent(src)) // see adjacent.dm
W.melee_attack_chain(src, A, params)
return
else
W.afterattack(A, src, 0, params)
return
//Give cyborgs hotkey clicks without breaking existing uses of hotkey clicks
// for non-doors/apcs
/mob/living/silicon/robot/CtrlShiftClickOn(atom/A)
A.BorgCtrlShiftClick(src)
/mob/living/silicon/robot/ShiftClickOn(atom/A)
A.BorgShiftClick(src)
/mob/living/silicon/robot/CtrlClickOn(atom/A, list/params)
A.BorgCtrlClick(src)
/mob/living/silicon/robot/AltClickOn(atom/A)
A.BorgAltClick(src)
/atom/proc/BorgCtrlShiftClick(mob/living/silicon/robot/user) //forward to human click if not overridden
CtrlShiftClick(user)
/obj/machinery/door/airlock/BorgCtrlShiftClick(mob/living/silicon/robot/user) // Sets/Unsets Emergency Access Override Forwards to AI code.
if(get_dist(src,user) <= user.interaction_range)
AICtrlShiftClick()
else
..()
/atom/proc/BorgShiftClick(mob/living/silicon/robot/user) //forward to human click if not overridden
ShiftClick(user)
/obj/machinery/door/airlock/BorgShiftClick(mob/living/silicon/robot/user) // Opens and closes doors! Forwards to AI code.
if(get_dist(src,user) <= user.interaction_range)
AIShiftClick()
else
..()
/atom/proc/BorgCtrlClick(mob/living/silicon/robot/user) //forward to human click if not overridden
CtrlClick(user)
/obj/machinery/door/airlock/BorgCtrlClick(mob/living/silicon/robot/user) // Bolts doors. Forwards to AI code.
if(get_dist(src,user) <= user.interaction_range)
AICtrlClick()
else
..()
/obj/machinery/power/apc/BorgCtrlClick(mob/living/silicon/robot/user) // turns off/on APCs. Forwards to AI code.
if(get_dist(src,user) <= user.interaction_range)
AICtrlClick()
else
..()
/obj/machinery/turretid/BorgCtrlClick(mob/living/silicon/robot/user) //turret control on/off. Forwards to AI code.
if(get_dist(src,user) <= user.interaction_range)
AICtrlClick()
else
..()
/atom/proc/BorgAltClick(mob/living/silicon/robot/user)
AltClick(user)
return
/obj/machinery/door/airlock/BorgAltClick(mob/living/silicon/robot/user) // Eletrifies doors. Forwards to AI code.
if(get_dist(src,user) <= user.interaction_range)
AIAltClick()
else
..()
/obj/machinery/turretid/BorgAltClick(mob/living/silicon/robot/user) //turret lethal on/off. Forwards to AI code.
if(get_dist(src,user) <= user.interaction_range)
AIAltClick()
else
..()
/*
As with AI, these are not used in click code,
because the code for robots is specific, not generic.
If you would like to add advanced features to robot
clicks, you can do so here, but you will have to
change attack_robot() above to the proper function
*/
/mob/living/silicon/robot/UnarmedAttack(atom/A, proximity_flag, list/modifiers)
if(!can_unarmed_attack())
return
A.attack_robot(src)
/mob/living/silicon/robot/RangedAttack(atom/A)
A.attack_robot(src)
/atom/proc/attack_robot(mob/user)
attack_ai(user)
return
/**
* What happens when the cyborg without active module 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_robot_secondary(mob/user, list/modifiers)
return attack_ai_secondary(user, modifiers)