User:Kroocsiogsi/Hero response formatting scripts

Introduction

 * 1) Install perl
 * 2) Put the subtitle files to be converted in a folder on your Desktop named "Responses"
 * 3) Put the perl script on your Desktop
 * 4) Correct the folder path in the perl script
 * 5) Run the perl script from the command line

If the hero has a 1-part name in the subtitle file:
opendir(DIR, "C:\\Users\\USERNAME\\Desktop\\Responses") or die "can't opendir $dirname: $!"; while (defined($file = readdir(DIR))) {
 * 1) open directory containing response files

open(F1, "C:\\Users\\USERNAME\\Desktop\\Responses\\$file"); open(F2, ">C:\\Users\\USERNAME\\Desktop\\NewResponses\\$file");
 * 1) open original response file
 * 1) open formatted response file


 * 1) print the beginning of the formatted response file

while ($line = ) { ## if $line is a response line, pull out mp3 name, response section, and subtitle if ($line =~ /^\s+"[a-z]+_([a-z]+_(\w+)_\d\d)"\s+"[\w ]+: (.+)"/) { ## check if a new reponse section should be printed unless ( $2 eq $currentsection) { unless ( $currentsection eq "") { print F2 "\n" }			$currentsection = $2; if ( $currentsection eq "spawn") { $prettysection = "Spawning" } elsif ( $currentsection eq "battlebegins") { $prettysection = "Beginning the Battle" } elsif ( $currentsection eq "begin") { $prettysection = "Beginning the Battle" } elsif ( $currentsection eq "firstblood") { $prettysection = "Drawing First Blood" } elsif ( $currentsection eq "first") { $prettysection = "Drawing First Blood" } elsif ( $currentsection eq "move") { $prettysection = "Moving" } elsif ( $currentsection eq "attack") { $prettysection = "Attacking" } elsif ( $currentsection eq "cast") { $prettysection = "Casting a Spell" } elsif ( $currentsection eq "level") { $prettysection = "Gaining a Level" } elsif ( $currentsection eq "levelup") { $prettysection = "Gaining a Level" } elsif ( $currentsection eq "kill") { $prettysection = "Killing a Hero" } elsif ( $currentsection eq "ability_failure") { $prettysection = "Failing to Kill a Hero" } elsif ( $currentsection eq "magicuser") { $prettysection = "Killing a Caster Hero" } elsif ( $currentsection eq "killspecial") { $prettysection = "Killing in a Special Way" } elsif ( $currentsection eq "rival") { $prettysection = "Killing a Rival" } elsif ( $currentsection eq "lasthit") { $prettysection = "Last Hitting" } elsif ( $currentsection eq "death") { $prettysection = "Dying" } elsif ( $currentsection eq "cough") { $prettysection = "Coughing" } elsif ( $currentsection eq "fastres") { $prettysection = "Respawning Quickly" } elsif ( $currentsection eq "respawn") { $prettysection = "Respawning" } elsif ( $currentsection eq "rare") { $prettysection = "Rare" } elsif ( $currentsection eq "tf2") { $prettysection = "Lines from Team Fortress 2" } elsif ( $currentsection eq "purch") { $prettysection = "Purchasing an Item" } elsif ( $currentsection eq "blink") { $prettysection = "Purchasing Blink Dagger" } elsif ( $currentsection eq "manta") { $prettysection = "Purchasing Manta Style" } elsif ( $currentsection eq "scepter") { $prettysection = "Purchasing Aghanim's Scepter" } elsif ( $currentsection eq "rapier") { $prettysection = "Purchasing Divine Rapier" } elsif ( $currentsection eq "heart") { $prettysection = "Purchasing Heart of Tarrasque" } elsif ( $currentsection eq "bfury") { $prettysection = "Purchasing Battlefury" } elsif ( $currentsection eq "armlet") { $prettysection = "Purchasing Armlet" } elsif ( $currentsection eq "travel") { $prettysection = "Purchasing Boots of Travel" } elsif ( $currentsection eq "refresh") { $prettysection = "Purchasing Refresher Orb" } elsif ( $currentsection eq "desolator") { $prettysection = "Purchasing Desolator" } elsif ( $currentsection eq "item") { $prettysection = "Purchasing a Specific Item" } elsif ( $currentsection eq "items") { $prettysection = "Purchasing a Specific Item" } elsif ( $currentsection eq "relic") { $prettysection = "Purchasing a Specific Item" } elsif ( $currentsection eq "sheepstick") { $prettysection = "Getting Hexed" } elsif ( $currentsection eq "bottle") { $prettysection = "Bottling a Rune" } elsif ( $currentsection eq "deny") { $prettysection = "Denying" } elsif ( $currentsection eq "lose") { $prettysection = "Losing" } elsif ( $currentsection eq "win") { $prettysection = "Winning" } elsif ( $currentsection eq "immort") { $prettysection = "Taking Aegis of the Immortal" } elsif ( $currentsection eq "haste") { $prettysection = "Activating Haste" } elsif ( $currentsection eq "doubdam") { $prettysection = "Activating Double Damage" } elsif ( $currentsection eq "regen") { $prettysection = "Activating Regeneration" } elsif ( $currentsection eq "illus") { $prettysection = "Activating Illusion" } elsif ( $currentsection eq "invis") { $prettysection = "Activating Invisibility" } elsif ( $currentsection eq "notyet") { $prettysection = "Attempting to Use an Ability on Cooldown" } elsif ( $currentsection eq "nomana") { $prettysection = "Attempting to Use an Ability without Mana" } elsif ( $currentsection eq "thanks") { $prettysection = "Thanking" } elsif ( $currentsection eq "underattack") { $prettysection = "Coming Under Attack" } elsif ( $currentsection eq "inthebag") { $prettysection = "Taunting" } elsif ( $currentsection eq "shitwiz") { $prettysection = "Shitty Wizard" } elsif ( $currentsection eq "crumwiz") { $prettysection = "Crummy Wizard" } elsif ( $currentsection eq "pain") { $prettysection = "Pain" } elsif ( $currentsection eq "anger") { $prettysection = "Anger" } elsif ( $currentsection eq "happy") { $prettysection = "Happiness" } elsif ( $currentsection eq "laugh") { $prettysection = "Laughter" } elsif ( $currentsection eq "sfx") { $prettysection = "Noises" } elsif ( $currentsection eq "acknow") { $prettysection = "Acknowledgment" } else { $prettysection = "Other: Please Classify" };			print F2 "==$prettysection==\n" };		## print the new response line print F2 "* $1.mp3 $3\n"; }; };
 * 1) read every line of the original response file

