forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
memorial_logger.cpp
1100 lines (1047 loc) · 45.5 KB
/
memorial_logger.cpp
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
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "memorial_logger.h"
#include <istream>
#include <list>
#include <map>
#include <memory>
#include <string>
#include <tuple>
#include <utility>
#include "achievement.h"
#include "addiction.h"
#include "avatar.h"
#include "bionics.h"
#include "bodypart.h"
#include "calendar.h"
#include "cata_variant.h"
#include "character.h"
#include "character_id.h"
#include "coordinates.h"
#include "debug.h"
#include "debug_menu.h"
#include "effect.h"
#include "enum_conversions.h"
#include "event.h"
#include "event_statistics.h"
#include "filesystem.h"
#include "game.h"
#include "get_version.h"
#include "inventory.h"
#include "item.h"
#include "item_factory.h"
#include "itype.h"
#include "json.h"
#include "kill_tracker.h"
#include "magic.h"
#include "martialarts.h"
#include "messages.h"
#include "monstergenerator.h"
#include "mtype.h"
#include "mutation.h"
#include "omdata.h"
#include "output.h"
#include "overmapbuffer.h"
#include "past_games_info.h"
#include "pimpl.h"
#include "profession.h"
#include "skill.h"
#include "stats_tracker.h"
#include "translations.h"
#include "trap.h"
#include "type_id.h"
#include "units.h"
static const efftype_id effect_adrenaline( "adrenaline" );
static const efftype_id effect_datura( "datura" );
static const efftype_id effect_drunk( "drunk" );
static const efftype_id effect_jetinjector( "jetinjector" );
static const trait_id trait_CANNIBAL( "CANNIBAL" );
static const trait_id trait_PSYCHOPATH( "PSYCHOPATH" );
static const trait_id trait_SAPIOVORE( "SAPIOVORE" );
memorial_log_entry::memorial_log_entry( const std::string &preformatted_msg ) :
preformatted_( preformatted_msg )
{}
memorial_log_entry::memorial_log_entry( time_point time, const oter_type_str_id &oter_id,
const std::string &oter_name, const std::string &msg ) :
time_( time ), oter_id_( oter_id ), oter_name_( oter_name ), message_( msg )
{}
std::string memorial_log_entry::to_string() const
{
if( preformatted_ ) {
return *preformatted_;
} else {
return "| " + ::to_string( time_ ) + " | " + oter_name_ + " | " + message_;
}
}
void memorial_log_entry::deserialize( const JsonObject &jo )
{
if( jo.read( "preformatted", preformatted_ ) ) {
return;
}
jo.read( "time", time_, true );
jo.read( "oter_id", oter_id_, true );
jo.read( "oter_name", oter_name_, true );
jo.read( "message", message_, true );
}
void memorial_log_entry::serialize( JsonOut &jsout ) const
{
jsout.start_object();
if( preformatted_ ) {
jsout.member( "preformatted", preformatted_ );
} else {
jsout.member( "time", time_ );
jsout.member( "oter_id", oter_id_ );
jsout.member( "oter_name", oter_name_ );
jsout.member( "message", message_ );
}
jsout.end_object();
}
void memorial_logger::clear()
{
log.clear();
}
/**
* Adds an event to the memorial log, to be written to the memorial file when
* the character dies. The message should contain only the informational string,
* as the timestamp and location will be automatically prepended.
*/
void memorial_logger::add( const std::string &male_msg,
const std::string &female_msg )
{
Character &player_character = get_player_character();
const std::string &msg = player_character.male ? male_msg : female_msg;
if( msg.empty() ) {
return;
}
const oter_id &cur_ter = overmap_buffer.ter( player_character.global_omt_location() );
const oter_type_str_id cur_oter_type = cur_ter->get_type_id();
const std::string &oter_name = cur_ter->get_name();
log.emplace_back( calendar::turn, cur_oter_type, oter_name, msg );
}
/**
* Loads the data in a memorial file from the given ifstream.
* In legacy format all the memorial entry lines begin with a pipe (|).
* (This legacy format stopped being used before 0.F release.)
* In new format the entries are stored as json.
* @param fin The stream to read the memorial entries from.
*/
void memorial_logger::load( std::istream &fin, const std::string &path )
{
log.clear();
if( fin.peek() == '|' ) {
// Legacy plain text format
while( fin.peek() == '|' ) {
std::string entry;
getline( fin, entry );
// strip all \r from end of string
while( *entry.rbegin() == '\r' ) {
entry.pop_back();
}
log.emplace_back( entry );
}
} else {
JsonIn jsin( fin, path );
if( !jsin.read( log ) ) {
debugmsg( "Error reading JSON memorial log" );
}
}
}
void memorial_logger::save( std::ostream &os ) const
{
JsonOut jsout( os );
jsout.write( log );
}
/**
* Concatenates all of the memorial log entries, delimiting them with newlines,
* and returns the resulting string. Used for saving and for writing out to the
* memorial file.
*/
std::string memorial_logger::dump() const
{
static const char *eol = cata_files::eol();
std::string output;
for( const memorial_log_entry &elem : log ) {
output += elem.to_string();
output += eol;
}
return output;
}
void memorial_logger::write_text_memorial( std::ostream &file,
const std::string &epitaph ) const
{
avatar &u = get_avatar();
static const char *eol = cata_files::eol();
//Size of indents in the memorial file
const std::string indent = " ";
const std::string pronoun = u.male ? _( "He" ) : _( "She" );
//Avoid saying "a male unemployed" or similar
std::string profession_name;
if( u.prof == profession::generic() ) {
if( u.male ) {
profession_name = _( "an unemployed male" );
} else {
profession_name = _( "an unemployed female" );
}
} else {
profession_name = string_format( _( "a %s" ), u.prof->gender_appropriate_name( u.male ) );
}
const std::string locdesc =
overmap_buffer.get_description_at( u.global_sm_location() );
//~ First parameter is a pronoun ("He"/"She"), second parameter is a description
//~ that designates the location relative to its surroundings.
const std::string kill_place = string_format( _( "%1$s was killed in a %2$s." ),
pronoun, locdesc );
//Header
file << string_format( _( "Cataclysm - Dark Days Ahead version %s memorial file" ),
getVersionString() ) << eol;
file << eol;
file << string_format( _( "In memory of: %s" ), u.get_name() ) << eol;
if( !epitaph.empty() ) { //Don't record empty epitaphs
//~ The "%s" will be replaced by an epitaph as displayed in the memorial files. Replace the quotation marks as appropriate for your language.
file << string_format( pgettext( "epitaph", "\"%s\"" ), epitaph ) << eol << eol;
}
//~ First parameter: Pronoun, second parameter: a profession name (with article)
file << string_format( _( "%1$s was %2$s when the apocalypse began." ),
pronoun, profession_name ) << eol;
file << string_format( _( "%1$s died on %2$s." ), pronoun,
to_string( calendar::turn ) ) << eol;
file << kill_place << eol;
file << eol;
//Misc
file << string_format( _( "Cash on hand: %s" ), format_money( u.cash ) ) << eol;
file << eol;
//HP
const auto limb_hp =
[&file, &indent, &u]( const std::string & desc, const bodypart_id & bp ) {
file << indent <<
string_format( desc, u.get_part_hp_cur( bp ), u.get_part_hp_max( bp ) ) << eol;
};
file << _( "Final HP:" ) << eol;
limb_hp( _( " Head: %d/%d" ), bodypart_id( "head" ) );
limb_hp( _( "Torso: %d/%d" ), bodypart_id( "torso" ) );
limb_hp( _( "L Arm: %d/%d" ), bodypart_id( "arm_l" ) );
limb_hp( _( "R Arm: %d/%d" ), bodypart_id( "arm_r" ) );
limb_hp( _( "L Leg: %d/%d" ), bodypart_id( "leg_l" ) );
limb_hp( _( "R Leg: %d/%d" ), bodypart_id( "leg_r" ) );
file << eol;
//Stats
file << _( "Final Stats:" ) << eol;
file << indent << string_format( _( "Str %d" ), u.str_cur )
<< indent << string_format( _( "Dex %d" ), u.dex_cur )
<< indent << string_format( _( "Int %d" ), u.int_cur )
<< indent << string_format( _( "Per %d" ), u.per_cur ) << eol;
file << _( "Base Stats:" ) << eol;
file << indent << string_format( _( "Str %d" ), u.str_max )
<< indent << string_format( _( "Dex %d" ), u.dex_max )
<< indent << string_format( _( "Int %d" ), u.int_max )
<< indent << string_format( _( "Per %d" ), u.per_max ) << eol;
file << eol;
//Last 20 messages
file << _( "Final Messages:" ) << eol;
std::vector<std::pair<std::string, std::string> > recent_messages =
Messages::recent_messages( 20 );
for( const std::pair<std::string, std::string> &recent_message : recent_messages ) {
file << indent << recent_message.first << " " << recent_message.second;
file << eol;
}
file << eol;
//Kill list
file << _( "Kills:" ) << eol;
int total_kills = 0;
std::map<std::tuple<std::string, std::string>, int> kill_counts;
// map <name, sym> to kill count
const kill_tracker &kills = g->get_kill_tracker();
for( const mtype &type : MonsterGenerator::generator().get_all_mtypes() ) {
int this_count = kills.kill_count( type.id );
if( this_count > 0 ) {
kill_counts[std::make_tuple( type.nname(), type.sym )] += this_count;
total_kills += this_count;
}
}
for( const std::pair<const std::tuple<std::string, std::string>, int> &entry : kill_counts ) {
file << " " << std::get<1>( entry.first ) << " - "
<< string_format( "%4d", entry.second ) << " "
<< std::get<0>( entry.first ) << eol;
}
if( total_kills == 0 ) {
file << indent << _( "No monsters were killed." ) << eol;
} else {
file << string_format( _( "Total kills: %d" ), total_kills ) << eol;
}
file << eol;
//Skills
file << _( "Skills:" ) << eol;
for( const std::pair<const skill_id, SkillLevel> &pair : u.get_all_skills() ) {
const SkillLevel &lobj = pair.second;
//~ 1. skill name, 2. skill level, 3. exercise percentage to next level
file << indent << string_format( _( "%s: %d (%d %%)" ), pair.first->name(), lobj.level(),
lobj.exercise() ) << eol;
}
file << eol;
//Traits
file << _( "Traits:" ) << eol;
for( const trait_id &mut : u.get_mutations() ) {
file << indent << u.mutation_name( mut ) << eol;
}
if( u.get_mutations().empty() ) {
file << indent << _( "(None)" ) << eol;
}
file << eol;
//Effects (illnesses)
file << _( "Ongoing Effects:" ) << eol;
bool had_effect = false;
if( u.get_perceived_pain() > 0 ) {
had_effect = true;
file << indent << _( "Pain" ) << " (" << u.get_perceived_pain() << ")";
}
if( !had_effect ) {
file << indent << _( "(None)" ) << eol;
}
file << eol;
//Bionics
file << _( "Bionics:" ) << eol;
for( const bionic_id &bionic : u.get_bionics() ) {
file << indent << bionic->name << eol;
}
if( u.get_bionics().empty() ) {
file << indent << _( "No bionics were installed." ) << eol;
}
file << string_format(
_( "Bionic Power: <color_light_blue>%d</color>/<color_light_blue>%d</color>" ),
units::to_kilojoule( u.get_power_level() ), units::to_kilojoule( u.get_max_power_level() ) ) << eol;
file << eol;
//Equipment
const item &weapon = u.get_wielded_item() ? *u.get_wielded_item() : null_item_reference();
file << _( "Weapon:" ) << eol;
file << indent << weapon.invlet << " - " << weapon.tname( 1, false ) << eol;
file << eol;
file << _( "Equipment:" ) << eol;
u.worn.write_text_memorial( file, indent, eol );
file << eol;
//Inventory
file << _( "Inventory:" ) << eol;
u.inv->restack( u );
invslice slice = u.inv->slice();
for( const std::list<item> *elem : slice ) {
const item &next_item = elem->front();
file << indent << next_item.invlet << " - " <<
next_item.tname( static_cast<unsigned>( elem->size() ), false );
if( elem->size() > 1 ) {
file << " [" << elem->size() << "]";
}
if( next_item.charges > 0 ) {
file << " (" << next_item.charges << ")";
}
file << eol;
}
file << eol;
//Lifetime stats
file << _( "Lifetime Stats and Scores" ) << eol;
for( const score *scr : get_stats().valid_scores() ) {
file << indent << scr->description( get_stats() ) << eol;
}
file << eol;
//History
file << _( "Game History" ) << eol;
file << dump();
}
void memorial_logger::write_json_memorial( std::ostream &memorial_file ) const
{
JsonOut jsout( memorial_file, true, 2 );
jsout.start_object();
jsout.member( "memorial_version", 0 );
jsout.member( "log", log );
jsout.member( "achievements", get_achievements() );
jsout.member( "stats", get_stats() );
std::map<string_id<score>, cata_variant> scores;
for( const score *scr : get_stats().valid_scores() ) {
scores.emplace( scr->id, scr->value( get_stats() ) );
}
jsout.member( "scores", scores );
jsout.end_object();
// Having written a new memorial file, we need to ensure that
// past_games_info now takes that into account
clear_past_games();
}
void memorial_logger::notify( const cata::event &e )
{
Character &player_character = get_player_character();
character_id avatar_id = player_character.getID();
std::string &avatar_name = player_character.name;
switch( e.type() ) {
case event_type::activates_artifact: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
std::string item_name = e.get<cata_variant_type::string>( "item_name" );
//~ %s is artifact name
add( pgettext( "memorial_male", "Activated the %s." ),
pgettext( "memorial_female", "Activated the %s." ),
item_name );
}
break;
}
case event_type::activates_mininuke: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Activated a mininuke." ),
pgettext( "memorial_female", "Activated a mininuke." ) );
}
break;
}
case event_type::administers_mutagen: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
mutagen_technique technique = e.get<mutagen_technique>( "technique" );
switch( technique ) {
case mutagen_technique::consumed_mutagen:
add( pgettext( "memorial_male", "Consumed mutagen." ),
pgettext( "memorial_female", "Consumed mutagen." ) );
break;
case mutagen_technique::injected_mutagen:
add( pgettext( "memorial_male", "Injected mutagen." ),
pgettext( "memorial_female", "Injected mutagen." ) );
break;
case mutagen_technique::consumed_purifier:
add( pgettext( "memorial_male", "Consumed purifier." ),
pgettext( "memorial_female", "Consumed purifier." ) );
break;
case mutagen_technique::injected_purifier:
add( pgettext( "memorial_male", "Injected purifier." ),
pgettext( "memorial_female", "Injected purifier." ) );
break;
case mutagen_technique::injected_smart_purifier:
add( pgettext( "memorial_male", "Injected smart purifier." ),
pgettext( "memorial_female", "Injected smart purifier." ) );
break;
case mutagen_technique::num_mutagen_techniques:
break;
}
}
break;
}
case event_type::angers_amigara_horrors: {
add( pgettext( "memorial_male", "Angered a group of amigara horrors!" ),
pgettext( "memorial_female", "Angered a group of amigara horrors!" ) );
break;
}
case event_type::awakes_dark_wyrms: {
add( pgettext( "memorial_male", "Awoke a group of dark wyrms!" ),
pgettext( "memorial_female", "Awoke a group of dark wyrms!" ) );
break;
}
case event_type::becomes_wanted: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Became wanted by the police!" ),
pgettext( "memorial_female", "Became wanted by the police!" ) );
}
break;
}
case event_type::broken_bone: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
bodypart_id part = e.get<bodypart_id>( "part" );
//~ %s is bodypart
add( pgettext( "memorial_male", "Broke his %s." ),
pgettext( "memorial_female", "Broke her %s." ),
body_part_name( part ) );
}
break;
}
case event_type::broken_bone_mends: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
bodypart_id part = e.get<bodypart_id>( "part" );
//~ %s is bodypart
add( pgettext( "memorial_male", "Broken %s began to mend." ),
pgettext( "memorial_female", "Broken %s began to mend." ),
body_part_name( part ) );
}
break;
}
case event_type::buries_corpse: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
const mtype &corpse_type = e.get<mtype_id>( "corpse_type" ).obj();
std::string corpse_name = e.get<cata_variant_type::string>( "corpse_name" );
if( corpse_name.empty() ) {
if( corpse_type.has_flag( MF_HUMAN ) ) {
add( pgettext( "memorial_male",
"You buried an unknown victim of the Cataclysm." ),
pgettext( "memorial_female",
"You buried an unknown victim of The Cataclysm." ) );
}
} else {
add( pgettext( "memorial_male", "You buried %s." ),
pgettext( "memorial_female", "You buried %s." ),
corpse_name );
}
}
break;
}
case event_type::causes_resonance_cascade: {
add( pgettext( "memorial_male", "Caused a resonance cascade." ),
pgettext( "memorial_female", "Caused a resonance cascade." ) );
break;
}
case event_type::character_gains_effect: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
const effect_type &type = e.get<efftype_id>( "effect" ).obj();
const std::string male_message = type.get_apply_memorial_log(
effect_type::memorial_gender::male );
const std::string female_message = type.get_apply_memorial_log(
effect_type::memorial_gender::female );
if( !male_message.empty() || !female_message.empty() ) {
add( male_message, female_message );
}
}
break;
}
case event_type::character_kills_character: {
character_id ch = e.get<character_id>( "killer" );
if( ch == avatar_id ) {
std::string name = e.get<cata_variant_type::string>( "victim_name" );
bool cannibal = player_character.has_trait( trait_CANNIBAL );
bool psycho = player_character.has_trait( trait_PSYCHOPATH );
if( player_character.has_trait( trait_SAPIOVORE ) ) {
add( pgettext( "memorial_male",
"Caught and killed an ape. Prey doesn't have a name." ),
pgettext( "memorial_female",
"Caught and killed an ape. Prey doesn't have a name." ) );
} else if( psycho && cannibal ) {
add( pgettext( "memorial_male",
"Killed a delicious-looking innocent, %s, in cold blood." ),
pgettext( "memorial_female",
"Killed a delicious-looking innocent, %s, in cold blood." ),
name );
} else if( psycho ) {
add( pgettext( "memorial_male",
"Killed an innocent, %s, in cold blood. They were weak." ),
pgettext( "memorial_female",
"Killed an innocent, %s, in cold blood. They were weak." ),
name );
} else if( cannibal ) {
add( pgettext( "memorial_male", "Killed an innocent, %s." ),
pgettext( "memorial_female", "Killed an innocent, %s." ),
name );
} else {
add( pgettext( "memorial_male",
"Killed an innocent person, %s, in cold blood and "
"felt terrible afterwards." ),
pgettext( "memorial_female",
"Killed an innocent person, %s, in cold blood and "
"felt terrible afterwards." ),
name );
}
}
break;
}
case event_type::character_kills_monster: {
character_id ch = e.get<character_id>( "killer" );
if( ch == avatar_id ) {
mtype_id victim_type = e.get<mtype_id>( "victim_type" );
if( victim_type->difficulty >= 30 ) {
add( pgettext( "memorial_male", "Killed a %s." ),
pgettext( "memorial_female", "Killed a %s." ),
victim_type->nname() );
}
}
break;
}
case event_type::character_loses_effect: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
const effect_type &type = e.get<efftype_id>( "effect" ).obj();
const std::string male_message = type.get_remove_memorial_log(
effect_type::memorial_gender::male );
const std::string female_message = type.get_remove_memorial_log(
effect_type::memorial_gender::female );
if( !male_message.empty() || !female_message.empty() ) {
add( male_message, female_message );
}
}
break;
}
case event_type::character_triggers_trap: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
trap_str_id trap = e.get<trap_str_id>( "trap" );
if( trap->has_memorial_msg() ) {
add( trap->memorial_msg( true ), trap->memorial_msg( false ) );
}
}
break;
}
case event_type::consumes_marloss_item: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
const itype *it = item_controller->find_template(
e.get<cata_variant_type::itype_id>( "itype" ) );
std::string itname = it->nname( 1 );
add( pgettext( "memorial_male", "Consumed a %s." ),
pgettext( "memorial_female", "Consumed a %s." ), itname );
}
break;
}
case event_type::crosses_marloss_threshold: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Opened the Marloss Gateway." ),
pgettext( "memorial_female", "Opened the Marloss Gateway." ) );
}
break;
}
case event_type::crosses_mutation_threshold: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
mutation_category_id category_id =
e.get<cata_variant_type::mutation_category_id>( "category" );
const mutation_category_trait &category =
mutation_category_trait::get_category( category_id );
add( category.memorial_message_male(),
category.memorial_message_female() );
}
break;
}
case event_type::crosses_mycus_threshold: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Became one with the Mycus." ),
pgettext( "memorial_female", "Became one with the Mycus." ) );
}
break;
}
case event_type::dermatik_eggs_hatch: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Dermatik eggs hatched." ),
pgettext( "memorial_female", "Dermatik eggs hatched." ) );
}
break;
}
case event_type::dermatik_eggs_injected: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Injected with dermatik eggs." ),
pgettext( "memorial_female", "Injected with dermatik eggs." ) );
}
break;
}
case event_type::destroys_triffid_grove: {
add( pgettext( "memorial_male", "Destroyed a triffid grove." ),
pgettext( "memorial_female", "Destroyed a triffid grove." ) );
break;
}
case event_type::dies_from_asthma_attack: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Succumbed to an asthma attack." ),
pgettext( "memorial_female", "Succumbed to an asthma attack." ) );
}
break;
}
case event_type::dies_from_drug_overdose: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
efftype_id effect = e.get<efftype_id>( "effect" );
if( effect == effect_datura ) {
add( pgettext( "memorial_male", "Died of datura overdose." ),
pgettext( "memorial_female", "Died of datura overdose." ) );
} else if( effect == effect_jetinjector ) {
add( pgettext( "memorial_male", "Died of a healing stimulant overdose." ),
pgettext( "memorial_female", "Died of a healing stimulant overdose." ) );
} else if( effect == effect_adrenaline ) {
add( pgettext( "memorial_male", "Died of adrenaline overdose." ),
pgettext( "memorial_female", "Died of adrenaline overdose." ) );
} else if( effect == effect_drunk ) {
add( pgettext( "memorial_male", "Died of an alcohol overdose." ),
pgettext( "memorial_female", "Died of an alcohol overdose." ) );
} else {
add( pgettext( "memorial_male", "Died of a drug overdose." ),
pgettext( "memorial_female", "Died of a drug overdose." ) );
}
}
break;
}
case event_type::dies_from_bleeding: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Bled to death." ),
pgettext( "memorial_female", "Bled to death." ) );
}
break;
}
case event_type::dies_from_hypovolemia: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Died of hypovolemic shock." ),
pgettext( "memorial_female", "Died of hypovolemic shock." ) );
}
break;
}
case event_type::dies_from_redcells_loss: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Died from loss of red blood cells." ),
pgettext( "memorial_female", "Died from loss of red blood cells." ) );
}
break;
}
case event_type::dies_of_infection: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Succumbed to the infection." ),
pgettext( "memorial_female", "Succumbed to the infection." ) );
}
break;
}
case event_type::dies_of_starvation: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Died of starvation." ),
pgettext( "memorial_female", "Died of starvation." ) );
}
break;
}
case event_type::dies_of_thirst: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Died of thirst." ),
pgettext( "memorial_female", "Died of thirst." ) );
}
break;
}
case event_type::digs_into_lava: {
add( pgettext( "memorial_male", "Dug a shaft into lava." ),
pgettext( "memorial_female", "Dug a shaft into lava." ) );
break;
}
case event_type::disarms_nuke: {
add( pgettext( "memorial_male", "Disarmed a nuclear missile." ),
pgettext( "memorial_female", "Disarmed a nuclear missile." ) );
break;
}
case event_type::eats_sewage: {
add( pgettext( "memorial_male", "Ate a sewage sample." ),
pgettext( "memorial_female", "Ate a sewage sample." ) );
break;
}
case event_type::evolves_mutation: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
trait_id from = e.get<trait_id>( "from_trait" );
trait_id to = e.get<trait_id>( "to_trait" );
add( pgettext( "memorial_male", "'%s' mutation turned into '%s'" ),
pgettext( "memorial_female", "'%s' mutation turned into '%s'" ),
get_avatar().mutation_name( from ), get_avatar().mutation_name( to ) );
}
break;
}
case event_type::exhumes_grave: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Exhumed a grave." ),
pgettext( "memorial_female", "Exhumed a grave." ) );
}
break;
}
case event_type::fails_to_install_cbm: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
std::string cbm_name = e.get<bionic_id>( "bionic" )->name.translated();
add( pgettext( "memorial_male", "Failed install of bionic: %s." ),
pgettext( "memorial_female", "Failed install of bionic: %s." ),
cbm_name );
}
break;
}
case event_type::fails_to_remove_cbm: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
std::string cbm_name = e.get<bionic_id>( "bionic" )->name.translated();
add( pgettext( "memorial_male", "Failed to remove bionic: %s." ),
pgettext( "memorial_female", "Failed to remove bionic: %s." ),
cbm_name );
}
break;
}
case event_type::falls_asleep_from_exhaustion: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
add( pgettext( "memorial_male", "Succumbed to lack of sleep." ),
pgettext( "memorial_female", "Succumbed to lack of sleep." ) );
}
break;
}
case event_type::fuel_tank_explodes: {
std::string name = e.get<cata_variant_type::string>( "vehicle_name" );
add( pgettext( "memorial_male", "The fuel tank of the %s exploded!" ),
pgettext( "memorial_female", "The fuel tank of the %s exploded!" ),
name );
break;
}
case event_type::gains_addiction: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
addiction_id type = e.get<addiction_id>( "add_type" );
//~ %s is addiction name
add( pgettext( "memorial_male", "Became addicted to %s." ),
pgettext( "memorial_female", "Became addicted to %s." ),
type->get_type_name().translated() );
}
break;
}
case event_type::gains_mutation: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
trait_id trait = e.get<trait_id>( "trait" );
add( pgettext( "memorial_male", "Gained the mutation '%s'." ),
pgettext( "memorial_female", "Gained the mutation '%s'." ),
get_avatar().mutation_name( trait ) );
}
break;
}
case event_type::gains_skill_level: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
int new_level = e.get<int>( "new_level" );
if( new_level % 4 == 0 ) {
skill_id skill = e.get<skill_id>( "skill" );
add( pgettext( "memorial_male",
//~ %d is skill level %s is skill name
"Reached skill level %1$d in %2$s." ),
pgettext( "memorial_female",
//~ %d is skill level %s is skill name
"Reached skill level %1$d in %2$s." ),
new_level, skill->name() );
}
}
break;
}
case event_type::game_over: {
bool suicide = e.get<bool>( "is_suicide" );
std::string last_words = e.get<cata_variant_type::string>( "last_words" );
if( suicide ) {
add( pgettext( "memorial_male", "%s committed suicide." ),
pgettext( "memorial_female", "%s committed suicide." ),
avatar_name );
} else {
add( pgettext( "memorial_male", "%s was killed." ),
pgettext( "memorial_female", "%s was killed." ),
avatar_name );
}
if( !last_words.empty() ) {
add( pgettext( "memorial_male", "Last words: %s" ),
pgettext( "memorial_female", "Last words: %s" ),
last_words );
}
break;
}
case event_type::game_start: {
add( //~ %s is player name
pgettext( "memorial_male", "%s began their journey into the Cataclysm." ),
pgettext( "memorial_female", "%s began their journey into the Cataclysm." ),
avatar_name );
break;
}
case event_type::installs_cbm: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
std::string cbm_name = e.get<bionic_id>( "bionic" )->name.translated();
add( pgettext( "memorial_male", "Installed bionic: %s." ),
pgettext( "memorial_female", "Installed bionic: %s." ),
cbm_name );
}
break;
}
case event_type::installs_faulty_cbm: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
std::string cbm_name = e.get<bionic_id>( "bionic" )->name.translated();
add( pgettext( "memorial_male", "Installed bad bionic: %s." ),
pgettext( "memorial_female", "Installed bad bionic: %s." ),
cbm_name );
}
break;
}
case event_type::learns_martial_art: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
matype_id mastyle = e.get<matype_id>( "martial_art" );
//~ %s is martial art
add( pgettext( "memorial_male", "Learned %s." ),
pgettext( "memorial_female", "Learned %s." ),
mastyle->name );
}
break;
}
case event_type::loses_addiction: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
addiction_id type = e.get<addiction_id>( "add_type" );
//~ %s is addiction name
add( pgettext( "memorial_male", "Overcame addiction to %s." ),
pgettext( "memorial_female", "Overcame addiction to %s." ),
type->get_type_name().translated() );
}
break;
}
case event_type::npc_becomes_hostile: {
std::string name = e.get<cata_variant_type::string>( "npc_name" );
add( pgettext( "memorial_male", "%s became hostile." ),
pgettext( "memorial_female", "%s became hostile." ),
name );
break;
}
case event_type::opens_portal: {
add( pgettext( "memorial_male", "Opened a portal." ),
pgettext( "memorial_female", "Opened a portal." ) );
break;
}
case event_type::opens_temple: {
add( pgettext( "memorial_male", "Opened a strange temple." ),
pgettext( "memorial_female", "Opened a strange temple." ) );
break;
}
case event_type::player_fails_conduct: {
add( pgettext( "memorial_male", "Lost the conduct %s%s." ),
pgettext( "memorial_female", "Lost the conduct %s%s." ),
e.get<achievement_id>( "conduct" )->name(),
e.get<bool>( "achievements_enabled" ) ? "" : _( " (disabled)" ) );
break;
}
case event_type::player_gets_achievement: {
add( pgettext( "memorial_male", "Gained the achievement %s%s." ),
pgettext( "memorial_female", "Gained the achievement %s%s." ),
e.get<achievement_id>( "achievement" )->name(),
e.get<bool>( "achievements_enabled" ) ? "" : _( " (disabled)" ) );
break;
}
case event_type::character_forgets_spell: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
std::string spell_name = e.get<spell_id>( "spell" )->name.translated();
add( pgettext( "memorial_male", "Forgot the spell %s." ),
pgettext( "memorial_female", "Forgot the spell %s." ),
spell_name );
}
break;
}
case event_type::character_learns_spell: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
std::string spell_name = e.get<spell_id>( "spell" )->name.translated();
add( pgettext( "memorial_male", "Learned the spell %s." ),
pgettext( "memorial_female", "Learned the spell %s." ),
spell_name );
}
break;
}
case event_type::player_levels_spell: {
character_id ch = e.get<character_id>( "character" );
if( ch == avatar_id ) {
std::string spell_name = e.get<spell_id>( "spell" )->name.translated();
add( pgettext( "memorial_male", "Gained a spell level on %s." ),
pgettext( "memorial_female", "Gained a spell level on %s." ),
spell_name );
}
break;
}