/
simple_animal.dm
516 lines (419 loc) · 13.8 KB
/
simple_animal.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
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
/mob/living/simple_animal
name = "animal"
icon = 'icons/mob/animal.dmi'
health = 20
maxHealth = 20
var/icon_living = ""
var/icon_dead = ""
var/icon_gib = null //We only try to show a gibbing animation if this exists.
var/list/speak = list()
var/list/speak_emote = list()// Emotes while speaking IE: Ian [emote], [text] -- Ian barks, "WOOF!". Spoken text is generated from the speak variable.
var/speak_chance = 0
var/list/emote_hear = list() //Hearable emotes
var/list/emote_see = list() //Unlike speak_emote, the list of things in this variable only show by themselves with no spoken text. IE: Ian barks, Ian yaps
var/turns_per_move = 1
var/turns_since_move = 0
universal_speak = 1
var/meat_amount = 0
var/meat_type
var/stop_automated_movement = 0 //Use this to temporarely stop random movement or to if you write special movement code for animals.
var/wander = 1 // Does the mob wander around when idle?
var/stop_automated_movement_when_pulled = 1 //When set to 1 this stops the animal from moving when someone is pulling it.
//Interaction
var/response_help = "pokes"
var/response_disarm = "shoves"
var/response_harm = "hits"
var/harm_intent_damage = 3
//Temperature effect
var/minbodytemp = 250
var/maxbodytemp = 350
var/heat_damage_per_tick = 3 //amount of damage applied if animal's body temperature is higher than maxbodytemp
var/cold_damage_per_tick = 2 //same as heat_damage_per_tick, only if the bodytemperature it's lower than minbodytemp
//Atmos effect - Yes, you can make creatures that require plasma or co2 to survive. N2O is a trace gas and handled separately, hence why it isn't here. It'd be hard to add it. Hard and me don't mix (Yes, yes make all the dick jokes you want with that.) - Errorage
var/min_oxy = 5
var/max_oxy = 0 //Leaving something at 0 means it's off - has no maximum
var/min_tox = 0
var/max_tox = 1
var/min_co2 = 0
var/max_co2 = 5
var/min_n2 = 0
var/max_n2 = 0
var/unsuitable_atoms_damage = 2 //This damage is taken when atmos doesn't fit all the requirements above
//LETTING SIMPLE ANIMALS ATTACK? WHAT COULD GO WRONG. Defaults to zero so Ian can still be cuddly
var/melee_damage_lower = 0
var/melee_damage_upper = 0
var/attacktext = "attacks"
var/attack_sound = null
var/friendly = "nuzzles" //If the mob does no damage with it's attack
var/wall_smash = 0 //if they can smash walls
var/speed = 0 //LETS SEE IF I CAN SET SPEEDS FOR SIMPLE MOBS WITHOUT DESTROYING EVERYTHING. Higher speed is slower, negative speed is faster
//Hot simple_animal baby making vars
var/childtype = null
var/scan_ready = 1
var/species //Sorry, no spider+corgi buttbabies.
/mob/living/simple_animal/New()
..()
verbs -= /mob/verb/observe
if(!real_name)
real_name = name
/mob/living/simple_animal/Login()
if(src && src.client)
src.client.screen = null
..()
/mob/living/simple_animal/updatehealth()
return
/mob/living/simple_animal/Life()
//Health
if(stat == DEAD)
if(health > 0)
icon_state = icon_living
dead_mob_list -= src
living_mob_list += src
stat = CONSCIOUS
density = 1
update_canmove()
return 0
if(health < 1 && stat != DEAD)
Die()
if(health > maxHealth)
health = maxHealth
if(stunned)
AdjustStunned(-1)
if(weakened)
AdjustWeakened(-1)
if(paralysis)
AdjustParalysis(-1)
//Movement
if(!client && !stop_automated_movement && wander)
if(isturf(src.loc) && !resting && !buckled && canmove) //This is so it only moves if it's not inside a closet, gentics machine, etc.
turns_since_move++
if(turns_since_move >= turns_per_move)
if(!(stop_automated_movement_when_pulled && pulledby)) //Soma animals don't move when pulled
Move(get_step(src,pick(cardinal)))
turns_since_move = 0
//Speaking
if(!client && speak_chance)
if(rand(0,200) < speak_chance)
if(speak && speak.len)
if((emote_hear && emote_hear.len) || (emote_see && emote_see.len))
var/length = speak.len
if(emote_hear && emote_hear.len)
length += emote_hear.len
if(emote_see && emote_see.len)
length += emote_see.len
var/randomValue = rand(1,length)
if(randomValue <= speak.len)
say(pick(speak))
else
randomValue -= speak.len
if(emote_see && randomValue <= emote_see.len)
emote(pick(emote_see),1)
else
emote(pick(emote_hear),2)
else
say(pick(speak))
else
if(!(emote_hear && emote_hear.len) && (emote_see && emote_see.len))
emote(pick(emote_see),1)
if((emote_hear && emote_hear.len) && !(emote_see && emote_see.len))
emote(pick(emote_hear),2)
if((emote_hear && emote_hear.len) && (emote_see && emote_see.len))
var/length = emote_hear.len + emote_see.len
var/pick = rand(1,length)
if(pick <= emote_see.len)
emote(pick(emote_see),1)
else
emote(pick(emote_hear),2)
//Atmos
var/atmos_suitable = 1
var/atom/A = src.loc
if(isturf(A))
var/turf/T = A
var/areatemp = T.temperature
if( abs(areatemp - bodytemperature) > 40 )
var/diff = areatemp - bodytemperature
diff = diff / 5
//world << "changed from [bodytemperature] by [diff] to [bodytemperature + diff]"
bodytemperature += diff
if(istype(T,/turf/simulated))
var/turf/simulated/ST = T
if(ST.air)
var/tox = ST.air.toxins
var/oxy = ST.air.oxygen
var/n2 = ST.air.nitrogen
var/co2 = ST.air.carbon_dioxide
if(min_oxy)
if(oxy < min_oxy)
atmos_suitable = 0
if(max_oxy)
if(oxy > max_oxy)
atmos_suitable = 0
if(min_tox)
if(tox < min_tox)
atmos_suitable = 0
if(max_tox)
if(tox > max_tox)
atmos_suitable = 0
if(min_n2)
if(n2 < min_n2)
atmos_suitable = 0
if(max_n2)
if(n2 > max_n2)
atmos_suitable = 0
if(min_co2)
if(co2 < min_co2)
atmos_suitable = 0
if(max_co2)
if(co2 > max_co2)
atmos_suitable = 0
//Atmos effect
if(bodytemperature < minbodytemp)
adjustBruteLoss(cold_damage_per_tick)
else if(bodytemperature > maxbodytemp)
adjustBruteLoss(heat_damage_per_tick)
if(!atmos_suitable)
adjustBruteLoss(unsuitable_atoms_damage)
return 1
/mob/living/simple_animal/Bumped(AM as mob|obj)
if(!AM) return
if(resting || buckled)
return
if(isturf(src.loc))
if(ismob(AM))
var/newamloc = src.loc
src.loc = AM:loc
AM:loc = newamloc
else
..()
/mob/living/simple_animal/gib(var/animation = 0)
if(icon_gib)
flick(icon_gib, src)
if(meat_amount && meat_type)
for(var/i = 0; i < meat_amount; i++)
new meat_type(src.loc)
..()
/mob/living/simple_animal/blob_act()
adjustBruteLoss(20)
return
/mob/living/simple_animal/say_quote(var/text)
if(speak_emote && speak_emote.len)
var/emote = pick(speak_emote)
if(emote)
return "[emote], \"[text]\""
return "says, \"[text]\"";
/mob/living/simple_animal/emote(var/act)
if(stat)
return
if(act)
if(act == "scream") act = "makes a loud and pained whimper" //ugly hack to stop animals screaming when crushed :P
for (var/mob/O in viewers(src, null))
O.show_message("<B>[src]</B> [act].")
/mob/living/simple_animal/attack_animal(mob/living/simple_animal/M as mob)
if(M.melee_damage_upper == 0)
M.emote("[M.friendly] [src]")
else
if(M.attack_sound)
playsound(loc, M.attack_sound, 50, 1, 1)
for(var/mob/O in viewers(src, null))
O.show_message("\red <B>\The [M]</B> [M.attacktext] [src]!", 1)
add_logs(M, src, "attacked", admin=0)
var/damage = rand(M.melee_damage_lower, M.melee_damage_upper)
adjustBruteLoss(damage)
/mob/living/simple_animal/bullet_act(var/obj/item/projectile/Proj)
if(!Proj) return
adjustBruteLoss(Proj.damage)
Proj.on_hit(src, 0)
return 0
/mob/living/simple_animal/attack_hand(mob/living/carbon/human/M as mob)
..()
switch(M.a_intent)
if("help")
if (health > 0)
for(var/mob/O in viewers(src, null))
if ((O.client && !( O.blinded )))
O.show_message("\blue [M] [response_help] [src].")
if("grab")
if (M == src || anchored)
return
if (!(status_flags & CANPUSH))
return
var/obj/item/weapon/grab/G = new /obj/item/weapon/grab(M, src )
M.put_in_active_hand(G)
G.synch()
LAssailant = M
for(var/mob/O in viewers(src, null))
if ((O.client && !( O.blinded )))
O.show_message(text("\red [] has grabbed [] passively!", M, src), 1)
if("harm", "disarm")
adjustBruteLoss(harm_intent_damage)
for(var/mob/O in viewers(src, null))
if ((O.client && !( O.blinded )))
O.show_message("\red [M] [response_harm] [src]!")
return
/mob/living/simple_animal/attack_alien(mob/living/carbon/alien/humanoid/M as mob)
switch(M.a_intent)
if ("help")
for(var/mob/O in viewers(src, null))
if ((O.client && !( O.blinded )))
O.show_message(text("\blue [M] caresses [src] with its scythe like arm."), 1)
if ("grab")
if(M == src || anchored)
return
if(!(status_flags & CANPUSH))
return
var/obj/item/weapon/grab/G = new /obj/item/weapon/grab(M, src )
M.put_in_active_hand(G)
G.synch()
LAssailant = M
playsound(loc, 'sound/weapons/thudswoosh.ogg', 50, 1, -1)
for(var/mob/O in viewers(src, null))
if ((O.client && !( O.blinded )))
O.show_message(text("\red [] has grabbed [] passively!", M, src), 1)
if("harm", "disarm")
var/damage = rand(15, 30)
visible_message("\red <B>[M] has slashed at [src]!</B>")
adjustBruteLoss(damage)
return
/mob/living/simple_animal/attack_larva(mob/living/carbon/alien/larva/L as mob)
switch(L.a_intent)
if("help")
visible_message("\blue [L] rubs it's head against [src]")
else
var/damage = rand(5, 10)
visible_message("\red <B>[L] bites [src]!</B>")
if(stat != DEAD)
adjustBruteLoss(damage)
L.amount_grown = min(L.amount_grown + damage, L.max_grown)
/mob/living/simple_animal/attack_slime(mob/living/carbon/slime/M as mob)
if (!ticker)
M << "You cannot attack people before the game has started."
return
if(M.Victim) return // can't attack while eating!
visible_message("\red <B>[M.name] glomps [src]!</B>")
var/damage = rand(1, 3)
if(istype(src, /mob/living/carbon/slime/adult))
damage = rand(20, 40)
else
damage = rand(5, 35)
adjustBruteLoss(damage)
return
/mob/living/simple_animal/attackby(var/obj/item/O as obj, var/mob/user as mob) //Marker -Agouri
if(istype(O, /obj/item/stack/medical))
if(stat != DEAD)
var/obj/item/stack/medical/MED = O
if(health < maxHealth)
if(MED.amount >= 1)
if(MED.heal_brute >= 1)
adjustBruteLoss(-MED.heal_brute)
MED.amount -= 1
if(MED.amount <= 0)
del(MED)
for(var/mob/M in viewers(src, null))
if ((M.client && !( M.blinded )))
M.show_message("\blue [user] applies [MED] on [src]")
return
else
user << "\blue [MED] won't help at all."
return
else
user << "\blue [src] is at full health."
return
else
user << "\blue [src] is dead, medical items won't bring it back to life."
return
else if(meat_type && (stat == DEAD)) //if the animal has a meat, and if it is dead.
if(istype(O, /obj/item/weapon/kitchenknife) || istype(O, /obj/item/weapon/butch))
harvest()
else
if(O.force)
var/damage = O.force
if (O.damtype == HALLOSS)
damage = 0
adjustBruteLoss(damage)
for(var/mob/M in viewers(src, null))
if ((M.client && !( M.blinded )))
M.show_message("\red \b "+"[src] has been attacked with [O] by [user]. ")
else
usr << "\red This weapon is ineffective, it does no damage."
for(var/mob/M in viewers(src, null))
if ((M.client && !( M.blinded )))
M.show_message("\red [user] gently taps [src] with [O]. ")
/mob/living/simple_animal/movement_delay()
var/tally = 0 //Incase I need to add stuff other than "speed" later
tally = speed
return tally+config.animal_delay
/mob/living/simple_animal/Stat()
..()
statpanel("Status")
stat(null, "Health: [round((health / maxHealth) * 100)]%")
/mob/living/simple_animal/proc/Die()
dead_mob_list += src
icon_state = icon_dead
stat = DEAD
density = 0
return
/mob/living/simple_animal/ex_act(severity)
..()
switch (severity)
if (1.0)
gib()
return
if (2.0)
adjustBruteLoss(60)
if(3.0)
adjustBruteLoss(30)
/mob/living/simple_animal/adjustBruteLoss(damage)
health = Clamp(health - damage, 0, maxHealth)
if(health < 1 && stat != DEAD)
Die()
/mob/living/simple_animal/proc/CanAttack(var/atom/the_target)
if(see_invisible < the_target.invisibility)
return 0
if (isliving(the_target))
var/mob/living/L = the_target
if(L.stat != CONSCIOUS)
return 0
if (istype(the_target, /obj/mecha))
var/obj/mecha/M = the_target
if (M.occupant)
return 0
return 1
/mob/living/simple_animal/update_fire()
return
/mob/living/simple_animal/IgniteMob()
return
/mob/living/simple_animal/ExtinguishMob()
return
/mob/living/simple_animal/revive()
health = maxHealth
..()
/mob/living/simple_animal/proc/make_babies() // <3 <3 <3
if(gender != FEMALE || stat || !scan_ready || !childtype || !species)
return
scan_ready = 0
spawn(400)
scan_ready = 1
var/alone = 1
var/mob/living/simple_animal/partner
var/children = 0
for(var/mob/M in oview(7, src))
if(istype(M, childtype)) //Check for children FIRST.
children++
else if(istype(M, species))
if(M.client)
continue
else if(!istype(M, childtype) && M.gender == MALE) //Better safe than sorry ;_;
partner = M
else if(istype(M, /mob/))
alone = 0
continue
if(alone && partner && children < 3)
new childtype(loc)
// Harvest an animal's delicious byproducts
/mob/living/simple_animal/proc/harvest()
new meat_type (get_turf(src))
if(prob(95))
del(src)
return
gib()
return