/
heretic_antag.dm
797 lines (655 loc) · 28.6 KB
/
heretic_antag.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
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
/*
* Simple helper to generate a string of
* garbled symbols up to [length] characters.
*
* Used in creating spooky-text for heretic ascension announcements.
*/
/proc/generate_heretic_text(length = 25)
. = ""
for(var/i in 1 to length)
. += pick("!", "$", "^", "@", "&", "#", "*", "(", ")", "?")
/// The heretic antagonist itself.
/datum/antagonist/heretic
name = "\improper Heretic"
roundend_category = "Heretics"
antagpanel_category = "Heretic"
ui_name = "AntagInfoHeretic"
antag_moodlet = /datum/mood_event/heretics
job_rank = ROLE_HERETIC
antag_hud_name = "heretic"
hijack_speed = 0.5
suicide_cry = "THE MANSUS SMILES UPON ME!!"
preview_outfit = /datum/outfit/heretic
can_assign_self_objectives = TRUE
default_custom_objective = "Turn a department into a testament for your dark knowledge."
hardcore_random_bonus = TRUE
/// Whether we give this antagonist objectives on gain.
var/give_objectives = TRUE
/// Whether we've ascended! (Completed one of the final rituals)
var/ascended = FALSE
/// The path our heretic has chosen. Mostly used for flavor.
var/heretic_path = PATH_START
/// A sum of how many knowledge points this heretic CURRENTLY has. Used to research.
var/knowledge_points = 1
/// The time between gaining influence passively. The heretic gain +1 knowledge points every this duration of time.
var/passive_gain_timer = 20 MINUTES
/// Assoc list of [typepath] = [knowledge instance]. A list of all knowledge this heretic's reserached.
var/list/researched_knowledge = list()
/// The organ slot we place our Living Heart in.
var/living_heart_organ_slot = ORGAN_SLOT_HEART
/// A list of TOTAL how many sacrifices completed. (Includes high value sacrifices)
var/total_sacrifices = 0
/// A list of TOTAL how many high value sacrifices completed. (Heads of staff)
var/high_value_sacrifices = 0
/// Lazy assoc list of [refs to humans] to [image previews of the human]. Humans that we have as sacrifice targets.
var/list/mob/living/carbon/human/sac_targets
/// List of all sacrifice target's names, used for end of round report
var/list/all_sac_targets = list()
/// Whether we're drawing a rune or not
var/drawing_rune = FALSE
/// A static typecache of all tools we can scribe with.
var/static/list/scribing_tools = typecacheof(list(/obj/item/pen, /obj/item/toy/crayon))
/// A blacklist of turfs we cannot scribe on.
var/static/list/blacklisted_rune_turfs = typecacheof(list(/turf/open/space, /turf/open/openspace, /turf/open/lava, /turf/open/chasm))
/// Static list of what each path converts to in the UI (colors are TGUI colors)
var/static/list/path_to_ui_color = list(
PATH_START = "grey",
PATH_SIDE = "green",
PATH_RUST = "brown",
PATH_FLESH = "red",
PATH_ASH = "white",
PATH_VOID = "blue",
PATH_BLADE = "label", // my favorite color is label
PATH_COSMIC = "purple",
PATH_LOCK = "yellow",
PATH_MOON = "blue",
)
var/static/list/path_to_rune_color = list(
PATH_START = COLOR_LIME,
PATH_RUST = COLOR_CARGO_BROWN,
PATH_FLESH = COLOR_SOFT_RED,
PATH_ASH = COLOR_VIVID_RED,
PATH_VOID = COLOR_CYAN,
PATH_BLADE = COLOR_SILVER,
PATH_COSMIC = COLOR_PURPLE,
PATH_LOCK = COLOR_YELLOW,
PATH_MOON = COLOR_BLUE_LIGHT,
)
/datum/antagonist/heretic/Destroy()
LAZYNULL(sac_targets)
return ..()
/datum/antagonist/heretic/ui_data(mob/user)
var/list/data = list()
data["charges"] = knowledge_points
data["total_sacrifices"] = total_sacrifices
data["ascended"] = ascended
// This should be cached in some way, but the fact that final knowledge
// has to update its disabled state based on whether all objectives are complete,
// makes this very difficult. I'll figure it out one day maybe
for(var/datum/heretic_knowledge/knowledge as anything in get_researchable_knowledge())
var/list/knowledge_data = list()
knowledge_data["path"] = knowledge
knowledge_data["name"] = initial(knowledge.name)
knowledge_data["desc"] = initial(knowledge.desc)
knowledge_data["gainFlavor"] = initial(knowledge.gain_text)
knowledge_data["cost"] = initial(knowledge.cost)
knowledge_data["disabled"] = initial(knowledge.cost) > knowledge_points
// Final knowledge can't be learned until all objectives are complete.
if(ispath(knowledge, /datum/heretic_knowledge/ultimate))
knowledge_data["disabled"] = !can_ascend()
knowledge_data["hereticPath"] = initial(knowledge.route)
knowledge_data["color"] = path_to_ui_color[initial(knowledge.route)] || "grey"
data["learnableKnowledge"] += list(knowledge_data)
return data
/datum/antagonist/heretic/ui_static_data(mob/user)
var/list/data = list()
data["objectives"] = get_objectives()
data["can_change_objective"] = can_assign_self_objectives
for(var/path in researched_knowledge)
var/list/knowledge_data = list()
var/datum/heretic_knowledge/found_knowledge = researched_knowledge[path]
knowledge_data["name"] = found_knowledge.name
knowledge_data["desc"] = found_knowledge.desc
knowledge_data["gainFlavor"] = found_knowledge.gain_text
knowledge_data["cost"] = found_knowledge.cost
knowledge_data["hereticPath"] = found_knowledge.route
knowledge_data["color"] = path_to_ui_color[found_knowledge.route] || "grey"
data["learnedKnowledge"] += list(knowledge_data)
return data
/datum/antagonist/heretic/ui_act(action, params)
. = ..()
if(.)
return
switch(action)
if("research")
var/datum/heretic_knowledge/researched_path = text2path(params["path"])
if(!ispath(researched_path, /datum/heretic_knowledge))
CRASH("Heretic attempted to learn non-heretic_knowledge path! (Got: [researched_path])")
if(initial(researched_path.cost) > knowledge_points)
return TRUE
if(!gain_knowledge(researched_path))
return TRUE
log_heretic_knowledge("[key_name(owner)] gained knowledge: [initial(researched_path.name)]")
knowledge_points -= initial(researched_path.cost)
return TRUE
/datum/antagonist/heretic/submit_player_objective(retain_existing = FALSE, retain_escape = TRUE, force = FALSE)
if (isnull(owner) || isnull(owner.current))
return
var/confirmed = tgui_alert(
owner.current,
message = "Are you sure? You will no longer be able to Ascend.",
title = "Reject the call?",
buttons = list("Yes", "No"),
) == "Yes"
if (!confirmed)
return
return ..()
/datum/antagonist/heretic/ui_status(mob/user, datum/ui_state/state)
if(user.stat == DEAD)
return UI_CLOSE
return ..()
/datum/antagonist/heretic/get_preview_icon()
var/icon/icon = render_preview_outfit(preview_outfit)
// MOTHBLOCKS TOOD: Copied and pasted from cult, make this its own proc
// The sickly blade is 64x64, but getFlatIcon crunches to 32x32.
// So I'm just going to add it in post, screw it.
// Center the dude, because item icon states start from the center.
// This makes the image 64x64.
icon.Crop(-15, -15, 48, 48)
var/obj/item/melee/sickly_blade/blade = new
icon.Blend(icon(blade.lefthand_file, blade.inhand_icon_state), ICON_OVERLAY)
qdel(blade)
// Move the guy back to the bottom left, 32x32.
icon.Crop(17, 17, 48, 48)
return finish_preview_icon(icon)
/datum/antagonist/heretic/farewell()
if(!silent)
to_chat(owner.current, span_userdanger("Your mind begins to flare as the otherwordly knowledge escapes your grasp!"))
return ..()
/datum/antagonist/heretic/on_gain()
if(give_objectives)
forge_primary_objectives()
owner.current.playsound_local(get_turf(owner.current), 'sound/ambience/antag/heretic/heretic_gain.ogg', 100, FALSE, pressure_affected = FALSE, use_reverb = FALSE)
for(var/starting_knowledge in GLOB.heretic_start_knowledge)
gain_knowledge(starting_knowledge)
addtimer(CALLBACK(src, PROC_REF(passive_influence_gain)), passive_gain_timer) // Gain +1 knowledge every 20 minutes.
return ..()
/datum/antagonist/heretic/on_removal()
for(var/knowledge_index in researched_knowledge)
var/datum/heretic_knowledge/knowledge = researched_knowledge[knowledge_index]
knowledge.on_lose(owner.current, src)
QDEL_LIST_ASSOC_VAL(researched_knowledge)
return ..()
/datum/antagonist/heretic/apply_innate_effects(mob/living/mob_override)
var/mob/living/our_mob = mob_override || owner.current
handle_clown_mutation(our_mob, "Ancient knowledge described to you has allowed you to overcome your clownish nature, allowing you to wield weapons without harming yourself.")
our_mob.faction |= FACTION_HERETIC
if (!issilicon(our_mob))
GLOB.reality_smash_track.add_tracked_mind(owner)
RegisterSignals(our_mob, list(COMSIG_MOB_BEFORE_SPELL_CAST, COMSIG_MOB_SPELL_ACTIVATED), PROC_REF(on_spell_cast))
RegisterSignal(our_mob, COMSIG_MOB_ITEM_AFTERATTACK, PROC_REF(on_item_afterattack))
RegisterSignal(our_mob, COMSIG_MOB_LOGIN, PROC_REF(fix_influence_network))
RegisterSignal(our_mob, COMSIG_LIVING_POST_FULLY_HEAL, PROC_REF(after_fully_healed))
/datum/antagonist/heretic/remove_innate_effects(mob/living/mob_override)
var/mob/living/our_mob = mob_override || owner.current
handle_clown_mutation(our_mob, removing = FALSE)
our_mob.faction -= FACTION_HERETIC
if (owner in GLOB.reality_smash_track.tracked_heretics)
GLOB.reality_smash_track.remove_tracked_mind(owner)
UnregisterSignal(our_mob, list(
COMSIG_MOB_BEFORE_SPELL_CAST,
COMSIG_MOB_SPELL_ACTIVATED,
COMSIG_MOB_ITEM_AFTERATTACK,
COMSIG_MOB_LOGIN,
COMSIG_LIVING_POST_FULLY_HEAL,
))
/datum/antagonist/heretic/on_body_transfer(mob/living/old_body, mob/living/new_body)
. = ..()
if(old_body == new_body) // if they were using a temporary body
return
for(var/knowledge_index in researched_knowledge)
var/datum/heretic_knowledge/knowledge = researched_knowledge[knowledge_index]
knowledge.on_lose(old_body, src)
knowledge.on_gain(new_body, src)
/*
* Signal proc for [COMSIG_MOB_BEFORE_SPELL_CAST] and [COMSIG_MOB_SPELL_ACTIVATED].
*
* Checks if our heretic has [TRAIT_ALLOW_HERETIC_CASTING] or is ascended.
* If so, allow them to cast like normal.
* If not, cancel the cast, and returns [SPELL_CANCEL_CAST].
*/
/datum/antagonist/heretic/proc/on_spell_cast(mob/living/source, datum/action/cooldown/spell/spell)
SIGNAL_HANDLER
// Heretic spells are of the forbidden school, otherwise we don't care
if(spell.school != SCHOOL_FORBIDDEN)
return
// If we've got the trait, we don't care
if(HAS_TRAIT(source, TRAIT_ALLOW_HERETIC_CASTING))
return
// All powerful, don't care
if(ascended)
return
// We shouldn't be able to cast this! Cancel it.
source.balloon_alert(source, "you need a focus!")
return SPELL_CANCEL_CAST
/*
* Signal proc for [COMSIG_MOB_ITEM_AFTERATTACK].
*
* If a heretic is holding a pen in their main hand,
* and have mansus grasp active in their offhand,
* they're able to draw a transmutation rune.
*/
/datum/antagonist/heretic/proc/on_item_afterattack(mob/living/source, atom/target, obj/item/weapon, proximity_flag, click_parameters)
SIGNAL_HANDLER
if(!is_type_in_typecache(weapon, scribing_tools))
return
if(!isturf(target) || !isliving(source) || !proximity_flag)
return
var/obj/item/offhand = source.get_inactive_held_item()
if(QDELETED(offhand) || !istype(offhand, /obj/item/melee/touch_attack/mansus_fist))
return
try_draw_rune(source, target, additional_checks = CALLBACK(src, PROC_REF(check_mansus_grasp_offhand), source))
return COMPONENT_CANCEL_ATTACK_CHAIN
/**
* Attempt to draw a rune on [target_turf].
*
* Arguments
* * user - the mob drawing the rune
* * target_turf - the place the rune's being drawn
* * drawing_time - how long the do_after takes to make the rune
* * additional checks - optional callbacks to be ran while drawing the rune
*/
/datum/antagonist/heretic/proc/try_draw_rune(mob/living/user, turf/target_turf, drawing_time = 20 SECONDS, additional_checks)
for(var/turf/nearby_turf as anything in RANGE_TURFS(1, target_turf))
if(!isopenturf(nearby_turf) || is_type_in_typecache(nearby_turf, blacklisted_rune_turfs))
target_turf.balloon_alert(user, "invalid placement for rune!")
return
if(locate(/obj/effect/heretic_rune) in range(3, target_turf))
target_turf.balloon_alert(user, "too close to another rune!")
return
if(drawing_rune)
target_turf.balloon_alert(user, "already drawing a rune!")
return
INVOKE_ASYNC(src, PROC_REF(draw_rune), user, target_turf, drawing_time, additional_checks)
/**
* The actual process of drawing a rune.
*
* Arguments
* * user - the mob drawing the rune
* * target_turf - the place the rune's being drawn
* * drawing_time - how long the do_after takes to make the rune
* * additional checks - optional callbacks to be ran while drawing the rune
*/
/datum/antagonist/heretic/proc/draw_rune(mob/living/user, turf/target_turf, drawing_time = 20 SECONDS, additional_checks)
drawing_rune = TRUE
var/rune_colour = path_to_rune_color[heretic_path]
target_turf.balloon_alert(user, "drawing rune...")
var/obj/effect/temp_visual/drawing_heretic_rune/drawing_effect
if (drawing_time < (10 SECONDS))
drawing_effect = new /obj/effect/temp_visual/drawing_heretic_rune/fast(target_turf, rune_colour)
else
drawing_effect = new(target_turf, rune_colour)
if(!do_after(user, drawing_time, target_turf, extra_checks = additional_checks, hidden = TRUE))
target_turf.balloon_alert(user, "interrupted!")
new /obj/effect/temp_visual/drawing_heretic_rune/fail(target_turf, rune_colour)
qdel(drawing_effect)
drawing_rune = FALSE
return
qdel(drawing_effect)
target_turf.balloon_alert(user, "rune created")
new /obj/effect/heretic_rune/big(target_turf, rune_colour)
drawing_rune = FALSE
/**
* Callback to check that the user's still got their Mansus Grasp out when drawing a rune.
*
* Arguments
* * user - the mob drawing the rune
*/
/datum/antagonist/heretic/proc/check_mansus_grasp_offhand(mob/living/user)
var/obj/item/offhand = user.get_inactive_held_item()
return !QDELETED(offhand) && istype(offhand, /obj/item/melee/touch_attack/mansus_fist)
/*
* Signal proc for [COMSIG_MOB_LOGIN].
*
* Calls rework_network() on our reality smash tracker
* whenever a login / client change happens, to ensure
* influence client visibility is fixed.
*/
/datum/antagonist/heretic/proc/fix_influence_network(mob/source)
SIGNAL_HANDLER
GLOB.reality_smash_track.rework_network()
/// Signal proc for [COMSIG_LIVING_POST_FULLY_HEAL],
/// Gives the heretic aliving heart on aheal or organ refresh
/datum/antagonist/heretic/proc/after_fully_healed(mob/living/source, heal_flags)
SIGNAL_HANDLER
if(heal_flags & (HEAL_REFRESH_ORGANS|HEAL_ADMIN))
var/datum/heretic_knowledge/living_heart/heart_knowledge = get_knowledge(/datum/heretic_knowledge/living_heart)
heart_knowledge.on_research(source, src)
/**
* Create our objectives for our heretic.
*/
/datum/antagonist/heretic/proc/forge_primary_objectives()
var/datum/objective/heretic_research/research_objective = new()
research_objective.owner = owner
objectives += research_objective
var/num_heads = 0
for(var/mob/player in GLOB.alive_player_list)
if(player.mind.assigned_role.job_flags & JOB_HEAD_OF_STAFF)
num_heads++
var/datum/objective/minor_sacrifice/sac_objective = new()
sac_objective.owner = owner
if(num_heads < 2) // They won't get major sacrifice, so bump up minor sacrifice a bit
sac_objective.target_amount += 2
sac_objective.update_explanation_text()
objectives += sac_objective
if(num_heads >= 2)
var/datum/objective/major_sacrifice/other_sac_objective = new()
other_sac_objective.owner = owner
objectives += other_sac_objective
/**
* Add [target] as a sacrifice target for the heretic.
* Generates a preview image and associates it with a weakref of the mob.
*/
/datum/antagonist/heretic/proc/add_sacrifice_target(mob/living/carbon/human/target)
var/image/target_image = image(icon = target.icon, icon_state = target.icon_state)
target_image.overlays = target.overlays
LAZYSET(sac_targets, target, target_image)
RegisterSignal(target, COMSIG_QDELETING, PROC_REF(on_target_deleted))
all_sac_targets += target.real_name
/**
* Removes [target] from the heretic's sacrifice list.
* Returns FALSE if no one was removed, TRUE otherwise
*/
/datum/antagonist/heretic/proc/remove_sacrifice_target(mob/living/carbon/human/target)
if(!(target in sac_targets))
return FALSE
LAZYREMOVE(sac_targets, target)
UnregisterSignal(target, COMSIG_QDELETING)
return TRUE
/**
* Signal proc for [COMSIG_QDELETING] registered on sac targets
* if sacrifice targets are deleted (gibbed, dusted, whatever), free their slot and reference
*/
/datum/antagonist/heretic/proc/on_target_deleted(mob/living/carbon/human/source)
SIGNAL_HANDLER
remove_sacrifice_target(source)
/**
* Increments knowledge by one.
* Used in callbacks for passive gain over time.
*/
/datum/antagonist/heretic/proc/passive_influence_gain()
knowledge_points++
if(owner.current.stat <= SOFT_CRIT)
to_chat(owner.current, "[span_hear("You hear a whisper...")] [span_hypnophrase(pick(strings(HERETIC_INFLUENCE_FILE, "drain_message")))]")
addtimer(CALLBACK(src, PROC_REF(passive_influence_gain)), passive_gain_timer)
/datum/antagonist/heretic/roundend_report()
var/list/parts = list()
var/succeeded = TRUE
parts += printplayer(owner)
parts += "<b>Sacrifices Made:</b> [total_sacrifices]"
parts += "The heretic's sacrifice targets were: [english_list(all_sac_targets, nothing_text = "No one")]."
if(length(objectives))
var/count = 1
for(var/datum/objective/objective as anything in objectives)
if(!objective.check_completion())
succeeded = FALSE
parts += "<b>Objective #[count]</b>: [objective.explanation_text] [objective.get_roundend_success_suffix()]"
count++
if(ascended)
parts += span_greentext(span_big("THE HERETIC ASCENDED!"))
else
if(succeeded)
parts += span_greentext("The heretic was successful, but did not ascend!")
else
parts += span_redtext("The heretic has failed.")
parts += "<b>Knowledge Researched:</b> "
var/list/string_of_knowledge = list()
for(var/knowledge_index in researched_knowledge)
var/datum/heretic_knowledge/knowledge = researched_knowledge[knowledge_index]
string_of_knowledge += knowledge.name
parts += english_list(string_of_knowledge)
return parts.Join("<br>")
/datum/antagonist/heretic/get_admin_commands()
. = ..()
switch(has_living_heart())
if(HERETIC_NO_LIVING_HEART)
.["Give Living Heart"] = CALLBACK(src, PROC_REF(give_living_heart))
if(HERETIC_HAS_LIVING_HEART)
.["Add Heart Target (Marked Mob)"] = CALLBACK(src, PROC_REF(add_marked_as_target))
.["Remove Heart Target"] = CALLBACK(src, PROC_REF(remove_target))
.["Adjust Knowledge Points"] = CALLBACK(src, PROC_REF(admin_change_points))
.["Give Focus"] = CALLBACK(src, PROC_REF(admin_give_focus))
/**
* Admin proc for giving a heretic a Living Heart easily.
*/
/datum/antagonist/heretic/proc/give_living_heart(mob/admin)
if(!admin.client?.holder)
to_chat(admin, span_warning("You shouldn't be using this!"))
return
var/datum/heretic_knowledge/living_heart/heart_knowledge = get_knowledge(/datum/heretic_knowledge/living_heart)
if(!heart_knowledge)
to_chat(admin, span_warning("The heretic doesn't have a living heart knowledge for some reason. What?"))
return
heart_knowledge.on_research(owner.current, src)
/**
* Admin proc for adding a marked mob to a heretic's sac list.
*/
/datum/antagonist/heretic/proc/add_marked_as_target(mob/admin)
if(!admin.client?.holder)
to_chat(admin, span_warning("You shouldn't be using this!"))
return
var/mob/living/carbon/human/new_target = admin.client?.holder.marked_datum
if(!istype(new_target))
to_chat(admin, span_warning("You need to mark a human to do this!"))
return
if(tgui_alert(admin, "Let them know their targets have been updated?", "Whispers of the Mansus", list("Yes", "No")) == "Yes")
to_chat(owner.current, span_danger("The Mansus has modified your targets. Go find them!"))
to_chat(owner.current, span_danger("[new_target.real_name], the [new_target.mind?.assigned_role?.title || "human"]."))
add_sacrifice_target(new_target)
/**
* Admin proc for removing a mob from a heretic's sac list.
*/
/datum/antagonist/heretic/proc/remove_target(mob/admin)
if(!admin.client?.holder)
to_chat(admin, span_warning("You shouldn't be using this!"))
return
var/list/removable = list()
for(var/mob/living/carbon/human/old_target as anything in sac_targets)
removable[old_target.name] = old_target
var/name_of_removed = tgui_input_list(admin, "Choose a human to remove", "Who to Spare", removable)
if(QDELETED(src) || !admin.client?.holder || isnull(name_of_removed))
return
var/mob/living/carbon/human/chosen_target = removable[name_of_removed]
if(QDELETED(chosen_target) || !ishuman(chosen_target))
return
if(!remove_sacrifice_target(chosen_target))
to_chat(admin, span_warning("Failed to remove [name_of_removed] from [owner]'s sacrifice list. Perhaps they're no longer in the list anyways."))
return
if(tgui_alert(admin, "Let them know their targets have been updated?", "Whispers of the Mansus", list("Yes", "No")) == "Yes")
to_chat(owner.current, span_danger("The Mansus has modified your targets."))
/**
* Admin proc for easily adding / removing knowledge points.
*/
/datum/antagonist/heretic/proc/admin_change_points(mob/admin)
if(!admin.client?.holder)
to_chat(admin, span_warning("You shouldn't be using this!"))
return
var/change_num = tgui_input_number(admin, "Add or remove knowledge points", "Points", 0, 100, -100)
if(!change_num || QDELETED(src))
return
knowledge_points += change_num
/**
* Admin proc for giving a heretic a focus.
*/
/datum/antagonist/heretic/proc/admin_give_focus(mob/admin)
if(!admin.client?.holder)
to_chat(admin, span_warning("You shouldn't be using this!"))
return
var/mob/living/pawn = owner.current
pawn.equip_to_slot_if_possible(new /obj/item/clothing/neck/heretic_focus(get_turf(pawn)), ITEM_SLOT_NECK, TRUE, TRUE)
to_chat(pawn, span_hypnophrase("The Mansus has manifested you a focus."))
/datum/antagonist/heretic/antag_panel_data()
var/list/string_of_knowledge = list()
for(var/knowledge_index in researched_knowledge)
var/datum/heretic_knowledge/knowledge = researched_knowledge[knowledge_index]
if(istype(knowledge, /datum/heretic_knowledge/ultimate))
string_of_knowledge += span_bold(knowledge.name)
else
string_of_knowledge += knowledge.name
return "<br><b>Research Done:</b><br>[english_list(string_of_knowledge, and_text = ", and ")]<br>"
/datum/antagonist/heretic/antag_panel_objectives()
. = ..()
. += "<br>"
. += "<i><b>Current Targets:</b></i><br>"
if(LAZYLEN(sac_targets))
for(var/mob/living/carbon/human/target as anything in sac_targets)
. += " - <b>[target.real_name]</b>, the [target.mind?.assigned_role?.title || "human"].<br>"
else
. += "<i>None!</i><br>"
. += "<br>"
/**
* Learns the passed [typepath] of knowledge, creating a knowledge datum
* and adding it to our researched knowledge list.
*
* Returns TRUE if the knowledge was added successfully. FALSE otherwise.
*/
/datum/antagonist/heretic/proc/gain_knowledge(datum/heretic_knowledge/knowledge_type)
if(!ispath(knowledge_type))
stack_trace("[type] gain_knowledge was given an invalid path! (Got: [knowledge_type])")
return FALSE
if(get_knowledge(knowledge_type))
return FALSE
var/datum/heretic_knowledge/initialized_knowledge = new knowledge_type()
researched_knowledge[knowledge_type] = initialized_knowledge
initialized_knowledge.on_research(owner.current, src)
update_static_data(owner.current)
return TRUE
/**
* Get a list of all knowledge TYPEPATHS that we can currently research.
*/
/datum/antagonist/heretic/proc/get_researchable_knowledge()
var/list/researchable_knowledge = list()
var/list/banned_knowledge = list()
for(var/knowledge_index in researched_knowledge)
var/datum/heretic_knowledge/knowledge = researched_knowledge[knowledge_index]
researchable_knowledge |= knowledge.next_knowledge
banned_knowledge |= knowledge.banned_knowledge
banned_knowledge |= knowledge.type
researchable_knowledge -= banned_knowledge
return researchable_knowledge
/**
* Check if the wanted type-path is in the list of research knowledge.
*/
/datum/antagonist/heretic/proc/get_knowledge(wanted)
return researched_knowledge[wanted]
/**
* Get a list of all rituals this heretic can invoke on a rune.
* Iterates over all of our knowledge and, if we can invoke it, adds it to our list.
*
* Returns an associated list of [knowledge name] to [knowledge datum] sorted by knowledge priority.
*/
/datum/antagonist/heretic/proc/get_rituals()
var/list/rituals = list()
for(var/knowledge_index in researched_knowledge)
var/datum/heretic_knowledge/knowledge = researched_knowledge[knowledge_index]
if(!knowledge.can_be_invoked(src))
continue
rituals[knowledge.name] = knowledge
return sortTim(rituals, GLOBAL_PROC_REF(cmp_heretic_knowledge), associative = TRUE)
/**
* Checks to see if our heretic can ccurrently ascend.
*
* Returns FALSE if not all of our objectives are complete, or TRUE otherwise.
*/
/datum/antagonist/heretic/proc/can_ascend()
if(!can_assign_self_objectives)
return FALSE // We spurned the offer of the Mansus :(
for(var/datum/objective/must_be_done as anything in objectives)
if(!must_be_done.check_completion())
return FALSE
return TRUE
/**
* Helper to determine if a Heretic
* - Has a Living Heart
* - Has a an organ in the correct slot that isn't a living heart
* - Is missing the organ they need in the slot to make a living heart
*
* Returns HERETIC_NO_HEART_ORGAN if they have no heart (organ) at all,
* Returns HERETIC_NO_LIVING_HEART if they have a heart (organ) but it's not a living one,
* and returns HERETIC_HAS_LIVING_HEART if they have a living heart
*/
/datum/antagonist/heretic/proc/has_living_heart()
var/obj/item/organ/our_living_heart = owner.current?.get_organ_slot(living_heart_organ_slot)
if(!our_living_heart)
return HERETIC_NO_HEART_ORGAN
if(!HAS_TRAIT(our_living_heart, TRAIT_LIVING_HEART))
return HERETIC_NO_LIVING_HEART
return HERETIC_HAS_LIVING_HEART
/// Heretic's minor sacrifice objective. "Minor sacrifices" includes anyone.
/datum/objective/minor_sacrifice
name = "minor sacrifice"
/datum/objective/minor_sacrifice/New(text)
. = ..()
target_amount = rand(3, 4)
update_explanation_text()
/datum/objective/minor_sacrifice/update_explanation_text()
. = ..()
explanation_text = "Sacrifice at least [target_amount] crewmembers."
/datum/objective/minor_sacrifice/check_completion()
var/datum/antagonist/heretic/heretic_datum = owner?.has_antag_datum(/datum/antagonist/heretic)
if(!heretic_datum)
return FALSE
return completed || (heretic_datum.total_sacrifices >= target_amount)
/// Heretic's major sacrifice objective. "Major sacrifices" are heads of staff.
/datum/objective/major_sacrifice
name = "major sacrifice"
target_amount = 1
explanation_text = "Sacrifice 1 head of staff."
/datum/objective/major_sacrifice/check_completion()
var/datum/antagonist/heretic/heretic_datum = owner?.has_antag_datum(/datum/antagonist/heretic)
if(!heretic_datum)
return FALSE
return completed || (heretic_datum.high_value_sacrifices >= target_amount)
/// Heretic's research objective. "Research" is heretic knowledge nodes (You start with some).
/datum/objective/heretic_research
name = "research"
/// The length of a main path. Calculated once in New().
var/static/main_path_length = 0
/datum/objective/heretic_research/New(text)
. = ..()
if(!main_path_length)
// Let's find the length of a main path. We'll use rust because it's the coolest.
// (All the main paths are (should be) the same length, so it doesn't matter.)
var/rust_paths_found = 0
for(var/datum/heretic_knowledge/knowledge as anything in subtypesof(/datum/heretic_knowledge))
if(initial(knowledge.route) == PATH_RUST)
rust_paths_found++
main_path_length = rust_paths_found
// Factor in the length of the main path first.
target_amount = main_path_length
// Add in the base research we spawn with, otherwise it'd be too easy.
target_amount += length(GLOB.heretic_start_knowledge)
// And add in some buffer, to require some sidepathing, especially since heretics get some free side paths.
target_amount += rand(2, 4)
update_explanation_text()
/datum/objective/heretic_research/update_explanation_text()
. = ..()
explanation_text = "Research at least [target_amount] knowledge from the Mansus. You start with [length(GLOB.heretic_start_knowledge)] researched."
/datum/objective/heretic_research/check_completion()
var/datum/antagonist/heretic/heretic_datum = owner?.has_antag_datum(/datum/antagonist/heretic)
if(!heretic_datum)
return FALSE
return completed || (length(heretic_datum.researched_knowledge) >= target_amount)
/datum/objective/heretic_summon
name = "summon monsters"
target_amount = 2
explanation_text = "Summon 2 monsters from the Mansus into this realm."
/// The total number of summons the objective owner has done
var/num_summoned = 0
/datum/objective/heretic_summon/check_completion()
return completed || (num_summoned >= target_amount)
/datum/outfit/heretic
name = "Heretic (Preview only)"
suit = /obj/item/clothing/suit/hooded/cultrobes/eldritch
head = /obj/item/clothing/head/hooded/cult_hoodie/eldritch
r_hand = /obj/item/melee/touch_attack/mansus_fist