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
/
living_defense.dm
453 lines (398 loc) · 18.6 KB
/
living_defense.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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
/mob/living/proc/run_armor_check(def_zone = null, attack_flag = "melee", absorb_text = null, soften_text = null, armour_penetration, penetrated_text, silent=FALSE)
var/armor = getarmor(def_zone, attack_flag)
if(armor <= 0)
return armor
if(silent)
return max(0, armor - armour_penetration)
//the if "armor" check is because this is used for everything on /living, including humans
if(armour_penetration)
armor = max(0, armor - armour_penetration)
if(penetrated_text)
to_chat(src, "<span class='userdanger'>[penetrated_text]</span>")
else
to_chat(src, "<span class='userdanger'>Your armor was penetrated!</span>")
else if(armor >= 100)
if(absorb_text)
to_chat(src, "<span class='notice'>[absorb_text]</span>")
else
to_chat(src, "<span class='notice'>Your armor absorbs the blow!</span>")
else
if(soften_text)
to_chat(src, "<span class='warning'>[soften_text]</span>")
else
to_chat(src, "<span class='warning'>Your armor softens the blow!</span>")
return armor
/mob/living/proc/getarmor(def_zone, type)
return 0
//this returns the mob's protection against eye damage (number between -1 and 2) from bright lights
/mob/living/proc/get_eye_protection()
return 0
//this returns the mob's protection against ear damage (0:no protection; 1: some ear protection; 2: has no ears)
/mob/living/proc/get_ear_protection()
return 0
/mob/living/proc/is_mouth_covered(head_only = 0, mask_only = 0)
return FALSE
/mob/living/proc/is_eyes_covered(check_glasses = 1, check_head = 1, check_mask = 1)
return FALSE
/mob/living/proc/is_pepper_proof(check_head = TRUE, check_mask = TRUE)
return FALSE
/mob/living/proc/on_hit(obj/projectile/P)
return BULLET_ACT_HIT
/mob/living/bullet_act(obj/projectile/P, def_zone)
var/armor = run_armor_check(def_zone, P.flag, "","",P.armour_penetration)
var/on_hit_state = P.on_hit(src, armor)
if(!P.nodamage && on_hit_state != BULLET_ACT_BLOCK)
apply_damage(P.damage, P.damage_type, def_zone, armor, wound_bonus=P.wound_bonus, bare_wound_bonus=P.bare_wound_bonus, sharpness = P.sharpness)
apply_effects(P.stun, P.knockdown, P.unconscious, P.irradiate, P.slur, P.stutter, P.eyeblur, P.drowsy, armor, P.stamina, P.jitter, P.paralyze, P.immobilize)
if(P.dismemberment)
check_projectile_dismemberment(P, def_zone)
return on_hit_state ? BULLET_ACT_HIT : BULLET_ACT_BLOCK
/mob/living/proc/check_projectile_dismemberment(obj/projectile/P, def_zone)
return 0
/obj/item/proc/get_volume_by_throwforce_and_or_w_class()
if(throwforce && w_class)
return clamp((throwforce + w_class) * 5, 30, 100)// Add the item's throwforce to its weight class and multiply by 5, then clamp the value between 30 and 100
else if(w_class)
return clamp(w_class * 8, 20, 100) // Multiply the item's weight class by 8, then clamp the value between 20 and 100
else
return 0
/mob/living/hitby(atom/movable/AM, skipcatch, hitpush = TRUE, blocked = FALSE, datum/thrownthing/throwingdatum)
if(istype(AM, /obj/item))
var/obj/item/I = AM
var/zone = ran_zone(BODY_ZONE_CHEST, 65)//Hits a random part of the body, geared towards the chest
var/dtype = BRUTE
var/nosell_hit = SEND_SIGNAL(I, COMSIG_MOVABLE_IMPACT_ZONE, src, zone, throwingdatum) // TODO: find a better way to handle hitpush and skipcatch for humans
if(nosell_hit)
skipcatch = TRUE
hitpush = FALSE
dtype = I.damtype
if(!blocked)
if(I.thrownby)
log_combat(I.thrownby, src, "threw and hit", I)
if(!nosell_hit)
visible_message("<span class='danger'>[src] is hit by [I]!</span>", \
"<span class='userdanger'>You're hit by [I]!</span>")
if(!I.throwforce)
return
var/armor = run_armor_check(zone, "melee", "Your armor has protected your [parse_zone(zone)].", "Your armor has softened hit to your [parse_zone(zone)].",I.armour_penetration)
apply_damage(I.throwforce, dtype, zone, armor, sharpness=I.get_sharpness(), wound_bonus=(nosell_hit * CANT_WOUND))
else
return 1
else
playsound(loc, 'sound/weapons/genhit.ogg', 50, TRUE, -1) //Item sounds are handled in the item itself
..()
/mob/living/mech_melee_attack(obj/mecha/M)
if(M.occupant.a_intent == INTENT_HARM)
if(HAS_TRAIT(M.occupant, TRAIT_PACIFISM))
to_chat(M.occupant, "<span class='warning'>You don't want to harm other living beings!</span>")
return
M.do_attack_animation(src)
if(M.damtype == "brute")
step_away(src,M,15)
switch(M.damtype)
if(BRUTE)
Unconscious(20)
take_overall_damage(rand(M.force/2, M.force))
playsound(src, 'sound/weapons/punch4.ogg', 50, TRUE)
if(BURN)
take_overall_damage(0, rand(M.force/2, M.force))
playsound(src, 'sound/items/welder.ogg', 50, TRUE)
if(TOX)
M.mech_toxin_damage(src)
else
return
updatehealth()
visible_message("<span class='danger'>[M.name] hits [src]!</span>", \
"<span class='userdanger'>[M.name] hits you!</span>", "<span class='hear'>You hear a sickening sound of flesh hitting flesh!</span>", COMBAT_MESSAGE_RANGE, M)
to_chat(M, "<span class='danger'>You hit [src]!</span>")
log_combat(M.occupant, src, "attacked", M, "(INTENT: [uppertext(M.occupant.a_intent)]) (DAMTYPE: [uppertext(M.damtype)])")
else
step_away(src,M)
log_combat(M.occupant, src, "pushed", M)
visible_message("<span class='warning'>[M] pushes [src] out of the way.</span>", \
"<span class='warning'>[M] pushes you out of the way.</span>", "<span class='hear'>You hear aggressive shuffling!</span>", 5, M)
to_chat(M, "<span class='danger'>You push [src] out of the way.</span>")
/mob/living/fire_act()
adjust_fire_stacks(3)
IgniteMob()
/mob/living/proc/grabbedby(mob/living/carbon/user, supress_message = FALSE)
if(user == src || anchored || !isturf(user.loc))
return FALSE
if(!user.pulling || user.pulling != src)
user.start_pulling(src, supress_message = supress_message)
return
if(!(status_flags & CANPUSH) || HAS_TRAIT(src, TRAIT_PUSHIMMUNE))
to_chat(user, "<span class='warning'>[src] can't be grabbed more aggressively!</span>")
return FALSE
if(user.grab_state >= GRAB_AGGRESSIVE && HAS_TRAIT(user, TRAIT_PACIFISM))
to_chat(user, "<span class='warning'>You don't want to risk hurting [src]!</span>")
return FALSE
grippedby(user)
//proc to upgrade a simple pull into a more aggressive grab.
/mob/living/proc/grippedby(mob/living/carbon/user, instant = FALSE)
if(user.grab_state < GRAB_KILL)
user.changeNext_move(CLICK_CD_GRABBING)
var/sound_to_play = 'sound/weapons/thudswoosh.ogg'
if(ishuman(user))
var/mob/living/carbon/human/H = user
if(H.dna.species.grab_sound)
sound_to_play = H.dna.species.grab_sound
playsound(src.loc, sound_to_play, 50, TRUE, -1)
if(user.grab_state) //only the first upgrade is instantaneous
var/old_grab_state = user.grab_state
var/grab_upgrade_time = instant ? 0 : 30
visible_message("<span class='danger'>[user] starts to tighten [user.p_their()] grip on [src]!</span>", \
"<span class='userdanger'>[user] starts to tighten [user.p_their()] grip on you!</span>", "<span class='hear'>You hear aggressive shuffling!</span>", null, user)
to_chat(user, "<span class='danger'>You start to tighten your grip on [src]!</span>")
switch(user.grab_state)
if(GRAB_AGGRESSIVE)
log_combat(user, src, "attempted to neck grab", addition="neck grab")
if(GRAB_NECK)
log_combat(user, src, "attempted to strangle", addition="kill grab")
if(!do_mob(user, src, grab_upgrade_time))
return 0
if(!user.pulling || user.pulling != src || user.grab_state != old_grab_state)
return 0
if(user.a_intent != INTENT_GRAB)
to_chat(user, "<span class='warning'>You must be on grab intent to upgrade your grab further!</span>")
return 0
user.setGrabState(user.grab_state + 1)
switch(user.grab_state)
if(GRAB_AGGRESSIVE)
var/add_log = ""
if(HAS_TRAIT(user, TRAIT_PACIFISM))
visible_message("<span class='danger'>[user] firmly grips [src]!</span>",
"<span class='danger'>[user] firmly grips you!</span>", "<span class='hear'>You hear aggressive shuffling!</span>", null, user)
to_chat(user, "<span class='danger'>You firmly grip [src]!</span>")
add_log = " (pacifist)"
else
visible_message("<span class='danger'>[user] grabs [src] aggressively!</span>", \
"<span class='userdanger'>[user] grabs you aggressively!</span>", "<span class='hear'>You hear aggressive shuffling!</span>", null, user)
to_chat(user, "<span class='danger'>You grab [src] aggressively!</span>")
drop_all_held_items()
stop_pulling()
log_combat(user, src, "grabbed", addition="aggressive grab[add_log]")
if(GRAB_NECK)
log_combat(user, src, "grabbed", addition="neck grab")
visible_message("<span class='danger'>[user] grabs [src] by the neck!</span>",\
"<span class='userdanger'>[user] grabs you by the neck!</span>", "<span class='hear'>You hear aggressive shuffling!</span>", null, user)
to_chat(user, "<span class='danger'>You grab [src] by the neck!</span>")
if(!buckled && !density)
Move(user.loc)
if(GRAB_KILL)
log_combat(user, src, "strangled", addition="kill grab")
visible_message("<span class='danger'>[user] is strangling [src]!</span>", \
"<span class='userdanger'>[user] is strangling you!</span>", "<span class='hear'>You hear aggressive shuffling!</span>", null, user)
to_chat(user, "<span class='danger'>You're strangling [src]!</span>")
if(!buckled && !density)
Move(user.loc)
user.set_pull_offsets(src, grab_state)
return 1
/mob/living/attack_slime(mob/living/simple_animal/slime/M)
if(!SSticker.HasRoundStarted())
to_chat(M, "You cannot attack people before the game has started.")
return
if(M.buckled)
if(M in buckled_mobs)
M.Feedstop()
return // can't attack while eating!
if(HAS_TRAIT(src, TRAIT_PACIFISM))
to_chat(M, "<span class='warning'>You don't want to hurt anyone!</span>")
return FALSE
if (stat != DEAD)
log_combat(M, src, "attacked")
M.do_attack_animation(src)
visible_message("<span class='danger'>\The [M.name] glomps [src]!</span>", \
"<span class='userdanger'>\The [M.name] glomps you!</span>", "<span class='hear'>You hear a sickening sound of flesh hitting flesh!</span>", COMBAT_MESSAGE_RANGE, M)
to_chat(M, "<span class='danger'>You glomp [src]!</span>")
return TRUE
/mob/living/attack_animal(mob/living/simple_animal/M)
M.face_atom(src)
if(M.melee_damage_upper == 0)
visible_message("<span class='notice'>\The [M] [M.friendly_verb_continuous] [src]!</span>", \
"<span class='notice'>\The [M] [M.friendly_verb_continuous] you!</span>", null, COMBAT_MESSAGE_RANGE, M)
to_chat(M, "<span class='notice'>You [M.friendly_verb_simple] [src]!</span>")
return FALSE
if(HAS_TRAIT(M, TRAIT_PACIFISM))
to_chat(M, "<span class='warning'>You don't want to hurt anyone!</span>")
return FALSE
if(M.attack_sound)
playsound(loc, M.attack_sound, 50, TRUE, TRUE)
M.do_attack_animation(src)
visible_message("<span class='danger'>\The [M] [M.attack_verb_continuous] [src]!</span>", \
"<span class='userdanger'>\The [M] [M.attack_verb_continuous] you!</span>", null, COMBAT_MESSAGE_RANGE, M)
to_chat(M, "<span class='danger'>You [M.attack_verb_simple] [src]!</span>")
log_combat(M, src, "attacked")
return TRUE
/mob/living/attack_paw(mob/living/carbon/monkey/M)
if(isturf(loc) && istype(loc.loc, /area/start))
to_chat(M, "No attacking people at spawn, you jackass.")
return FALSE
if (M.a_intent == INTENT_HARM)
if(HAS_TRAIT(M, TRAIT_PACIFISM))
to_chat(M, "<span class='warning'>You don't want to hurt anyone!</span>")
return FALSE
if(M.is_muzzled() || M.is_mouth_covered(FALSE, TRUE))
to_chat(M, "<span class='warning'>You can't bite with your mouth covered!</span>")
return FALSE
M.do_attack_animation(src, ATTACK_EFFECT_BITE)
if (prob(75))
log_combat(M, src, "attacked")
playsound(loc, 'sound/weapons/bite.ogg', 50, TRUE, -1)
visible_message("<span class='danger'>[M.name] bites [src]!</span>", \
"<span class='userdanger'>[M.name] bites you!</span>", "<span class='hear'>You hear a chomp!</span>", COMBAT_MESSAGE_RANGE, M)
to_chat(M, "<span class='danger'>You bite [src]!</span>")
return TRUE
else
visible_message("<span class='danger'>[M.name]'s bite misses [src]!</span>", \
"<span class='danger'>You avoid [M.name]'s bite!</span>", "<span class='hear'>You hear the sound of jaws snapping shut!</span>", COMBAT_MESSAGE_RANGE, M)
to_chat(M, "<span class='warning'>Your bite misses [src]!</span>")
return FALSE
/mob/living/attack_larva(mob/living/carbon/alien/larva/L)
switch(L.a_intent)
if("help")
visible_message("<span class='notice'>[L.name] rubs its head against [src].</span>", \
"<span class='notice'>[L.name] rubs its head against you.</span>", null, null, L)
to_chat(L, "<span class='notice'>You rub your head against [src].</span>")
return FALSE
else
if(HAS_TRAIT(L, TRAIT_PACIFISM))
to_chat(L, "<span class='warning'>You don't want to hurt anyone!</span>")
return
L.do_attack_animation(src)
if(prob(90))
log_combat(L, src, "attacked")
visible_message("<span class='danger'>[L.name] bites [src]!</span>", \
"<span class='userdanger'>[L.name] bites you!</span>", "<span class='hear'>You hear a chomp!</span>", COMBAT_MESSAGE_RANGE, L)
to_chat(L, "<span class='danger'>You bite [src]!</span>")
playsound(loc, 'sound/weapons/bite.ogg', 50, TRUE, -1)
return TRUE
else
visible_message("<span class='danger'>[L.name]'s bite misses [src]!</span>", \
"<span class='danger'>You avoid [L.name]'s bite!</span>", "<span class='hear'>You hear the sound of jaws snapping shut!</span>", COMBAT_MESSAGE_RANGE, L)
to_chat(L, "<span class='warning'>Your bite misses [src]!</span>")
return FALSE
/mob/living/attack_alien(mob/living/carbon/alien/humanoid/M)
switch(M.a_intent)
if ("help")
visible_message("<span class='notice'>[M] caresses [src] with its scythe-like arm.</span>", \
"<span class='notice'>[M] caresses you with its scythe-like arm.</span>", null, null, M)
to_chat(M, "<span class='notice'>You caress [src] with your scythe-like arm.</span>")
return FALSE
if ("grab")
grabbedby(M)
return FALSE
if("harm")
if(HAS_TRAIT(M, TRAIT_PACIFISM))
to_chat(M, "<span class='warning'>You don't want to hurt anyone!</span>")
return FALSE
M.do_attack_animation(src)
return TRUE
if("disarm")
M.do_attack_animation(src, ATTACK_EFFECT_DISARM)
return TRUE
/mob/living/attack_hulk(mob/living/carbon/human/user)
..()
if(HAS_TRAIT(user, TRAIT_PACIFISM))
to_chat(user, "<span class='warning'>You don't want to hurt [src]!</span>")
return FALSE
return TRUE
/mob/living/ex_act(severity, target, origin)
if(origin && istype(origin, /datum/spacevine_mutation) && isvineimmune(src))
return
..()
//Looking for irradiate()? It's been moved to radiation.dm under the rad_act() for mobs.
/mob/living/acid_act(acidpwr, acid_volume)
take_bodypart_damage(acidpwr * min(1, acid_volume * 0.1))
return 1
///As the name suggests, this should be called to apply electric shocks.
/mob/living/proc/electrocute_act(shock_damage, source, siemens_coeff = 1, flags = NONE)
SEND_SIGNAL(src, COMSIG_LIVING_ELECTROCUTE_ACT, shock_damage, source, siemens_coeff, flags)
shock_damage *= siemens_coeff
if((flags & SHOCK_TESLA) && HAS_TRAIT(src, TRAIT_TESLA_SHOCKIMMUNE))
return FALSE
if(HAS_TRAIT(src, TRAIT_SHOCKIMMUNE))
return FALSE
if(shock_damage < 1)
return FALSE
if(!(flags & SHOCK_ILLUSION))
adjustFireLoss(shock_damage)
else
adjustStaminaLoss(shock_damage)
visible_message(
"<span class='danger'>[src] was shocked by \the [source]!</span>", \
"<span class='userdanger'>You feel a powerful shock coursing through your body!</span>", \
"<span class='hear'>You hear a heavy electrical crack.</span>" \
)
return shock_damage
/mob/living/emp_act(severity)
. = ..()
if(. & EMP_PROTECT_CONTENTS)
return
for(var/obj/O in contents)
O.emp_act(severity)
///Logs, gibs and returns point values of whatever mob is unfortunate enough to get eaten.
/mob/living/singularity_act()
investigate_log("([key_name(src)]) has been consumed by the singularity.", INVESTIGATE_SINGULO) //Oh that's where the clown ended up!
gib()
return 20
/mob/living/narsie_act()
if(status_flags & GODMODE || QDELETED(src))
return
if(GLOB.cult_narsie && GLOB.cult_narsie.souls_needed[src])
GLOB.cult_narsie.souls_needed -= src
GLOB.cult_narsie.souls += 1
if((GLOB.cult_narsie.souls == GLOB.cult_narsie.soul_goal) && (GLOB.cult_narsie.resolved == FALSE))
GLOB.cult_narsie.resolved = TRUE
sound_to_playing_players('sound/machines/alarm.ogg')
addtimer(CALLBACK(GLOBAL_PROC, .proc/cult_ending_helper, 1), 120)
addtimer(CALLBACK(GLOBAL_PROC, .proc/ending_helper), 270)
if(client)
makeNewConstruct(/mob/living/simple_animal/hostile/construct/harvester, src, cultoverride = TRUE)
else
switch(rand(1, 4))
if(1)
new /mob/living/simple_animal/hostile/construct/juggernaut/hostile(get_turf(src))
if(2)
new /mob/living/simple_animal/hostile/construct/wraith/hostile(get_turf(src))
if(3)
new /mob/living/simple_animal/hostile/construct/artificer/hostile(get_turf(src))
if(4)
new /mob/living/simple_animal/hostile/construct/proteon/hostile(get_turf(src))
spawn_dust()
gib()
return TRUE
//called when the mob receives a bright flash
/mob/living/proc/flash_act(intensity = 1, override_blindness_check = 0, affect_silicon = 0, visual = 0, type = /obj/screen/fullscreen/flash)
if(HAS_TRAIT(src, TRAIT_NOFLASH))
return FALSE
if(get_eye_protection() < intensity && (override_blindness_check || !is_blind()))
overlay_fullscreen("flash", type)
addtimer(CALLBACK(src, .proc/clear_fullscreen, "flash", 25), 25)
return TRUE
return FALSE
//called when the mob receives a loud bang
/mob/living/proc/soundbang_act()
return 0
//to damage the clothes worn by a mob
/mob/living/proc/damage_clothes(damage_amount, damage_type = BRUTE, damage_flag = 0, def_zone)
return
/mob/living/do_attack_animation(atom/A, visual_effect_icon, obj/item/used_item, no_effect)
if(!used_item)
used_item = get_active_held_item()
..()
setMovetype(movement_type & ~FLOATING) // If we were without gravity, the bouncing animation got stopped, so we make sure we restart the bouncing after the next movement.
/** Handles exposing a mob to reagents.
*
* If the method is INGEST the mob tastes the reagents.
* If the method is VAPOR it incorporates permiability protection.
*/
/mob/living/expose_reagents(list/reagents, datum/reagents/source, method=TOUCH, volume_modifier=1, show_message=TRUE)
if((. = ..()) & COMPONENT_NO_EXPOSE_REAGENTS)
return
if(method == INGEST)
taste(source)
var/touch_protection = (method == VAPOR) ? get_permeability_protection() : 0
for(var/reagent in reagents)
var/datum/reagent/R = reagent
. |= R.expose_mob(src, method, reagents[R], show_message, touch_protection)