/
other_mobs.dm
308 lines (247 loc) · 10.7 KB
/
other_mobs.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/// Checks for RIGHT_CLICK in modifiers and runs resolve_right_click_attack if so. Returns TRUE if normal chain blocked.
/mob/living/proc/right_click_attack_chain(atom/target, list/modifiers)
if (!LAZYACCESS(modifiers, RIGHT_CLICK))
return
var/secondary_result = resolve_right_click_attack(target, modifiers)
if (secondary_result == SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN || secondary_result == SECONDARY_ATTACK_CONTINUE_CHAIN)
return TRUE
else if (secondary_result != SECONDARY_ATTACK_CALL_NORMAL)
CRASH("resolve_right_click_attack (probably attack_hand_secondary) did not return a SECONDARY_ATTACK_* define.")
/**
* Checks if this mob is in a valid state to punch someone.
*
* (Potentially) gives feedback to the mob if they cannot.
*/
/mob/living/proc/can_unarmed_attack()
return !HAS_TRAIT(src, TRAIT_HANDS_BLOCKED)
/mob/living/carbon/can_unarmed_attack()
. = ..()
if(!.)
return FALSE
if(!has_active_hand()) //can't attack without a hand.
var/obj/item/bodypart/check_arm = get_active_hand()
if(check_arm?.bodypart_disabled)
to_chat(src, span_warning("Your [check_arm.name] is in no condition to be used."))
return FALSE
to_chat(src, span_notice("You look at your arm and sigh."))
return FALSE
return TRUE
/mob/living/UnarmedAttack(atom/attack_target, proximity_flag, list/modifiers)
// The sole reason for this signal needing to exist is making FotNS incompatible with Hulk.
// Note that it is send before [proc/can_unarmed_attack] is called, keep this in mind.
var/sigreturn = SEND_SIGNAL(src, COMSIG_LIVING_EARLY_UNARMED_ATTACK, attack_target, proximity_flag, modifiers)
if(sigreturn & COMPONENT_CANCEL_ATTACK_CHAIN)
return TRUE
if(sigreturn & COMPONENT_SKIP_ATTACK)
return FALSE
if(!can_unarmed_attack())
return FALSE
sigreturn = SEND_SIGNAL(src, COMSIG_LIVING_UNARMED_ATTACK, attack_target, proximity_flag, modifiers)
if(sigreturn & COMPONENT_CANCEL_ATTACK_CHAIN)
return TRUE
if(sigreturn & COMPONENT_SKIP_ATTACK)
return FALSE
if(!right_click_attack_chain(attack_target, modifiers))
resolve_unarmed_attack(attack_target, modifiers)
return TRUE
/mob/living/carbon/human/UnarmedAttack(atom/attack_target, proximity_flag, list/modifiers)
// Humans can always check themself regardless of having their hands blocked or w/e
if(src == attack_target && !combat_mode && HAS_TRAIT(src, TRAIT_HANDS_BLOCKED))
check_self_for_injuries()
return TRUE
return ..()
/mob/living/carbon/resolve_unarmed_attack(atom/attack_target, list/modifiers)
return attack_target.attack_paw(src, modifiers)
/mob/living/carbon/human/resolve_unarmed_attack(atom/attack_target, list/modifiers)
if(!ISADVANCEDTOOLUSER(src))
return ..()
return attack_target.attack_hand(src, modifiers)
/mob/living/carbon/human/resolve_right_click_attack(atom/target, list/modifiers)
return target.attack_hand_secondary(src, modifiers)
/// Return TRUE to cancel other attack hand effects that respect it. Modifiers is the assoc list for click info such as if it was a right click.
/atom/proc/attack_hand(mob/user, list/modifiers)
. = FALSE
if(!(interaction_flags_atom & INTERACT_ATOM_NO_FINGERPRINT_ATTACK_HAND))
add_fingerprint(user)
if(SEND_SIGNAL(src, COMSIG_ATOM_ATTACK_HAND, user, modifiers) & COMPONENT_CANCEL_ATTACK_CHAIN)
. = TRUE
if(interaction_flags_atom & INTERACT_ATOM_ATTACK_HAND)
. = _try_interact(user)
/// When the user uses their hand on an item while holding right-click
/// Returns a SECONDARY_ATTACK_* value.
/atom/proc/attack_hand_secondary(mob/user, list/modifiers)
if(SEND_SIGNAL(src, COMSIG_ATOM_ATTACK_HAND_SECONDARY, user, modifiers) & COMPONENT_CANCEL_ATTACK_CHAIN)
return SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN
return SECONDARY_ATTACK_CALL_NORMAL
//Return a non FALSE value to cancel whatever called this from propagating, if it respects it.
/atom/proc/_try_interact(mob/user)
if(isAdminGhostAI(user)) //admin abuse
return interact(user)
if(can_interact(user))
return interact(user)
return FALSE
/atom/proc/can_interact(mob/user, require_adjacent_turf = TRUE)
if(!user.can_interact_with(src, interaction_flags_atom & INTERACT_ATOM_ALLOW_USER_LOCATION))
return FALSE
if((interaction_flags_atom & INTERACT_ATOM_REQUIRES_DEXTERITY) && !ISADVANCEDTOOLUSER(user))
to_chat(user, span_warning("You don't have the dexterity to do this!"))
return FALSE
if(!(interaction_flags_atom & INTERACT_ATOM_IGNORE_INCAPACITATED))
var/ignore_flags = NONE
if(interaction_flags_atom & INTERACT_ATOM_IGNORE_RESTRAINED)
ignore_flags |= IGNORE_RESTRAINTS
if(!(interaction_flags_atom & INTERACT_ATOM_CHECK_GRAB))
ignore_flags |= IGNORE_GRAB
if(user.incapacitated(ignore_flags))
return FALSE
return TRUE
/atom/ui_status(mob/user, datum/ui_state/state)
. = ..()
//Check if both user and atom are at the same location
if(!can_interact(user))
. = min(., UI_UPDATE)
/atom/movable/can_interact(mob/user)
. = ..()
if(!.)
return
if(!anchored && (interaction_flags_atom & INTERACT_ATOM_REQUIRES_ANCHORED))
return FALSE
/atom/proc/interact(mob/user)
if(interaction_flags_atom & INTERACT_ATOM_NO_FINGERPRINT_INTERACT)
add_hiddenprint(user)
else
add_fingerprint(user)
if(interaction_flags_atom & INTERACT_ATOM_UI_INTERACT)
SEND_SIGNAL(src, COMSIG_ATOM_UI_INTERACT, user)
return ui_interact(user)
return FALSE
/mob/living/carbon/human/RangedAttack(atom/A, modifiers)
. = ..()
if(.)
return
if(isturf(A) && get_dist(src,A) <= 1)
Move_Pulled(A)
return TRUE
/*
Animals & All Unspecified
*/
/**
* Called when the unarmed attack hasn't been stopped by the LIVING_UNARMED_ATTACK_BLOCKED macro or the right_click_attack_chain proc.
* This will call an attack proc that can vary from mob type to mob type on the target.
*/
/mob/living/proc/resolve_unarmed_attack(atom/attack_target, list/modifiers)
attack_target.attack_animal(src, modifiers)
/**
* Called when an unarmed attack performed with right click hasn't been stopped by the LIVING_UNARMED_ATTACK_BLOCKED macro.
* This will call a secondary attack proc that can vary from mob type to mob type on the target.
* Sometimes, a target is interacted differently when right_clicked, in that case the secondary attack proc should return
* a SECONDARY_ATTACK_* value that's not SECONDARY_ATTACK_CALL_NORMAL.
* Otherwise, it should just return SECONDARY_ATTACK_CALL_NORMAL. Failure to do so will result in an exception (runtime error).
*/
/mob/living/proc/resolve_right_click_attack(atom/target, list/modifiers)
return target.attack_animal_secondary(src, modifiers)
/**
* Called when a simple animal is unarmed attacking / clicking on this atom.
*/
/atom/proc/attack_animal(mob/user, list/modifiers)
SEND_SIGNAL(src, COMSIG_ATOM_ATTACK_ANIMAL, user)
/**
* Called when a simple animal or basic mob right clicks an atom.
* Returns a SECONDARY_ATTACK_* value.
*/
/atom/proc/attack_animal_secondary(mob/user, list/modifiers)
return SECONDARY_ATTACK_CALL_NORMAL
///When a basic mob attacks something, either by AI or user.
/atom/proc/attack_basic_mob(mob/user, list/modifiers)
SHOULD_CALL_PARENT(TRUE)
SEND_SIGNAL(src, COMSIG_ATOM_ATTACK_BASIC_MOB, user)
return handle_basic_attack(user, modifiers) //return value of attack animal, this is how much damage was dealt to the attacked thing
///This exists so stuff can override the default call of attack_animal for attack_basic_mob
///Remove this when simple animals are removed and everything can be handled on attack basic mob.
/atom/proc/handle_basic_attack(user, modifiers)
return attack_animal(user, modifiers)
///Attacked by monkey. It doesn't need its own *_secondary proc as it just uses attack_hand_secondary instead.
/atom/proc/attack_paw(mob/user, list/modifiers)
if(SEND_SIGNAL(src, COMSIG_ATOM_ATTACK_PAW, user, modifiers) & COMPONENT_CANCEL_ATTACK_CHAIN)
return TRUE
return FALSE
/*
Aliens
Defaults to same as monkey in most places
*/
/mob/living/carbon/alien/resolve_unarmed_attack(atom/attack_target, list/modifiers)
attack_target.attack_alien(src, modifiers)
/mob/living/carbon/alien/resolve_right_click_attack(atom/target, list/modifiers)
return target.attack_alien_secondary(src, modifiers)
/atom/proc/attack_alien(mob/living/carbon/alien/user, list/modifiers)
return attack_paw(user, modifiers)
/**
* Called when an alien right clicks an atom.
* Returns a SECONDARY_ATTACK_* value.
*/
/atom/proc/attack_alien_secondary(mob/living/carbon/alien/user, list/modifiers)
return SECONDARY_ATTACK_CALL_NORMAL
// Babby aliens
/mob/living/carbon/alien/larva/resolve_unarmed_attack(atom/attack_target, list/modifiers)
attack_target.attack_larva(src, modifiers)
/mob/living/carbon/alien/larva/resolve_right_click_attack(atom/target, list/modifiers)
return target.attack_larva_secondary(src, modifiers)
/mob/living/carbon/alien/larva/can_unarmed_attack() //We bite stuff, and our head is always free.
return TRUE
/atom/proc/attack_larva(mob/user, list/modifiers)
return
/**
* Called when an alien larva right clicks an atom.
* Returns a SECONDARY_ATTACK_* value.
*/
/atom/proc/attack_larva_secondary(mob/user, list/modifiers)
return SECONDARY_ATTACK_CALL_NORMAL
/*
Drones
*/
/mob/living/basic/drone/resolve_unarmed_attack(atom/attack_target, proximity_flag, list/modifiers)
attack_target.attack_drone(src, modifiers)
/mob/living/basic/drone/resolve_right_click_attack(atom/target, list/modifiers)
return target.attack_drone_secondary(src, modifiers)
/// Defaults to attack_hand. Override it when you don't want drones to do same stuff as humans.
/atom/proc/attack_drone(mob/living/basic/drone/user, list/modifiers)
attack_hand(user, modifiers)
/**
* Called when a maintenance drone right clicks an atom.
* Defaults to attack_hand_secondary.
* When overriding it, remember that it ought to return a SECONDARY_ATTACK_* value.
*/
/atom/proc/attack_drone_secondary(mob/living/basic/drone/user, list/modifiers)
return attack_hand_secondary(user, modifiers)
/*
Brain
*/
/mob/living/brain/UnarmedAttack(atom/attack_target, proximity_flag, list/modifiers)//Stops runtimes due to attack_animal being the default
return
/*
pAI
*/
/mob/living/silicon/pai/resolve_unarmed_attack(atom/attack_target, list/modifiers)
attack_target.attack_pai(src, modifiers)
/mob/living/silicon/pai/resolve_right_click_attack(atom/target, list/modifiers)
return target.attack_pai_secondary(src, modifiers)
/atom/proc/attack_pai(mob/user, list/modifiers)
return
/**
* Called when a pAI right clicks an atom.
* Returns a SECONDARY_ATTACK_* value.
*/
/atom/proc/attack_pai_secondary(mob/user, list/modifiers)
return SECONDARY_ATTACK_CALL_NORMAL
/*
Hostile animals
*/
/mob/living/simple_animal/hostile/resolve_unarmed_attack(atom/attack_target, list/modifiers)
GiveTarget(attack_target)
INVOKE_ASYNC(src, PROC_REF(AttackingTarget), attack_target)
/*
New Players:
Have no reason to click on anything at all.
*/
/mob/dead/new_player/ClickOn()
return