/
heretic_knowledge.dm
740 lines (627 loc) · 27.5 KB
/
heretic_knowledge.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
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
/**
* # Heretic Knowledge
*
* The datums that allow heretics to progress and learn new spells and rituals.
*
* Heretic Knowledge datums are not singletons - they are instantiated as they
* are given to heretics, and deleted if the heretic antagonist is removed.
*
*/
/datum/heretic_knowledge
/// Name of the knowledge, shown to the heretic.
var/name = "Basic knowledge"
/// Description of the knowledge, shown to the heretic. Describes what it unlocks / does.
var/desc = "Basic knowledge of forbidden arts."
/// What's shown to the heretic when the knowledge is aquired
var/gain_text
/// The abstract parent type of the knowledge, used in determine mutual exclusivity in some cases
var/datum/heretic_knowledge/abstract_parent_type = /datum/heretic_knowledge
/// If TRUE, populates the banned_knowledge list of every other subtype of this knowledge's abstract_parent_type
var/mutually_exclusive = FALSE
/// The knowledge this unlocks next after learning.
var/list/next_knowledge = list()
/// What knowledge is incompatible with this. Knowledge in this list cannot be researched with this current knowledge.
var/list/banned_knowledge = list()
/// Assoc list of [typepaths we need] to [amount needed].
/// If set, this knowledge allows the heretic to do a ritual on a transmutation rune with the components set.
/// If one of the items in the list is a list, it's treated as 'any of these items will work'
var/list/required_atoms
/// Paired with above. If set, the resulting spawned atoms upon ritual completion.
var/list/result_atoms = list()
/// If set, required_atoms checks for these *exact* types and doesn't allow them to be ingredients.
var/list/banned_atom_types = list()
/// Cost of knowledge in knowledge points
var/cost = 0
/// The priority of the knowledge. Higher priority knowledge appear higher in the ritual list.
/// Number itself is completely arbitrary. Does not need to be set for non-ritual knowledge.
var/priority = 0
/// What path is this on. If set to "null", assumed to be unreachable (or abstract).
var/route
/datum/heretic_knowledge/New()
if(!mutually_exclusive)
return
for(var/knowledge_type in subtypesof(abstract_parent_type))
if(knowledge_type == type)
continue
banned_knowledge += knowledge_type
/**
* Called when the knowledge is first researched.
* This is only ever called once per heretic.
*
* Arguments
* * user - The heretic who researched something
* * our_heretic - The antag datum of who researched us. This should never be null.
*/
/datum/heretic_knowledge/proc/on_research(mob/user, datum/antagonist/heretic/our_heretic)
SHOULD_CALL_PARENT(TRUE)
if(gain_text)
to_chat(user, span_warning("[gain_text]"))
on_gain(user, our_heretic)
/**
* Called when the knowledge is applied to a mob.
* This can be called multiple times per heretic,
* in the case of bodyswap shenanigans.
*
* Arguments
* * user - the heretic which we're applying things to
* * our_heretic - The antag datum of who gained us. This should never be null.
*/
/datum/heretic_knowledge/proc/on_gain(mob/user, datum/antagonist/heretic/our_heretic)
return
/**
* Called when the knowledge is removed from a mob,
* either due to a heretic being de-heretic'd or bodyswap memery.
*
* Arguments
* * user - the heretic which we're removing things from
* * our_heretic - The antag datum of who is losing us. This should never be null.
*/
/datum/heretic_knowledge/proc/on_lose(mob/user, datum/antagonist/heretic/our_heretic)
return
/**
* Determines if a heretic can actually attempt to invoke the knowledge as a ritual.
* By default, we can only invoke knowledge with rituals associated.
*
* Return TRUE to have the ritual show up in the rituals list, FALSE otherwise.
*/
/datum/heretic_knowledge/proc/can_be_invoked(datum/antagonist/heretic/invoker)
return !!LAZYLEN(required_atoms)
/**
* Special check for rituals.
* Called before any of the required atoms are checked.
*
* If you are adding a more complex summoning,
* or something that requires a special check
* that parses through all the atoms,
* you should override this.
*
* Arguments
* * user - the mob doing the ritual
* * atoms - a list of all atoms being checked in the ritual.
* * selected_atoms - an empty list(!) instance passed in by the ritual. You can add atoms to it in this proc.
* * loc - the turf the ritual's occuring on
*
* Returns: TRUE, if the ritual will continue, or FALSE, if the ritual is skipped / cancelled
*/
/datum/heretic_knowledge/proc/recipe_snowflake_check(mob/living/user, list/atoms, list/selected_atoms, turf/loc)
return TRUE
/**
* Parses specific items into a more readble form.
* Can be overriden by knoweldge subtypes.
*/
/datum/heretic_knowledge/proc/parse_required_item(atom/item_path, number_of_things)
// If we need a human, there is a high likelihood we actually need a (dead) body
if(ispath(item_path, /mob/living/carbon/human))
return "bod[number_of_things > 1 ? "ies" : "y"]"
if(ispath(item_path, /mob/living))
return "carcass[number_of_things > 1 ? "es" : ""] of any kind"
return "[initial(item_path.name)]\s"
/**
* Called whenever the knowledge's associated ritual is completed successfully.
*
* Creates atoms from types in result_atoms.
* Override this if you want something else to happen.
* This CAN sleep, such as for summoning rituals which poll for ghosts.
*
* Arguments
* * user - the mob who did the ritual
* * selected_atoms - an list of atoms chosen as a part of this ritual.
* * loc - the turf the ritual's occuring on
*
* Returns: TRUE, if the ritual should cleanup afterwards, or FALSE, to avoid calling cleanup after.
*/
/datum/heretic_knowledge/proc/on_finished_recipe(mob/living/user, list/selected_atoms, turf/loc)
if(!length(result_atoms))
return FALSE
for(var/result in result_atoms)
new result(loc)
return TRUE
/**
* Called after on_finished_recipe returns TRUE
* and a ritual was successfully completed.
*
* Goes through and cleans up (deletes)
* all atoms in the selected_atoms list.
*
* Remove atoms from the selected_atoms
* (either in this proc or in on_finished_recipe)
* to NOT have certain atoms deleted on cleanup.
*
* Arguments
* * selected_atoms - a list of all atoms we intend on destroying.
*/
/datum/heretic_knowledge/proc/cleanup_atoms(list/selected_atoms)
SHOULD_CALL_PARENT(TRUE)
for(var/atom/sacrificed as anything in selected_atoms)
if(isliving(sacrificed))
continue
if(isstack(sacrificed))
var/obj/item/stack/sac_stack = sacrificed
var/how_much_to_use = 0
for(var/requirement in required_atoms)
// If it's not requirement type and type is not a list, skip over this check
if(!istype(sacrificed, requirement) && !islist(requirement))
continue
// If requirement *is* a list and the stack *is* in the list, skip over this check
if(islist(requirement) && !is_type_in_list(sacrificed, requirement))
continue
how_much_to_use = min(required_atoms[requirement], sac_stack.amount)
break
sac_stack.use(how_much_to_use)
continue
selected_atoms -= sacrificed
qdel(sacrificed)
/**
* A knowledge subtype that grants the heretic a certain spell.
*/
/datum/heretic_knowledge/spell
abstract_parent_type = /datum/heretic_knowledge/spell
/// Spell path we add to the heretic. Type-path.
var/datum/action/cooldown/spell/spell_to_add
/// The spell we actually created.
var/datum/weakref/created_spell_ref
/datum/heretic_knowledge/spell/Destroy()
QDEL_NULL(created_spell_ref)
return ..()
/datum/heretic_knowledge/spell/on_gain(mob/user, datum/antagonist/heretic/our_heretic)
// Added spells are tracked on the body, and not the mind,
// because we handle heretic mind transfers
// via the antag datum (on_gain and on_lose).
var/datum/action/cooldown/spell/created_spell = created_spell_ref?.resolve() || new spell_to_add(user)
created_spell.Grant(user)
created_spell_ref = WEAKREF(created_spell)
/datum/heretic_knowledge/spell/on_lose(mob/user, datum/antagonist/heretic/our_heretic)
var/datum/action/cooldown/spell/created_spell = created_spell_ref?.resolve()
if(created_spell?.owner == user)
created_spell.Remove(user)
/**
* A knowledge subtype for knowledge that can only
* have a limited amount of it's resulting atoms
* created at once.
*/
/datum/heretic_knowledge/limited_amount
abstract_parent_type = /datum/heretic_knowledge/limited_amount
/// The limit to how many items we can create at once.
var/limit = 1
/// A list of weakrefs to all items we've created.
var/list/datum/weakref/created_items
/datum/heretic_knowledge/limited_amount/Destroy(force)
LAZYCLEARLIST(created_items)
return ..()
/datum/heretic_knowledge/limited_amount/recipe_snowflake_check(mob/living/user, list/atoms, list/selected_atoms, turf/loc)
for(var/datum/weakref/ref as anything in created_items)
var/atom/real_thing = ref.resolve()
if(QDELETED(real_thing))
LAZYREMOVE(created_items, ref)
if(LAZYLEN(created_items) >= limit)
loc.balloon_alert(user, "ritual failed, at limit!")
return FALSE
return TRUE
/datum/heretic_knowledge/limited_amount/on_finished_recipe(mob/living/user, list/selected_atoms, turf/loc)
for(var/result in result_atoms)
var/atom/created_thing = new result(loc)
LAZYADD(created_items, WEAKREF(created_thing))
return TRUE
/**
* A knowledge subtype for limited_amount knowledge
* used for base knowledge (the ones that make blades)
*
* A heretic can only learn one /starting type knowledge,
* and their ascension depends on whichever they chose.
*/
/datum/heretic_knowledge/limited_amount/starting
abstract_parent_type = /datum/heretic_knowledge/limited_amount/starting
mutually_exclusive = TRUE
limit = 2
cost = 1
priority = MAX_KNOWLEDGE_PRIORITY - 5
/datum/heretic_knowledge/limited_amount/starting/New()
. = ..()
// Starting path also determines the final knowledge we're limited too
for(var/datum/heretic_knowledge/final_knowledge_type as anything in subtypesof(/datum/heretic_knowledge/ultimate))
if(initial(final_knowledge_type.route) == route)
continue
banned_knowledge += final_knowledge_type
/datum/heretic_knowledge/limited_amount/starting/on_research(mob/user, datum/antagonist/heretic/our_heretic)
. = ..()
our_heretic.heretic_path = route
SSblackbox.record_feedback("tally", "heretic_path_taken", 1, route)
/**
* A knowledge subtype for heretic knowledge
* that applies a mark on use.
*
* A heretic can only learn one /mark type knowledge.
*/
/datum/heretic_knowledge/mark
abstract_parent_type = /datum/heretic_knowledge/mark
mutually_exclusive = TRUE
cost = 2
/// The status effect typepath we apply on people on mansus grasp.
var/datum/status_effect/eldritch/mark_type
/datum/heretic_knowledge/mark/on_gain(mob/user, datum/antagonist/heretic/our_heretic)
RegisterSignal(user, COMSIG_HERETIC_MANSUS_GRASP_ATTACK, PROC_REF(on_mansus_grasp))
RegisterSignal(user, COMSIG_HERETIC_BLADE_ATTACK, PROC_REF(on_eldritch_blade))
/datum/heretic_knowledge/mark/on_lose(mob/user, datum/antagonist/heretic/our_heretic)
UnregisterSignal(user, list(COMSIG_HERETIC_MANSUS_GRASP_ATTACK, COMSIG_HERETIC_BLADE_ATTACK))
/**
* Signal proc for [COMSIG_HERETIC_MANSUS_GRASP_ATTACK].
*
* Whenever we cast mansus grasp on someone, apply our mark.
*/
/datum/heretic_knowledge/mark/proc/on_mansus_grasp(mob/living/source, mob/living/target)
SIGNAL_HANDLER
create_mark(source, target)
/**
* Signal proc for [COMSIG_HERETIC_BLADE_ATTACK].
*
* Whenever we attack someone with our blade, attempt to trigger any marks on them.
*/
/datum/heretic_knowledge/mark/proc/on_eldritch_blade(mob/living/source, mob/living/target, obj/item/melee/sickly_blade/blade)
SIGNAL_HANDLER
trigger_mark(source, target)
/**
* Creates the mark status effect on our target.
* This proc handles the instatiate and the application of the station effect,
* and returns the /datum/status_effect instance that was made.
*
* Can be overriden to set or pass in additional vars of the status effect.
*/
/datum/heretic_knowledge/mark/proc/create_mark(mob/living/source, mob/living/target)
if(target.stat == DEAD)
return
return target.apply_status_effect(mark_type)
/**
* Handles triggering the mark on the target.
*
* If there is no mark, returns FALSE. Returns TRUE if a mark was triggered.
*/
/datum/heretic_knowledge/mark/proc/trigger_mark(mob/living/source, mob/living/target)
var/datum/status_effect/eldritch/mark = target.has_status_effect(/datum/status_effect/eldritch)
if(!istype(mark))
return FALSE
mark.on_effect()
return TRUE
/**
* A knowledge subtype for heretic knowledge that
* upgrades their sickly blade, either on melee or range.
*
* A heretic can only learn one /blade_upgrade type knowledge.
*/
/datum/heretic_knowledge/blade_upgrade
abstract_parent_type = /datum/heretic_knowledge/blade_upgrade
mutually_exclusive = TRUE
cost = 2
/datum/heretic_knowledge/blade_upgrade/on_gain(mob/user, datum/antagonist/heretic/our_heretic)
RegisterSignal(user, COMSIG_HERETIC_BLADE_ATTACK, PROC_REF(on_eldritch_blade))
RegisterSignal(user, COMSIG_HERETIC_RANGED_BLADE_ATTACK, PROC_REF(on_ranged_eldritch_blade))
/datum/heretic_knowledge/blade_upgrade/on_lose(mob/user, datum/antagonist/heretic/our_heretic)
UnregisterSignal(user, list(COMSIG_HERETIC_BLADE_ATTACK, COMSIG_HERETIC_RANGED_BLADE_ATTACK))
/**
* Signal proc for [COMSIG_HERETIC_BLADE_ATTACK].
*
* Apply any melee effects from hitting someone with our blade.
*/
/datum/heretic_knowledge/blade_upgrade/proc/on_eldritch_blade(mob/living/source, mob/living/target, obj/item/melee/sickly_blade/blade)
SIGNAL_HANDLER
do_melee_effects(source, target, blade)
/**
* Signal proc for [COMSIG_HERETIC_RANGED_BLADE_ATTACK].
*
* Apply any ranged effects from hitting someone with our blade.
*/
/datum/heretic_knowledge/blade_upgrade/proc/on_ranged_eldritch_blade(mob/living/source, mob/living/target, obj/item/melee/sickly_blade/blade)
SIGNAL_HANDLER
do_ranged_effects(source, target, blade)
/**
* Overridable proc that invokes special effects
* whenever the heretic attacks someone in melee with their heretic blade.
*/
/datum/heretic_knowledge/blade_upgrade/proc/do_melee_effects(mob/living/source, mob/living/target, obj/item/melee/sickly_blade/blade)
return
/**
* Overridable proc that invokes special effects
* whenever the heretic clicks on someone at range with their heretic blade.
*/
/datum/heretic_knowledge/blade_upgrade/proc/do_ranged_effects(mob/living/source, mob/living/target, obj/item/melee/sickly_blade/blade)
return
/**
* A knowledge subtype lets the heretic curse someone with a ritual.
*/
/datum/heretic_knowledge/curse
abstract_parent_type = /datum/heretic_knowledge/curse
/// How far can we curse people?
var/max_range = 64
/// The duration of the curse
var/duration = 1 MINUTES
/// The duration of the curse on people which have a fingerprint or blood sample present
var/duration_modifier = 2
/// What color do we outline cursed folk with?
var/curse_color = "#dadada"
/// A list of all the fingerprints that were found on our atoms, in our last go at the ritual
var/list/fingerprints
/// A list of all the blood samples that were found on our atoms, in our last go at the ritual
var/list/blood_samples
/datum/heretic_knowledge/curse/recipe_snowflake_check(mob/living/user, list/atoms, list/selected_atoms, turf/loc)
fingerprints = list()
blood_samples = list()
for(var/atom/requirement as anything in atoms)
for(var/print in GET_ATOM_FINGERPRINTS(requirement))
fingerprints[print] = 1
for(var/blood in GET_ATOM_BLOOD_DNA(requirement))
blood_samples[blood] = 1
return TRUE
/datum/heretic_knowledge/curse/on_finished_recipe(mob/living/user, list/selected_atoms, turf/loc)
// Potential targets is an assoc list of [names] to [human mob ref].
var/list/potential_targets = list()
// Boosted targets is a list of human mob references.
var/list/boosted_targets = list()
for(var/datum/mind/crewmember as anything in get_crewmember_minds())
var/mob/living/carbon/human/human_to_check = crewmember.current
if(!istype(human_to_check) || human_to_check.stat == DEAD || !human_to_check.dna)
continue
var/their_prints = md5(human_to_check.dna.unique_identity)
var/their_blood = human_to_check.dna.unique_enzymes
// Having their fingerprints or blood present will boost the curse
// and also not run any z or dist checks, as a bonus for those going beyond
if(fingerprints[their_prints] || blood_samples[their_blood])
boosted_targets += human_to_check
potential_targets["[human_to_check.real_name] (Boosted)"] = human_to_check
continue
// No boost present, so we should be a little stricter moving forward
var/turf/check_turf = get_turf(human_to_check)
// We have to match z-levels.
// Otherwise, you could probably hard own miners, which is funny but mean.
// Multi-z stations technically work though.
if(!is_valid_z_level(check_turf, loc))
continue
// Also has to abide by our max range.
if(get_dist(check_turf, loc) > max_range)
continue
potential_targets[human_to_check.real_name] = human_to_check
var/chosen_mob = tgui_input_list(user, "Select the victim you wish to curse.", name, sort_list(potential_targets, GLOBAL_PROC_REF(cmp_text_asc)))
if(isnull(chosen_mob))
return FALSE
var/mob/living/carbon/human/to_curse = potential_targets[chosen_mob]
if(QDELETED(to_curse))
loc.balloon_alert(user, "ritual failed, invalid choice!")
return FALSE
// Yes, you COULD curse yourself, not sure why but you could
if(to_curse == user)
var/are_you_sure = tgui_alert(user, "Are you sure you want to curse yourself?", name, list("Yes", "No"))
if(are_you_sure != "Yes")
return FALSE
var/boosted = (to_curse in boosted_targets)
var/turf/curse_turf = get_turf(to_curse)
if(!boosted && (!is_valid_z_level(curse_turf, loc) || get_dist(curse_turf, loc) > max_range * 1.5)) // Give a bit of leeway on max range for people moving around
loc.balloon_alert(user, "ritual failed, too far!")
return FALSE
if(to_curse.can_block_magic(MAGIC_RESISTANCE|MAGIC_RESISTANCE_HOLY, charge_cost = 0))
to_chat(to_curse, span_warning("You feel a ghastly chill, but the feeling passes shortly."))
return TRUE
log_combat(user, to_curse, "cursed via heretic ritual", addition = "([boosted ? "Boosted" : ""] [name])")
curse(to_curse, boosted)
to_chat(user, span_hierophant("You cast a[boosted ? "n empowered":""] [name] upon [to_curse.real_name]."))
fingerprints = null
blood_samples = null
return TRUE
/**
* Calls a curse onto [chosen_mob].
*/
/datum/heretic_knowledge/curse/proc/curse(mob/living/carbon/human/chosen_mob, boosted = FALSE)
SHOULD_CALL_PARENT(TRUE)
addtimer(CALLBACK(src, PROC_REF(uncurse), chosen_mob, boosted), duration * (boosted ? duration_modifier : 1))
if(!curse_color)
return
chosen_mob.add_filter(name, 2, list("type" = "outline", "color" = curse_color, "size" = 1))
/**
* Removes a curse from [chosen_mob]. Used in timers / callbacks.
*/
/datum/heretic_knowledge/curse/proc/uncurse(mob/living/carbon/human/chosen_mob, boosted = FALSE)
SHOULD_CALL_PARENT(TRUE)
if(QDELETED(chosen_mob))
return
if(!curse_color)
return
chosen_mob.remove_filter(name)
/**
* A knowledge subtype lets the heretic summon a monster with the ritual.
*/
/datum/heretic_knowledge/summon
abstract_parent_type = /datum/heretic_knowledge/summon
/// Typepath of a mob to summon when we finish the recipe.
var/mob/living/mob_to_summon
///Determines what kind of monster ghosts will ignore from here on out. Defaults to POLL_IGNORE_HERETIC_MONSTER, but we define other types of monsters for more granularity.
var/poll_ignore_define = POLL_IGNORE_HERETIC_MONSTER
/datum/heretic_knowledge/summon/on_finished_recipe(mob/living/user, list/selected_atoms, turf/loc)
var/mob/living/summoned = new mob_to_summon(loc)
summoned.ai_controller?.set_ai_status(AI_STATUS_OFF)
// Fade in the summon while the ghost poll is ongoing.
// Also don't let them mess with the summon while waiting
summoned.alpha = 0
ADD_TRAIT(summoned, TRAIT_NO_TRANSFORM, REF(src))
summoned.move_resist = MOVE_FORCE_OVERPOWERING
animate(summoned, 10 SECONDS, alpha = 155)
message_admins("A [summoned.name] is being summoned by [ADMIN_LOOKUPFLW(user)] in [ADMIN_COORDJMP(summoned)].")
var/mob/chosen_one = SSpolling.poll_ghosts_for_target(check_jobban = ROLE_HERETIC, poll_time = 10 SECONDS, checked_target = summoned, ignore_category = poll_ignore_define, alert_pic = summoned, role_name_text = summoned.name)
if(isnull(chosen_one))
loc.balloon_alert(user, "ritual failed, no ghosts!")
animate(summoned, 0.5 SECONDS, alpha = 0)
QDEL_IN(summoned, 0.6 SECONDS)
return FALSE
// Ok let's make them an interactable mob now, since we got a ghost
summoned.alpha = 255
REMOVE_TRAIT(summoned, TRAIT_NO_TRANSFORM, REF(src))
summoned.move_resist = initial(summoned.move_resist)
summoned.ghostize(FALSE)
summoned.key = chosen_one.key
user.log_message("created a [summoned.name], controlled by [key_name(chosen_one)].", LOG_GAME)
message_admins("[ADMIN_LOOKUPFLW(user)] created a [summoned.name], [ADMIN_LOOKUPFLW(summoned)].")
var/datum/antagonist/heretic_monster/heretic_monster = summoned.mind.add_antag_datum(/datum/antagonist/heretic_monster)
heretic_monster.set_owner(user.mind)
var/datum/objective/heretic_summon/summon_objective = locate() in user.mind.get_all_objectives()
summon_objective?.num_summoned++
return TRUE
/// The amount of knowledge points the knowledge ritual gives on success.
#define KNOWLEDGE_RITUAL_POINTS 4
/**
* A subtype of knowledge that generates random ritual components.
*/
/datum/heretic_knowledge/knowledge_ritual
name = "Ritual of Knowledge"
desc = "A randomly generated transmutation ritual that rewards knowledge points and can only be completed once."
gain_text = "Everything can be a key to unlocking the secrets behind the Gates. I must be wary and wise."
abstract_parent_type = /datum/heretic_knowledge/knowledge_ritual
mutually_exclusive = TRUE
cost = 1
priority = MAX_KNOWLEDGE_PRIORITY - 10 // A pretty important midgame ritual.
/// Whether we've done the ritual. Only doable once.
var/was_completed = FALSE
/datum/heretic_knowledge/knowledge_ritual/New()
. = ..()
var/static/list/potential_organs = list(
/obj/item/organ/internal/appendix,
/obj/item/organ/external/tail,
/obj/item/organ/internal/eyes,
/obj/item/organ/internal/tongue,
/obj/item/organ/internal/ears,
/obj/item/organ/internal/heart,
/obj/item/organ/internal/liver,
/obj/item/organ/internal/stomach,
/obj/item/organ/internal/lungs,
)
var/static/list/potential_easy_items = list(
/obj/item/shard,
/obj/item/flashlight/flare/candle,
/obj/item/book,
/obj/item/pen,
/obj/item/paper,
/obj/item/toy/crayon,
/obj/item/flashlight,
/obj/item/clipboard,
)
var/static/list/potential_uncommoner_items = list(
/obj/item/restraints/legcuffs/beartrap,
/obj/item/restraints/handcuffs/cable/zipties,
/obj/item/circular_saw,
/obj/item/scalpel,
/obj/item/binoculars,
/obj/item/clothing/gloves/color/yellow,
/obj/item/melee/baton/security,
/obj/item/clothing/glasses/sunglasses,
)
required_atoms = list()
// 2 organs. Can be the same.
required_atoms[pick(potential_organs)] += 1
required_atoms[pick(potential_organs)] += 1
// 2-3 random easy items.
required_atoms[pick(potential_easy_items)] += rand(2, 3)
// 1 uncommon item.
required_atoms[pick(potential_uncommoner_items)] += 1
/datum/heretic_knowledge/knowledge_ritual/on_research(mob/user, datum/antagonist/heretic/our_heretic)
. = ..()
var/list/requirements_string = list()
to_chat(user, span_hierophant("The [name] requires the following:"))
for(var/obj/item/path as anything in required_atoms)
var/amount_needed = required_atoms[path]
to_chat(user, span_hypnophrase("[amount_needed] [initial(path.name)]\s..."))
requirements_string += "[amount_needed == 1 ? "":"[amount_needed] "][initial(path.name)]\s"
to_chat(user, span_hierophant("Completing it will reward you [KNOWLEDGE_RITUAL_POINTS] knowledge points. You can check the knowledge in your Researched Knowledge to be reminded."))
desc = "Allows you to transmute [english_list(requirements_string)] for [KNOWLEDGE_RITUAL_POINTS] bonus knowledge points. This can only be completed once."
/datum/heretic_knowledge/knowledge_ritual/can_be_invoked(datum/antagonist/heretic/invoker)
return !was_completed
/datum/heretic_knowledge/knowledge_ritual/recipe_snowflake_check(mob/living/user, list/atoms, list/selected_atoms, turf/loc)
return !was_completed
/datum/heretic_knowledge/knowledge_ritual/on_finished_recipe(mob/living/user, list/selected_atoms, turf/loc)
var/datum/antagonist/heretic/our_heretic = IS_HERETIC(user)
our_heretic.knowledge_points += KNOWLEDGE_RITUAL_POINTS
was_completed = TRUE
var/drain_message = pick(strings(HERETIC_INFLUENCE_FILE, "drain_message"))
to_chat(user, span_boldnotice("[name] completed!"))
to_chat(user, span_hypnophrase(span_big("[drain_message]")))
desc += " (Completed!)"
log_heretic_knowledge("[key_name(user)] completed a [name] at [worldtime2text()].")
user.add_mob_memory(/datum/memory/heretic_knowledge_ritual)
return TRUE
#undef KNOWLEDGE_RITUAL_POINTS
/**
* The special final tier of knowledges that unlocks ASCENSION.
*/
/datum/heretic_knowledge/ultimate
abstract_parent_type = /datum/heretic_knowledge/ultimate
mutually_exclusive = TRUE // I guess, but it doesn't really matter by this point
cost = 2
priority = MAX_KNOWLEDGE_PRIORITY + 1 // Yes, the final ritual should be ABOVE the max priority.
required_atoms = list(/mob/living/carbon/human = 3)
/datum/heretic_knowledge/ultimate/on_research(mob/user, datum/antagonist/heretic/our_heretic)
. = ..()
var/total_points = 0
for(var/datum/heretic_knowledge/knowledge as anything in flatten_list(our_heretic.researched_knowledge))
total_points += knowledge.cost
log_heretic_knowledge("[key_name(user)] gained knowledge of their final ritual at [worldtime2text()]. \
They have [length(our_heretic.researched_knowledge)] knowledge nodes researched, totalling [total_points] points \
and have sacrificed [our_heretic.total_sacrifices] people ([our_heretic.high_value_sacrifices] of which were high value)")
/datum/heretic_knowledge/ultimate/can_be_invoked(datum/antagonist/heretic/invoker)
if(invoker.ascended)
return FALSE
if(!invoker.can_ascend())
return FALSE
return TRUE
/datum/heretic_knowledge/ultimate/recipe_snowflake_check(mob/living/user, list/atoms, list/selected_atoms, turf/loc)
var/datum/antagonist/heretic/heretic_datum = IS_HERETIC(user)
if(!can_be_invoked(heretic_datum))
return FALSE
// Remove all non-dead humans from the atoms list.
// (We only want to sacrifice dead folk.)
for(var/mob/living/carbon/human/sacrifice in atoms)
if(!is_valid_sacrifice(sacrifice))
atoms -= sacrifice
// All the non-dead humans are removed in this proc.
// We handle checking if we have enough humans in the ritual itself.
return TRUE
/**
* Checks if the passed human is a valid sacrifice for our ritual.
*/
/datum/heretic_knowledge/ultimate/proc/is_valid_sacrifice(mob/living/carbon/human/sacrifice)
return (sacrifice.stat == DEAD) && !ismonkey(sacrifice)
/datum/heretic_knowledge/ultimate/on_finished_recipe(mob/living/user, list/selected_atoms, turf/loc)
var/datum/antagonist/heretic/heretic_datum = IS_HERETIC(user)
heretic_datum.ascended = TRUE
// Show the cool red gradiant in our UI
heretic_datum.update_static_data(user)
if(ishuman(user))
var/mob/living/carbon/human/human_user = user
human_user.physiology.brute_mod *= 0.5
human_user.physiology.burn_mod *= 0.5
SSblackbox.record_feedback("tally", "heretic_ascended", 1, route)
log_heretic_knowledge("[key_name(user)] completed their final ritual at [worldtime2text()].")
notify_ghosts(
"[user] has completed an ascension ritual!",
source = user,
header = "A Heretic is Ascending!",
)
return TRUE
/datum/heretic_knowledge/ultimate/cleanup_atoms(list/selected_atoms)
for(var/mob/living/carbon/human/sacrifice in selected_atoms)
selected_atoms -= sacrifice
sacrifice.gib(DROP_ALL_REMAINS)
return ..()