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
/
slime.dm
495 lines (413 loc) · 15.6 KB
/
slime.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
/mob/living/simple_animal/slime
name = "grey baby slime (123)"
icon = 'icons/mob/slimes.dmi'
icon_state = "grey baby slime"
pass_flags = PASSTABLE | PASSGRILLE
ventcrawler = VENTCRAWLER_ALWAYS
gender = NEUTER
var/is_adult = 0
var/docile = 0
faction = list("slime","neutral")
harm_intent_damage = 5
icon_living = "grey baby slime"
icon_dead = "grey baby slime dead"
response_help_continuous = "pets"
response_help_simple = "pet"
response_disarm_continuous = "shoos"
response_disarm_simple = "shoo"
response_harm_continuous = "stomps on"
response_harm_simple = "stomp on"
emote_see = list("jiggles", "bounces in place")
speak_emote = list("blorbles")
bubble_icon = "slime"
initial_language_holder = /datum/language_holder/slime
atmos_requirements = list("min_oxy" = 0, "max_oxy" = 0, "min_tox" = 0, "max_tox" = 0, "min_co2" = 0, "max_co2" = 0, "min_n2" = 0, "max_n2" = 0)
maxHealth = 150
health = 150
healable = 0
see_in_dark = 8
verb_say = "blorbles"
verb_ask = "inquisitively blorbles"
verb_exclaim = "loudly blorbles"
verb_yell = "loudly blorbles"
// canstun and canknockdown don't affect slimes because they ignore stun and knockdown variables
// for the sake of cleanliness, though, here they are.
status_flags = CANUNCONSCIOUS|CANPUSH
var/cores = 1 // the number of /obj/item/slime_extract's the slime has left inside
var/mutation_chance = 30 // Chance of mutating, should be between 25 and 35
var/powerlevel = 0 // 1-10 controls how much electricity they are generating
var/amount_grown = 0 // controls how long the slime has been overfed, if 10, grows or reproduces
var/number = 0 // Used to understand when someone is talking to it
var/mob/living/Target = null // AI variable - tells the slime to hunt this down
var/mob/living/Leader = null // AI variable - tells the slime to follow this person
var/attacked = 0 // Determines if it's been attacked recently. Can be any number, is a cooloff-ish variable
var/rabid = 0 // If set to 1, the slime will attack and eat anything it comes in contact with
var/holding_still = 0 // AI variable, cooloff-ish for how long it's going to stay in one place
var/target_patience = 0 // AI variable, cooloff-ish for how long it's going to follow its target
var/list/Friends = list() // A list of friends; they are not considered targets for feeding; passed down after splitting
var/list/speech_buffer = list() // Last phrase said near it and person who said it
var/mood = "" // To show its face
var/mutator_used = FALSE //So you can't shove a dozen mutators into a single slime
var/force_stasis = FALSE
var/static/regex/slime_name_regex = new("\\w+ (baby|adult) slime \\(\\d+\\)")
///////////TIME FOR SUBSPECIES
var/colour = "grey"
var/coretype = /obj/item/slime_extract/grey
var/list/slime_mutation[4]
var/static/list/slime_colours = list("rainbow", "grey", "purple", "metal", "orange",
"blue", "dark blue", "dark purple", "yellow", "silver", "pink", "red",
"gold", "green", "adamantine", "oil", "light pink", "bluespace",
"cerulean", "sepia", "black", "pyrite")
///////////CORE-CROSSING CODE
var/effectmod //What core modification is being used.
var/applied = 0 //How many extracts of the modtype have been applied.
/mob/living/simple_animal/slime/Initialize(mapload, new_colour="grey", new_is_adult=FALSE)
var/datum/action/innate/slime/feed/F = new
F.Grant(src)
is_adult = new_is_adult
if(is_adult)
var/datum/action/innate/slime/reproduce/R = new
R.Grant(src)
health = 200
maxHealth = 200
else
var/datum/action/innate/slime/evolve/E = new
E.Grant(src)
create_reagents(100)
set_colour(new_colour)
. = ..()
set_nutrition(700)
AddComponent(/datum/component/footstep, FOOTSTEP_MOB_SLIME, 7.5)
/mob/living/simple_animal/slime/Destroy()
for (var/A in actions)
var/datum/action/AC = A
AC.Remove(src)
Target = null
Leader = null
Friends.Cut()
speech_buffer.Cut()
return ..()
/mob/living/simple_animal/slime/proc/set_colour(new_colour)
colour = new_colour
update_name()
slime_mutation = mutation_table(colour)
var/sanitizedcolour = replacetext(colour, " ", "")
coretype = text2path("/obj/item/slime_extract/[sanitizedcolour]")
regenerate_icons()
/mob/living/simple_animal/slime/proc/update_name()
if(slime_name_regex.Find(name))
number = rand(1, 1000)
name = "[colour] [is_adult ? "adult" : "baby"] slime ([number])"
real_name = name
/mob/living/simple_animal/slime/proc/random_colour()
set_colour(pick(slime_colours))
/mob/living/simple_animal/slime/regenerate_icons()
cut_overlays()
var/icon_text = "[colour] [is_adult ? "adult" : "baby"] slime"
icon_dead = "[icon_text] dead"
if(stat != DEAD)
icon_state = icon_text
if(mood && !stat)
add_overlay("aslime-[mood]")
else
icon_state = icon_dead
..()
/mob/living/simple_animal/slime/on_reagent_change()
. = ..()
remove_movespeed_modifier(/datum/movespeed_modifier/slime_reagentmod)
var/amount = 0
if(reagents.has_reagent(/datum/reagent/medicine/morphine)) // morphine slows slimes down
amount = 2
if(reagents.has_reagent(/datum/reagent/consumable/frostoil)) // Frostoil also makes them move VEEERRYYYYY slow
amount = 5
if(amount)
add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/slime_reagentmod, multiplicative_slowdown = amount)
/mob/living/simple_animal/slime/updatehealth()
. = ..()
var/mod = 0
if(!HAS_TRAIT(src, TRAIT_IGNOREDAMAGESLOWDOWN))
var/health_deficiency = (maxHealth - health)
if(health_deficiency >= 45)
mod += (health_deficiency / 25)
if(health <= 0)
mod += 2
add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/slime_healthmod, multiplicative_slowdown = mod)
/mob/living/simple_animal/slime/adjust_bodytemperature()
. = ..()
var/mod = 0
if(bodytemperature >= 330.23) // 135 F or 57.08 C
mod = -1 // slimes become supercharged at high temperatures
else if(bodytemperature < 283.222)
mod = ((283.222 - bodytemperature) / 10) * 1.75
if(mod)
add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/slime_tempmod, multiplicative_slowdown = mod)
/mob/living/simple_animal/slime/ObjBump(obj/O)
if(!client && powerlevel > 0)
var/probab = 10
switch(powerlevel)
if(1 to 2)
probab = 20
if(3 to 4)
probab = 30
if(5 to 6)
probab = 40
if(7 to 8)
probab = 60
if(9)
probab = 70
if(10)
probab = 95
if(prob(probab))
if(istype(O, /obj/structure/window) || istype(O, /obj/structure/grille))
if(nutrition <= get_hunger_nutrition() && !Atkcool)
if (is_adult || prob(5))
O.attack_slime(src)
Atkcool = TRUE
addtimer(VARSET_CALLBACK(src, Atkcool, FALSE), 4.5 SECONDS)
/mob/living/simple_animal/slime/Process_Spacemove(movement_dir = 0)
return 2
/mob/living/simple_animal/slime/get_status_tab_items()
. = ..()
if(!docile)
. += "Nutrition: [nutrition]/[get_max_nutrition()]"
if(amount_grown >= SLIME_EVOLUTION_THRESHOLD)
if(is_adult)
. += "You can reproduce!"
else
. += "You can evolve!"
switch(stat)
if(HARD_CRIT, UNCONSCIOUS)
. += "You are knocked out by high levels of BZ!"
else
. += "Power Level: [powerlevel]"
/mob/living/simple_animal/slime/adjustFireLoss(amount, updating_health = TRUE, forced = FALSE)
if(!forced)
amount = -abs(amount)
return ..() //Heals them
/mob/living/simple_animal/slime/bullet_act(obj/projectile/Proj)
attacked += 10
if((Proj.damage_type == BURN))
adjustBruteLoss(-abs(Proj.damage)) //fire projectiles heals slimes.
Proj.on_hit(src)
else
. = ..(Proj)
. = . || BULLET_ACT_BLOCK
/mob/living/simple_animal/slime/emp_act(severity)
. = ..()
if(. & EMP_PROTECT_SELF)
return
powerlevel = 0 // oh no, the power!
/mob/living/simple_animal/slime/MouseDrop(atom/movable/A as mob|obj)
if(isliving(A) && A != src && usr == src)
var/mob/living/Food = A
if(CanFeedon(Food))
Feedon(Food)
return ..()
/mob/living/simple_animal/slime/doUnEquip(obj/item/I, force, newloc, no_move, invdrop = TRUE, silent = FALSE)
return
/mob/living/simple_animal/slime/start_pulling(atom/movable/AM, state, force = move_force, supress_message = FALSE)
return
/mob/living/simple_animal/slime/attack_ui(slot)
return
/mob/living/simple_animal/slime/attack_slime(mob/living/simple_animal/slime/M)
if(..()) //successful slime attack
if(M == src)
return
if(buckled)
Feedstop(silent = TRUE)
visible_message("<span class='danger'>[M] pulls [src] off!</span>", \
"<span class='danger'>You pull [src] off!</span>")
return
attacked += 5
if(nutrition >= 100) //steal some nutrition. negval handled in life()
adjust_nutrition(-(50 + (40 * M.is_adult)))
M.add_nutrition(50 + (40 * M.is_adult))
if(health > 0)
M.adjustBruteLoss(-10 + (-10 * M.is_adult))
M.updatehealth()
/mob/living/simple_animal/slime/attack_animal(mob/living/simple_animal/M)
. = ..()
if(.)
attacked += 10
/mob/living/simple_animal/slime/attack_paw(mob/living/carbon/monkey/M)
if(..()) //successful monkey bite.
attacked += 10
/mob/living/simple_animal/slime/attack_larva(mob/living/carbon/alien/larva/L)
if(..()) //successful larva bite.
attacked += 10
/mob/living/simple_animal/slime/attack_hulk(mob/living/carbon/human/user)
. = ..()
if(!.)
return
discipline_slime(user)
/mob/living/simple_animal/slime/attack_hand(mob/living/carbon/human/M)
if(buckled)
M.do_attack_animation(src, ATTACK_EFFECT_DISARM)
if(buckled == M)
if(prob(60))
M.visible_message("<span class='warning'>[M] attempts to wrestle \the [name] off!</span>", \
"<span class='danger'>You attempt to wrestle \the [name] off!</span>")
playsound(loc, 'sound/weapons/punchmiss.ogg', 25, TRUE, -1)
else
M.visible_message("<span class='warning'>[M] manages to wrestle \the [name] off!</span>", \
"<span class='notice'>You manage to wrestle \the [name] off!</span>")
playsound(loc, 'sound/weapons/thudswoosh.ogg', 50, TRUE, -1)
discipline_slime(M)
else
if(prob(30))
buckled.visible_message("<span class='warning'>[M] attempts to wrestle \the [name] off of [buckled]!</span>", \
"<span class='warning'>[M] attempts to wrestle \the [name] off of you!</span>")
playsound(loc, 'sound/weapons/punchmiss.ogg', 25, TRUE, -1)
else
buckled.visible_message("<span class='warning'>[M] manages to wrestle \the [name] off of [buckled]!</span>", \
"<span class='notice'>[M] manage to wrestle \the [name] off of you!</span>")
playsound(loc, 'sound/weapons/thudswoosh.ogg', 50, TRUE, -1)
discipline_slime(M)
else
if(stat == DEAD && surgeries.len)
if(M.a_intent == INTENT_HELP || M.a_intent == INTENT_DISARM)
for(var/datum/surgery/S in surgeries)
if(S.next_step(M,M.a_intent))
return 1
if(..()) //successful attack
attacked += 10
/mob/living/simple_animal/slime/attack_alien(mob/living/carbon/alien/humanoid/M)
if(..()) //if harm or disarm intent.
attacked += 10
discipline_slime(M)
/mob/living/simple_animal/slime/attackby(obj/item/W, mob/living/user, params)
if(stat == DEAD && surgeries.len)
if(user.a_intent == INTENT_HELP || user.a_intent == INTENT_DISARM)
for(var/datum/surgery/S in surgeries)
if(S.next_step(user,user.a_intent))
return 1
if(istype(W, /obj/item/stack/sheet/mineral/plasma) && !stat) //Let's you feed slimes plasma.
if (user in Friends)
++Friends[user]
else
Friends[user] = 1
to_chat(user, "<span class='notice'>You feed the slime the plasma. It chirps happily.</span>")
var/obj/item/stack/sheet/mineral/plasma/S = W
S.use(1)
return
if(W.force > 0)
attacked += 10
if(prob(25))
user.do_attack_animation(src)
user.changeNext_move(CLICK_CD_MELEE)
to_chat(user, "<span class='danger'>[W] passes right through [src]!</span>")
return
if(Discipline && prob(50)) // wow, buddy, why am I getting attacked??
Discipline = 0
if(W.force >= 3)
var/force_effect = 2 * W.force
if(is_adult)
force_effect = round(W.force/2)
if(prob(10 + force_effect))
discipline_slime(user)
if(istype(W, /obj/item/storage/bag/bio))
var/obj/item/storage/P = W
if(!effectmod)
to_chat(user, "<span class='warning'>The slime is not currently being mutated.</span>")
return
var/hasOutput = FALSE //Have we outputted text?
var/hasFound = FALSE //Have we found an extract to be added?
for(var/obj/item/slime_extract/S in P.contents)
if(S.effectmod == effectmod)
SEND_SIGNAL(P, COMSIG_TRY_STORAGE_TAKE, S, get_turf(src), TRUE)
qdel(S)
applied++
hasFound = TRUE
if(applied >= SLIME_EXTRACT_CROSSING_REQUIRED)
to_chat(user, "<span class='notice'>You feed the slime as many of the extracts from the bag as you can, and it mutates!</span>")
playsound(src, 'sound/effects/attackblob.ogg', 50, TRUE)
spawn_corecross()
hasOutput = TRUE
break
if(!hasOutput)
if(!hasFound)
to_chat(user, "<span class='warning'>There are no extracts in the bag that this slime will accept!</span>")
else
to_chat(user, "<span class='notice'>You feed the slime some extracts from the bag.</span>")
playsound(src, 'sound/effects/attackblob.ogg', 50, TRUE)
return
..()
/mob/living/simple_animal/slime/proc/spawn_corecross()
var/static/list/crossbreeds = subtypesof(/obj/item/slimecross)
visible_message("<span class='danger'>[src] shudders, its mutated core consuming the rest of its body!</span>")
playsound(src, 'sound/magic/smoke.ogg', 50, TRUE)
var/crosspath
for(var/X in crossbreeds)
var/obj/item/slimecross/S = X
if(initial(S.colour) == colour && initial(S.effect) == effectmod)
crosspath = S
break
if(crosspath)
new crosspath(loc)
else
visible_message("<span class='warning'>The mutated core shudders, and collapses into a puddle, unable to maintain its form.</span>")
qdel(src)
/mob/living/simple_animal/slime/proc/apply_water()
adjustBruteLoss(rand(15,20))
if(!client)
if(Target) // Like cats
Target = null
++Discipline
return
/mob/living/simple_animal/slime/examine(mob/user)
. = list("<span class='info'>*---------*\nThis is [icon2html(src, user)] \a <EM>[src]</EM>!")
if (stat == DEAD)
. += "<span class='deadsay'>It is limp and unresponsive.</span>"
else
if (stat == UNCONSCIOUS || stat == HARD_CRIT) // Slime stasis
. += "<span class='deadsay'>It appears to be alive but unresponsive.</span>"
if (getBruteLoss())
. += "<span class='warning'>"
if (getBruteLoss() < 40)
. += "It has some punctures in its flesh!"
else
. += "<B>It has severe punctures and tears in its flesh!</B>"
. += "</span>\n"
switch(powerlevel)
if(2 to 3)
. += "It is flickering gently with a little electrical activity."
if(4 to 5)
. += "It is glowing gently with moderate levels of electrical activity."
if(6 to 9)
. += "<span class='warning'>It is glowing brightly with high levels of electrical activity.</span>"
if(10)
. += "<span class='warning'><B>It is radiating with massive levels of electrical activity!</B></span>"
. += "*---------*</span>"
/mob/living/simple_animal/slime/proc/discipline_slime(mob/user)
if(stat)
return
if(prob(80) && !client)
Discipline++
if(!is_adult)
if(Discipline == 1)
attacked = 0
if(Target)
Target = null
if(buckled)
Feedstop(silent = TRUE) //we unbuckle the slime from the mob it latched onto.
SStun = world.time + rand(20,60)
Stun(3)
if(user)
step_away(src,user,15)
addtimer(CALLBACK(src, .proc/slime_move, user), 0.3 SECONDS)
/mob/living/simple_animal/slime/proc/slime_move(mob/user)
if(user)
step_away(src,user,15)
/mob/living/simple_animal/slime/pet
docile = 1
/mob/living/simple_animal/slime/can_unbuckle()
return 0
/mob/living/simple_animal/slime/can_buckle()
return 0
/mob/living/simple_animal/slime/get_mob_buckling_height(mob/seat)
if(..())
return 3
/mob/living/simple_animal/slime/can_be_implanted()
return TRUE
/mob/living/simple_animal/slime/random/Initialize(mapload, new_colour, new_is_adult)
. = ..(mapload, pick(slime_colours), prob(50))