-
Notifications
You must be signed in to change notification settings - Fork 287
/
Copy pathartifact.cpp
1554 lines (1430 loc) · 60.4 KB
/
artifact.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 "artifact.h"
#include <algorithm>
#include <array>
#include <cstdint>
#include <cstdlib>
#include <iosfwd>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <vector>
#include "assign.h"
#include "bodypart.h"
#include "cata_utility.h"
#include "color.h"
#include "damage.h"
#include "debug.h"
#include "fstream_utils.h"
#include "item_factory.h"
#include "iuse.h"
#include "json.h"
#include "rng.h"
#include "string_formatter.h"
#include "translations.h"
#include "type_id.h"
#include "units.h"
#include "value_ptr.h"
#include "world.h"
template<typename V, typename B>
inline units::quantity<V, B> rng( const units::quantity<V, B> &min,
const units::quantity<V, B> &max )
{
return units::quantity<V, B>( rng( min.value(), max.value() ), B{} );
}
std::vector<art_effect_passive> fill_good_passive();
std::vector<art_effect_passive> fill_bad_passive();
std::vector<art_effect_active> fill_good_active();
std::vector<art_effect_active> fill_bad_active();
static const std::array<int, NUM_AEPS> passive_effect_cost = { {
0, // AEP_NULL
3, // AEP_STR_UP
3, // AEP_DEX_UP
3, // AEP_PER_UP
3, // AEP_INT_UP
5, // AEP_ALL_UP
4, // AEP_SPEED_UP
2, // AEP_PBLUE
4, // AEP_SNAKES
7, // AEP_INVISIBLE
5, // AEP_CLAIRVOYANCE
7, // AEP_CLAIRVOYANCE_PLUS
50,// AEP_SUPER_CLAIRVOYANCE
2, // AEP_STEALTH
2, // AEP_EXTINGUISH
1, // AEP_GLOW
1, // AEP_PSYSHIELD
3, // AEP_RESIST_ELECTRICITY
3, // AEP_CARRY_MORE
5, // AEP_SAP_LIFE
1, // AEP_FUN
0, // AEP_SPLIT
-2, // AEP_HUNGER
-2, // AEP_THIRST
-1, // AEP_SMOKE
-5, // AEP_EVIL
-3, // AEP_SCHIZO
-5, // AEP_RADIOACTIVE
-3, // AEP_MUTAGENIC
-5, // AEP_ATTENTION
-2, // AEP_STR_DOWN
-2, // AEP_DEX_DOWN
-2, // AEP_PER_DOWN
-2, // AEP_INT_DOWN
-5, // AEP_ALL_DOWN
-4, // AEP_SPEED_DOWN
-5, // AEP_FORCE_TELEPORT
-3, // AEP_MOVEMENT_NOISE
-2, // AEP_BAD_WEATHER
-1 // AEP_SICK
}
};
static const std::array<int, NUM_AEAS> active_effect_cost = { {
0, // AEA_NULL
2, // AEA_STORM
4, // AEA_FIREBALL
5, // AEA_ADRENALINE
4, // AEA_MAP
0, // AEA_BLOOD
0, // AEA_FATIGUE
4, // AEA_ACIDBALL
5, // AEA_PULSE
4, // AEA_HEAL
3, // AEA_CONFUSED
3, // AEA_ENTRANCE
3, // AEA_BUGS
5, // AEA_TELEPORT
1, // AEA_LIGHT
4, // AEA_GROWTH
6, // AEA_HURTALL
2, // AEA_FUN
0, // AEA_SPLIT
-3, // AEA_RADIATION
-2, // AEA_PAIN
-3, // AEA_MUTATE
-2, // AEA_PARALYZE
-3, // AEA_FIRESTORM
-6, // AEA_ATTENTION
-4, // AEA_TELEGLOW
-2, // AEA_NOISE
-2, // AEA_SCREAM
-3, // AEA_DIM
-4, // AEA_FLASH
-2, // AEA_VOMIT
-5 // AEA_SHADOWS
- 2 // AEA_STAMINA_EMPTY
}
};
enum artifact_natural_shape {
ARTSHAPE_SPHERE,
ARTSHAPE_ROD,
ARTSHAPE_TEARDROP,
ARTSHAPE_LAMP,
ARTSHAPE_SNAKE,
ARTSHAPE_DISC,
ARTSHAPE_BEADS,
ARTSHAPE_NAPKIN,
ARTSHAPE_URCHIN,
ARTSHAPE_JELLY,
ARTSHAPE_SPIRAL,
ARTSHAPE_PIN,
ARTSHAPE_TUBE,
ARTSHAPE_PYRAMID,
ARTSHAPE_CRYSTAL,
ARTSHAPE_KNOT,
ARTSHAPE_CRESCENT,
ARTSHAPE_MAX
};
struct artifact_shape_datum {
std::string name;
std::string desc;
units::volume volume_min, volume_max;
units::mass weight_min, weight_max;
};
struct artifact_property_datum {
std::string name;
std::string desc;
std::array<art_effect_passive, 4> passive_good;
std::array<art_effect_passive, 4> passive_bad;
std::array<art_effect_active, 4> active_good;
std::array<art_effect_active, 4> active_bad;
};
//Used only when generating - stored as individual members of each artifact
struct artifact_dream_datum {
std::vector<std::string> msg_unmet;
std::vector<std::string> msg_met;
// Once per hour while sleeping, makes a list of each artifact that passes a (freq) in 100 check
// One item is picked from artifacts that passed that chance, and the appropriate msg is shown
// If multiple met/unmet messages are specified for the item, one is picked at random
// 100 if no reqs, since should never be unmet in that case
// 0 if no reqs
int freq_unmet;
int freq_met;
};
enum artifact_weapon_type {
ARTWEAP_BULK, // A bulky item that works okay for bashing
ARTWEAP_CLUB, // An item designed to bash
ARTWEAP_SPEAR, // A stab-only weapon
ARTWEAP_SWORD, // A long slasher
ARTWEAP_KNIFE, // Short, slash and stab
NUM_ARTWEAPS
};
struct artifact_tool_form_datum {
std::string name;
char sym;
deferred_color color;
// Most things had 0 to 1 material.
material_id material;
units::volume volume_min, volume_max;
units::mass weight_min, weight_max;
artifact_weapon_type base_weapon;
std::array<artifact_weapon_type, 3> extra_weapons;
};
enum artifact_tool_form {
ARTTOOLFORM_HARP,
ARTTOOLFORM_STAFF,
ARTTOOLFORM_SWORD,
ARTTOOLFORM_KNIFE,
ARTTOOLFORM_CUBE,
NUM_ARTTOOLFORMS
};
struct artifact_weapon_datum {
std::string adjective;
units::volume volume;
// Only applicable if this is an *extra* weapon
units::mass weight;
int bash_min;
int bash_max;
int cut_min;
int cut_max;
int stab_min;
int stab_max;
int to_hit_min;
int to_hit_max;
std::string tag;
};
enum artifact_armor_mod {
ARMORMOD_NULL,
ARMORMOD_LIGHT,
ARMORMOD_BULKY,
ARMORMOD_POCKETED,
ARMORMOD_FURRED,
ARMORMOD_PADDED,
ARMORMOD_PLATED,
NUM_ARMORMODS
};
struct artifact_armor_form_datum {
std::string name;
deferred_color color;
// Most things had 0 to 1 material.
material_id material;
units::volume volume;
units::mass weight;
int encumb;
int max_encumb;
int coverage;
int thickness;
int env_resist;
int warmth;
units::volume storage;
int melee_bash;
int melee_cut;
int melee_hit;
body_part_set covers;
bool plural;
std::array<artifact_armor_mod, 5> available_mods;
};
enum artifact_armor_form {
ARTARMFORM_ROBE,
ARTARMFORM_COAT,
ARTARMFORM_MASK,
ARTARMFORM_HELM,
ARTARMFORM_GLOVES,
ARTARMFORM_BOOTS,
ARTARMFORM_RING,
NUM_ARTARMFORMS
};
static const std::array<artifact_shape_datum, ARTSHAPE_MAX> artifact_shape_data = { {
{translate_marker( "sphere" ), translate_marker( "smooth sphere" ), 500_ml, 1_liter, 1_gram, 1150_gram},
{translate_marker( "rod" ), translate_marker( "tapered rod" ), 250_ml, 1750_ml, 1_gram, 800_gram},
{translate_marker( "teardrop" ), translate_marker( "teardrop-shaped stone" ), 500_ml, 1500_ml, 1_gram, 950_gram},
{translate_marker( "lamp" ), translate_marker( "hollow, transparent cube" ), 1_liter, 225_ml, 1_gram, 350_gram},
{translate_marker( "snake" ), translate_marker( "winding, flexible rod" ), 0_ml, 2_liter, 1_gram, 950_gram},
{translate_marker( "disc" ), translate_marker( "smooth disc" ), 1_liter, 1500_ml, 200_gram, 400_gram},
{translate_marker( "beads" ), translate_marker( "string of beads" ), 750_ml, 1750_ml, 1_gram, 700_gram},
{translate_marker( "napkin" ), translate_marker( "very thin sheet" ), 0_ml, 750_ml, 1_gram, 350_gram},
{translate_marker( "urchin" ), translate_marker( "spiked sphere" ), 750_ml, 1250_ml, 200_gram, 700_gram},
{translate_marker( "jelly" ), translate_marker( "malleable blob" ), 500_ml, 2_liter, 200_gram, 450_gram},
{translate_marker( "spiral" ), translate_marker( "spiraling rod" ), 1250_ml, 1500_ml, 200_gram, 350_gram},
{translate_marker( "pin" ), translate_marker( "pointed rod" ), 250_ml, 1250_ml, 100_gram, 1050_gram},
{translate_marker( "tube" ), translate_marker( "hollow tube" ), 500_ml, 1250_ml, 350_gram, 700_gram},
{translate_marker( "pyramid" ), translate_marker( "regular tetrahedron" ), 750_ml, 1750_ml, 200_gram, 450_gram},
{translate_marker( "crystal" ), translate_marker( "translucent crystal" ), 250_ml, 1500_ml, 200_gram, 800_gram},
{translate_marker( "knot" ), translate_marker( "twisted, knotted cord" ), 500_ml, 1500_ml, 100_gram, 800_gram},
{translate_marker( "crescent" ), translate_marker( "crescent-shaped stone" ), 500_ml, 1500_ml, 200_gram, 700_gram}
}
};
static const std::array<artifact_property_datum, ARTPROP_MAX> artifact_property_data = { {
{
"BUG", "BUG",
{{AEP_NULL, AEP_NULL, AEP_NULL, AEP_NULL}},
{{AEP_NULL, AEP_NULL, AEP_NULL, AEP_NULL}},
{{AEA_NULL, AEA_NULL, AEA_NULL, AEA_NULL}},
{{AEA_NULL, AEA_NULL, AEA_NULL, AEA_NULL}}
},
{
translate_marker( "wriggling" ), translate_marker( "is constantly wriggling" ),
{{AEP_SPEED_UP, AEP_SNAKES, AEP_FUN, AEP_NULL}},
{{AEP_DEX_DOWN, AEP_FORCE_TELEPORT, AEP_SICK, AEP_NULL}},
{{AEA_TELEPORT, AEA_ADRENALINE, AEA_FUN, AEA_NULL}},
{{AEA_MUTATE, AEA_ATTENTION, AEA_VOMIT, AEA_NULL}}
},
{
translate_marker( "glowing" ), translate_marker( "glows faintly" ),
{{AEP_INT_UP, AEP_GLOW, AEP_CLAIRVOYANCE, AEP_NULL}},
{{AEP_RADIOACTIVE, AEP_MUTAGENIC, AEP_ATTENTION, AEP_NULL}},
{{AEA_LIGHT, AEA_LIGHT, AEA_LIGHT, AEA_NULL}},
{{AEA_ATTENTION, AEA_TELEGLOW, AEA_FLASH, AEA_SHADOWS}}
},
{
translate_marker( "humming" ), translate_marker( "hums very quietly" ),
{{AEP_ALL_UP, AEP_PSYSHIELD, AEP_FUN, AEP_NULL}},
{{AEP_SCHIZO, AEP_PER_DOWN, AEP_INT_DOWN, AEP_NULL}},
{{AEA_PULSE, AEA_ENTRANCE, AEA_FUN, AEA_NULL}},
{{AEA_NOISE, AEA_NOISE, AEA_SCREAM, AEA_STAMINA_EMPTY}}
},
{
translate_marker( "moving" ), translate_marker( "shifts from side to side slowly" ),
{{AEP_STR_UP, AEP_DEX_UP, AEP_SPEED_UP, AEP_NULL}},
{{AEP_HUNGER, AEP_PER_DOWN, AEP_FORCE_TELEPORT, AEP_NULL}},
{{AEA_TELEPORT, AEA_TELEPORT, AEA_MAP, AEA_NULL}},
{{AEA_PARALYZE, AEA_VOMIT, AEA_VOMIT, AEA_NULL}}
},
{
translate_marker( "whispering" ), translate_marker( "makes very faint whispering sounds" ),
{{AEP_CLAIRVOYANCE, AEP_EXTINGUISH, AEP_STEALTH, AEP_NULL}},
{{AEP_EVIL, AEP_SCHIZO, AEP_ATTENTION, AEP_NULL}},
{{AEA_FATIGUE, AEA_ENTRANCE, AEA_ENTRANCE, AEA_NULL}},
{{AEA_ATTENTION, AEA_SCREAM, AEA_SCREAM, AEA_SHADOWS}}
},
{
translate_marker( "breathing" ),
translate_marker( "shrinks and grows very slightly with a regular pulse, as if breathing" ),
{{AEP_SAP_LIFE, AEP_ALL_UP, AEP_SPEED_UP, AEP_CARRY_MORE}},
{{AEP_HUNGER, AEP_THIRST, AEP_SICK, AEP_BAD_WEATHER}},
{{AEA_ADRENALINE, AEA_HEAL, AEA_ENTRANCE, AEA_GROWTH}},
{{AEA_MUTATE, AEA_ATTENTION, AEA_SHADOWS, AEA_STAMINA_EMPTY}}
},
{
translate_marker( "dead" ), translate_marker( "is icy cold to the touch" ),
{{AEP_INVISIBLE, AEP_CLAIRVOYANCE, AEP_EXTINGUISH, AEP_SAP_LIFE}},
{{AEP_HUNGER, AEP_EVIL, AEP_ALL_DOWN, AEP_SICK}},
{{AEA_BLOOD, AEA_HURTALL, AEA_NULL, AEA_NULL}},
{{AEA_PAIN, AEA_SHADOWS, AEA_DIM, AEA_VOMIT}}
},
{
translate_marker( "itchy" ), translate_marker( "makes your skin itch slightly when it is close" ),
{{AEP_DEX_UP, AEP_SPEED_UP, AEP_PSYSHIELD, AEP_FUN}},
{{AEP_RADIOACTIVE, AEP_MUTAGENIC, AEP_SICK, AEP_NULL}},
{{AEA_ADRENALINE, AEA_BLOOD, AEA_HEAL, AEA_BUGS}},
{{AEA_RADIATION, AEA_PAIN, AEA_PAIN, AEA_VOMIT}}
},
{
translate_marker( "glittering" ), translate_marker( "glitters faintly under direct light" ),
{{AEP_INT_UP, AEP_EXTINGUISH, AEP_GLOW, AEP_NULL}},
{{AEP_SMOKE, AEP_ATTENTION, AEP_NULL, AEP_NULL}},
{{AEA_MAP, AEA_LIGHT, AEA_CONFUSED, AEA_ENTRANCE}},
{{AEA_RADIATION, AEA_MUTATE, AEA_ATTENTION, AEA_FLASH}}
},
{
translate_marker( "electric" ), translate_marker( "very weakly shocks you when touched" ),
{{AEP_RESIST_ELECTRICITY, AEP_DEX_UP, AEP_SPEED_UP, AEP_PSYSHIELD}},
{{AEP_THIRST, AEP_SMOKE, AEP_STR_DOWN, AEP_BAD_WEATHER}},
{{AEA_STORM, AEA_ADRENALINE, AEA_LIGHT, AEA_FUN}},
{{AEA_PAIN, AEA_PARALYZE, AEA_FLASH, AEA_FLASH}}
},
{
translate_marker( "slimy" ), translate_marker( "feels slimy" ),
{{AEP_SNAKES, AEP_STEALTH, AEP_EXTINGUISH, AEP_SAP_LIFE}},
{{AEP_THIRST, AEP_DEX_DOWN, AEP_SPEED_DOWN, AEP_SICK}},
{{AEA_BLOOD, AEA_ACIDBALL, AEA_GROWTH, AEA_ACIDBALL}},
{{AEA_MUTATE, AEA_MUTATE, AEA_VOMIT, AEA_VOMIT}}
},
{
translate_marker( "engraved" ), translate_marker( "is covered with odd etchings" ),
{{AEP_CLAIRVOYANCE, AEP_INVISIBLE, AEP_PSYSHIELD, AEP_SAP_LIFE}},
{{AEP_EVIL, AEP_ATTENTION, AEP_NULL, AEP_NULL}},
{{AEA_FATIGUE, AEA_TELEPORT, AEA_HEAL, AEA_FATIGUE}},
{{AEA_ATTENTION, AEA_ATTENTION, AEA_TELEGLOW, AEA_DIM}}
},
{
translate_marker( "crackling" ), translate_marker( "occasionally makes a soft crackling sound" ),
{{AEP_EXTINGUISH, AEP_RESIST_ELECTRICITY, AEP_NULL, AEP_NULL}},
{{AEP_SMOKE, AEP_RADIOACTIVE, AEP_MOVEMENT_NOISE, AEP_NULL}},
{{AEA_STORM, AEA_FIREBALL, AEA_PULSE, AEA_NULL}},
{{AEA_PAIN, AEA_PARALYZE, AEA_NOISE, AEA_NOISE}}
},
{
translate_marker( "warm" ), translate_marker( "is warm to the touch" ),
{{AEP_STR_UP, AEP_EXTINGUISH, AEP_GLOW, AEP_FUN}},
{{AEP_SMOKE, AEP_RADIOACTIVE, AEP_NULL, AEP_NULL}},
{{AEA_FIREBALL, AEA_FIREBALL, AEA_FIREBALL, AEA_LIGHT}},
{{AEA_FIRESTORM, AEA_FIRESTORM, AEA_TELEGLOW, AEA_NULL}}
},
{
translate_marker( "rattling" ), translate_marker( "makes a rattling sound when moved" ),
{{AEP_DEX_UP, AEP_SPEED_UP, AEP_SNAKES, AEP_CARRY_MORE}},
{{AEP_ATTENTION, AEP_INT_DOWN, AEP_MOVEMENT_NOISE, AEP_MOVEMENT_NOISE}},
{{AEA_BLOOD, AEA_PULSE, AEA_BUGS, AEA_NULL}},
{{AEA_PAIN, AEA_ATTENTION, AEA_NOISE, AEA_NULL}}
},
{
translate_marker( "scaled" ), translate_marker( "has a surface reminiscent of reptile scales" ),
{{AEP_SNAKES, AEP_SNAKES, AEP_SNAKES, AEP_STEALTH}},
{{AEP_THIRST, AEP_MUTAGENIC, AEP_SPEED_DOWN, AEP_NULL}},
{{AEA_ADRENALINE, AEA_BUGS, AEA_GROWTH, AEA_NULL}},
{{AEA_MUTATE, AEA_SCREAM, AEA_DIM, AEA_STAMINA_EMPTY}}
},
{
translate_marker( "fractal" ),
translate_marker( "has a self-similar pattern which repeats until it is too small for you to see" ),
{{AEP_ALL_UP, AEP_ALL_UP, AEP_CLAIRVOYANCE, AEP_PSYSHIELD}},
{{AEP_SCHIZO, AEP_ATTENTION, AEP_FORCE_TELEPORT, AEP_BAD_WEATHER}},
{{AEA_STORM, AEA_FATIGUE, AEA_TELEPORT, AEA_FUN}},
{{AEA_RADIATION, AEA_MUTATE, AEA_TELEGLOW, AEA_TELEGLOW}}
}
}
};
static const std::array<artifact_tool_form_datum, NUM_ARTTOOLFORMS> artifact_tool_form_data = { {
{
translate_marker( "Harp" ), ';', def_c_yellow, material_id( "wood" ), 5_liter, 7500_ml, 1150_gram, 2100_gram, ARTWEAP_BULK,
{{ARTWEAP_SPEAR, ARTWEAP_SWORD, ARTWEAP_KNIFE}}
},
{
translate_marker( "Staff" ), '/', def_c_brown, material_id( "wood" ), 1500_ml, 3_liter, 450_gram, 1150_gram, ARTWEAP_CLUB,
{{ARTWEAP_BULK, ARTWEAP_SPEAR, ARTWEAP_KNIFE}}
},
{
translate_marker( "Sword" ), '/', def_c_light_blue, material_id( "steel" ), 2_liter, 3500_ml, 900_gram, 3259_gram, ARTWEAP_SWORD,
{{ARTWEAP_BULK, NUM_ARTWEAPS, NUM_ARTWEAPS}}
},
{
translate_marker( "Dagger" ), ';', def_c_light_blue, material_id( "steel" ), 250_ml, 1_liter, 100_gram, 700_gram, ARTWEAP_KNIFE,
{{NUM_ARTWEAPS, NUM_ARTWEAPS, NUM_ARTWEAPS}}
},
{
translate_marker( "Cube" ), '*', def_c_white, material_id( "steel" ), 250_ml, 750_ml, 100_gram, 2300_gram, ARTWEAP_BULK,
{{ARTWEAP_SPEAR, NUM_ARTWEAPS, NUM_ARTWEAPS}}
}
}
};
static const std::array<artifact_weapon_datum, NUM_ARTWEAPS> artifact_weapon_data = { {
// Adjective Vol Weight Bashing Cutting Stabbing To-hit Flag
{ translate_marker( "Heavy" ), 0_ml, 1400_gram, 10, 20, 0, 0, 0, 0, -2, 0, "" },
{ translate_marker( "Knobbed" ), 250_ml, 250_gram, 14, 30, 0, 0, 0, 0, -1, 1, "" },
{ translate_marker( "Spiked" ), 250_ml, 100_gram, 0, 0, 0, 0, 20, 40, -1, 1, "" },
{ translate_marker( "Edged" ), 500_ml, 450_gram, 0, 0, 20, 50, 0, 0, -1, 2, "SHEATH_SWORD" },
{ translate_marker( "Bladed" ), 250_ml, 2250_gram, 0, 0, 0, 0, 12, 30, -1, 1, "SHEATH_KNIFE" }
}
};
static const std::array<artifact_armor_form_datum, NUM_ARTARMFORMS> artifact_armor_form_data = { {
// Name color Material Vol Wgt Enc MaxEnc Cov Thk Env Wrm Sto Bsh Cut Hit
{
translate_marker( "Robe" ), def_c_red, material_id( "wool" ), 1500_ml, 700_gram, 1, 1, 90, 3, 0, 2, 0_ml, -8, 0, -3,
{ { bodypart_str_id( "torso" ), bodypart_str_id( "leg_l" ), bodypart_str_id( "leg_r" ) } }, false,
{{
ARMORMOD_LIGHT, ARMORMOD_BULKY, ARMORMOD_POCKETED, ARMORMOD_FURRED,
ARMORMOD_PADDED
}
}
},
{
translate_marker( "Coat" ), def_c_brown, material_id( "leather" ), 3500_ml, 1600_gram, 2, 2, 80, 2, 1, 4, 1_liter, -6, 0, -3,
{ bodypart_str_id( "torso" ) }, false,
{{
ARMORMOD_LIGHT, ARMORMOD_POCKETED, ARMORMOD_FURRED, ARMORMOD_PADDED,
ARMORMOD_PLATED
}
}
},
{
translate_marker( "Mask" ), def_c_white, material_id( "wood" ), 1_liter, 100_gram, 2, 2, 50, 2, 1, 2, 0_ml, 2, 0, -2,
{ { bodypart_str_id( "eyes" ), bodypart_str_id( "mouth" ) } }, false,
{{
ARMORMOD_FURRED, ARMORMOD_FURRED, ARMORMOD_NULL, ARMORMOD_NULL,
ARMORMOD_NULL
}
}
},
// Name color Materials Vol Wgt Enc MaxEnc Cov Thk Env Wrm Sto Bsh Cut Hit
{
translate_marker( "Helm" ), def_c_dark_gray, material_id( "silver" ), 1500_ml, 700_gram, 2, 2, 85, 3, 0, 1, 0_ml, 8, 0, -2,
{ bodypart_str_id( "head" ) }, false,
{{
ARMORMOD_BULKY, ARMORMOD_FURRED, ARMORMOD_PADDED, ARMORMOD_PLATED,
ARMORMOD_NULL
}
}
},
{
translate_marker( "Gloves" ), def_c_light_blue, material_id( "leather" ), 500_ml, 100_gram, 1, 1, 90, 3, 1, 2, 0_ml, -4, 0, -2,
{ { bodypart_str_id( "hand_l" ), bodypart_str_id( "hand_r" ) } }, true,
{{
ARMORMOD_BULKY, ARMORMOD_FURRED, ARMORMOD_PADDED, ARMORMOD_PLATED,
ARMORMOD_NULL
}
}
},
// Name color Materials Vol Wgt Enc MaxEnc Cov Thk Env Wrm Sto Bsh Cut Hit
{
translate_marker( "Boots" ), def_c_blue, material_id( "leather" ), 1500_ml, 250_gram, 1, 1, 75, 3, 1, 3, 0_ml, 4, 0, -1,
{ { bodypart_str_id( "foot_l" ), bodypart_str_id( "foot_r" ) } }, true,
{{
ARMORMOD_LIGHT, ARMORMOD_BULKY, ARMORMOD_PADDED, ARMORMOD_PLATED,
ARMORMOD_NULL
}
}
},
{
translate_marker( "Ring" ), def_c_light_green, material_id( "silver" ), 0_ml, 4_gram, 0, 0, 0, 0, 0, 0, 0_ml, 0, 0, 0,
{}, false,
{{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}}
}
}
};
/*
* Armor mods alter the normal values of armor.
* If the basic armor type has "null" as its second material, and the mod has a
* material attached, the second material will be changed.
*/
static const std::array<artifact_armor_form_datum, NUM_ARMORMODS> artifact_armor_mod_data = { {
{
"", def_c_white, material_id( "null" ), 0_ml, 0_gram, 0, 0, 0, 0, 0, 0, 0_ml, 0, 0, 0, {}, false,
{{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}}
},
// Description; "It is ..." or "They are ..."
{
translate_marker( "very thin and light." ), def_c_white, material_id( "null" ),
// Vol Wgt Enc MaxEnc Cov Thk Env Wrm Sto
-1_liter, -950_gram, -2, -2, -1, -1, -1, -1, 0_ml, 0, 0, 0, {}, false,
{{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}}
},
{
translate_marker( "extremely bulky." ), def_c_white, material_id( "null" ),
2_liter, 1150_gram, 2, 2, 1, 1, 0, 1, 0_ml, 0, 0, 0, {}, false,
{{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}}
},
{
translate_marker( "covered in pockets." ), def_c_white, material_id( "null" ),
250_ml, 150_gram, 1, 1, 0, 0, 0, 0, 4_liter, 0, 0, 0, {}, false,
{{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}}
},
{
translate_marker( "disgustingly furry." ), def_c_white, material_id( "wool" ),
// Vol Wgt Enc MaxEnc Dmg Cut Env Wrm Sto
1_liter, 250_gram, 1, 1, 1, 1, 1, 3, 0_ml, 0, 0, 0, {}, false,
{{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}}
},
{
translate_marker( "leather-padded." ), def_c_white, material_id( "leather" ),
1_liter, 450_gram, 1, 1, 1, 1, 0, 1, -750_ml, 0, 0, 0, {}, false,
{{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}}
},
{
translate_marker( "plated in iron." ), def_c_white, material_id( "iron" ),
1_liter, 1400_gram, 3, 3, 2, 2, 0, 1, -1_liter, 0, 0, 0, {}, false,
{{ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL, ARMORMOD_NULL}}
},
}
};
static const std::array<std::string, 20> artifact_adj = { {
translate_marker( "Forbidden" ), translate_marker( "Unknowable" ), translate_marker( "Forgotten" ), translate_marker( "Hideous" ), translate_marker( "Eldritch" ),
translate_marker( "Gelatinous" ), translate_marker( "Ancient" ), translate_marker( "Cursed" ), translate_marker( "Bloody" ), translate_marker( "Undying" ),
translate_marker( "Shadowy" ), translate_marker( "Silent" ), translate_marker( "Cyclopean" ), translate_marker( "Fungal" ), translate_marker( "Unspeakable" ),
translate_marker( "Antediluvian" ), translate_marker( "Frigid" ), translate_marker( "Shattered" ), translate_marker( "Sleeping" ), translate_marker( "Repellent" )
}
};
static const std::array<std::string, 20> artifact_noun = { {
translate_marker( "%s Technique" ), translate_marker( "%s Dreams" ), translate_marker( "%s Beasts" ), translate_marker( "%s Evil" ), translate_marker( "%s Miasma" ),
translate_marker( "the %s Abyss" ), translate_marker( "the %s City" ), translate_marker( "%s Shadows" ), translate_marker( "%s Shade" ), translate_marker( "%s Illusion" ),
translate_marker( "%s Justice" ), translate_marker( "the %s Necropolis" ), translate_marker( "%s Ichor" ), translate_marker( "the %s Monolith" ), translate_marker( "%s Aeons" ),
translate_marker( "%s Graves" ), translate_marker( "%s Horrors" ), translate_marker( "%s Suffering" ), translate_marker( "%s Death" ), translate_marker( "%s Horror" )
}
};
std::string artifact_name( const std::string &type );
//Dreams for each charge req
static const std::array<artifact_dream_datum, NUM_ACRS> artifact_dream_data = { {
{ {translate_marker( "The %s is somehow vaguely dissatisfied even though it doesn't want anything. Seeing this is a bug!" )},
{translate_marker( "The %s is satisfied, as it should be because it has no standards. Seeing this is a bug!" )},
100, 0
}, { {translate_marker( "Your %s feels needy, like it wants to be held." )},
{translate_marker( "You snuggle your %s closer." )},
50, 35
}, { {translate_marker( "Your %s feels needy, like it wants to be touched." )},
{translate_marker( "You press your %s against your skin." )},
50, 35
}, { {translate_marker( "The %s is confused to find you dreaming while awake. Seeing this is a bug!" )},
{translate_marker( "Your %s sleeps soundly." )},
100, 33
}, { {translate_marker( "Your %s longs for the glow." )},
{translate_marker( "Your %s basks in the glow." )},
25, 75
}, { {translate_marker( "You dream of angels' tears falling on your %s." )},
{translate_marker( "You dream of playing in the rain with your %s." )},
50, 60
}, { {translate_marker( "You dream that your %s is being buried alive." )},
{translate_marker( "You dream of your %s dancing in a blue void." )},
50, 50
}
}
};
// Constructors for artifact itypes.
it_artifact_tool::it_artifact_tool()
{
tool = cata::make_value<islot_tool>();
artifact = cata::make_value<islot_artifact>();
id = item_controller->create_artifact_id();
price = 0_cent;
tool->charges_per_use = 1;
artifact->charge_type = ARTC_NULL;
artifact->charge_req = ACR_NULL;
artifact->dream_msg_unmet = artifact_dream_data[static_cast<int>( ACR_NULL )].msg_unmet;
artifact->dream_msg_met = artifact_dream_data[static_cast<int>( ACR_NULL )].msg_met;
artifact->dream_freq_unmet = artifact_dream_data[static_cast<int>( ACR_NULL )].freq_unmet;
artifact->dream_freq_met = artifact_dream_data[static_cast<int>( ACR_NULL )].freq_met;
use_methods.emplace( "ARTIFACT", use_function( "ARTIFACT", &iuse::artifact ) );
}
it_artifact_tool::it_artifact_tool( const JsonObject &jo )
{
tool = cata::make_value<islot_tool>();
artifact = cata::make_value<islot_artifact>();
use_methods.emplace( "ARTIFACT", use_function( "ARTIFACT", &iuse::artifact ) );
deserialize( jo );
}
it_artifact_armor::it_artifact_armor()
{
armor = cata::make_value<islot_armor>();
artifact = cata::make_value<islot_artifact>();
id = item_controller->create_artifact_id();
price = 0_cent;
}
it_artifact_armor::it_artifact_armor( const JsonObject &jo )
{
armor = cata::make_value<islot_armor>();
artifact = cata::make_value<islot_artifact>();
deserialize( jo );
}
void it_artifact_tool::create_name( const std::string &type )
{
name = no_translation( artifact_name( type ) );
}
void it_artifact_tool::create_name( const std::string &property_name,
const std::string &shape_name )
{
name = no_translation( string_format( pgettext( "artifact name (property, shape)", "%1$s %2$s" ),
property_name, shape_name ) );
}
void it_artifact_armor::create_name( const std::string &type )
{
name = no_translation( artifact_name( type ) );
}
itype_id new_artifact()
{
if( one_in( 2 ) ) {
// Generate a "tool" artifact
it_artifact_tool def;
const artifact_tool_form_datum &info = random_entry_ref( artifact_tool_form_data );
def.create_name( _( info.name ) );
def.color = info.color;
def.sym = std::string( 1, info.sym );
def.materials.push_back( info.material );
def.volume = rng( info.volume_min, info.volume_max );
def.weight = rng( info.weight_min, info.weight_max );
// Set up the basic weapon type
const artifact_weapon_datum &weapon = artifact_weapon_data[info.base_weapon];
def.melee[DT_BASH] = rng( weapon.bash_min, weapon.bash_max );
def.melee[DT_CUT] = rng( weapon.cut_min, weapon.cut_max );
def.melee[DT_STAB] = rng( weapon.stab_min, weapon.stab_max );
def.m_to_hit = rng( weapon.to_hit_min, weapon.to_hit_max );
if( !weapon.tag.empty() ) {
def.item_tags.insert( flag_id( weapon.tag ) );
}
// Add an extra weapon perhaps?
if( one_in( 2 ) ) {
const artifact_weapon_type select = random_entry_ref( info.extra_weapons );
if( select != NUM_ARTWEAPS ) {
const artifact_weapon_datum &weapon = artifact_weapon_data[select];
def.volume += weapon.volume;
def.weight += weapon.weight;
def.melee[DT_BASH] += rng( weapon.bash_min, weapon.bash_max );
def.melee[DT_CUT] += rng( weapon.cut_min, weapon.cut_max );
def.melee[DT_STAB] += rng( weapon.stab_min, weapon.stab_max );
def.m_to_hit += rng( weapon.to_hit_min, weapon.to_hit_max );
if( !weapon.tag.empty() ) {
def.item_tags.insert( flag_id( weapon.tag ) );
}
def.create_name( std::string( _( weapon.adjective ) ) + " " + _( info.name ) );
}
}
def.description = no_translation(
string_format(
_( "This is the %s.\nIt is the only one of its kind.\nIt may have unknown powers; try activating them." ),
def.nname( 1 ) ) );
// Finally, pick some powers
art_effect_passive passive_tmp = AEP_NULL;
art_effect_active active_tmp = AEA_NULL;
int num_good = 0;
int num_bad = 0;
int value = 0;
std::vector<art_effect_passive> good_effects = fill_good_passive();
std::vector<art_effect_passive> bad_effects = fill_bad_passive();
// Wielded effects first
while( !good_effects.empty() && !bad_effects.empty() &&
num_good < 3 && num_bad < 3 &&
( num_good < 1 || num_bad < 1 || one_in( num_good + 1 ) ||
one_in( num_bad + 1 ) || value > 1 ) ) {
if( value < 1 && one_in( 2 ) ) {
// Good
passive_tmp = random_entry_removed( good_effects );
num_good++;
} else if( !bad_effects.empty() ) {
// Bad effect
passive_tmp = random_entry_removed( bad_effects );
num_bad++;
}
value += passive_effect_cost[passive_tmp];
def.artifact->effects_wielded.push_back( passive_tmp );
}
// Next, carried effects; more likely to be just bad
num_good = 0;
num_bad = 0;
value = 0;
good_effects = fill_good_passive();
bad_effects = fill_bad_passive();
while( one_in( 2 ) && !good_effects.empty() && !bad_effects.empty() &&
num_good < 3 && num_bad < 3 &&
( num_bad < 1 || one_in( num_bad + 1 ) || value > 1 ) ) {
if( value < 1 && one_in( 3 ) ) {
// Good
passive_tmp = random_entry_removed( good_effects );
num_good++;
} else {
// Bad effect
passive_tmp = random_entry_removed( bad_effects );
num_bad++;
}
value += passive_effect_cost[passive_tmp];
def.artifact->effects_carried.push_back( passive_tmp );
}
// Finally, activated effects; not necessarily good or bad
num_good = 0;
num_bad = 0;
value = 0;
std::vector<art_effect_active> good_a_effects = fill_good_active();
std::vector<art_effect_active> bad_a_effects = fill_bad_active();
while( !good_a_effects.empty() && !bad_a_effects.empty() &&
num_good < 3 && num_bad < 3 &&
( value > 3 || ( num_bad > 0 && num_good == 0 ) ||
!one_in( 3 - num_good ) || !one_in( 3 - num_bad ) ) ) {
if( !one_in( 3 ) && value <= 1 ) {
// Good effect
active_tmp = random_entry_removed( good_a_effects );
num_good++;
value += active_effect_cost[active_tmp];
} else {
// Bad effect
active_tmp = random_entry_removed( bad_a_effects );
num_bad++;
value += active_effect_cost[active_tmp];
}
def.artifact->effects_activated.push_back( active_tmp );
def.tool->max_charges += rng( 1, 3 );
}
def.tool->def_charges = def.tool->max_charges;
// If we have charges, pick a recharge mechanism
if( def.tool->max_charges > 0 ) {
def.artifact->charge_type = static_cast<art_charge>( rng( ARTC_NULL + 1, NUM_ARTCS - 1 ) );
}
// 1 in 8 chance that it can't recharge!
if( one_in( 8 ) && num_bad + num_good >= 4 ) {
def.artifact->charge_type = ARTC_NULL;
}
// Maybe pick an extra recharge requirement
if( one_in( std::max( 1, 6 - num_good ) ) && def.artifact->charge_type != ARTC_NULL ) {
def.artifact->charge_req = static_cast<art_charge_req>( rng( ACR_NULL + 1, NUM_ACRS - 1 ) );
}
// Assign dream data (stored individually so they can be overridden in json)
def.artifact->dream_msg_unmet = artifact_dream_data[static_cast<int>
( def.artifact->charge_req )].msg_unmet;
def.artifact->dream_msg_met = artifact_dream_data[static_cast<int>
( def.artifact->charge_req )].msg_met;
def.artifact->dream_freq_unmet = artifact_dream_data[static_cast<int>
( def.artifact->charge_req )].freq_unmet;
def.artifact->dream_freq_met = artifact_dream_data[static_cast<int>
( def.artifact->charge_req )].freq_met;
// Stronger artifacts have a higher chance of picking their dream
def.artifact->dream_freq_unmet *= ( 1 + 0.1 * ( num_bad + num_good ) );
def.artifact->dream_freq_met *= ( 1 + 0.1 * ( num_bad + num_good ) );
item_controller->add_item_type( static_cast<itype &>( def ) );
return def.get_id();
} else {
// Generate an armor artifact
it_artifact_armor def;
const artifact_armor_form_datum &info = random_entry_ref( artifact_armor_form_data );
def.create_name( _( info.name ) );
// Armor is always [
def.sym = "[";
def.color = info.color;
def.materials.push_back( info.material );
def.volume = info.volume;
def.weight = info.weight;
def.melee[DT_BASH] = info.melee_bash;
def.melee[DT_CUT] = info.melee_cut;
def.m_to_hit = info.melee_hit;
def.armor->data.push_back( { info.encumb, info.max_encumb, info.coverage, info.covers } );
def.armor->thickness = info.thickness;
def.armor->env_resist = info.env_resist;
def.armor->warmth = info.warmth;
def.armor->storage = info.storage;
std::string description = string_format( info.plural ?
_( "This is the %s.\nThey are the only ones of their kind." ) :
_( "This is the %s.\nIt is the only one of its kind." ), def.nname( 1 ) );
// Modify the armor further
if( !one_in( 4 ) ) {
const artifact_armor_mod mod = random_entry_ref( info.available_mods );
if( mod != ARMORMOD_NULL ) {
const artifact_armor_form_datum &modinfo = artifact_armor_mod_data[mod];
if( modinfo.volume >= 0_ml || def.volume > -modinfo.volume ) {
def.volume += modinfo.volume;
} else {
def.volume = 250_ml;
}
if( modinfo.weight >= 0_gram || def.weight.value() > std::abs( modinfo.weight.value() ) ) {
def.weight += modinfo.weight;
} else {
def.weight = 1_gram;
}
def.armor->data.push_back( { modinfo.encumb, modinfo.max_encumb, modinfo.coverage, modinfo.covers } );
if( modinfo.thickness > 0 || def.armor->thickness > std::abs( modinfo.thickness ) ) {
def.armor->thickness += modinfo.thickness;
} else {
def.armor->thickness = 0;
}
if( modinfo.env_resist > 0 || def.armor->env_resist > std::abs( modinfo.env_resist ) ) {
def.armor->env_resist += modinfo.env_resist;
} else {
def.armor->env_resist = 0;
}
def.armor->warmth += modinfo.warmth;
if( modinfo.storage > 0_ml || def.armor->storage > -modinfo.storage ) {
def.armor->storage += modinfo.storage;
} else {
def.armor->storage = 0_ml;
}
description += string_format( info.plural ?
_( "\nThey are %s" ) :
_( "\nIt is %s" ),
_( modinfo.name ) );
}
}
def.description = no_translation( description );
// Finally, pick some effects
int num_good = 0;
int num_bad = 0;
int value = 0;
art_effect_passive passive_tmp = AEP_NULL;
std::vector<art_effect_passive> good_effects = fill_good_passive();
std::vector<art_effect_passive> bad_effects = fill_bad_passive();
while( !good_effects.empty() && !bad_effects.empty() &&
num_good < 3 && num_bad < 3 &&
( num_good < 1 || one_in( num_good * 2 ) || value > 1 ||
!one_in( 3 - num_bad ) ) ) {
if( value < 1 && one_in( 2 ) ) {
// Good effect
passive_tmp = random_entry_removed( good_effects );
num_good++;
} else {
// Bad effect
passive_tmp = random_entry_removed( bad_effects );
num_bad++;
}
value += passive_effect_cost[passive_tmp];
def.artifact->effects_worn.push_back( passive_tmp );
}
item_controller->add_item_type( static_cast<itype &>( def ) );
return def.get_id();
}
}
itype_id new_natural_artifact( artifact_natural_property prop )
{
// Natural artifacts are always tools.
it_artifact_tool def;
// Pick a form
const artifact_shape_datum &shape_data = random_entry_ref( artifact_shape_data );
// Pick a property
const artifact_natural_property property = ( prop > ARTPROP_NULL ? prop :
static_cast<artifact_natural_property>( rng( ARTPROP_NULL + 1,
ARTPROP_MAX - 1 ) ) );
const artifact_property_datum &property_data = artifact_property_data[property];
def.sym = ":";
def.color = c_yellow;
def.materials.emplace_back( "stone" );
def.volume = rng( shape_data.volume_min, shape_data.volume_max );
def.weight = rng( shape_data.weight_min, shape_data.weight_max );
def.melee[DT_BASH] = 0;
def.melee[DT_CUT] = 0;
def.m_to_hit = 0;
def.create_name( _( property_data.name ), _( shape_data.name ) );
def.description = no_translation(
string_format( pgettext( "artifact description", "This %1$s %2$s." ),
_( shape_data.desc ), _( property_data.desc ) ) );
// Three possibilities: good passive + bad passive, good active + bad active,
// and bad passive + good active
bool good_passive = false, bad_passive = false,
good_active = false, bad_active = false;
switch( rng( 1, 3 ) ) {
case 1:
good_passive = true;
bad_passive = true;
break;
case 2:
good_active = true;
bad_active = true;
break;
case 3:
bad_passive = true;
good_active = true;
break;
}
// This is slowly incremented, allowing for better arts
int value_to_reach = 0;
int value = 0;
art_effect_passive aep_good = AEP_NULL, aep_bad = AEP_NULL;
art_effect_active aea_good = AEA_NULL, aea_bad = AEA_NULL;
do {
if( good_passive ) {
aep_good = random_entry_ref( property_data.passive_good );
if( aep_good == AEP_NULL || one_in( 4 ) ) {
aep_good = static_cast<art_effect_passive>( rng( AEP_NULL + 1, AEP_SPLIT - 1 ) );
}
}
if( bad_passive ) {
aep_bad = random_entry_ref( property_data.passive_bad );
if( aep_bad == AEP_NULL || one_in( 4 ) ) {
aep_bad = static_cast<art_effect_passive>( rng( AEP_SPLIT + 1, NUM_AEAS - 1 ) );
}
}
if( good_active ) {
aea_good = random_entry_ref( property_data.active_good );
if( aea_good == AEA_NULL || one_in( 4 ) ) {
aea_good = static_cast<art_effect_active>( rng( AEA_NULL + 1, AEA_SPLIT - 1 ) );
}
}
if( bad_active ) {
aea_bad = random_entry_ref( property_data.active_bad );
if( aea_bad == AEA_NULL || one_in( 4 ) ) {
aea_bad = static_cast<art_effect_active>( rng( AEA_SPLIT + 1, NUM_AEAS - 1 ) );
}
}