print F2 "}}\n\n";
 * 1) print the end of the formatted response file

close(F1); close(F2);
 * 1) close original response file
 * 1) close formatted response file

$currentsection = "";

}; closedir(DIR);
 * 1) close directory

If the hero has a 2-part name in the subtitle file:
opendir(DIR, "C:\\Users\\USERNAME\\Desktop\\Responses") or die "can't opendir $dirname: $!"; while (defined($file = readdir(DIR))) {
 * 1) open directory containing response files

open(F1, "C:\\Users\\USERNAME\\Desktop\\Responses\\$file"); open(F2, ">C:\\Users\\USERNAME\\Desktop\\NewResponses\\$file");
 * 1) open original response file
 * 1) open formatted response file


 * 1) print the beginning of the formatted response file

while ($line = ) { ## if $line is a response line, pull out mp3 name, response section, and subtitle if ($line =~ /^\s+"[a-z]+_[a-z]+_([a-z]+_(\w+)_\d\d)"\s+"[\w ]+: (.+)"/) { ## check if a new reponse section should be printed unless ( $2 eq $currentsection) { unless ( $currentsection eq "") { print F2 "\n" }			$currentsection = $2; if ( $currentsection eq "spawn") { $prettysection = "Spawning" } elsif ( $currentsection eq "battlebegins") { $prettysection = "Beginning the Battle" } elsif ( $currentsection eq "begin") { $prettysection = "Beginning the Battle" } elsif ( $currentsection eq "firstblood") { $prettysection = "Drawing First Blood" } elsif ( $currentsection eq "first") { $prettysection = "Drawing First Blood" } elsif ( $currentsection eq "move") { $prettysection = "Moving" } elsif ( $currentsection eq "attack") { $prettysection = "Attacking" } elsif ( $currentsection eq "cast") { $prettysection = "Casting a Spell" } elsif ( $currentsection eq "level") { $prettysection = "Gaining a Level" } elsif ( $currentsection eq "levelup") { $prettysection = "Gaining a Level" } elsif ( $currentsection eq "kill") { $prettysection = "Killing a Hero" } elsif ( $currentsection eq "ability_failure") { $prettysection = "Failing to Kill a Hero" } elsif ( $currentsection eq "magicuser") { $prettysection = "Killing a Caster Hero" } elsif ( $currentsection eq "killspecial") { $prettysection = "Killing in a Special Way" } elsif ( $currentsection eq "rival") { $prettysection = "Killing a Rival" } elsif ( $currentsection eq "lasthit") { $prettysection = "Last Hitting" } elsif ( $currentsection eq "death") { $prettysection = "Dying" } elsif ( $currentsection eq "cough") { $prettysection = "Coughing" } elsif ( $currentsection eq "fastres") { $prettysection = "Respawning Quickly" } elsif ( $currentsection eq "respawn") { $prettysection = "Respawning" } elsif ( $currentsection eq "rare") { $prettysection = "Rare" } elsif ( $currentsection eq "tf2") { $prettysection = "Lines from Team Fortress 2" } elsif ( $currentsection eq "purch") { $prettysection = "Purchasing an Item" } elsif ( $currentsection eq "blink") { $prettysection = "Purchasing Blink Dagger" } elsif ( $currentsection eq "manta") { $prettysection = "Purchasing Manta Style" } elsif ( $currentsection eq "scepter") { $prettysection = "Purchasing Aghanim's Scepter" } elsif ( $currentsection eq "rapier") { $prettysection = "Purchasing Divine Rapier" } elsif ( $currentsection eq "heart") { $prettysection = "Purchasing Heart of Tarrasque" } elsif ( $currentsection eq "bfury") { $prettysection = "Purchasing Battlefury" } elsif ( $currentsection eq "armlet") { $prettysection = "Purchasing Armlet" } elsif ( $currentsection eq "travel") { $prettysection = "Purchasing Boots of Travel" } elsif ( $currentsection eq "refresh") { $prettysection = "Purchasing Refresher Orb" } elsif ( $currentsection eq "desolator") { $prettysection = "Purchasing Desolator" } elsif ( $currentsection eq "item") { $prettysection = "Purchasing a Specific Item" } elsif ( $currentsection eq "items") { $prettysection = "Purchasing a Specific Item" } elsif ( $currentsection eq "relic") { $prettysection = "Purchasing a Specific Item" } elsif ( $currentsection eq "sheepstick") { $prettysection = "Getting Hexed" } elsif ( $currentsection eq "bottle") { $prettysection = "Bottling a Rune" } elsif ( $currentsection eq "deny") { $prettysection = "Denying" } elsif ( $currentsection eq "lose") { $prettysection = "Losing" } elsif ( $currentsection eq "win") { $prettysection = "Winning" } elsif ( $currentsection eq "immort") { $prettysection = "Taking Aegis of the Immortal" } elsif ( $currentsection eq "haste") { $prettysection = "Activating Haste" } elsif ( $currentsection eq "doubdam") { $prettysection = "Activating Double Damage" } elsif ( $currentsection eq "regen") { $prettysection = "Activating Regeneration" } elsif ( $currentsection eq "illus") { $prettysection = "Activating Illusion" } elsif ( $currentsection eq "invis") { $prettysection = "Activating Invisibility" } elsif ( $currentsection eq "notyet") { $prettysection = "Attempting to Use an Ability on Cooldown" } elsif ( $currentsection eq "nomana") { $prettysection = "Attempting to Use an Ability without Mana" } elsif ( $currentsection eq "thanks") { $prettysection = "Thanking" } elsif ( $currentsection eq "underattack") { $prettysection = "Coming Under Attack" } elsif ( $currentsection eq "inthebag") { $prettysection = "Taunting" } elsif ( $currentsection eq "shitwiz") { $prettysection = "Shitty Wizard" } elsif ( $currentsection eq "crumwiz") { $prettysection = "Crummy Wizard" } elsif ( $currentsection eq "pain") { $prettysection = "Pain" } elsif ( $currentsection eq "anger") { $prettysection = "Anger" } elsif ( $currentsection eq "happy") { $prettysection = "Happiness" } elsif ( $currentsection eq "laugh") { $prettysection = "Laughter" } elsif ( $currentsection eq "sfx") { $prettysection = "Noises" } elsif ( $currentsection eq "acknow") { $prettysection = "Acknowledgment" } else { $prettysection = "Other: Please Classify" };			print F2 "==$prettysection==\n" };		## print the new response line print F2 "* $1.mp3 $3\n"; }; };
 * 1) read every line of the original response file

