forked from PekanMmd/Pokemon-XD-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Code snippets.swift
8000 lines (7649 loc) · 296 KB
/
Code snippets.swift
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
//
// Code snippets.swift
// XGCommandLineTools
//
// Created by StarsMmd on 20/03/2017.
// Copyright © 2017 StarsMmd. All rights reserved.
//
import Foundation
// infinite TMs
//infiniteUseTMs()
//
//
//loadAllStrings()
//let list = [(20,"Blizzard-"),(32,"Scald-"),(51,"Thunder-"),(54,"Rock Slide-")]
//var indices = [Int]()
//let rel = XGFiles.common_rel.data!
//for (index,next) in list {
// let move = XGMoves.move(index).data
// let oldNameId = XGOriginalMoves.move(index).nameID
// rel.replace2BytesAtOffset(move.startOffset + kMoveNameIDOffset, withBytes: oldNameId)
// indices.append(oldNameId)
//}
//rel.save()
//for i in 0 ..< list.count {
// getStringWithID(id: indices[i])!.duplicateWithString(list[i].1).replace()
//}
//let pelipper = pokemon("pelipper").stats
//pelipper.ability1 = ability("drizzle")
//pelipper.save()
//
//let torkoal = pokemon("torkoal").stats
//torkoal.ability1 = ability("drought")
//torkoal.save()
//let rage_powder = move("rage powder").data
//rage_powder.priority = 2
//rage_powder.save()
//
//let xg001 = pokemon("xg001").stats
//xg001.modelIndex = 0x1A1
//xg001.save()
//
//let typhlosion = pokemon("typhlosion").stats
//typhlosion.levelUpMoves[1].move = move("heat wave")
//typhlosion.save()
//let cyndaquil = pokemon("cyndaquil").stats
//cyndaquil.levelUpMoves[6].move = move("heat wave")
//cyndaquil.save()
//
//let blaziken = pokemon("blaziken").stats
//blaziken.learnableTMs[24] = true
//blaziken.save()
//
//
//for deck in TrainerDecksArray {
// if deck != .DeckVirtual {
// for poke in deck.allPokemon {
// if poke.species.index == pokemon("wobbuffet").index {
// poke.moves = [move("mirror coat"), move("counter"), move("safeguard"), move("destiny bond")]
// poke.save()
// }
// if poke.isShadowPokemon {
// if poke.species.stats.evolutions[0].evolutionMethod == .maxHappiness {
// poke.happiness = 120
// poke.save()
// }
// }
// }
// }
//}
//let scizor = pokemon("scizor").stats
//scizor.learnableTMs[30] = false
//scizor.save()
//
//XGTMs.tm(41).replaceWithMove(move("thunder"))
//
//let thunderLearners = [19,20,25,26,29,30,31,32,33,34,35,36,39,40,52,53,56,57,81,82,83,88,89,92,93,94,100,101,109,110,111,112,113,115,120,121,122,125,128,130,131,135,137,143,145,147,148,149,150,151,162,170,171,172,179,180,181,200,203,206,209,210,233,234,239,241,242,243,248,249,250,260,261,262,265,267,288,289,315,316,317,320,337,338,353,354,364,365,366,376,377,378,380,384,385,386,387,401,402,403,404,406,407,408,409,410]
//for i in 1..<kNumberOfPokemon {
// let poke = XGPokemon.pokemon(i).stats
// if thunderLearners.contains(i) {
// poke.learnableTMs[40] = true
// } else {
// poke.learnableTMs[40] = false
// }
// poke.save()
//}
//
//let banette = pokemon("banette").stats
//for i in [8,27,36,42] {
// banette.learnableTMs[i] = false
//}
//for i in [3,4,5,6] {
// banette.tutorMoves[i] = false
//}
//banette.save()
//
//
//let normaliseMoves = [20,32,40,51,54,80]
//
//var normalised = [XGTrainerPokemon]()
//for deck in TrainerDecksArray {
// if deck != .DeckVirtual {
// for poke in deck.allPokemon {
// for m in normaliseMoves {
// if poke.moves.contains(where: { (m1) -> Bool in
// return m1.index == m
// }) {
// normalised.append(poke)
// break
// }
// }
// }
// }
//}
//
//normalised[0].moves[1] = XGMoves.move(0)
//normalised[1].moves[0] = move("tackle")
//normalised[2].moves[0] = move("absorb")
//normalised[3].moves[0] = move("rock throw")
//normalised[4].moves[2] = move("taunt")
//normalised[5].moves[1] = move("thunderwave")
//normalised[6].moves[3] = move("rock throw")
//normalised[7].moves[3] = move("poison jab")
//normalised[8].moves[3] = move("rock throw")
//normalised[9].moves[2] = move("tackle")
//normalised[10].moves[1] = move("megahorn")
//normalised[11].moves[2] = move("giga drain")
//normalised[12].moves[2] = move("spikes")
//normalised[13].moves[2] = move("giga drain")
//normalised[14].moves[2] = move("iron head")
//normalised[14].moves[3] = move("bulldoze")
//normalised[15].moves[2] = move("ice shard")
//normalised[16].moves[2] = move("poison fang")
//normalised[17].moves[3] = move("ice beam")
//normalised[18].moves[3] = move("ice beam")
//
//
//for pokemon in normalised {
// pokemon.save()
//}
//loadAllStrings()
//let bigd = XGDecks.DeckColosseum
//var strs = [XGString]()
//for i in 41 ... 68 {
// let trainer = XGTrainer(index: i, deck: bigd)
// let name = trainer.name.string
// let trclass = trainer.trainerClass.name.string
// let pre = getStringSafelyWithID(id: trainer.preBattleTextID)
// let vic = getStringSafelyWithID(id: trainer.victoryTextID)
// let def = getStringSafelyWithID(id: trainer.defeatTextID)
// strs += [pre, vic, def]
//}
//
//let replacementStrs = [
// "[Speaker]: Cipher Green here!", "[Speaker]: You got weeded out![6d]", "[Speaker]: I got rooted.[6d]", // sage
// "[Speaker]: I'll show you why they call[New Line]me the gatekeeper of Pyrite.", "[Speaker]: Don't come back, punk![6d]", "[Speaker]: Locked out...[6d]", // kane
// "[Speaker]: Sylvia'll chew me out if[New Line]I lose again.", "[Speaker]: I did it![6d]", "[Speaker]: I'm in so much trouble.[6d]", // mark
// "[Speaker]: Did you Mark lose again?[New Line]I'll have to #PunishHim later but[New Line]now it's #MyTurn!", "[Speaker]: #GetRekt![6d]", "[Speaker]: #NoFair![6d]", // sylvia
// "[Speaker]: Do you know what they call[New Line]me?[New Line]They call me the storm bringer!", "[Speaker]: I stormed to victory![6d]", "[Speaker]: Darn![New Line]My feelings are stormy after this loss![6d]", // luthor
// "[Speaker]: Let me show you what a[New Line]Gym Leader can do!", "[Speaker]: You need more training.[6d]", "[Speaker]: I need more training.[6d]", // derek
// "[Speaker]: I'll crush you this time!", "[Speaker]: My muscles show my strength![6d]", "[Speaker]: I-I Lost?.[6d]", // ray
// "[Speaker]: I've got some secret techs[New Line]to catch you off guard!", "[Speaker]: You're too predictable.[6d]", "[Speaker]: You saw through my tactics.[6d]", // blaine
// "[Speaker]: Check out my seismic moves.", "[Speaker]: Hit the road.[6d]", "[Speaker]: You really ground me up.[6d]", // sandy
// "[Speaker]: I'll stall you out of[New Line]all your pp.", "[Speaker]: Guess you got impatient![6d]", "[Speaker]: You broke our defenses!?.[6d]", // dexter
// "[Speaker]: YOU AGAIN?!", "[Speaker]: I'm the greatest![6d]", "[Speaker]: You're crampin' my style.[6d]", // zeke
// "[Speaker]: This time, I will crush you and pulverize you!", "[Speaker]: That's for wrecking my[New Line]factory![New Line]Don't you forget it![6d]", "[Speaker]: Why?[New Line]Why can't I ever beat you?![6d]", // bruce
// "[Speaker]: Roar, my dragons!", "[Speaker]: Did my dragons scare you?[6d]", "[Speaker]: You weren't scared at all.[6d]", // drake
// "[Speaker]: Run away while you can.", "[Speaker]: I told you to run.[6d]", "[Speaker]: I should have run away![6d]", // ryder
// "[Speaker]: I held back last time.[New Line]You won't win this one.", "[Speaker]: This is how I play for real.[6d]", "[Speaker]: I can't catch a break![6d]", // nick
// "[Speaker]: I won't let you keep ruining[New Line]Sangem Gang's reputation like this.", "[Speaker]: Don't cross Snagem Gang again.[6d]", "[Speaker]: I'll admit it. You're tough[New Line]kid. Snagem Gang could really[New Line]use someone competent like you.[6d]", // duncan
// "[Speaker]: I'll sink you.", "[Speaker]: You're all washed up.[6d]", "[Speaker]: You rinsed me.[6d]", // azure
// "[Speaker]: We meet again, buddy.[New Line]Yeeehah. We're burning up!", "[Speaker]: It's my win this time![6d]", "[Speaker]: whew, you smoked my team.[6d]", // will
// "[Speaker]: Hohoho. It's you again.[New Line]Ready for my sweet, sweet moves[New Line]darling? Try and keep up!", "[Speaker]: I'm in the groove.[6d]", "[Speaker]: The tempo was too fast![6d]", // mirror b.
// "[Speaker]: I'll flood the whole arena[New Line]to defeat you this time.", "[Speaker]: I'm unstoppable in the rain.[6d]", "[Speaker]: You made my deluge look[New Line]like a puddle. You're strong.[New Line]I concede to you.[6d]", // Troy
// "[Speaker]: Time to get hot and sweaty.", "[Speaker]: Can't stand the heat?[6d]", "[Speaker]: I got burned.[6d]", // blaze
// "[Speaker]: You won't get past me again.", "[Speaker]: I finally stopped you.[6d]", "[Speaker]: It's like I'm not even here![6d]", // nate
// "[Speaker]: I may be old but I have[New Line]a lot of experience.[New Line]Don't hold back!", "[Speaker]: I told you not to go[New Line]easy on me.[6d]", "[Speaker]: You went all out.[New Line]We didn't stand a chance![6d]", // ash
// "[Speaker]: I've been to Mt.Battle to hone[New Line]my skills since our last encounter.[New Line]I won't lose!", "[Speaker]: Your team lacks discipline.[6d]", "[Speaker]: I still need more training.[6d]", // des
// "[Speaker]: Chobin fine tuned the machines.[New Line]They're oiled up and charged to 100%.", "[Speaker]: I collected some useful data.[6d]", "[Speaker]: There was still some input lag.[New Line]I must return to the lab![6d]", // zack
// "[Speaker]: I have to hold back on Mt.Battle.[New Line]I come here to go all out!", "[Speaker]: Come to Mt.Battle some time.[New Line]You need more training.[6d]", "[Speaker]: Maybe I should train on[New Line]Mt.Battle myself![6d]", // mick
// "[Speaker]: You took everything from me![New Line]Years of hard work down the drain![New Line]I'll make you pay for your[New Line]insolence.", "[Speaker]: Crushing your team is so[New Line]satisfying.[6d]", "[Speaker]: aarrghh![6d]", // tyrion
// "[Speaker]: Welcome to Orre Colosseum's[New Line]final challenge.[New Line]Let me show you what a hacker[New Line]can do!", "[Speaker]: I made the game.[New Line]What did you really expect?[6d]", "[Speaker]: Thanks for playing XG![New Line]Don't forget to check out Mt.Battle.[New Line]There's a surprise at the top. ;)[6d]", // stars
//]
//for i in 0..<replacementStrs.count {
// strs[i].duplicateWithString(replacementStrs[i]).replace()
//}
// convert ability list to add more abilities
//increaseNumberOfAbilities()
//var unused = [Int]()
//for string in XGFiles.common_rel.stringTable.allStrings() {
// if string.string == "_" {
// unused.append(string.id)
// }
//}
//let dol = XGFiles.dol.data!
//var nextUnused = 0
////
//let abNames = ["Hard Shell","Magic Bounce", "Pure Heart", "Adaptability","Multilayered","Solar Power","Regenerator","Snow Warning","Refrigerate","Slush Rush","Tough Claws","Prankster","Sand Force","Sand Rush","Amplifier", "No Guard"]
//let abDes = ["Blocks projectile moves.", "Reflects status moves.","Weakens evil moves.","Powers same type moves.", "Max HP halves Damage.","Sunlight powers moves.", "Heals when switching out.","Summons hail in battle.","Makes normal moves ice.","Hail doubles speed.","Powers up contact moves.","Status moves go first.","Sandstorm powers moves.","Raises speed in sandstorm.","Powers sound moves.", "Moves always hit."]
//
//
//var nextAb = 0
//var nextDe = 0
//for i in 78 ..< (0x3A8 / 8) {
//
// if !(nextUnused < unused.count) {
// break
// }
//
// if !(nextAb < abNames.count) {
// break
// }
//
// let start = 0x3FCC50 + (i * 8)
//
// if dol.getWordAtOffset(start) == 0 {
// dol.replaceWordAtOffset(start, withBytes: UInt32(unused[nextUnused]))
// XGFiles.common_rel.stringTable.stringWithID(unused[nextUnused])!.duplicateWithString(abNames[nextAb]).replace()
// nextAb += 1
// nextUnused += 1
// }
//
// if dol.getWordAtOffset(start + 4) == 0 {
// dol.replaceWordAtOffset(start + 4, withBytes: UInt32(unused[nextUnused]))
// XGFiles.common_rel.stringTable.stringWithID(unused[nextUnused])!.duplicateWithString(abDes[nextDe]).replace()
// nextDe += 1
// nextUnused += 1
// }
//
//
//}
//
//dol.save()
//let plus = ability("plus")
//plus.name.duplicateWithString("Battery").replace()
//plus.adescription.duplicateWithString("Powers ally special moves.").replace()
//let minus = XGAbilities.ability(58)
//minus.name.duplicateWithString("Shadow Aura").replace()
//minus.adescription.duplicateWithString("Powers ally shadow moves.").replace()
//let plus = ability("plus")
//plus.name.duplicateWithString("Battery").replace()
//plus.adescription.duplicateWithString("Powers ally special moves.").replace()
//let minus = XGAbilities.ability(58)
//minus.name.duplicateWithString("Shadow Aura").replace()
//minus.adescription.duplicateWithString("Powers ally shadow moves.").replace()
//
//let anonyItems = [42,43,46,47,48,49,50,51,81,80,83,84,85,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,254,255,256,257,258]
//for i in anonyItems {
// let item = XGItems.item(i)
// item.descriptionString.duplicateWithString("_").replace()
// item.name.duplicateWithString("_").replace()
// let data = item.data
// data.nameID = 0
// data.descriptionID = 0
// data.save()
//}
//
//
//var nextUnused = 0
//var unused = [item("stick"), item("metal powder"), item("lucky punch"), item("up-grade"), item("dragon scale"), item("deepseascale"), item("deepseatooth"), item("repel"), item("blue flute"), item("yellow flute"), item("red flute")]
//
//let itNames = ["Choice Scarf","Choice Specs","Eviolite","Wise Glasses","Muscle Band","Pixie Plate","Aura Amplifier","Aura Booster","Aura Limiter","Aura Filter","Life Orb"]
//
//let itDes = ["Raises speed[New Line]but permits only[New Line]one move.","Raises sp.atk[New Line]but permits only[New Line]one move.","Raises defenses of[New Line]Pokemon that can[New Line]Evolve.","Slightly boosts special[New Line]moves' power.","Slightly boosts physical[New Line]moves' power.","A hold item that[New Line]raises the power of[New Line]Fairy-type moves.","Boosts the power[New Line]of a pokemon's[New Line]shadow moves.","Boosts the power[New Line]of a shadow pokemon's[New Line]moves.","The wearer takes[New Line]half the damage from[New Line]shadow pokemon.","The wearer takes[New Line]half the damage from[New Line]shadow moves.","Powers up moves but the[New Line]holder loses health."]
//
//item("choice band").descriptionString.duplicateWithString("Raises attack[New Line]but permits only[New Line]one move.").replace()
//item("focus band").descriptionString.duplicateWithString("Prevents fainting at[New Line]max HP.").replace()
//item("focus band").name.duplicateWithString("Focus Sash").replace()
//
//
//var itNext = 0
//for i in 0 ..< itNames.count {
//
// let old = unused[i].data
// let name = old.name
// let desc = old.descriptionString
//
// let item = XGItems.item(i + 52).data
// item.nameID = name.id
// name.duplicateWithString(itNames[itNext]).replace()
//
// item.descriptionID = desc.id
// desc.duplicateWithString(itDes[itNext]).replace()
// nextUnused += 1
// itNext += 1
// item.save()
//
// old.nameID = 0
// old.descriptionID = 0
// old.save()
//
//
//}
//for i in 1 ..< kNumberOfMoves {
//
// let data = XGMove(index: i)
//
// data.mirrorMoveFlag = false
// data.HMFlag = data.isShadowMove ? true : false
// data.snatchFlag = false
//
// data.save()
//
//}
//
//
//let auramoves = [move("aura sphere"), move("water pulse"), move("dragon pulse"), move("dark pulse"),move("shadow pulse")]
//for move in auramoves {
// let data = move.data
// data.mirrorMoveFlag = true
// data.save()
//}
//
//// shadow moves use HM flag
//let shadowMovesCheckStartAddress = 0x8013d03c - kDOLtoRAMOffsetDifference
//let shadowCheckInstructions : [UInt32] = [0x9421fff0,0x7c0802a6,0x90010014,0x480014cd,0x80010014,0x7c0803a6,0x38210010,0x4e800020]
//let adol = XGFiles.dol.data!
//for i in 0 ..< shadowCheckInstructions.count {
//
// adol.replaceWordAtOffset(shadowMovesCheckStartAddress + (i * 4), withBytes: shadowCheckInstructions[i])
//
//}
//
////remove move flag depedencies
//let li_r3_0 : UInt32 = 0x38600000
//let dependentOffsets = [0x8021aafc,0x801bd9e0,0x80210628,0x802187b0]
//for offset in dependentOffsets {
// adol.replaceWordAtOffset(offset - kDOLtoRAMOffsetDifference, withBytes: li_r3_0)
//}
//
//adol.save()
////snow warning
//let snowWarningIndex = kNumberOfAbilities + 8
//let bdol = XGFiles.dol.data!
//let nops = [0x80225d24 - kDOLtoRAMOffsetDifference, 0x80225d54 - kDOLtoRAMOffsetDifference]
//for offset in nops {
// bdol.replaceWordAtOffset(offset, withBytes: kNopInstruction)
//}
//bdol.replaceWordAtOffset(0x80225d4c - kDOLtoRAMOffsetDifference, withBytes: UInt32(0x2c000000 + snowWarningIndex))
//
//let rainToSnow : UInt32 = 0x80225e90 - 0x80225d7c
//let weatherStarter : [UInt32] = [0x38600000, 0x38800053, 0x4BFCD1F9 - rainToSnow, 0x5460063E, 0x28000002, 0x40820188 - rainToSnow, 0x38600000, 0x38800053, 0x38A00000, 0x4BFCD189 - rainToSnow, 0x7FE4FB78, 0x38600000, 0x4BFD09D5 - rainToSnow, 0x3C608041, 0x3863783C, 0x4BFFD8F1 - rainToSnow, kNopInstruction]
//
//let snowstart = 0x80225e90 - kDOLtoRAMOffsetDifference
//for i in 0 ..< weatherStarter.count {
// bdol.replaceWordAtOffset(snowstart + (i * 4), withBytes: weatherStarter[i])
//}
//
//loadAllStrings()
//getStringWithID(id: 0x4eea)!.duplicateWithString("[1e]'s [1c][New Line]activated!").replace()
//// snow warning uses hail animation
//let snowRoutineStart = 0xB9AC60
//let snowWarningRoutine = [0x46, 0x19, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x29, 0x80, 0x41, 0x78, 0x43]
//let rel = XGFiles.common_rel.data!
//rel.replaceBytesFromOffset(snowRoutineStart - kRELtoRAMOffsetDifference, withByteStream: snowWarningRoutine)
//rel.save()
//
//let snowRoutineBranch = 0x225ec4
//XGAssembly.replaceASM(startOffset: snowRoutineBranch - kDOLtoRAMOffsetDifference, newASM: [
// .lis(.r3, 0x80ba),
// .subi(.r3, .r3, 0x10000 - 0xac60),
//])
//let dugtrio = pokemon("dugtrio").stats
//dugtrio.attack = 100
//dugtrio.save()
//
//let dodrio = pokemon("dodrio").stats
//dodrio.speed = 110
//dodrio.save()
//
//let electrode = pokemon("electrode").stats
//electrode.speed = 150
//electrode.save()
//
//let pelipper = pokemon("pelipper").stats
//pelipper.specialAttack = 95
//pelipper.save()
//
//let mantine = pokemon("mantine").stats
//mantine.hp = 85
//mantine.save()
//
//let lunatone = pokemon("lunatone").stats
//lunatone.hp = 100
//lunatone.attack = 50
//lunatone.defense = 65
//lunatone.specialDefense = 85
//lunatone.specialAttack = 105
//lunatone.speed = 50
//lunatone.save()
//
//let solrock = pokemon("solrock").stats
//solrock.hp = 100
//solrock.attack = 50
//solrock.defense = 85
//solrock.specialDefense = 65
//solrock.specialAttack = 105
//solrock.speed = 50
//solrock.save()
//
//let masquerain = pokemon("masquerain").stats
//masquerain.specialAttack = 100
//masquerain.speed = 80
//masquerain.save()
//let cdol = XGFiles.dol.data!
//
////crit multipliers
//let critOffsets = [0x8020dd7c,0x8020dd8c,0x8020dd9c,0x801f0968]
//let critValues : [UInt32] = [0x38800003,0x38800002,0x38800002,0x38800002]
//
//for i in 0 ..< critOffsets.count {
// cdol.replaceWordAtOffset(critOffsets[i] - kDOLtoRAMOffsetDifference, withBytes: critValues[i])
//}
//
//// reverse mode residual
//cdol.replaceWordAtOffset(0x8022811c - kDOLtoRAMOffsetDifference, withBytes: 0x38800008)
//
//// paralysis to halve speed
//cdol.replaceWordAtOffset(0x80203adc - kDOLtoRAMOffsetDifference, withBytes: 0x56f7f87e)
//
//// choice scarf
//let choicescarfindex : UInt32 = 52
//let choiceStart = 0x80203ab4 - kDOLtoRAMOffsetDifference
//let choiceInstructions : [UInt32] = [kNopInstruction,0x7f43d378,0x4bfffdb5,0x28030000 + choicescarfindex,0x4082000C,0x1EF70003,0x56f7f87e]
//for i in 0 ..< choiceInstructions.count {
// cdol.replaceWordAtOffset(choiceStart + (i * 4), withBytes: choiceInstructions[i])
//}
//
//// move maintenance
//
// new shadow moves
//for m in [197,330,346] {
// let mov = XGMoves.move(m).data
// mov.HMFlag = true
// mov.save()
// let rel = XGFiles.common_rel.data!
// rel.replaceWordAtOffset(mov.startOffset + 0x14, withBytes: 0x00023101)
// rel.save()
//
//}
//
//var currentDescs = [Int]()
//var currentNames = [Int]()
//
//for m in 1 ..< kNumberOfMoves {
// let move = XGMoves.move(m)
// currentDescs.append(move.descriptionID)
// currentNames.append(move.nameID)
//}
//
//loadAllStrings()
//let obsoleteMoves = [129,149,74,175,298,145,287,260,343,48,155,125,217,255,288,120,107,229,138,135,259,102,2,141,292,203,249,285,262,10,18,293,190,237,256,307,294,316,335,272,208,291,128,338,244,40,80,111,119,289]
//
//
//for obs in obsoleteMoves {
// let oName = XGOriginalMoves.move(obs).nameID
// let oDesc = XGOriginalMoves.move(obs).descriptionID
// let m = XGMove(index: obs)
// m.moveName = oName
// m.moveDescription = oDesc
// m.type = .normal
// m.basePower = 0
// m.target = .selectedTarget
// m.category = .none
// m.effect = 0
// m.priority = 0
// m.pp = 1
// m.accuracy = 0
// m.effectAccuracy = 0
// m.contactFlag = false
// m.mirrorMoveFlag = false
// m.protectFlag = false
// m.kingsRockFlag = false
// m.magicCoatFlag = false
// m.soundBasedFlag = false
// m.snatchFlag = false
// m.HMFlag = false
// m.save()
// if !currentNames.contains(oName) {
// getStringWithID(id: oName)!.duplicateWithString("*").replace()
// }
// if !currentDescs.contains(oDesc) {
// getStringWithID(id: oDesc)!.duplicateWithString("*").replace()
// }
//}
//// hard shell flag
//let hardshells = ["aura sphere", "seed bomb","focus blast","pin missile","rock throw","energy ball","ice shard","icicle crash","explosion","sludge","sludgebomb","gunk shot","rock slide","zap cannon","shadow ball","leech seed","bullet seed","icicle spear","mud shot","rock blast","shadow pulse"]
//for name in hardshells {
// let mo = move(name).data
// mo.snatchFlag = true
// mo.save()
//}
//
////magic bounce
//let magicBounceBranchAddress = 0x8021855c
//let magicBounceCompareAddress = 0x80218564
//let magicBounceIndex : UInt32 = UInt32(kNumberOfAbilities + 2)
//let magicBounceBranchInstruction : UInt32 = 0x4bf3033d
//let magicBounceCompareInstruction : UInt32 = 0x28000000 + magicBounceIndex
//
//cdol.replaceWordAtOffset(magicBounceBranchAddress - kDOLtoRAMOffsetDifference, withBytes: magicBounceBranchInstruction)
//cdol.replaceWordAtOffset(magicBounceCompareAddress - kDOLtoRAMOffsetDifference, withBytes: magicBounceCompareInstruction)
//
//cdol.save()
//let ddol = XGFiles.dol.data!
//// sheer force
//let sheerForceStart = 0x80213d6c
//let sheerForceInstructions : [UInt32] = [0x7C7C1B78,0x7FA3EB78,0x4BFF1855,0x28030023,0x4082000C,0x3BA00000,0x48000024,0x7C7D1B78,0x7F83E378,0x4BF2A925,0x281D0020,0x7C7D1B78,0x4082000C,0x54600DFC,0x7C1D0378]
//
//for i in 0 ..< sheerForceInstructions.count {
// let offset = sheerForceStart + (i * 4) - kDOLtoRAMOffsetDifference
// ddol.replaceWordAtOffset(offset, withBytes: sheerForceInstructions[i])
//}
//
//// -ate abilities types
//let ateStart = 0x802c8648 - kDOLtoRAMOffsetDifference
//let ateInstructions = [0x7F83E378,0x4BE76225,0x28030000,0x408200E0,0x7FA3EB78,0x4BF3CF6D,0x28030056,0x4082000C,0x3860000F,0x480000DC,0x28030044,0x4082000C,0x38600009,0x480000CC,0x28030001,0x4082000C,0x38600002,0x480000BC,0x480000A4]
//
//for i in 0 ..< ateInstructions.count {
// let offset = ateStart + (i * 4)
// ddol.replaceWordAtOffset(offset, withBytes: UInt32(ateInstructions[i]))
//}
//
//let priorityAbilitiesStart = 0x8015224c - kDOLtoRAMOffsetDifference
//let priorityAbilitiesInstructions : [UInt32] = [0x9421fff0,0x7C0802A6,0x90010014,0x93E1000C,0x93C10008,0x7C7F1B78,0x48000074,0x4BFEC551,0x28030000,0x40820050,0x7FE3FB78,0x480B3351,0x28030059,0x41820024,0x28030043,0x40820034,0x7FC3F378,0x4BFEC5e1,0x28030002,0x40820024,0x38600001,0x48000020,0x7FC3F378,0x4bfec549,0x28030000,0x4082000C,0x38600001,0x48000008,0x38600000,0x80010014,0x83E1000C,0x83C10008,0x7C0803A6,0x38210010,0x4E800020,0x480B22DD,0x7C7E1B78,0x4BFFFF88]
//
//for i in 0 ..< priorityAbilitiesInstructions.count {
// let offset = priorityAbilitiesStart + (i * 4)
// ddol.replaceWordAtOffset(offset, withBytes: priorityAbilitiesInstructions[i])
//}
//
//let determineOrderOffsets = [0x801f43e8,0x801f43ec,0x801f43f4,0x801f43f8]
//let determineOrderInstructions : [UInt32] = [0x7f23cb78,0x4bf5de61,0x7f43d378,0x4bf5de55]
//
//for i in 0 ..< determineOrderOffsets.count {
// ddol.replaceWordAtOffset(determineOrderOffsets[i] - kDOLtoRAMOffsetDifference, withBytes: determineOrderInstructions[i])
//}
//
//ddol.save()
//let dol2 = XGFiles.dol.data!
//// hard shell ability
//let hardshellindex = 78
//let hardoffset1 = 0x8022580c - kDOLtoRAMOffsetDifference
//let hardcomparison : UInt32 = 0x2c00004e
//let hardoffset2 = 0x8022582c - kDOLtoRAMOffsetDifference
//let hardbranch : UInt32 = 0x4bf18db9
//
//dol2.replaceWordAtOffset(hardoffset1, withBytes: hardcomparison)
//dol2.replaceWordAtOffset(hardoffset2, withBytes: hardbranch)
//
//// regenerator
//let naturalcurechangestart = 0x8021c5cc - kDOLtoRAMOffsetDifference
//let naturalcurechanges : [UInt32] = [0x7C7E1B78,0x48002559,0x7fe3fb78]
//for i in 0 ... 2 {
// dol2.replaceWordAtOffset(naturalcurechangestart + (i * 4), withBytes: naturalcurechanges[i])
//}
//
//let regenStart = 0x8021eb28 - kDOLtoRAMOffsetDifference
//let regenCode : [UInt32] = [0x7fe3fb78,0xa063080c,0x28030054,0x41820008,0x4e800020,0x7fe3fb78,0x80630000,0x38630004,0xA0830090,0xa0630004,0x38000003, 0x7C0403D6,0x7C630214,0x7C032040,0x40810014,0x7fe3fb78,0x80630000,0x38630004,0xA0630090,0x7C641B78,0x7fe3fb78,0x80630000,0x38630004,0xb0830004,0x4e800020]
//for i in 0 ..< regenCode.count {
// dol2.replaceWordAtOffset(regenStart + (i * 4), withBytes: regenCode[i])
//}
//dol2.save()
//
//
//
//// effect accuracies
//for m in ["baby doll eyes","toxic","brave bird","head smash","short circuit","snore","outrage","swagger","knock off","overheat","psycho boost","shadow star"] {
// let mov = move(m).data
// mov.effectAccuracy = 0
// mov.save()
//}
//let newPokespotStart = 0x73300
//relocatePokespots(startOffset: UInt32(newPokespotStart), numberOfEntries: 25)
//
//let spotmons : [ [(name: String, minLevel: Int, maxLevel: Int, encounterPercentage: Int, stepsPerSnack: Int)] ] = [
// // rock
// [
// ("entei" , 25, 25, 2, 75),
// ("jirachi" , 10, 10, 1, 25),
// ("aerodactyl" , 24, 27, 9, 150),
// ("ponyta" , 15, 22, 5, 300),
// ("larvitar" , 19, 23, 9, 100),
// ("miltank" , 27, 32, 2, 400),
// ("sandshrew" , 18, 23, 7, 300),
// ("sandslash" , 28, 31, 2, 100),
// ("cacnea" , 26, 29, 8, 400),
// ("trapinch" , 21, 25, 6, 300),
// ("vibrava" , 35, 35, 2, 80),
// ("onix" , 21, 26, 2, 400),
// ("numel" , 23, 26, 5, 400),
// ("camerupt" , 33, 34, 1, 100),
// ("dugtrio" , 28, 29, 2, 100),
// ("hitmontop" , 22, 26, 8, 200),
// ("gligar" , 23, 26, 3, 400),
// ("graveler" , 25, 27, 2, 200),
// ("kecleon" , 23, 25, 3, 250),
// ("electrode" , 30, 32, 2, 150),
// ("cubone" , 18, 23, 4, 400),
// ("marowak" , 28, 29, 3, 100),
// ("kangaskhan" , 22, 26, 2, 300),
// ("tauros" , 23, 26, 4, 200),
// ("seviper" , 24, 27, 6, 400)
// ],
//
// // oasis
// [
// ("suicune" , 25, 26, 3, 50),
// ("celebi" , 15, 15, 1, 25),
// ("chansey" , 17, 22, 9, 100),
// ("roselia" , 26, 29, 2, 300),
// ("eevee" , 5, 13, 7, 400),
// ("lanturn" , 27, 28, 6, 200),
// ("gloom" , 21, 24, 2, 300),
// ("persian" , 28, 29, 2, 300),
// ("bellsprout" , 21, 26, 6, 250),
// ("weepinbell" , 22, 23, 2, 150),
// ("kingler" , 28, 29, 2, 250),
// ("scyther" , 23, 27, 7, 150),
// ("ninjask" , 22, 28, 2, 250),
// ("exeggcute" , 21, 26, 8, 200),
// ("feebas" , 1, 1, 3, 100),
// ("magikarp" , 1, 1, 8, 400),
// ("tangela" , 24, 28, 2, 300),
// ("tentacool" , 22, 25, 3, 400),
// ("tentacruel" , 30, 32, 2, 150),
// ("octillery" , 25, 27, 3, 250),
// ("vulpix" , 18, 22, 5, 350),
// ("ninetales" , 23, 26, 2, 150),
// ("jumpluff" , 27, 29, 2, 200),
// ("tropius" , 26, 29, 4, 250),
// ("swablu" , 21, 26, 7, 350)
// ],
//
// // cave
// [
// ("raikou" , 25, 25, 2, 100),
// ("mew" , 5, 5, 1, 25),
// ("dratini" , 11, 22, 9, 150),
// ("absol" , 24, 26, 7, 250),
// ("golbat" , 22, 25, 6, 400),
// ("porygon2" , 24, 26, 7, 300),
// ("mantine" , 23, 25, 2, 300),
// ("wailmer" , 22, 24, 2, 400),
// ("omanyte" , 23, 26, 7, 150),
// ("kabuto" , 22, 27, 7, 150),
// ("psyduck" , 19, 24, 5, 300),
// ("golduck" , 33, 34, 1, 100),
// ("poliwhirl" , 25, 26, 2, 250),
// ("abra" , 17, 21, 6, 350),
// ("kadabra" , 19, 24, 2, 150),
// ("horsea" , 21, 24, 3, 400),
// ("seadra" , 32, 33, 2, 50),
// ("shellder" , 21, 23, 5, 400),
// ("cloyster" , 22, 25, 2, 150),
// ("crawdaunt" , 30, 30, 7, 100),
// ("ditto" , 20, 23, 5, 300),
// ("wooper" , 18, 22, 3, 400),
// ("quagsire" , 21, 24, 2, 200),
// ("mr. mime" , 24, 26, 2, 250),
// ("qwilfish" , 25, 27, 3, 300)
// ],
//
// // all
// [
// ("bonsly" , 10, 10, 35, 100),
// ("munchlax" , 10, 10, 5, 50),
// ],
//]
//
//for i in 0 ... 3 {
// let spot = XGPokeSpots(rawValue: i)!
// let monList = spotmons[i]
//
// var percentageTotal = 0
//
// for j in 0 ..< monList.count {
// let (name, minLevel, maxLevel, encounterPercentage, stepsPerSnack) = monList[j]
// let mon = XGPokeSpotPokemon(index: j, pokespot: spot)
// mon.pokemon = pokemon(name)
// mon.minLevel = minLevel
// mon.maxLevel = maxLevel
// mon.encounterPercentage = encounterPercentage
// mon.stepsPerSnack = stepsPerSnack
// mon.save()
//
// percentageTotal += encounterPercentage
// }
//
// if percentageTotal != 100 && spot != .all {
// printg("wrong percentage total for spot: " + spot.string, percentageTotal)
// }
//}
//let kFirstFieldEffectEntry = 0x03fc3e0
//let kSizeOfFieldEffectEntry = 0x14
//let kNumberOfFieldEffects = 0x57
//
//let kFieldEffectDurationOffset = 0x4
//let kFieldEffectStringIDOffset = 0x12
//
//let rel = XGFiles.nameAndFolder("xg ram.raw", .Documents).data
//for i in 0 ..< kNumberOfFieldEffects {
// let effect = kFirstFieldEffectEntry + (i * kSizeOfFieldEffectEntry)
// let stringID = rel.get2BytesAtOffset(effect + kFieldEffectStringIDOffset)
// let duration = rel.getByteAtOffset(effect + kFieldEffectDurationOffset)
// print(i,getStringSafelyWithID(id: stringID),"duration: ", duration)
//}
//let iso = XGISO()
//
//for file in ["kyogre","ootachi","hanecco","groudon","kongpang","kyukon","garagara","sleeper"].map({ (str) -> String in
// return "pkx_" + str + ".fsys"
// }).sorted(by: { (s1, s2) -> Bool in
// return iso.sizeForFile(s1)! < iso.sizeForFile(s2)!
// }) {
// print(file, iso.sizeForFile(file)!)
//}
//
//let replacements = [("robo_groudon","hanecco"),("robo_kyogre","sleeper"),("alolan_marowak","kongpang"),("alolan_ninetales","ootachi")]
//for (new,old) in replacements {
// let oldFile = "pkx_" + old + ".fsys"
// let oldFsys = iso.dataForFile(filename: oldFile)!
// let fsys = XGFiles.fsys(oldFile)
// oldFsys.file = fsys
// oldFsys.save()
// fsys.fsysData.shiftAndReplaceFileWithIndex(0, withFile: XGFiles.nameAndFolder(new + ".fdat", .TextureImporter).compress())
// iso.importFiles([fsys])
//}
//let ldol = XGFiles.dol.data!
//
//// old stat booster (r3 index of stat to boost, r4 battle pokemon)
//let statBoosterStart = 0x8015258c - kDOLtoRAMOffsetDifference
//let statBoosterCode : [UInt32] = [0x9421ffe0,0x7c0802a6,0x90010024,0x93e1001c,0x93c10018,0x93a10014,0x93810010,
//0x7C9F2378,0x480cfed9,0x7c601b78,0x7fe3fb78,0x7c1d0378,0x38800000,0x7fa5eb78,0x38c00000,0x4bff08b5,
//0x7c7c0774,0x2c1c000c,0x4080006c,//------
//0x7fe3fb78,0x4bff64bd,0x5460043e,0x28000002,0x41820058, // ------
//0x7fe4fb78,0x38600000,0x480a418d,0x381c0001,0x7fe3fb78,0x7c070774,0x7fa5eb78,0x38800000,0x38c00000,
//0x4bfef705,0x808dbb04,0x3c608041,0x38a00011,0x38000000,0x3c840001,0x38637957,
//0x98a460a4,0x808dbb04,0x3c840001,0x980460a5,0x480d106d,
//0x80010024,0x83e1001c,0x83c10018,0x83a10014,0x83810010,0x7c0803a6,0x38210020,0x4e800020
//]
//
//for i in 0 ..< statBoosterCode.count {
// ldol.replaceWordAtOffset(statBoosterStart + (i * 4), withBytes: statBoosterCode[i])
//}
//
//// tailwind and trick room
//let safeguards = [0x80214040,0x8021bd6c,0x8022cd90,0x8022d538,0x8022d94c,0x8022e0fc,0x8022e244,0x8022ee48,0x80230154,0x802302f4,0x802306b8,0x80230bd0,0x802314e8,0x802ccf60,0x802de1b4]
//let mists = [0x8022c910,0x802cc790,0x802ccab4,0x802cccf8,0x802ccf40,0x802220a4,0x80210990]
//for offset in safeguards + mists {
// ldol.replaceWordAtOffset(offset - kDOLtoRAMOffsetDifference, withBytes: 0x38600000)
//}
//
//let tailBranchOffset = 0x801f4430 - kDOLtoRAMOffsetDifference
//let tailBranchInstruction = 0x4bf5e04d
//ldol.replaceWordAtOffset(tailBranchOffset, withBytes: UInt32(tailBranchInstruction))
//
//let tailStart = 0x8015247c - kDOLtoRAMOffsetDifference
//let tailCode : [UInt32] = [0x9421ffe0,0x7c0802a6,0x90010024,0x93e1001c,0x93c10018,0x93a10014,0x93810010,
//0x7f23cb78,0x3880004b,0x480a6041,0x28030001,0x40820008,0x57BD083C,
//0x7f43d378,0x3880004b,0x480a6029,0x28030001,0x40820008,0x57DE083C,
//0x7f23cb78,0x3880004c,0x480a6011,0x28030001,0x40820008,0x48000018,
//0x7f43d378,0x3880004c,0x480a5ff9,0x28030001,0x4082000c,0x7C1EE840,0x48000008,0x7c1df040,
//0x80010024,0x83e1001c,0x83c10018,0x83a10014,0x83810010,0x7c0803a6,0x38210020,0x4e800020
//]
//
//for i in 0 ..< tailCode.count {
// ldol.replaceWordAtOffset(tailStart + (i * 4), withBytes: tailCode[i])
//}
//
//
// assault vest status moves
//
//let avBranchOffset = 0x802014ac - kDOLtoRAMOffsetDifference
//let avBranchInstruction : UInt32 = 0x4bf16619
//
//ldol.replaceWordAtOffset(avBranchOffset, withBytes: avBranchInstruction)
//
//let assaultVestStart = 0x80117ac4 - kDOLtoRAMOffsetDifference
//let assaultVestCode : [UInt32] = [0x28030001,0x40820008,0x4e800020,0x281f004c,0x4082000c,0x38600001,0x4e800020,0x38600000,0x4e800020]
//
//for i in 0 ..< assaultVestCode.count {
// ldol.replaceWordAtOffset(assaultVestStart + (i * 4), withBytes: assaultVestCode[i])
//}
//ldol.replaceWordAtOffset(0x802014b0 - kDOLtoRAMOffsetDifference, withBytes: 0x28030001)
//
//
//// allow shadow moves to use hm flag
//let shadowBranchOffsetsR0 = [0x8001c60c,0x8001c7ec,0x8001e314,0x80036c60]
//for offset in shadowBranchOffsetsR0 {
// ldol.replaceWordAtOffset(offset - kDOLtoRAMOffsetDifference, withBytes: createBranchAndLinkFrom(offset: offset - 0x80000000, toOffset: 0x21eb8c))
//}
//
//let shadowStart = 0x8021eb8c - kDOLtoRAMOffsetDifference
//let shadowCode : [UInt32] = [0x7C030378,0x9421fff0,0x7c0802a6,0x90010014,
//0x4bf1e4a1,0x28030001,
//0x80010014,0x7c0803a6,0x38210010,0x38000165,0x4e800020,
//0x7C641B78,
//0x1c030038,0x806d89d4,0x7c630214,//pointer to move
//0x88630012,0x28030001,0x7C832378,
//0x4d800020,0x38600000,0x4e800020
//]
//
//for i in 0 ..< shadowCode.count {
// ldol.replaceWordAtOffset(shadowStart + (i * 4), withBytes: shadowCode[i])
//}
//
//let shadowR3Offsets = [0x8007e6dc,0x80034e98]
//for offset in shadowR3Offsets {
// ldol.replaceWordAtOffset(offset - kDOLtoRAMOffsetDifference, withBytes: createBranchFrom(offset: offset - 0x80000000, toOffset: 0x21ebb8))
//}
//
//ldol.save()
//
//let origin = XGStringTable.common_relOriginal()
//var newIDs = [Int]()
//
//loadAllStrings()
//for str in allStrings {
// if str.table == XGFiles.common_rel {
// if str.string == "*" || str.string == "_" {
// if str.id > 0x1000 {
// if origin.stringSafelyWithID(str.id).string.characters.count > 3 {
// newIDs.append(str.id)
// }
// }
// }
// }
//}
//
//let newAbs = ["Motor Drive", "Storm Drain", "Sap Sipper", "Justified","Reckless","Download","Scrappy","Skill Link","Defiant","Competitive","Snow Cloak","Magic Guard"]
//let newDescs = ["Electricity raises speed.","Water raises sp.atk.","Grass raises attack.","Dark raises attack.","Powers recoil moves.","Raises sp.atk in battle.", "Can hit ghosts.","Always 5 hits.","Drops raise attack.", "Drops raise sp.atk.","Hail boosts evasion.","Prevents side damage."]
//
//
//for i in 0 ..< newAbs.count {
// let ab = XGAbilities.ability(95 + i)
// ab.replaceNameID(newID: newIDs[i * 2])
// ab.replaceDescriptionID(newID: newIDs[(i * 2) + 1])
// getStringSafelyWithID(id: newIDs[i * 2]).duplicateWithString(newAbs[i]).replace()
// getStringSafelyWithID(id: newIDs[(i * 2) + 1]).duplicateWithString(newDescs[i]).replace()
//}
//// trick room tailwind part 2
//let kdol = XGFiles.dol.data!
//
//let tr2BranchOffset = 0x80152498 - kDOLtoRAMOffsetDifference
//let tr2BranchInstr = createBranchFrom(offset: 0x152498, toOffset: 0x152520)
//kdol.replaceWordAtOffset(tr2BranchOffset, withBytes: tr2BranchInstr)
//
//let tr2Start = 0x80152520 - kDOLtoRAMOffsetDifference
//let tr2Instructions : [UInt32] = [
// 0x7F24CB78,0x38600002,createBranchAndLinkFrom(offset: 0x152528, toOffset: 0x1efcac),0x7C7C1B78,
// 0x7F44D378,0x38600002,createBranchAndLinkFrom(offset: 0x152538, toOffset: 0x1efcac),0x7c7f1b78,
// 0x7F83E378,createBranchFrom(offset: 0x152544, toOffset: 0x15249c) // mr r3, r28 to continue original tr code
//]
//
//
//for i in 0 ..< tr2Instructions.count {
// kdol.replaceWordAtOffset(tr2Start + (i * 4), withBytes: tr2Instructions[i])
//}
//
//kdol.replaceWordAtOffset(0x801524c8 - kDOLtoRAMOffsetDifference, withBytes: 0x7F83E378)
//for offset in [0x801524b0,0x801524e0] {
// kdol.replaceWordAtOffset(offset - kDOLtoRAMOffsetDifference, withBytes: 0x7FE3FB78)
//}
//// No guard
//let noguardindex = 93
//let noguardstart = 0x802178d4 - kDOLtoRAMOffsetDifference
//let noguardinstructions : [UInt32] = [kNopInstruction,0x2819005D,
// 0x4182000C,
// 0x281A005D,
// 0x4082000C,
// 0x3AC00064,
// 0x480000CC
//]
//
//for i in 0 ..< noguardinstructions.count {
// kdol.replaceWordAtOffset(noguardstart + (i * 4), withBytes: noguardinstructions[i])
//}
//
//kdol.save()
//
//switchNextPokemonAtEndOfTurn()
//paralysisHalvesSpped()
//for mon in XGDecks.DeckDarkPokemon.allPokemon.sorted(by: { (p1, p2) -> Bool in
// return p1.shadowFleeValue < p2.shadowFleeValue
//}).filter({ (p) -> Bool in
// return p.species.index > 0
//}) {
// let tabs = 11 - (mon.species.name.string.characters.count)
// var nameTab = " "
// for t in 0 ..< tabs {
// nameTab += " "
// }
//
// print(mon.species.name, nameTab, mon.shadowFleeValue.hex(), "\t", mon.shadowAggression, "\t", mon.shadowUnknown2,"\t")
//}
//for mon in XGDecks.DeckStory.allPokemon.filter({ (p1) -> Bool in
// return p1.unknown1 > 0
//}) {
// let tabs = 11 - (mon.species.name.string.characters.count)
// var nameTab = " "
// for t in 0 ..< tabs {
// nameTab += " "
// }
// let tab = "\t"
//
// var binary = String(mon.unknown1, radix: 2)
// for i in 0 ..< (8 - binary.characters.count) {
// binary = "0" + binary
// }
//
// print(mon.species.name,nameTab,String(format:"%2d",mon.level),tab,String(format:"%2x",mon.unknown1),binary)
//}
// skill link part 2
//let dol = XGFiles.dol.data!
//
//dol.replaceWordAtOffset(0x80221d70 - kDOLtoRAMOffsetDifference, withBytes: createBranchAndLinkFrom(offset: 0x221d70, toOffset: 0x152548))
//
//dol.save()
//let skillLinkStart = 0x80152548 - kDOLtoRAMOffsetDifference
//let skillLinkBranchOffset = 0x80221d98 - kDOLtoRAMOffsetDifference
//let skillLinkBranchInstruction = createBranchAndLinkFrom(offset: skillLinkBranchOffset, toOffset: skillLinkStart)
//let skillLinkCode : [UInt32] = [
//0x5404063e, // rlwinm r4, r0, 0, 24, 31 (000000ff) like original code
//0x387F0648, // addi r3, r31, 1608 turns r31 back to battle pokemon pointer
//0xa063080c, // lhz r3, 0x080C (r3) get the pokemon's ability
//0x28030066, // compare with skill link
//0x41820008, // beq 0x8 if skill link then continue
//0x4e800020, // else return
//0x38800005, // li r4,5 load 5 turns
//0x4e800020, // return
//]
//
//let bdol = XGFiles.dol.data!
//bdol.replaceWordAtOffset(skillLinkBranchOffset, withBytes: skillLinkBranchInstruction)
//for i in 0 ..< skillLinkCode.count {
// bdol.replaceWordAtOffset(skillLinkStart + (i * 4), withBytes: skillLinkCode[i])
//}
//
//// foes can enter reverse mode
//let reverseOffset = 0x80226754 - kDOLtoRAMOffsetDifference
//bdol.replaceWordAtOffset(reverseOffset, withBytes: kNopInstruction)
//
//
////// no infinite weather
//let infiniteOffsets = [0x80225dc4, 0x80225ddc,0x80225d80,0x80225d98,0x80225e20,0x80225e08]
//let infiniteReplacements : [UInt32] = [0x38800056,0x38800055,0x38800054]
//for i in 0 ..< infiniteReplacements.count {
// let index = i * 2
// bdol.replaceWordAtOffset(infiniteOffsets[index] - kDOLtoRAMOffsetDifference, withBytes: infiniteReplacements[i])
// bdol.replaceWordAtOffset(infiniteOffsets[index + 1] - kDOLtoRAMOffsetDifference, withBytes: infiniteReplacements[i])