diff --git a/Tools/Loot Position/ConvertLoottables2.pl b/Tools/Loot Position/ConvertLoottables2.pl new file mode 100644 index 000000000..9bc611abd --- /dev/null +++ b/Tools/Loot Position/ConvertLoottables2.pl @@ -0,0 +1,48 @@ +use strict; +use warnings; +use Data::Dumper; + +# Customize +my $configFile = '../../SQF/dayz_code/Configs/CfgBuildingLoot/cfgLoot.hpp'; + +# do not touch +my $cfg = ''; +my $collect = 0; +my $small = 0; +my @itemType; +my @itemChance; +open(CFG, '<', $configFile) or die $!; +while (my $line = ) { + if ($line =~ /^\s*(\w+)\[\]\s*=\s*\{/i) { + $collect = 1; + $cfg .= "\t".$1."[] = {\n"; + } + elsif ($collect == 1 && $line =~ /^\s*"([^"]+)"/) { + push(@itemType, $1); + } + elsif ($collect == 1 && $line =~ /^\s*\},/) { + $collect = 2; + } + elsif ($collect == 2 && $line =~ /^\s*(\d+\.\d+),?/) { + push(@itemChance, $1); + } + elsif ($collect == 2 && $line =~ /^\t\}/) { + $collect = 0; + + for (my $i=0; $i 0 ? ',' : ''), $itemType[$i], $itemChance[$i]); + } + + $cfg .= "\t};\n"; + } + elsif ($collect == 0 && $line !~ /^\s*\/\// && $line !~ /^\s*$/) { + $cfg .= $line; + } +} +close(CFG); + +open(NEWCFG,'>', $configFile) or die $!; +print NEWCFG $cfg; +close(NEWCFG); + +exit(0); \ No newline at end of file