print F2 "}}\n\n";
 * 1) print the end of the formatted response file

close(F1); close(F2);
 * 1) close original response file
 * 1) close formatted response file

$currentsection = "";

}; closedir(DIR);
 * 1) close directory

If it's something weird, like the Shopkeeper:
opendir(DIR, "C:\\Users\\USERNAME\\Desktop\\Responses") or die "can't opendir $dirname: $!"; while (defined($file = readdir(DIR))) {
 * 1) open directory containing response files

open(F1, "C:\\Users\\USERNAME\\Desktop\\Responses\\$file"); open(F2, ">C:\\Users\\USERNAME\\Desktop\\NewResponses\\$file");
 * 1) open original response file
 * 1) open formatted response file

print F2 "==Other==\n";
 * 1) print the beginning of the formatted response file

while ($line = ) { ## if $line is a response line, pull out mp3 name and subtitle if ($line =~ /^\s+"[a-z]+_([a-z]+_(\w+)(_\d)?(\d)?)"\s+"[\w ]+: (.+)"/) { ## print the new response line print F2 "* $1.mp3 $5\n"; }; };
 * 1) read every line of the original response file

print F2 "}}\n\n";
 * 1) print the end of the formatted response file

close(F1); close(F2);
 * 1) close original response file
 * 1) close formatted response file

}; closedir(DIR);
 * 1) close directory