index_datamanip 0.5.2

Library for working with CoH's Pigg, MessageStore, and Parse7 (bin) formats
Documentation
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
#![allow(missing_docs)]

use serde::{Deserialize, Serialize};

type LString = std::ffi::CString;

#[derive(Debug, Serialize)]
pub struct ArchetypeName {
    pub name: String,
    pub internal: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct Class {
    pub name: String,
    pub display_name: String,
    pub display_help: String,
    pub allowed_origins: Vec<String>,
    pub special_restrictions: Vec<String>,
    pub store_requires: String,
    pub locked_tooltip: String,
    pub product_code: String,
    pub reduction_class: String,
    pub reduce_as_archvillain: bool,
    pub level_up_respecs: Vec<u32>,
    pub display_short_help: String,
    pub icon: String,
    pub primary_category: String,
    pub secondary_category: String,
    pub power_pool_category: String,
    pub epic_pool_category: String,
    pub attrib_min: Vec<CharacterAttributes>,
    pub attrib_base: Vec<CharacterAttributes>,
    pub strength_min: Vec<CharacterAttributes>,
    pub resistance_min: Vec<CharacterAttributes>,
    pub atrrib_dimin_str_in: Vec<CharacterAttributes>,
    pub atrrib_dimin_str_out: Vec<CharacterAttributes>,
    pub atrrib_dimin_cur_in: Vec<CharacterAttributes>,
    pub atrrib_dimin_cur_out: Vec<CharacterAttributes>,
    pub atrrib_dimin_res_in: Vec<CharacterAttributes>,
    pub atrrib_dimin_res_out: Vec<CharacterAttributes>,
    pub attrib_max_table: Vec<CharacterAttributesTable>,
    pub attrib_max_max_table: Vec<CharacterAttributesTable>,
    pub strength_max_table: Vec<CharacterAttributesTable>,
    pub resistance_max_table: Vec<CharacterAttributesTable>,
    pub mod_table: Vec<NamedTable>,
    pub connect_hp_and_status: bool,
}

impl Class {
    pub fn fix_strings(&mut self, pmessages: &std::collections::HashMap<String, String>) {
        // TODO: Switch to proper error handling
        self.display_name = pmessages.get(&self.display_name).unwrap().to_string();
        self.display_help = pmessages.get(&self.display_help).unwrap().to_string();
        self.display_short_help = pmessages.get(&self.display_short_help).unwrap().to_string();
        if !self.locked_tooltip.is_empty() {
            self.locked_tooltip = pmessages
                .get(&self.locked_tooltip)
                .unwrap_or_else(|| panic!("Not found: {}", self.locked_tooltip))
                .to_string();
        }
    }
}

#[derive(Debug, Deserialize, Serialize)]
pub struct CharacterAttributes {
    pub damage_type00: f32,
    pub damage_type01: f32,
    pub damage_type02: f32,
    pub damage_type03: f32,
    pub damage_type04: f32,
    pub damage_type05: f32,
    pub damage_type06: f32,
    pub damage_type07: f32,
    pub damage_type08: f32,
    pub damage_type09: f32,
    pub damage_type10: f32,
    pub damage_type11: f32,
    pub damage_type12: f32,
    pub damage_type13: f32,
    pub damage_type14: f32,
    pub damage_type15: f32,
    pub damage_type16: f32,
    pub damage_type17: f32,
    pub damage_type18: f32,
    pub damage_type19: f32,
    pub hit_points: f32,
    pub absorb: f32,
    pub endurance: f32,
    pub insight: f32,
    pub rage: f32,
    pub to_hit: f32,
    pub defense_type00: f32,
    pub defense_type01: f32,
    pub defense_type02: f32,
    pub defense_type03: f32,
    pub defense_type04: f32,
    pub defense_type05: f32,
    pub defense_type06: f32,
    pub defense_type07: f32,
    pub defense_type08: f32,
    pub defense_type09: f32,
    pub defense_type10: f32,
    pub defense_type11: f32,
    pub defense_type12: f32,
    pub defense_type13: f32,
    pub defense_type14: f32,
    pub defense_type15: f32,
    pub defense_type16: f32,
    pub defense_type17: f32,
    pub defense_type18: f32,
    pub defense_type19: f32,
    pub defense: f32,
    pub speed_running: f32,
    pub speed_flying: f32,
    pub speed_swimming: f32,
    pub speed_jumping: f32,
    pub jump_height: f32,
    pub movement_control: f32,
    pub movement_friction: f32,
    pub stealth: f32,
    pub stealth_radius: f32,
    pub stealth_radius_player: f32,
    pub perception_radius: f32,
    pub regeneration: f32,
    pub recovery: f32,
    pub insight_recovery: f32,
    pub threat_level: f32,
    pub taunt: f32,
    pub placate: f32,
    pub confused: f32,
    pub afraid: f32,
    pub terrorized: f32,
    pub held: f32,
    pub immobilized: f32,
    pub stunned: f32,
    pub sleep: f32,
    pub fly: f32,
    pub jumppack: f32,
    pub teleport: f32,
    pub untouchable: f32,
    pub intangible: f32,
    pub only_affects_self: f32,
    pub experience_gain: f32,
    pub influence_gain: f32,
    pub prestige_gain: f32,
    pub null_bool: f32,
    pub knockup: f32,
    pub knockback: f32,
    pub repel: f32,
    pub accuracy: f32,
    pub radius: f32,
    pub arc: f32,
    pub range: f32,
    pub time_to_activate: f32,
    pub recharge_time: f32,
    pub interrupt_time: f32,
    pub endurance_discount: f32,
    pub insight_discount: f32,
    pub meter: f32,
    pub elusivity00: f32,
    pub elusivity01: f32,
    pub elusivity02: f32,
    pub elusivity03: f32,
    pub elusivity04: f32,
    pub elusivity05: f32,
    pub elusivity06: f32,
    pub elusivity07: f32,
    pub elusivity08: f32,
    pub elusivity09: f32,
    pub elusivity10: f32,
    pub elusivity11: f32,
    pub elusivity12: f32,
    pub elusivity13: f32,
    pub elusivity14: f32,
    pub elusivity15: f32,
    pub elusivity16: f32,
    pub elusivity17: f32,
    pub elusivity18: f32,
    pub elusivity19: f32,
    pub elusivity_base: f32,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct CharacterAttributesTable {
    pub damage_type00: Vec<f32>,
    pub damage_type01: Vec<f32>,
    pub damage_type02: Vec<f32>,
    pub damage_type03: Vec<f32>,
    pub damage_type04: Vec<f32>,
    pub damage_type05: Vec<f32>,
    pub damage_type06: Vec<f32>,
    pub damage_type07: Vec<f32>,
    pub damage_type08: Vec<f32>,
    pub damage_type09: Vec<f32>,
    pub damage_type10: Vec<f32>,
    pub damage_type11: Vec<f32>,
    pub damage_type12: Vec<f32>,
    pub damage_type13: Vec<f32>,
    pub damage_type14: Vec<f32>,
    pub damage_type15: Vec<f32>,
    pub damage_type16: Vec<f32>,
    pub damage_type17: Vec<f32>,
    pub damage_type18: Vec<f32>,
    pub damage_type19: Vec<f32>,
    pub hit_points: Vec<f32>,
    pub endurance: Vec<f32>,
    pub insight: Vec<f32>,
    pub rage: Vec<f32>,
    pub to_hit: Vec<f32>,
    pub defense_type00: Vec<f32>,
    pub defense_type01: Vec<f32>,
    pub defense_type02: Vec<f32>,
    pub defense_type03: Vec<f32>,
    pub defense_type04: Vec<f32>,
    pub defense_type05: Vec<f32>,
    pub defense_type06: Vec<f32>,
    pub defense_type07: Vec<f32>,
    pub defense_type08: Vec<f32>,
    pub defense_type09: Vec<f32>,
    pub defense_type10: Vec<f32>,
    pub defense_type11: Vec<f32>,
    pub defense_type12: Vec<f32>,
    pub defense_type13: Vec<f32>,
    pub defense_type14: Vec<f32>,
    pub defense_type15: Vec<f32>,
    pub defense_type16: Vec<f32>,
    pub defense_type17: Vec<f32>,
    pub defense_type18: Vec<f32>,
    pub defense_type19: Vec<f32>,
    pub defense: Vec<f32>,
    pub speed_running: Vec<f32>,
    pub speed_flying: Vec<f32>,
    pub speed_swimming: Vec<f32>,
    pub speed_jumping: Vec<f32>,
    pub jump_height: Vec<f32>,
    pub movement_control: Vec<f32>,
    pub movement_friction: Vec<f32>,
    pub stealth: Vec<f32>,
    pub stealth_radius: Vec<f32>,
    pub stealth_radius_player: Vec<f32>,
    pub perception_radius: Vec<f32>,
    pub regeneration: Vec<f32>,
    pub recovery: Vec<f32>,
    pub insight_recovery: Vec<f32>,
    pub threat_level: Vec<f32>,
    pub taunt: Vec<f32>,
    pub placate: Vec<f32>,
    pub confused: Vec<f32>,
    pub afraid: Vec<f32>,
    pub terrorized: Vec<f32>,
    pub held: Vec<f32>,
    pub immobilized: Vec<f32>,
    pub stunned: Vec<f32>,
    pub sleep: Vec<f32>,
    pub fly: Vec<f32>,
    pub jumppack: Vec<f32>,
    pub teleport: Vec<f32>,
    pub untouchable: Vec<f32>,
    pub intangible: Vec<f32>,
    pub only_affects_self: Vec<f32>,
    pub experience_gain: Vec<f32>,
    pub influence_gain: Vec<f32>,
    pub prestige_gain: Vec<f32>,
    pub null_bool: Vec<f32>,
    pub knockup: Vec<f32>,
    pub knockback: Vec<f32>,
    pub repel: Vec<f32>,
    pub accuracy: Vec<f32>,
    pub radius: Vec<f32>,
    pub arc: Vec<f32>,
    pub range: Vec<f32>,
    pub time_to_activate: Vec<f32>,
    pub recharge_time: Vec<f32>,
    pub interrupt_time: Vec<f32>,
    pub endurance_discount: Vec<f32>,
    pub insight_discount: Vec<f32>,
    pub meter: Vec<f32>,
    pub elusivity00: Vec<f32>,
    pub elusivity01: Vec<f32>,
    pub elusivity02: Vec<f32>,
    pub elusivity03: Vec<f32>,
    pub elusivity04: Vec<f32>,
    pub elusivity05: Vec<f32>,
    pub elusivity06: Vec<f32>,
    pub elusivity07: Vec<f32>,
    pub elusivity08: Vec<f32>,
    pub elusivity09: Vec<f32>,
    pub elusivity10: Vec<f32>,
    pub elusivity11: Vec<f32>,
    pub elusivity12: Vec<f32>,
    pub elusivity13: Vec<f32>,
    pub elusivity14: Vec<f32>,
    pub elusivity15: Vec<f32>,
    pub elusivity16: Vec<f32>,
    pub elusivity17: Vec<f32>,
    pub elusivity18: Vec<f32>,
    pub elusivity19: Vec<f32>,
    pub defense_whats_this: Vec<f32>, // Does this override the defense above?
    pub absorb: Vec<f32>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct NamedTable {
    pub name: String,
    pub values: Vec<f32>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct PowerCategory {
    pub source_file: String,
    pub name: String,
    pub display_name: String,
    pub display_help: String,
    pub display_short_help: String,
    pub powersets: Vec<String>,
}

impl PowerCategory {
    pub fn fix_strings(&mut self, pmessages: &std::collections::HashMap<String, String>) {
        // TODO: Switch to proper error handling
        if !self.display_name.is_empty() {
            self.display_name = pmessages.get(&self.display_name).unwrap().to_string();
        }
        if !self.display_help.is_empty() {
            self.display_help = pmessages.get(&self.display_help).unwrap().to_string();
        }
        if !self.display_short_help.is_empty() {
            self.display_short_help = pmessages.get(&self.display_short_help).unwrap().to_string();
        }
    }
}

#[derive(Debug, Deserialize, Serialize)]
pub struct PowerRedirect {
    pub power: String,
    pub requires: Vec<String>,
    pub show_in_info: bool,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct Power {
    pub full_name: String,
    pub crcfull_name: u32,
    pub source_file: String,
    pub name: String,
    pub source_name: String,
    pub system: u32,
    pub auto_issue: bool,
    pub auto_issue_save_level: bool,
    pub free: bool,
    pub display_name: String,
    pub display_help: String,
    pub display_short_help: String,
    // display_caster_help: String,
    // display_caster_short_help: String,
    pub display_target_help: String,
    pub display_target_short_help: String,
    pub display_attacker_attack: String,
    pub display_attacker_attack_floater: String,
    pub display_attacker_hit: String,
    pub display_victim_hit: String,
    pub display_confirm: String,
    pub float_rewarded: String,
    pub display_power_defense_float: String,
    pub icon_name: String,
    #[serde(rename = "type")]
    pub power_type: u32,
    pub num_allowed: u32,
    pub attack_types: Vec<AttackType>,
    // pub attack_types: Vec<u32>,
    pub buy_requires: Vec<String>,
    pub activate_requires: Vec<String>,
    pub slot_requires: Vec<String>,
    pub target_requires: Vec<String>,
    pub reward_requires: Vec<String>,
    pub auction_requires: Vec<String>,
    pub reward_fallback: String,
    pub accuracy: f32,
    pub near_ground: bool,
    pub target_near_ground: bool,
    pub castable_after_death: u32,
    pub cast_through_hold: bool,
    pub cast_through_sleep: bool,
    pub cast_through_stun: bool,
    pub cast_through_terrorize: bool,
    pub toggle_ignore_hold: bool,
    pub toggle_ignore_sleep: bool,
    pub toggle_ignore_stun: bool,
    pub ignore_level_bought: bool,
    pub shoot_through_untouchable: bool,
    pub interrupt_like_sleep: bool,
    pub ai_report: u32,
    pub effect_area: u32,
    pub max_targets_hit: u32,
    pub _unknown_unused: u32, // This is always 0x00000000
    pub radius: f32,
    pub arc: f32,
    pub chain_delay: f32,
    pub chain_eff: Vec<String>,
    pub chain_fork: Vec<u32>,
    pub box_offset: (f32, f32, f32),
    pub box_size: (f32, f32, f32),
    pub range: f32,
    pub range_secondary: f32,
    pub time_to_activate: f32,
    pub recharge_time: f32,
    pub activate_period: f32,
    pub endurance_cost: f32,
    pub idea_cost: f32,
    pub time_to_confirm: u32,
    pub self_confirm: u32,
    pub confirm_requires: Vec<String>,
    pub destroy_on_limit: bool,
    pub stacking_usage: bool,
    pub num_charges: u32,
    pub max_num_charges: u32,
    pub usage_time: f32,
    pub max_usage_time: f32,
    pub lifetime: f32,
    pub max_lifetime: f32,
    pub lifetime_in_game: f32,
    pub max_lifetime_in_game: f32,
    pub interrupt_time: f32,
    pub target_visibility: u32,
    pub target: u32,
    pub target_secondary: u32,
    pub ents_auto_hit: Vec<u32>,
    pub ents_affected: Vec<u32>,
    pub targets_through_vision_phase: bool,
    pub boosts_allowed: Vec<u32>,
    pub group_membership: Vec<u32>,
    pub modes_required: Vec<u32>,
    pub modes_disallowed: Vec<u32>,
    pub ai_groups: Vec<String>,
    pub redirect: Vec<PowerRedirect>,
    pub effects: Vec<Effects>,
    pub ignore_strength: bool,
    pub show_buff_icon: bool,
    pub show_in_inventory: u32,
    pub show_in_manage: bool,
    pub show_in_info: bool,
    pub deletable: bool,
    pub tradeable: bool,
    pub max_boosts: u32,
    pub do_not_save: bool,
    pub boost_ignore_effectiveness: bool,
    pub boost_always_count_for_set: bool,
    pub boost_tradeable: bool,
    pub boost_combinable: bool,
    pub boost_account_bound: bool,
    pub boost_boostable: bool,
    pub boost_use_player_level: bool,
    pub boost_catalyst_conversion: String,
    pub store_product: String,
    pub boost_license_level: u32,
    pub min_slot_level: i32,
    pub max_slot_level: u32,
    pub max_boost_level: u32,
    pub var: Vec<Var>,
    pub toggle_droppable: u32,
    pub proc_allowed: u32,
    pub strengths_disallowed: Vec<u32>,
    pub proc_main_target_only: bool,
    pub anim_main_target_only: bool,
    pub highlight_eval: Vec<String>,
    pub highlight_icon: String,
    pub highlight_ring: RGBA,
    pub travel_suppression: f32,
    pub preference_multiplier: f32,
    pub dont_set_stance: bool,
    pub point_value: f32,
    pub point_multiplier: f32,
    pub chain_into_power: String,
    pub instance_locked: bool,
    pub is_environment_hit: bool,
    pub shuffle_targets: bool,
    pub force_level_bought: i32,
    pub refreshes_on_active_player_change: bool,
    pub cancelable: bool,
    pub ignore_toggle_max_distance: bool,
    pub server_tray_priority: u32,
    pub server_tray_requires: Vec<String>,
    pub abusive_buff: bool,
    pub position_center: u32,
    pub position_distance: f32,
    pub position_height: f32,
    pub position_yaw: f32,
    pub face_target: bool,
    pub attrib_cache: Vec<u32>,
    pub visual_fx: String,
    pub attack_bits: Vec<u32>,
    pub block_bits: Vec<u32>,
    pub wind_up_bits: Vec<u32>,
    pub hit_bits: Vec<u32>,
    pub death_bits: Vec<u32>,
    pub activation_bits: Vec<u32>,
    pub deactivation_bits: Vec<u32>,
    pub initial_attack_bits: Vec<u32>,
    pub continuing_bits: Vec<u32>,
    pub conditional_bits: Vec<u32>,
    pub activation_fx: String,
    pub deactivation_fx: String,
    pub attack_fx: String,
    pub secondary_attack_fx: String,
    pub hit_fx: String,
    pub wind_up_fx: String,
    pub block_fx: String,
    pub death_fx: String,
    pub initial_attack_fx: String,
    pub continuing_fx: String,
    pub continuing_fx1: String,
    pub continuing_fx2: String,
    pub continuing_fx3: String,
    pub continuing_fx4: String,
    pub conditional_fx: String,
    pub conditional_fx1: String,
    pub conditional_fx2: String,
    pub conditional_fx3: String,
    pub conditional_fx4: String,
    pub mode_bits: Vec<u32>,
    pub frames_before_hit: u32,
    pub frames_before_secondary_hit: u32,
    pub delayed_hit: bool,
    pub attack_frames: u32,
    pub initial_frames_before_hit: u32,
    pub initial_attack_fxframe_delay: u32,
    pub projectile_speed: f32,
    pub secondary_projectile_speed: f32,
    pub initial_frames_before_block: u32,
    pub ignore_attack_time_errors: String,
    pub frames_before_block: u32,
    pub fx_important: bool,
    pub primary_tint: ConditionalRGBA,
    pub secondary_tint: ConditionalRGBA,
    pub custom_fx: Vec<CustomFx>,
}

impl Power {
    pub fn fix_strings(&mut self, pmessages: &std::collections::HashMap<String, String>) {
        // TODO: Switch to proper error handling
        self.display_name = pmessages.get(&self.display_name).unwrap().to_string();
        self.display_help = pmessages.get(&self.display_help).unwrap().to_string();
        self.display_short_help = pmessages.get(&self.display_short_help).unwrap().to_string();
    }
}

#[derive(Debug, Deserialize, Serialize)]
pub struct CustomFx {
    pub token: String,
    pub alt_theme: Vec<String>,
    pub source_file: String,
    pub category: String,
    pub display_name: String,
    pub attack_bits: Vec<u32>,
    pub block_bits: Vec<u32>,
    pub wind_up_bits: Vec<u32>,
    pub hit_bits: Vec<u32>,
    pub death_bits: Vec<u32>,
    pub activation_bits: Vec<u32>,
    pub deactivation_bits: Vec<u32>,
    pub initial_attack_bits: Vec<u32>,
    pub continuing_bits: Vec<u32>,
    pub conditional_bits: Vec<u32>,
    pub activation_fx: String,
    pub deactivation_fx: String,
    pub attack_fx: String,
    pub secondary_attack_fx: String,
    pub hit_fx: String,
    pub wind_up_fx: String,
    pub block_fx: String,
    pub death_fx: String,
    pub initial_attack_fx: String,
    pub continuing_fx: String,
    pub continuing_fx1: String,
    pub continuing_fx2: String,
    pub continuing_fx3: String,
    pub continuing_fx4: String,
    pub conditional_fx: String,
    pub conditional_fx1: String,
    pub conditional_fx2: String,
    pub conditional_fx3: String,
    pub conditional_fx4: String,
    pub mode_bits: Vec<u32>,
    pub frames_before_hit: u32,
    pub frames_before_secondary_hit: u32,
    pub delayed_hit: bool,
    pub attack_frames: u32,
    pub initial_frames_before_hit: u32,
    pub initial_attack_fxframe_delay: u32,
    pub projectile_speed: f32,
    pub secondary_projectile_speed: f32,
    pub initial_frames_before_block: u32,
    pub ignore_attack_time_errors: String,
    pub frames_before_block: u32,
    pub fx_important: bool,
    pub primary_tint: ConditionalRGBA,
    pub secondary_tint: ConditionalRGBA,
    pub palette: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct RGBA(u8, u8, u8, u8);

#[derive(Debug, Deserialize, Serialize)]
pub struct ConditionalRGBA(u8, u8, u8, u8);

#[derive(Debug, Deserialize, Serialize)]
pub struct Var {
    pub index: u32,
    pub name: String,
    pub min: f32,
    pub max: f32,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct Effects {
    pub tag: Vec<String>,
    pub chance: f32,
    pub procs_per_minute: f32,
    pub delay: f32,
    pub radius_inner: f32,
    pub radius_outer: f32,
    pub requires: Vec<String>,
    pub flags: u32,
    pub eval_flags: u32,
    pub attrib_mod: Vec<AttribMod>,
    pub effect: Vec<Effects>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct AttribMod {
    pub attrib: Vec<u32>,
    pub aspect: u32,
    pub application_type: u32,
    #[serde(rename = "type")]
    pub attrib_type: u32,
    pub target: u32,
    pub target_info: Vec<TargetInfo>,
    pub table: String,
    pub scale: f32,
    pub duration: f32,
    pub magnitude: f32,
    pub duration_expr: Vec<String>,
    pub magnitude_expr: Vec<String>,
    pub delay: f32,
    pub period: f32,
    pub tick_chance: f32,
    pub delayed_requires: Vec<String>,
    pub caster_stack_type: u32,
    pub stack_type: u32,
    pub stack_limit: u32,
    pub stack_key: u32,
    pub cancel_events: Vec<u32>,
    pub suppress: Vec<Suppress>,
    pub boost_mod_allowed: u32,
    pub flags: AttribModFlags,
    pub messages: Vec<AttribModMessages>,
    pub fx: Vec<AttribModFX>,
    pub param: AttribModParam,
}

#[derive(Debug, Deserialize, Serialize)]
pub enum AttribModParam {
    None,
    Costume(attrib_mod_param_structs::Costume),
    Reward(attrib_mod_param_structs::Reward),
    EntCreate(attrib_mod_param_structs::EntCreate),
    Power(attrib_mod_param_structs::Power),
    Phase(attrib_mod_param_structs::Phase),
    Teleport(attrib_mod_param_structs::Teleport),
    Behavior(attrib_mod_param_structs::Behavior),
    SZEValue(attrib_mod_param_structs::SZEValue),
    Token(attrib_mod_param_structs::Token),
    EffectFilter(attrib_mod_param_structs::EffectFilter),
}

#[derive(Debug, Deserialize, Serialize)]
pub struct AttribModMessages {
    pub display_attacker_hit: String,
    pub display_victim_hit: String,
    pub display_float: String,
    pub display_attrib_defense_float: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct AttribModFX {
    pub continuing_bits: Vec<u32>,
    pub continuing_fx: String,
    pub conditional_bits: Vec<u32>,
    pub conditional_fx: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct AttribModFlags(u32, u32);

#[derive(Debug, Deserialize, Serialize)]
pub struct TargetInfo {
    pub marker: Vec<String>,
    pub count: Vec<u32>,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct Suppress {
    pub event: u32,
    pub seconds: u32,
    pub always: bool,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct Powerset {
    pub source_file: String,
    pub full_name: String,
    pub name: String,
    pub system: u32,
    pub shared: u8,
    pub display_name: String,
    pub display_help: String,
    pub display_short_help: String,
    pub icon_name: String,
    pub costume_keys: Vec<String>,
    pub costume_parts: Vec<String>,
    pub set_account_requires: String,
    pub set_account_tooltip: String,
    pub set_account_product: String,
    pub set_buy_requires: Vec<String>,
    pub set_buy_requires_failed_text: String,
    pub show_in_inventory: u32,
    pub show_in_manage: bool,
    pub show_in_info: bool,
    pub specialize_at: u32,
    pub specialize_requires: Vec<String>,
    pub powers: Vec<String>,
    pub available: Vec<u32>,
    pub aimax_level: Vec<u32>,
    pub aimin_rank_con: Vec<u32>,
    pub aimax_rank_con: Vec<u32>,
    pub min_difficulty: Vec<u32>,
    pub max_difficulty: Vec<u32>,
    pub force_level_bought: u32,
}

impl Powerset {
    pub fn fix_strings(&mut self, pmessages: &std::collections::HashMap<String, String>) {
        // TODO: Switch to proper error handling
        self.display_name = pmessages.get(&self.display_name).unwrap().to_string();
        self.display_help = pmessages.get(&self.display_help).unwrap().to_string();
        self.display_short_help = pmessages.get(&self.display_short_help).unwrap().to_string();
    }
}

pub mod attrib_mod_param_structs {
    use serde::{Deserialize, Serialize};
    #[derive(Debug, Deserialize, Serialize)]
    pub struct Costume {
        pub costume: String,
        pub priority: u32,
    }

    #[derive(Debug, Deserialize, Serialize)]
    pub struct Reward {
        pub reward: Vec<String>,
    }

    #[derive(Debug, Deserialize, Serialize)]
    pub struct EntCreate {
        pub entity_def: String,
        pub class: String,
        pub costume: String,
        pub display_name: String,
        pub priority_list: String,
        pub ai_config: String,
        pub power_category: Vec<String>,
        pub powerset: Vec<String>,
        pub power: Vec<String>,
        pub unknown1: u32,
    }

    #[derive(Debug, Deserialize, Serialize)]
    pub struct Power {
        pub power_category: Vec<String>,
        pub powerset: Vec<String>,
        pub power: Vec<String>,
        pub count: u32,
    }

    #[derive(Debug, Deserialize, Serialize)]
    pub struct Phase {
        pub unknown1: Vec<u32>,
        pub unknown2: Vec<u32>,
        pub unknown3: u32,
    }

    #[derive(Debug, Deserialize, Serialize)]
    pub struct Teleport {
        pub destination: String,
    }

    #[derive(Debug, Deserialize, Serialize)]
    pub struct Behavior {
        pub behavior: Vec<String>,
    }

    #[derive(Debug, Deserialize, Serialize)]
    pub struct SZEValue {
        pub script_id: Vec<String>,
        pub script_value: Vec<String>,
    }

    #[derive(Debug, Deserialize, Serialize)]
    pub struct Token {
        pub token: Vec<String>,
    }

    #[derive(Debug, Deserialize, Serialize)]
    pub struct EffectFilter {
        pub power_category: Vec<String>,
        pub powerset: Vec<String>,
        pub power: Vec<String>,
        pub tag: Vec<String>,
    }
}

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(from = "u32", into = "u32")]
pub enum AttackType {
    Ranged,
    Melee,
    AOE,
    Smashing,
    Lethal,
    Fire,
    Cold,
    Energy,
    NegativeEnergy,
    Psionic,
    Toxic,
    Unknown(u32),
}

impl std::convert::From<u32> for AttackType {
    fn from(num: u32) -> Self {
        match num {
            104 => AttackType::Ranged,
            108 => AttackType::Melee,
            112 => AttackType::AOE,
            116 => AttackType::Smashing,
            120 => AttackType::Lethal,
            124 => AttackType::Fire,
            128 => AttackType::Cold,
            132 => AttackType::Energy,
            136 => AttackType::NegativeEnergy,
            140 => AttackType::Psionic,
            144 => AttackType::Toxic,
            num => AttackType::Unknown(num),
        }
    }
}

impl std::convert::Into<u32> for AttackType {
    fn into(self) -> u32 {
        match self {
            AttackType::Ranged => 104,
            AttackType::Melee => 108,
            AttackType::AOE => 112,
            AttackType::Smashing => 116,
            AttackType::Lethal => 120,
            AttackType::Fire => 124,
            AttackType::Cold => 128,
            AttackType::Energy => 132,
            AttackType::NegativeEnergy => 136,
            AttackType::Psionic => 140,
            AttackType::Toxic => 144,
            AttackType::Unknown(num) => num,
        }
    }
}

#[derive(Debug, Deserialize, Serialize)]
pub struct BoostSet {
    pub name: String,
    pub display_name: String,
    pub group_name: String,
    pub conversion_groups: Vec<String>,
    pub powers: Vec<LString>,
    pub boost_lists: Vec<BoostList>,
    pub bonuses: Vec<BoostSetBonus>,
    pub min_level: u32,
    pub max_level: u32,
    pub store_product: String,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct BoostList {
    pub boosts: Vec<LString>,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct BoostSetBonus {
    pub display_text: String,
    pub min_boosts: u32,
    pub max_boosts: u32,
    pub requires: Vec<String>,
    pub auto_powers: Vec<LString>,
    pub bonus_power: LString,
}