PageRenderTime 52ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/atweaks/ssl/make_baf.pl

https://github.com/FredrikLindgren/aTweaks
Perl | 77 lines | 68 code | 8 blank | 1 comment | 3 complexity | 8ba8f0ed0c18e37fc1d19d76210d06a9 MD5 | raw file
  1. #!/usr/bin/perl
  2. use strict;
  3. use File::Copy;
  4. use File::Path;
  5. my @cmd_args = split(" ", shift);
  6. my @undead = (
  7. "banshee.ssl:fl#bansh.baf",
  8. "deathknight.ssl IsDurlagKnight=True:fl#bg1kn.baf",
  9. "deathknight.ssl:fl#death.baf",
  10. "fl#dksw5.ssl:fl#dksw5.baf",
  11. "ghast.ssl Ghast=True:fl#ghast.baf",
  12. "ghast.ssl GhoulLord=True:fl#glord.baf",
  13. "ghoul.ssl:fl#ghoul.baf",
  14. "gmummy.ssl:fl#gmum.baf",
  15. "mummy.ssl:fl#mum.baf",
  16. "skelwa_melee.ssl:fl#sklwm.baf",
  17. "skelwa_ranged.ssl:fl#sklwr.baf",
  18. "zombie_sea.ssl:fl#zomse.baf",
  19. "fl#lowm.ssl:fl#lowm.baf",
  20. "fl#lowr.ssl:fl#lowr.baf",
  21. "fl#midmc.ssl:fl#midmc.baf",
  22. "fl#higmc.ssl:fl#higmc.baf",
  23. "skelwa_summoned.ssl:fl#skwsu.baf",
  24. "skeleton_summoned.ssl:fl#sklsu.baf"
  25. );
  26. my @beholders = (
  27. "beholder.ssl:fl#behol.baf",
  28. "beholder.ssl DeathTyrant=True:fl#bhund.baf",
  29. "beholder.ssl HiveMother=True:fl#bhhiv.baf",
  30. "director.ssl:fl#bhdir.baf",
  31. "gauth.ssl:fl#gauth.baf",
  32. "spectator.ssl:fl#bhspe.baf"
  33. );
  34. my @fiends = (
  35. "fl#adead.ssl:fl#adead.baf",
  36. "fl#sarca.ssl:fl#sarca.baf",
  37. "fl#snyca.ssl:fl#snyca.baf",
  38. "fl#sultr.ssl:fl#sultr.baf",
  39. "fl#shafi.ssl:fl#shafi.baf",
  40. "fl#shafi.ssl DevilShade=True:fl#shaf2.baf",
  41. "fl#arcsu.ssl:fl#arcsu.baf",
  42. "fl#nycsu.ssl:fl#nycsu.baf",
  43. "fl#ultsu.ssl:fl#ultsu.baf"
  44. );
  45. sub process_files {
  46. my @files = @{$_[0]};
  47. my $to_dir = $_[1];
  48. my $from_dir = $_[2];
  49. File::Path::make_path($to_dir);
  50. File::Path::make_path($from_dir . "/ssl_out"); #perl on win does not automatically create it and instead errors out
  51. foreach (@files) {
  52. my @collection = split(":");
  53. my $arg = $from_dir . $collection[0];
  54. my $file = $collection[1];
  55. system("perl", "ssl.pl", "$arg -l lib.slb");
  56. my $index = index $collection[0], " ";
  57. my $res = substr $collection[0], 0, $index > 0 ? $index - 4 : -4;
  58. my $from = $from_dir . "ssl_out/" . $res . ".baf";
  59. my $to = $to_dir . $file;
  60. File::Copy::move($from, $to);
  61. }
  62. File::Path::remove_tree($from_dir . "ssl_out/");
  63. }
  64. File::Path::remove_tree("baf/");
  65. foreach (@cmd_args) {
  66. process_files(\@undead, "baf/undead/", "undead/") if $_ eq "undead";
  67. process_files(\@beholders, "baf/beholders/", "beholder/") if $_ eq "beholders";
  68. process_files(\@fiends, "baf/fiends/", "fiends/") if $_ eq "fiends";
  69. }