-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathshow-unit-syndromes.rb
1036 lines (872 loc) · 26.4 KB
/
show-unit-syndromes.rb
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
# Show syndromes affecting units, including duration
# original author: drayath, edited by expwnent
=begin
show-unit-syndromes
===================
Show syndromes affecting units and the remaining and maximum duration, along
with (optionally) substantial detail on the effects.
Use one or more of the following options:
:help: Show the help message
:showall: Show units even if not affected by any syndrome
:showeffects: Show detailed effects of each syndrome
:showdisplayeffects: Show effects that only change the look of the unit
:selected: Show selected unit
:dwarves: Show dwarves
:livestock: Show livestock
:wildanimals: Show wild animals
:hostile: Show hostiles (e.g. invaders, thieves, forgotten beasts etc)
:world: Show all defined syndromes in the world
:export: ``export:<filename>`` sends output to the given file, showing all
syndromes affecting each unit with the maximum and present duration.
=end
#TODO: When showing effects on a unit, show the actual change to the unit
# E.g. if +150%, +500 strength show actual total bonus based on the unit stats.
# For this also need to know
# how does size_delays affect the start/peak/end time
# how does size_dilute affect the Severity, does it also affect the phy/mental stat adjustments?
# how does peak affect the Severity, does it also affect the phy/mental stat adjustments?
#TODO: Add interaction info needs to display a bit more data, but the required structures are not yet decoded
#TODO: Several of the unk_xxx fields have been identified here, and can get some more by comparing the raws with the printed interaction and effect information. Pass these onto the dfhack guys.
def print_help()
puts "Use one or more of the following options:"
puts " showall: Show units even if not affected by any syndrome"
puts " showeffects: shows detailed effects of each syndrome"
puts " showdisplayeffects: show effects that only change the look of the unit"
puts " ignorehiddencurse: Hides syndromes the user should not be able to know about (TODO)"
puts " selected: Show selected unit"
puts " dwarves: Show dwarves"
puts " livestock: Show livestock"
puts " wildanimals: Show wild animals"
puts " hostile: Show hostiles (e.g. invaders, thieves, forgotten beasts etc)"
puts " world: Show all defined syndromes in the world"
puts " export:<filename> Write the output to a file instead of the console."
puts ""
puts "Will show all syndromes affecting each units with the maximum and present duration."
end
class Output
attr_accessor :fileLogger, :indent_level
def initialize(filename)
indent_level = ""
if filename==nil
@fileLogger = nil
else
@fileLogger = File.new(filename + ".html", "w")
@fileLogger.puts("<html><body>")
end
end
RED = "red"
GREEN = "green"
BLUE = "blue"
DEFAULT = "black"
HIGHLIGHT = "black\" size=\"+1"
def colorize(text, color_code)
if @fileLogger == nil
return text
else
new_text = "<font color=\"#{color_code}\">#{text}</font>"
if color_code == HIGHLIGHT
new_text = "<b>" + new_text + "</b>"
end
return new_text
end
end
def inactive(text)
if @fileLogger == nil
return "###" + text
else
return "<del>#{text}</del>"
end
end
def indent()
if @fileLogger == nil
@indent_level = "#{@indent_level} - "
else
@fileLogger.puts("<ul>")
end
end
def unindent()
if @fileLogger == nil
@indent_level = @indent_level.chomp(" - ")
else
@fileLogger.puts("</ul>")
end
end
def break()
if @fileLogger == nil
puts("\n")
else
@fileLogger.puts("<hr/></br>")
end
end
def close()
if @fileLogger != nil
@fileLogger.puts("</body></html>")
@fileLogger.flush
@fileLogger.close
@fileLogger = nil
end
end
def log(text, color=nil)
if @fileLogger == nil
puts("#{@indent_level}#{text}")
elsif color==nil
@fileLogger.puts(text+"<br/>")
elsif @indent_level == ""
@fileLogger.puts(colorize(text, color))
else
@fileLogger.puts("<li>" + colorize(text, color)+"</li>")
end
end
end
def get_mental_att(att_index)
case att_index
when 0
return "Analytical Ability"
when 1
return "Focus"
when 2
return "Willpower"
when 3
return "Creativity"
when 4
return "Intuition"
when 5
return "Patience"
when 6
return "Memory"
when 7
return "Linguistics"
when 8
return "Spacial Sense"
when 9
return "Musicality"
when 10
return "Kinesthetic Sense"
when 11
return "Empathy"
when 12
return "Social Awareness"
else
return "Unknown"
end
end
def get_physical_att(att_index)
case att_index
when 0
return "strength"
when 1
return "agility"
when 2
return "toughness"
when 3
return "endurance"
when 4
return "recuperation"
when 5
return "disease resistance"
else
return "unknown"
end
end
def get_effect_target(target)
values = []
limit = target.key.length - 1
for i in (0..limit)
if(target.mode[i].to_s() != "")
items = ""
#case target.mode[i].to_s()
#when "BY_TYPE"
# item = "type("
#when "BY_TOKEN"
# item = "token("
#when "BY_CATEGORY"
# item = "category("
#end
if(target.key[i].to_s()!="")
item = "#{item}#{target.key[i].to_s().capitalize()}"
end
if target.tissue[i].to_s() != "ALL"
if(target.key[i].to_s()!="" and target.tissue[i].to_s()!="")
item = "#{item}:"
end
if(target.tissue[i].to_s()!="")
item = "#{item}#{target.tissue[i].to_s().capitalize()}"
end
end
#item = item + ")"
values.push(item)
end
end
if values.length == 0 or (values.length == 1 and values[0] == "All")
return ""
else
return ", target=" + values.join(", ")
end
end
def get_att_pairs(values, percents, physical)
items = []
color = Output::DEFAULT
limit = values.length - 1
for i in (0..limit)
if (values[i] != 0 or percents[i] != 100)
if physical
item = "#{get_physical_att(i)}("
else
item = "#{get_mental_att(i)}("
end
if(values[i]!=0)
item = item + "%+d" % values[i]
end
if (values[i]!=0 and percents[i]!=100)
item = item + ", "
end
if (percents[i]!=100 or values[i]==0)
item = item + "%d" % percents[i] + "%"
end
item = item + ")"
if color != Output::RED and values[i] >= 0 and percents[i] > 100
color = Output::GREEN
elsif values[i] <0 || percents[i] < 100
color = Output::RED
end
items.push(item)
end
end
return items.join(", "), color
end
def get_display_name(name, verb)
if name != nil and name != ""
return name.capitalize()
end
if verb == nil or verb == ""
return "Mystery"
end
if verb.length > 100
verb = verb.slice(0, 100).capitalize()
end
pos = verb.index(".")
if pos == nil
return verb.slice(0, verb.rindex(" ")).capitalize()
else
return verb.slice(0, pos).capitalize()
end
end
def get_interaction(interaction)
# name, USAGE_HINT, range, wait period are probably all we really want to show.
#result = "a=#{interaction.unk_6c} b=#{interaction.unk_7c} c=#{interaction.unk_8c} d=#{interaction.unk_a8} e=#{interaction.unk_c4} f=#{interaction.unk_e4} "
#result = result + "g=#{interaction.unk_e0} h=#{interaction.unk_e4} i=#{interaction.unk_100} j=#{interaction.unk_11c} k=#{interaction.unk_138} l=#{interaction.unk_154} "
#result = result + "m=#{interaction.unk_170} n=#{interaction.unk_18c} o=#{interaction.unk_1a8} p=#{interaction.unk_1c4} q=#{interaction.unk_1e8} r=#{interaction.unk_25c} "
#result = result + "s=#{interaction.unk_278}"
interaction = interaction.interaction
if interaction.adv_name == ""
name = "mystery"
else
name = interaction.adv_name
end
return "ability=#{get_display_name(interaction.adv_name, interaction.verb_2nd)}, delay=#{interaction.wait_period}, actionType=TODO, range=TODO, maxTargets=TODO"
end
def get_effect_flags(flags)
values = []
if(flags.SIZE_DELAYS) then values.push("size delays") end
if(flags.SIZE_DILUTES) then values.push("size dilutes") end
if(flags.VASCULAR_ONLY) then values.push("vascular only") end
if(flags.MUSCULAR_ONLY) then values.push("muscles only") end
if(flags.RESISTABLE) then values.push("resistable") end
if(flags.LOCALIZED) then values.push("localized") end
return values.join(",")
end
def get_tag1_flags(logger, flags, add)
values = []
good = false
bad = false
if add
good_color = Output::GREEN
bad_color = Output::RED
else
good_color = Output::RED
bad_color = Output::GREEN
end
if(flags.EXTRAVISION)
values.push(logger.colorize("extravision", good_color))
good = true
end
if(flags.OPPOSED_TO_LIFE)
values.push(logger.colorize("attack the living", bad_color))
bad = true
end
if(flags.NOT_LIVING)
values.push(logger.colorize("undead", Output::DEFAULT))
end
if(flags.NOEXERT)
values.push(logger.colorize("does not tire", good_color))
good = true
end
if(flags.NOPAIN)
values.push(logger.colorize("does not feel pain", good_color))
good = true
end
if(flags.NOBREATHE)
values.push(logger.colorize("does not breathe", good_color))
good = true
end
if(flags.HAS_BLOOD)
values.push(logger.colorize("has blood", Output::DEFAULT))
end
if(flags.NOSTUN)
values.push(logger.colorize("can't be stunned", good_color))
good = true
end
if(flags.NONAUSEA)
values.push(logger.colorize("does not get nausea", good_color))
good = true
end
if(flags.NO_DIZZINESS)
values.push(logger.colorize("does not get dizzy", good_color))
good = true
end
if(flags.NO_FEVERS)
values.push(logger.colorize("does not get fever", good_color))
good = true
end
if(flags.TRANCES)
values.push(logger.colorize("can enter trance", good_color))
good = true
end
if(flags.NOEMOTION)
values.push(logger.colorize("feels no emotion", good_color))
good = true
end
if(flags.LIKES_FIGHTING)
values.push(logger.colorize("like fighting", Output::DEFAULT))
end
if(flags.PARALYZEIMMUNE)
values.push(logger.colorize("can't be paralyzed", good_color))
good = true
end
if(flags.NOFEAR)
values.push(logger.colorize("does not feel fear", good_color))
good = true
end
if(flags.NO_EAT)
values.push(logger.colorize("does not eat", good_color))
good = true
end
if(flags.NO_DRINK)
values.push(logger.colorize("does not drink", good_color))
good = true
end
if(flags.NO_SLEEP)
values.push(logger.colorize("does not sleep", good_color))
good = true
end
if(flags.MISCHIEVOUS)
values.push(logger.colorize("mischievous", Output::DEFAULT))
end
if(flags.NO_PHYS_ATT_GAIN)
values.push(logger.colorize("physical stats cant improve", good_color))
good = true
end
if(flags.NO_PHYS_ATT_RUST)
values.push(logger.colorize("physical stats do not rust", good_color))
good = true
end
if(flags.NOTHOUGHT)
values.push(logger.colorize("stupid", bad_color))
bad = true
end
if(flags.NO_THOUGHT_CENTER_FOR_MOVEMENT)
values.push(logger.colorize("no brain needed to move", good_color))
good = true
end
if(flags.CAN_SPEAK)
values.push(logger.colorize("can speak", good_color))
good = true
end
if(flags.CAN_LEARN)
values.push(logger.colorize("can learn", good_color))
good = true
end
if(flags.UTTERANCES)
values.push(logger.colorize("utterances", Output::DEFAULT))
end
if(flags.CRAZED)
values.push(logger.colorize("crazed", bad_color))
bad = true
end
if(flags.BLOODSUCKER)
values.push(logger.colorize("drinks blood", bad_color))
bad = true
end
if(flags.NO_CONNECTIONS_FOR_MOVEMENT)
values.push(logger.colorize("can move without nerves", good_color))
good = true
end
if(flags.SUPERNATURAL)
values.push(logger.colorize("supernatural", good_color))
good = true
end
if add
if bad
color = Output::RED
elsif good
color = Output::GREEN
else
color = Output::DEFAULT
end
else
if good
color = Output::RED
elsif bad
color = Output::GREEN
else
color = Output::DEFAULT
end
end
return values.join(", "), color
end
def get_tag2_flags(logger, flags, add)
values = []
good = false
bad = false
if add
good_color = Output::GREEN
bad_color = Output::RED
else
good_color = Output::RED
bad_color = Output::GREEN
end
if(flags.NO_AGING)
good = true
values.push(logger.colorize("does not age", good_color))
end
if(flags.MORTAL)
bad = true
values.push(logger.colorize("mortal", bad_color))
end
if(flags.STERILE)
values.push(logger.colorize("can't have children", Output::DEFAULT))
end
if(flags.FIT_FOR_ANIMATION)
values.push(logger.colorize("can be animated", Output::DEFAULT))
end
if(flags.FIT_FOR_RESURRECTION)
good = true
values.push(logger.colorize("can be resurrected", Output::DEFAULT))
end
if add
if bad
color = Output::RED
elsif good
color = Output::GREEN
else
color = Output::DEFAULT
end
else
if good
color = Output::RED
elsif bad
color = Output::GREEN
else
color = Output::DEFAULT
end
end
return values.join(", "), color
end
def find_creature_name(id, casteid)
creature = df.world.raws.creatures.all.find{ |c| c.creature_id == id }
if creature == nil
return id, casteid
end
creature_name = creature.name[0].capitalize()
if casteid == "DEFAULT"
return creature_name, ""
end
caste = creature.caste.find{ |c| c.caste_id == casteid }
if caste == nil
return creature_name, casteid
elsif creature.name[0].downcase() == caste.caste_name[0].downcase()
return creature_name, ""
else
castename = caste.caste_name[0].downcase().chomp(creature.name[0].downcase()).strip()
if castename.start_with?(creature.name[0])
castename = castename.slice(creature.name[0].length, castename.length - creature.name[0].length).strip()
end
if castename.start_with?("of the")
castename = castename.slice("of the".length, castename.length - "of the".length).strip()
end
return creature_name, castename.downcase()
end
end
def get_effect(logger, ce, ticks, showdisplayeffects)
flags = get_effect_flags(ce.flags)
if flags != ""
flags = " (#{flags})"
end
if ce.end == -1
duration = " [permanent]"
elsif ce.start >= ce.peak or ce.peak <= 1
duration = " [#{ce.start}-#{ce.end}]"
else
duration = " [#{ce.start}-#{ce.peak}-#{ce.end}]"
end
case ce.getType().to_s()
when "PAIN"
name = "Pain"
desc = "power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "SWELLING"
name = "Swelling"
desc = "power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "OOZING"
name = "Oozing"
desc = "power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "BRUISING"
name = "Bruising"
desc = "power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "BLISTERS"
name = "Blisters"
desc = "power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "NUMBNESS"
name = "Numbness"
desc = "power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::GREEN
when "PARALYSIS"
name = "Paralysis"
desc = "power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "FEVER"
name = "Fever"
desc = "power=#{ce.sev}"
color = Output::RED
when "BLEEDING"
name = "Bleeding"
desc = "power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "COUGH_BLOOD"
name = "Cough Blood"
desc = "power=#{ce.sev}"
color = Output::RED
when "VOMIT_BLOOD"
name = "Vomit Blood"
desc = "power=#{ce.sev}"
color = Output::RED
when "NAUSEA"
name = "Nausea"
desc = "power=#{ce.sev}"
color = Output::RED
when "UNCONSCIOUSNESS"
name = "Unconsciousness"
desc = "power=#{ce.sev}"
color = Output::RED
when "NECROSIS"
name = "Necrosis"
desc = "power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "IMPAIR_FUNCTION"
name = "Impairs"
desc = "power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "DROWSINESS"
name = "Drowsiness"
desc = "power=#{ce.sev}"
color = Output::RED
when "DIZZINESS"
name = "Dizziness"
desc = "power=#{ce.sev}"
color = Output::RED
when "ADD_TAG"
name = "Add"
tags1 = get_tag1_flags(logger, ce.tags1, true)
tags2 = get_tag2_flags(logger, ce.tags2, true)
desc = "#{tags1[0]},#{tags2[0]}"
if tags1[1] == Output::RED || tags2[1] == Output::RED
color = Output::RED
elsif tags1[1] == Output::GREEN || tags2[1] == Output::GREEN
color = Output::GREEN
else
color = Output::DEFAULT
end
when "REMOVE_TAG"
name = "Remove"
tags1 = get_tag1_flags(logger, ce.tags1, true)
tags2 = get_tag2_flags(logger, ce.tags2, true)
desc = "#{tags1[0]},#{tags2[0]}"
if tags1[1] == Output::RED || tags2[1] == Output::RED
color = Output::RED
elsif tags1[1] == Output::GREEN || tags2[1] == Output::GREEN
color = Output::GREEN
else
color = Output::DEFAULT
end
when "DISPLAY_TILE"
if !showdisplayeffects then return "", Output::DEFAULT end
name = "Tile"
desc = "Tile=#{ce.tile}, Colour=#{ce.color}"
color = Output::DEFAULT
when "FLASH_TILE"
if !showdisplayeffects then return "", Output::DEFAULT end
name = "Flash"
color = ce.sym_color[1]
tile = ce.sym_color[0]
desc = "tile = #{tile}, colour=#{color}, time=#{ce.period}, period=#{ce.time}"
color = Output::DEFAULT
when "SPEED_CHANGE"
name = "Physical"
desc = "speed("
value = ce.bonus_add
percent = ce.bonus_perc
if(value!=0)
desc = desc + "%+d" % value
end
if (value!=0 and percent!=100)
desc = desc + ", "
end
if (percent!=100 or value==0)
desc = desc + "%d" % percent + "%"
end
desc = desc + ")"
if value < 0 or percent < 100
color = Output::RED
elsif value >0 or percent >100
color = Output::GREEN
else
color = Output::DEFAULT
end
when "CAN_DO_INTERACTION"
name = "Add interaction"
desc = "#{get_interaction(ce)}"
color = Output::GREEN
when "SKILL_ROLL_ADJUST"
name = "Skill check"
desc = "modifier=#{ce.multiplier}%, chance=#{ce.chance}%"
if ce.multiplier > 100
color = Output::GREEN
elsif ce.multiplier < 100
color = Output::RED
else
color = Output::DEFAULT
end
when "BODY_TRANSFORMATION"
name = "Transformation"
if ce.chance > 0
chance = ", chance=#{ce.chance} "
else
chance = ""
end
creature_name = find_creature_name(ce.race_str, ce.caste_str)
if creature_name[1] == ""
desc = "#{creature_name[0]}#{chance}"
else
desc = "#{creature_name[0]}(#{creature_name[1]})#{chance}"
end
color = Output::BLUE
when "PHYS_ATT_CHANGE"
name = "Physical"
data = get_att_pairs(ce.phys_att_add, ce.phys_att_perc, true)
desc = data[0]
color = data[1]
when "MENT_ATT_CHANGE"
name = "Mental"
data = get_att_pairs(ce.ment_att_add, ce.ment_att_perc, false)
desc = data[0]
color = data[1]
when "MATERIAL_FORCE_MULTIPLIER"
name = "Material force multiplier"
desc = "received damage scaled by #{(ce.fraction_mul * 100 / ce.fraction_div * 100)/100}%"
if ce.fraction_div > ce.fraction_mul
color = Output::GREEN
elsif ce.fraction_div < ce.fraction_mul
color = Output::RED
else
color = Output::DEFAULT
end
if ce.mat_index >=0
mat = df.decode_mat(ce.mat_type, ce.mat_index )
elsif ce.mat_type >= 0
mat = df.decode_mat(ce.mat_type, 0 )
else
mat = nil
end
if mat!= nil
token = mat.token
if token.start_with?("INORGANIC:")
token = token.slice("INORGANIC:".length, token.length - "INORGANIC:".length)
end
desc = "#{desc} vs #{token.capitalize()}"
end
when "BODY_MAT_INTERACTION"
# interactionId, SundromeTriggerType
name = "Body material interaction"
desc = "a???=#{ce.unk_6c}, b???=#{ce.unk_88}, c???=#{ce.unk_8c}, d???=#{ce.unk_90}, e???=#{ce.unk_94}"
color = Output::DEFAULT
when "BODY_APPEARANCE_MODIFIER"
if !showdisplayeffects then return "", Output::DEFAULT end
# !!! seems to be missing info class !!!
# should be enum and value
name = "Body Appearance"
desc = "<TODO>"
color = Output::DEFAULT
when "BP_APPEARANCE_MODIFIER"
if !showdisplayeffects then return "", Output::DEFAULT end
name = "Body part appearance"
desc = "value=#{ce.value} change_type_enum?=#{ce.unk_6c}#{get_effect_target(ce.target)}"
color = Output::DEFAULT
when "DISPLAY_NAME"
if !showdisplayeffects then return "", Output::DEFAULT end
name = "Set display name"
desc = "#{ce.name}"
color = Output::DEFAULT
else
name = "Unknown"
color = Output::HIGHLIGHT
end
text = "#{name}#{duration}#{flags} #{desc}"
if ticks > 0 and ((ce.start > 0 and ticks < ce.start) or (ce.end > 0 and ticks > ce.end))
text = logger.inactive(text)
end
return text, color
end
print_syndrome = lambda { |logger, syndrome, showeffects, showdisplayeffects|
rawsyndrome = df.world.raws.syndromes.all[syndrome.type]
duration = rawsyndrome.ce.minmax_by{ |ce| ce.end }
if duration[0].end == -1
durationStr = "permanent"
else
if duration[0].end == duration[1].end
durationStr = "#{syndrome.ticks} of #{duration[0].end}"
else
durationStr = "#{syndrome.ticks} of #{duration[0].end}-#{duration[1].end}"
end
end
effects = rawsyndrome.ce.collect { |effect| get_effect(logger, effect, syndrome.ticks, showdisplayeffects) }
if effects.any?{ |text, color| color==Output::RED }
color = Output::RED
elsif effects.any?{|text, color| color==Output::GREEN }
color = Output::GREEN
else
color = Output::DEFAULT
end
logger.indent()
logger.log "#{get_display_name(rawsyndrome.syn_name, "")} [#{durationStr}]", color
if showeffects
logger.indent()
effects.each{ |text, color| if text!="" then logger.log text, color end }
logger.unindent()
end
logger.unindent()
}
print_raw_syndrome = lambda { |logger, rawsyndrome, showeffects, showdisplayeffects|
effects = rawsyndrome.ce.collect { |effect| get_effect(logger, effect, -1, showdisplayeffects) }
if effects.any?{ |item| item[1]==Output::RED }
color = Output::RED
elsif effects.any?{|item| item[1]==Output::GREEN }
color = Output::GREEN
else
color = Output::DEFAULT
end
logger.indent()
logger.log get_display_name(rawsyndrome.syn_name, ""), color
if showeffects
logger.indent()
effects.each{ |text, color| if text!="" then logger.log text, color end }
logger.unindent()
end
logger.unindent()
}
print_syndromes = lambda { |logger, unit, showrace, showall, showeffects, showhiddencurse, showdisplayeffects|
if showhiddencurse
syndromes = unit.syndromes.active
else
syndromes = unit.syndromes.active
# TODO: syndromes = unit.syndromes.active.select{ |s| visible_syndrome?(unit, s) }
end
if !syndromes.empty? or showall
if showrace
logger.log "#{df.world.raws.creatures.all[unit.race].name[0]}#{unit.name == '' ? "" : ": "}#{unit.name}", Output::HIGHLIGHT
else
logger.log "#{unit.name}", Output::HIGHLIGHT
end
end
syndromes.each { |syndrome| print_syndrome[logger, syndrome, showeffects, showdisplayeffects] }
}
def starts_with?(str, prefix)
prefix = prefix.to_s
str[0, prefix.length] == prefix
end
showall = false
showeffects = false
selected = false
dwarves = false
livestock = false
wildanimals = false
hostile = false
world = false
showhiddencurse = false
showdisplayeffects = false
if $script_args.any?{ |arg| arg == "help" or arg == "?" or arg == "-?" }
print_help()
elsif $script_args.empty?
dwarves = true
showeffects = true
else
if $script_args.any?{ |arg| arg == "showall" } then showall=true end
if $script_args.any?{ |arg| arg == "showeffects" } then showeffects=true end
if $script_args.any?{ |arg| arg == "ignorehiddencurse" } then showhiddencurse=true end
if $script_args.any?{ |arg| arg == "showdisplayeffects" } then showdisplayeffects=true end
if $script_args.any?{ |arg| arg == "selected" } then selected=true end
if $script_args.any?{ |arg| arg == "dwarves" } then dwarves=true end
if $script_args.any?{ |arg| arg == "livestock" } then livestock=true end
if $script_args.any?{ |arg| arg == "wildanimals" } then wildanimals=true end
if $script_args.any?{ |arg| arg == "hostile" } then hostile=true end
if $script_args.any?{ |arg| arg == "world" } then world=true end
if $script_args.any?{ |arg| starts_with?(arg, "export:") }
exportfile = $script_args.find{ |arg| starts_with?(arg, "export:") }.gsub("export:", "")
export=true
end
end
if export
logger = Output.new(exportfile)
else
logger = Output.new(nil)
end
if selected
print_syndromes[logger, df.unit_find(), true, showall, showeffects, showhiddencurse, showdisplayeffects]
logger.break()
end
if dwarves
logger.log "Dwarves", Output::HIGHLIGHT