{
return null;
}
File file = new File(vpkPath);
VPKArchive vpk = new VPKArchive();
File entryFile = new File("");
String waveSubstring = "";
int startIndex = -1;
int endIndex = -1;
if (waveString.contains("\"wave\""))
{
startIndex = Utility.nthOccurrence(waveString, '\"', 2);
endIndex = Utility.nthOccurrence(waveString, '\"', 3);
}
//For weird special cases where the "wave" part of the string is missing, i.e. Treant's Overgrowth.Target spell
else
{
startIndex = Utility.nthOccurrence(waveString, '\"', 0);
endIndex = Utility.nthOccurrence(waveString, '\"', 1);
}
waveSubstring = waveString.substring(startIndex, endIndex + 1);
waveSubstring = waveSubstring.replace(")", "");
waveSubstring = waveSubstring.replace("\"", "");
waveSubstring = waveSubstring.replace("\\", "/");
waveSubstring = waveSubstring.replace("#", "");
waveSubstring = waveSubstring.replace("*", "");
if (!waveString.contains("custom"))
{
File localFile = new File(Paths.get(installDir + "/sound/" + waveSubstring).toString());
if (localFile.isFile())
{
return localFile;
}
try
{
vpk.load(file);
}
catch (Exception ex)
{
System.err.println("Can't open archive: " + ex.getMessage());
}
waveSubstring = "sound/" + waveSubstring;
VPKEntry entry = vpk.getEntry(waveSubstring.toLowerCase());
entryFile = entry.getType().contains("wav")
? new File(Paths.get(System.getProperty("user.dir") + "/scratch/scratch.wav").toString())
: new File(Paths.get(System.getProperty("user.dir") + "/scratch/scratch.mp3").toString());